Jump to content
Sign in to follow this  
sprucewaine

Getting AI to land Chopper

Recommended Posts

I want the crew to stay in the helicopter, but i don't know how to get it to land in any other way but this.

 

	player addEventHandler ["Fired", {
	params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
		if (_ammo isEqualTo "SmokeShell") then {
			_unit removeEventHandler ["Fired", 0];
			
			_pos = [getPos _projectile, 500, 500] call BIS_fnc_findSafePos;
			_veh = createVehicle ["B_CTRG_Heli_Transport_01_tropic_F", _pos, [], 0, "FLY"];
			_veh allowdamage false;
			createVehicleCrew _veh;
			
			{myCurator addCuratorEditableObjects [[_x],true ];}forEach units group _veh; //debug
			
			_wp = group _veh addWaypoint [position _projectile, 0];
			_wp setWaypointType "GETOUT";
			
			_veh addEventHandler ["GetIn", {
				params ["_vehicle", "_role", "_unit", "_turret"];
				[tsk,"SUCCEEDED"] call BIS_fnc_taskSetState;
				[tsk] call BIS_fnc_deleteTask;
				call selectRandom [HNK_fnc_createTask_HVT];
				{deleteVehicle _x}forEach crew _vehicle;
				deleteVehicle _vehicle;
			}];
		};
	}];

Keep in mind, ive spent the whole day trying out setWaypointstatement, and trying utilizing what the wiki example gave.

_helicopter move (getPos _destination);

sleep 3;

while { ( (alive _helicopter) && !(unitReady _helicopter) ) } do
{
       sleep 1;
};

if (alive _helicopter) then
{
       _helicopter land "LAND";
};

And the AI will just hover over where it is suppose to land.

 

Also if you know how to add a waitUntil {speed _projectile == 0}, much appreciated because i keep getting generic error in any form of implementation i choose.

Share this post


Link to post
Share on other sites
17 minutes ago, sprucewaine said:

I want the crew to stay in the helicopter, but i don't know how to get it to land in any other way but this.

 


	player addEventHandler ["Fired", {
	params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
		if (_ammo isEqualTo "SmokeShell") then {
			_unit removeEventHandler ["Fired", 0];
			
			_pos = [getPos _projectile, 500, 500] call BIS_fnc_findSafePos;
			_veh = createVehicle ["B_CTRG_Heli_Transport_01_tropic_F", _pos, [], 0, "FLY"];
			_veh allowdamage false;
			createVehicleCrew _veh;
			
			{myCurator addCuratorEditableObjects [[_x],true ];}forEach units group _veh; //debug
			
			_wp = group _veh addWaypoint [position _projectile, 0];
			_wp setWaypointType "GETOUT";
			
			_veh addEventHandler ["GetIn", {
				params ["_vehicle", "_role", "_unit", "_turret"];
				[tsk,"SUCCEEDED"] call BIS_fnc_taskSetState;
				[tsk] call BIS_fnc_deleteTask;
				call selectRandom [HNK_fnc_createTask_HVT];
				{deleteVehicle _x}forEach crew _vehicle;
				deleteVehicle _vehicle;
			}];
		};
	}];

Keep in mind, ive spent the whole day trying out setWaypointstatement, and trying utilizing what the wiki example gave.


_helicopter move (getPos _destination);

sleep 3;

while { ( (alive _helicopter) && !(unitReady _helicopter) ) } do
{
       sleep 1;
};

if (alive _helicopter) then
{
       _helicopter land "LAND";
};

And the AI will just hover over where it is suppose to land.

 

Also if you know how to add a waitUntil {speed _projectile == 0}, much appreciated because i keep getting generic error in any form of implementation i choose.

Why would you go through the hassle of all that? Just go into the editor and grab the "Land" waypoint off the advanced waypoint list and use an invisible helipad and if that doesn't work try 

vehicle this land 'land';

EDIT:

 

Here's a video for helicopter insertion/extraction, I understand that may not be what you're looking for but this goes through some key points and scripting in forcing choppers to land. It was helpful to me so maybe you'll find use in it as well. 

 

Share this post


Link to post
Share on other sites

You need to put a doStop in front of the land command, so the chopper stops where he's heading to and lands instead.

Also don't do this:

_unit removeEventHandler ["Fired", 0];

Since you can't be sure at any time if the eventhandler you added has the ID 0, might be some addon/mod already using it.

Use this instead:

_unit removeEventHandler ["Fired", _thisEventHandler];

Is a rather new magic variable.

 

Cheers

  • Thanks 1

Share this post


Link to post
Share on other sites
20 minutes ago, Grumpy Old Man said:

You need to put a doStop in front of the land command, so the chopper stops where he's heading to and lands instead.

Also don't do this:


_unit removeEventHandler ["Fired", 0];

Since you can't be sure at any time if the eventhandler you added has the ID 0, might be some addon/mod already using it.

Use this instead:


_unit removeEventHandler ["Fired", _thisEventHandler];

Is a rather new magic variable.

 

Cheers

 

The do stop did not work, perhaps i did it wrong. I did both doStop units _veh, and doStop _veh. edit *I made a mistake and put _veh instead of this, but i tried this, and it still didn't work?*

Spoiler

	player addEventHandler ["Fired", {
	params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
		if (_ammo isEqualTo "SmokeShell") then {
			_unit removeEventHandler ["Fired", _thisEventHandler];
			
			_pos = [getPos _projectile, 500, 500] call BIS_fnc_findSafePos;
			_veh = createVehicle ["B_CTRG_Heli_Transport_01_tropic_F", _pos, [], 0, "FLY"];
			_veh allowdamage false;
			createVehicleCrew _veh;
			
			{myCurator addCuratorEditableObjects [[_x],true ];}forEach units group _veh; //debug
			
			_wp = group _veh addWaypoint [position _projectile, 0];
			_wp setWaypointStatements ["true", "doStop units _veh; this land 'LAND'"];
			    
			_veh addEventHandler ["GetIn", {
				params ["_vehicle", "_role", "_unit", "_turret"];
				[tsk,"SUCCEEDED"] call BIS_fnc_taskSetState;
				[tsk] call BIS_fnc_deleteTask;
				call selectRandom [HNK_fnc_createTask_HVT];
				{deleteVehicle _x}forEach crew _vehicle;
				deleteVehicle _vehicle;
			}];
		};
	}];

 

thanks for the suggestions on removing the event handler.

Share this post


Link to post
Share on other sites

Helicopter is searching for nearest place to land. You can force it to land on spot by placing invisible helipad (object) where you want to helicopter to land.

  • Like 1

Share this post


Link to post
Share on other sites
8 minutes ago, M1ke_SK said:

Helicopter is searching for nearest place to land. You can force it to land on spot by placing invisible helipad (object) where you want to helicopter to land.

 

Its not searching, its just hovering. The command works pretty well, but i haven't gotten it to work on a way point statement might be the issue. Although the way point statement works fine with any other command.

 

 

Share this post


Link to post
Share on other sites
1 minute ago, sprucewaine said:

 

Its not searching, its just hovering. The command works pretty well, but i haven't gotten it to work on a way point statement might be the issue. Although the way point statement works fine with any other command.

 

 

 

hovering == searching (processing), try place helipad near landing zone

Share this post


Link to post
Share on other sites
 
Its not searching, its just hovering. The command works pretty well, but i haven't gotten it to work on a way point statement might be the issue. Although the way point statement works fine with any other command.
 
 


Hi...

https://www.dropbox.com/s/mtz5xwul6h2wtee/HeloScripts.zip?dl=0

I spent a great deal of time trying to make helo troop insertions and covering gun ship support as easy as possible - basically using markers to drive everything - the descriptions are in the header of each script... Maybe something useful in this ?

Best of luck...

Regards,
Scott


Sent from my iPad using Tapatalk

Share this post


Link to post
Share on other sites

Welp, so apparently telling the leader of the group to land does nothing. You must tell the actual helicopter to land. so by adding a "vehicle this" to the waypointstatement, i managed to get it to work. :( half a day gone.

Spoiler
1 hour ago, socs said:

Why would you go through the hassle of all that? Just go into the editor and grab the "Land" waypoint off the advanced waypoint list and use an invisible helipad and if that doesn't work try 



vehicle this land 'land';

EDIT:

 

Here's a video for helicopter insertion/extraction, I understand that may not be what you're looking for but this goes through some key points and scripting in forcing choppers to land. It was helpful to me so maybe you'll find use in it as well. 

 

 

Learning to script out everything so that you don't have to use the editor is an amazing and wroth while endeavor. You have the potential to create a live universe that can spawn it self when needed, and delete itself when not. If you do it correctly, it won't even matter what map its on, you could just copy and paste the scripts into any map and it will work.

 

 

Share this post


Link to post
Share on other sites
50 minutes ago, sprucewaine said:

Welp, so apparently telling the leader of the group to land does nothing. You must tell the actual helicopter to land. so by adding a "vehicle this" to the waypointstatement, i managed to get it to work. :( half a day gone.

  Hide contents

 

Learning to script out everything so that you don't have to use the editor is an amazing and wroth while endeavor. You have the potential to create a live universe that can spawn it self when needed, and delete itself when not. If you do it correctly, it won't even matter what map its on, you could just copy and paste the scripts into any map and it will work.

 

 

Yes but there's certain things that are just made easier for you as scripting isn't an easy task. Learning to script is cool and all but useless when you don't put in the time to read on the wiki about each command etc. Not intentionally trying to sound rude or throw you off, I'm just saying there's some things you script, and other things you just don't... 

Share this post


Link to post
Share on other sites
1 hour ago, socs said:

Yes but there's certain things that are just made easier for you as scripting isn't an easy task. Learning to script is cool and all but useless when you don't put in the time to read on the wiki about each command etc. Not intentionally trying to sound rude or throw you off, I'm just saying there's some things you script, and other things you just don't... 

You are right about me reading the wiki wrong, i didn't expect it wanting the vehicle instead of the driver.

Share this post


Link to post
Share on other sites
1 hour ago, sprucewaine said:

You are right about me reading the wiki wrong, i didn't expect it wanting the vehicle instead of the driver.

Well, nonetheless, I hope the tip I gave you helped! Enjoy!

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  

×