Jump to content
Sign in to follow this  
KingLouie2

AI Helo landing

Recommended Posts

Hi All,

Firstly sorry if there is indeed a subject similar already but I have trawled the Internet for about 4 months now periodically and doesn't seem like anyone has the answer or has indeed asked the question:

What effects AI direction when "landing" to unload transport?

Basically I am getting a transport helo to insert guys into a remote LZ but everytime the helo comes in to land it will change it's heading whilst in the hover (why!?). I do NOT want this to happen.

I have acheived it by using a lot of timed waypoints, flyinheight, and group eject but whilst the flight itself looks good the unload is rather messy to say the least!!

I have tried using Mando's Heliroute but I am no good with stuff of that sort I am sure someone might be able to point out specifically what Mando does to achieve it though???

Oh and I tried using GetPos but that just flings the aircraft round instantly, not the realism I am trying to achieve here.....

Thank you

Share this post


Link to post
Share on other sites

Wait... Are you using an invisible Heli-H? If not, then just use one of them. Simply place a Heli pad on the map (doesn't matter if it's invisible or not) and put your waypoint directly on it. That way the chopper will land on the spot precisely.

I think this also works:

<Heli's name> land <Position>;

Should give an accurate landing (though I haven't tested this one).

Hope it helps.

Edited by kyfohatl

Share this post


Link to post
Share on other sites

Thanks for your reply,

Sorry I should have mentioned yes I am using invisible H.

The heli will often land on the pad what I am specifically talking about is the landing process of the AI.

It will come to a hover and then for some reason change the azimuth (direction) to a random point not relating to either the direction it came in from or the direction of the next waypoint. I want it to land in the direction it was traveling, a simple request one would think....

Am I doing something drastically wrong here?

Is it something to do with where the waypoint(s) of the squad(s) in the chopper?

Wind direction?

Share this post


Link to post
Share on other sites
Thanks for your reply,

Sorry I should have mentioned yes I am using invisible H.

The heli will often land on the pad what I am specifically talking about is the landing process of the AI.

It will come to a hover and then for some reason change the azimuth (direction) to a random point and not in the direction of the next waypoint. I want it to land in the direction it was traveling, a simple request one would think....

Am I doing something drastically wrong here?

Is it something to do with where the waypoint(s) of the squad(s) in the chopper?

Wind direction?

Hi there,

You have to consider that its an AI pilot who is driving the chopper.

The only solution I see would be to use the functions unitCapture and unitPlay.

You can read more about it here.

_neo_

Share this post


Link to post
Share on other sites

What about:

<Heli's name> setDir <Desired azimuth>;

Say you are unloading 5 men, then you could have:

private ["_N0Crew"];
_N0crew = countCrew Heli1;
// Loop
while {_N0Crew > 1} do {
Heli1 setDir 160;
sleep 2;
};

Where Heli1 is your Heli's name and 160 is the desired direction (note: script assumes your chppoer has only 1 pilot; if you have more just change the countCrew part of course). If you execute this script before landing, the chopper should reset it's direction every two seconds to the direction you want, preventing the chopper from changing direction. Though Neo's solution is good, I thought this might be simpler, though I havent tested it, so it may not work.

Share this post


Link to post
Share on other sites

Thanks kyfohatl I will try this tonight and let you know.

I had tried something similar before - putting a getpos command into the "transport unload" waypoint but the heli would do it's turny thang, get to ground and then jump to that pos (not good). With your code am I right in thinking that it will stop once the transport has been unloaded? I only want it to remain in that position during the landing.

Whilst neokika's option does look the best it is far too complicated for my simple mind. It does make sense but putting it into practice would just confuse the life out of me.

Share this post


Link to post
Share on other sites
With your code am I right in thinking that it will stop once the transport has been unloaded? I only want it to remain in that position during the landing.

Yes, once the chopper has been unloaded, the script will stop. This is done by the line:

while {_N0Crew > 1} do{...

If the number of crew becomes equal to (or less than) one, then the script assumes that unloading has taken place, and will stop executing. Note that it assumes that your chopper has only 1 pilot. If it has more crew, then you need to change the 1 to whatever number of pilots it has.

Share this post


Link to post
Share on other sites

If you moveinCargo units, they won't be heli crew, will they?

So your script won't work. What you need I guess is a condition if count units in heli1 greater than count crew heli1, or something like this.

Edited by zapat

Share this post


Link to post
Share on other sites
If you moveinCargo units, they won't be heli crew, will they?

So your script won't work. What you need I guess is a condition if count units in heli1 greater than count crew heli1, or something like this.

Are you sure about this? Cause in one of my missions, I have moveInCargo for my whole squad, transported by a truck. When unloading, the truck has the condition countCrew = 1 before moving on to the next waypoint, and it works fine (so it waits untill my squad unloads before moving back to base). So, no; I think moveInCargo makes the units a part of the "crew", although as I said, I haven't tested the script I gave, so you could very well be right.

Share this post


Link to post
Share on other sites

Well, it takes a hint to check this. I don't have ARMA besides me right now...

I was only guessing though, so you may be right.

Share this post


Link to post
Share on other sites

Hmmm, so I tried using a loop on the getpos but the heli simply jumps along it's path. Not really what I am looking for.

Looks like I am going to have to learn about the UnitCapture procedure then :mad:

Artificial Intelligence my arse!

Share this post


Link to post
Share on other sites

Here is (tested and working) code that distinguishes between helicopter cargo ("passengers") and the helicopter crew, and stops issueing land commands when all passengers have disembarked (or have been killed while still in the heli).

You can ignore the code for the land commands; just focus on the tracking of passengers and disembarkes.

comment "Force the helicopter to land, even under fire, until all passengers have disembarked.";
comment "William van der Sterren, www.plannedassault.com, 2010";

private ["_script", "_aircraft", "_landing_mode", "_update_delay", "_debug"];
_aircraft               = _this select 0;
_script                 = 'vehicle_land_under_any_condition';
_landing_mode           = "GET OUT";
_update_delay           =   0.5;
_debug                  =   0;


if (_debug == 1) then { diag_log (format ["time: %1 [%2] exec '%3' - started", time, _aircraft, _script]); };


comment "identify and track the passengers";
private ["_passengers", "_aircraft_group"];
_aircraft_group = group _aircraft;
_passengers = [];
{
if ( (group _x) != _aircraft_group ) then { _passengers = _passengers + [_x]; };
} forEach (crew _aircraft);
if (_debug == 1) then { diag_log (format ["time: %1 %2 passengers are: '%3'", time, _aircraft, _passengers]); };


comment "order aircraft to land, repeatedly if necessary until all passengers have disembarked";
_aircraft land _landing_mode;

private ["_empty"];
_empty   = 0;
while { ((landResult _aircraft) != "NotFound") and (_empty == 0) } do
{
sleep _update_delay;

comment "remove dead and disembarked passengers";
private ["_disembarked"];
_disembarked = [];
if ( (count _passengers) == 0 ) then { _empty = 1; };
{
	if ( (!alive _x) || (_x == (vehicle _x)) ) then { _disembarked = _disembarked + [_x]; };
} forEach _passengers;
if ( (_debug == 1) && ((count _disembarked) > 0) ) then { diag_log (format ["time %1: '%3' disembarked from aircraft %2", time, _aircraft, _disembarked]); };
_passengers = _passengers - _disembarked;

comment "determine whether we're empty, and abort any landing if we are";
if ( (count _passengers) == 0 ) then 
{ 
	_empty = 1; 
	_aircraft land "NONE";
	if (_debug == 1) then { diag_log (format ["time %1: %2 completed disembarking", time, _aircraft]); };
}
else
{
	comment "reissue the land command unless we're moving or a group vehicle is close and underneath us";
	if ( unitReady _aircraft ) then 
	{
		comment "check if any of this groups' aircraft is near and lower";
		private ["_group_aircraft", "_above_aircraft"];
		_group_aircraft = [];
		{ if (((vehicle _x) != _aircraft) && (_x != (vehicle _x)) && (_x == driver (vehicle _x))) then { _group_aircraft = _group_aircraft + [vehicle _x]; }; } forEach (units _aircraft_group);
		_above_aircraft = 0;
		{
			if ( ((getPos _aircraft select 2) > (getPos _x select 2)) and ((_x distance _aircraft) < 10.0) ) then { _above_aircraft = 1; };
		} forEach _group_aircraft;

		if ( 0 == _above_aircraft ) then 
		{
			_aircraft land _landing_mode;
		};
	};
};

};

if (_debug == 1) then { diag_log (format ["time: %1 [%2] exec '%3' - exited", time, _aircraft, _script]); };

true

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  

×