Jump to content
Sign in to follow this  
Furrez

Make AI land plane when ammunition is low

Recommended Posts

So I want an AI plane to land on northeast airfield in Chernarus (plane landAt 1) when ammo = 0 or its damaged or the fuel is < 0.2. There is trigger on the airfield that detects when the plane is present and it starts to rearm, repair and refuel. After the plane takes off again, I want him to keep doing the current waypoint and the next ones. So basically I need script that forces an AI plane to land on airfield when it runs out of ammo and after that go back to objectives. I tried some "if" sentences but I didn't know how to check the ammo/damage/fuel.

Share this post


Link to post
Share on other sites

Hi, I was pondering the same thing the other day, I was thinking maybe simply placing support vehicles at the airport with support waypoints? I doubt it could be that simple but never got around to testing it, this is in Arma 3 but should be same principle.. Probably it would need a trigger with certain conditions? Just guessing.

Share this post


Link to post
Share on other sites

What is in your trigger that detects the plane and continually rearms/refuel/repairs it?

Share this post


Link to post
Share on other sites

Check if fuel is low:

fuel (vehicleName) <= 0.4

Check damage:

damage (vehicleName) >= 0.5

Share this post


Link to post
Share on other sites
What is in your trigger that detects the plane and continually rearms/refuel/repairs it?

I am using this and I have activation BLUFOR, repeatedly and present. Now I only need the ammo check if it's possible and the waypoint script.

vehicleMaintenance.sqf

while {(true)} do {
{
	if (not (_x isKindOf "Man") and (count crew _x != 0) and (speed _x < 60) and (speed _x > -1) and (getPos _x select 2 < 1)) then {
		_x setVehicleAmmo 1;

		while {(count crew _x != 0) and ((damage _x > 0) or (fuel _x < 0.99)) and (speed _x < 60) and (speed _x > -1) and (getPos _x select 2 < 1)} do {
			if (damage _x > 0) then {
				_x setDamage ((damage _x) - 1);
			};

			if (fuel _x < 1) then {
				_x setFuel ((fuel _x) + 1);
			};

			sleep 0.1;
		};
	};
} forEach list _this;

sleep 1;
};

I modified it a little bit.

Edited by Furrez

Share this post


Link to post
Share on other sites

Okay, so I got it working by creating a trigger that is activated repeatedly when condition is: "((fuel (pln1) < 0.3) or (damage (pln1) > 0.4));", "pln1" being name of the plane and On Act. "pln1 landAt 1;". The plane was forced to land so it came back to waypoints automatically. However I don't know how to check the ammunition of the plane or is it possible?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×