Comrades in Arms Discussion Board

Full Version: heli extraction script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
here`s a script i found for heli extraction for those who maybe need one.

/*
Filename: COB_extraction.sqf
Author: cobra4v320

Description:
Spawns a helicopter at a marker location, the helicopter moves to another marker location and picks up a group of soldiers.
Prior to the helicopter touching down it will open both of its doors. When the group is in the helicopter the doors will close.
The helicopter will then move to another marker and drop off the group. Prior to landing the doors will open. When the
group gets out the doors will close and the helicopter will return to its spawn position and delete the crew, helicopter, and markers.
Requires pre-placed helicopter pads or place the marker over a pad that already has them like camp rogain or stratis airbase.

Parameter(s):
_this select 0: this is the side of the extraction helicopter (blufor, opfor, independent).
_this select 1: this is the group that the extraction helicopter will pick up.
_this select 2: the is the helicopter classname or type.
_this select 3: this will set the helicopter as captive, keeps the enemy from shooting at them. (default is false)

Example(s):
0 = [blufor, group player, "B_Heli_Transport_01_camo_F", true] execVM "COB_extraction.sqf" //this will spawn a ghosthawk and it will be setCaptive True
*/

if (!isServer) exitWith {};



_side = _this select 0;
_group = _this select 1;
_heliType = _this select 2;
_captive = if (count _this > 3) then {_this select 3} else {false};

_spawnPos = getMarkerPos "heliSpawnMrk";
_extractPos = getMarkerPos "extractMrk";
_basePos = getMarkerPos "baseMrk";
_spawnDir = [_spawnPos, _extractPos] call BIS_fnc_dirTo;

_helisv = [_spawnPos, _spawnDir, _heliType, _side] call BIS_fnc_spawnVehicle;
_heli = _helisv select 0;
_heliGroup = _helisv select 2;
_dir = direction _heli;
_heli setVelocity [sin(_dir)*60,cos(_dir)*60,0];

{
    _x disableAI "AUTOTARGET";
    _x disableAI "TARGET";
    _x allowFleeing 0;
    _x setCaptive _captive;
} forEach (units _heliGroup);

_heli spawn {
    while { alive _this } do {
        player action ["collisionlightOff", _this]; //turn off lights
        sleep 0.01;
    };
};

_wp0 = _heliGroup addWaypoint [_extractPos, 0];
_wp0 setWaypointType "MOVE";
_wp0 setWaypointSpeed "FULL";
_wp0 setWaypointBehaviour "CARELESS";
_wp0 setWaypointStatements ["true", "(vehicle this) land 'GET IN'; {(vehicle this) animateDoor [_x, 1]} forEach ['door_back_L','door_back_R','door_L','door_R']"];
       
waituntil {{_x in _heli} count (units _group) == {alive _x} count (units _group)};

{_heli animateDoor [_x, 0]} forEach ["door_back_L","door_back_R","door_L","door_R"];

_wp1 = _heliGroup addWaypoint [_basePos, 0];   
_wp1 setWaypointType "MOVE";
_wp1 setWaypointSpeed "FULL";
_wp1 setWaypointBehaviour "CARELESS";
_wp1 setWaypointStatements ["true", "(vehicle this) land 'GET OUT'; {(vehicle this) animateDoor [_x, 1]} forEach ['door_back_L','door_back_R','door_L','door_R']"];

waituntil {{_x in _heli} count (units _group) < 1};

{_heli animateDoor [_x, 0]} forEach ["door_back_L","door_back_R","door_L","door_R"];

_wp2 = _heliGroup addWaypoint [_spawnPos, 0];
_wp2 setWaypointType "MOVE";
_wp2 setWaypointSpeed "FULL";
_wp2 setWaypointBehaviour "CARELESS";
_wp2 setWaypointStatements ["true", "{deleteVehicle _x} forEach (crew vehicle this) + [vehicle this]"];

deleteMarker "heliSpawnMrk";
deleteMarker "extractMrk";
deleteMarker "baseMrk";

i fiddling around with it for some days and it works in SP and MP for a defind group so that any alive group member is a condition for the heli to take off. if anyone had a look and has an idea how to define more than one group please let me know.

cya