Jump to content
patpowercat

Helicopter Extract Script

Recommended Posts

I know this has been discussed before. But most of what I could find involves extracting using just the editor, and I am trying to use only a script. I want to spawn a helicopter, move to WP and land, wait until player group is in helicopter, then take off and move to next waypoint. I have got everything to work, but the helicopter will not take off once people are in.

 

I have tried

waitUntil { { ( alive _x ) || { ( _x in ( _airframe1 select 0 ) ) } } count (units ALPHA) == count (units ALPHA)};

waitUntil {player1 in _airframe1};

waitUntil  {{_x in _airframe1} count (units ALPHA) == {alive _x} count (units ALPHA)};

waitUntil {alive _X && !(_X in crew heli)} count (units ALPHA) <= 0;
                                                                   
waituntil {{_x in _airframe1} count (units group player) == {alive _x} count (units group player)};

With ALPHA being the player's group or the unit being named player1, with the helo being named _airframe1. Any help appreciated. 

Share this post


Link to post
Share on other sites
waitUntil {sleep 3; (count (allplayers select {alive _x})) isEqualTo (count (allplayers select {_x in _airframe1}))};

 

Share this post


Link to post
Share on other sites

Didn't work. Helicopter still just sits and never takes off. Any other ideas?

 

Here is the whole script in case it helps. 

_crew1 = [];
_airframe1 = [];

if (isServer) then {

_crew1 = creategroup WEST; 
_airframe1 = [getMarkerPos "pickup_spawn", markerDir "pickup_spawn", "B_Heli_Transport_01_F", _crew1] call BIS_fnc_spawnVehicle;

_wp1 = _crew1 addWaypoint [(getmarkerpos "pickup"), 0];
_wp1 setWaypointType "LOAD";
_wp1 setWaypointSpeed "FAST";
_wp1 setwaypointstatements ["true", "(vehicle this) LAND 'GET IN';"];

//waitUntil { { ( alive _x ) || { ( _x in ( _airframe1 select 0 ) ) } } count (units ALPHA) == count (units ALPHA)};
//waitUntil {player1 in _airframe1};
//waitUntil  {{_x in _airframe1} count (units ALPHA) == {alive _x} count (units ALPHA)};
//waitUntil {alive _X && !(_X in crew heli)} count (units ALPHA) <= 0;
//waituntil {{_x in _airframe1} count (units group player) == {alive _x} count (units group player)};
//waitUntil {sleep 3; (count (allplayers select {alive _x})) isEqualTo (count (allplayers select {_x in _airframe1}))};

_wp2 = _crew1 addWaypoint [(getmarkerpos "pickup_spawn"), 100];
_wp2 setWaypointType "MOVE";
_wp2 setWaypointSpeed "FAST";

}; 

All the different waitUntils I have tried are commented. 

Share this post


Link to post
Share on other sites

I can successfully get this to work with a number of different code in the condition field of a waypoint if the unit it already placed in editor. For example this works perfectly in the condition field:

 

{_x in transport} count (units ALPHA) == {alive _x} count (units ALPHA);

However in the script nothing with waitUntil works. 

Share this post


Link to post
Share on other sites

here you go

 

_crew1 = [];
_airframe1 = [];
_heli = objNull;

if (isServer) then {

_crew1 = creategroup WEST; 
_airframe1 = [getMarkerPos "pickup_spawn", markerDir "pickup_spawn", "B_Heli_Transport_01_F", _crew1] call BIS_fnc_spawnVehicle;
_heli = _airframe1 select 0;
_wp1 = _crew1 addWaypoint [(getmarkerpos "pickup"), 0];
_wp1 setWaypointType "LOAD";
_wp1 setWaypointSpeed "FAST";
_wp1 setwaypointstatements ["true", "(vehicle this) LAND 'GET IN';"];

waitUntil {sleep 3;(count (allplayers select {alive _x})) isEqualTo (count (allplayers select {_x in _heli}))};

_wp2 = _crew1 addWaypoint [(getmarkerpos "pickup_spawn"), 100];
_wp2 setWaypointType "MOVE";
_wp2 setWaypointSpeed "FAST";

}; 

 

Issue was you didn't check the vehicle but the whole array.

https://community.bistudio.com/wiki/BIS_fnc_spawnVehicle

 

Return Value:

Array - 0: created vehicle (Object), 1: all crew (Array of Objects), 2: vehicle's group (Group)

  • Like 2

Share this post


Link to post
Share on other sites

just glancing at this , this line appears wrong

 

Quote

waitUntil {alive _X && !(_X in crew heli)} count (units ALPHA) <= 0;

 

the waituntil condition will never be true, need to move the bracket

 

Quote

waitUntil {alive _X && !(_X in crew heli) count (units ALPHA) <= 0;}

 

Share this post


Link to post
Share on other sites
2 hours ago, nomadd said:

just glancing at this , this line appears wrong

 

 

the waituntil condition will never be true, need to move the bracket

 

 

Actually it needs to be like this:

waitUntil {{alive _x && !(_x in crew heli)} count (units ALPHA) <= 0}

 

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

×