Jump to content
Sign in to follow this  
yoannis1995

Helicopter extraction script

Recommended Posts

Hi,

I'm trying to make a script for an extraction by helicopter with units disembarking the helicopter and protecting it while waiting for the player and its group to go on board.

Here's the beginning of the script:

_veh = [getMarkerPos "heli_start", 0, "B_Heli_Transport_01_F", west] call BIS_fnc_spawnVehicle;  
createVehicleCrew (_veh select 0);
sleep 3;
_grp1 = createGroup west;
_qrf1 = "B_Soldier_SL_F" createUnit [getMarkerPos "heli_start", _grp1,"this MoveInCargo _veh;", 0.6, "corporal"];
_qrf2 = "B_Soldier_F" createUnit [getMarkerPos "heli_start", _grp1,"this MoveInCargo _veh;", 0.6];
_qrf3 = "B_Soldier_GL_F" createUnit [getMarkerPos "heli_start", _grp1,"this MoveInCargo _veh;", 0.6];
_qrf4 = "B_Soldier_F" createUnit [getMarkerPos "heli_start", _grp1,"this MoveInCargo _veh;", 0.6];
_qrfArray = [];
_qrfArray = [qrf4,qrf3,qrf2,qrf1];

_driver = driver _veh;
_grp2 = group _driver;

_wp1 = _grp2 addWaypoint [getMarkerPos "move_heli", 0];
[_grp2, 0] setWaypointType "TR UNLOAD";
_wp1 setWaypointStatements ["true", "_veh land 'LAND'; {_x setUnitPos 'middle'; _x setSpeedMode 'LIMITED'; _x setCombatMode 'YELLOW';}foreach units _grp1;"];
_wp2 = _grp2 addWaypoint [getMarkerPos "move_heli", 1];
[_grp2, 1] setWaypointType "LAND";
doStop _driver;
waitUntil {{vehicle _x = _veh} forEach units group player && {vehicle _x = _veh} forEach units _grp1};

And also the 2 first problems... :P First the units of the group _grp1 are not in the helicopter but on the ground. And secondly, the helicopter is not moving to its given waypoint but staying static in the air instead. How can I fix this ?

Share this post


Link to post
Share on other sites

Untested...

	_side = WEST;
_grp2 = createGroup WEST;
_pos = getMarkerPos "heli_start";
_veh = createVehicle ["B_Heli_Transport_01_F", _pos, [], 270, "FLY"];
_pilot = _grp2 createUnit ["B_Pilot_F",_pos,[],0,"FORM"];
_pilot assignasdriver _veh;
_pilot moveindriver _veh;
_veh flyinheight 150;
_units = ["B_Soldier_SL_F","B_Soldier_F","B_Soldier_GL_F","B_Soldier_F"];
_grp = [_pos, _side, _units, [], [], 0.6] call BIS_fnc_spawnGroup;
{_x moveincargo _veh;} foreach units _grp;
// Your Waypoints
_wp1 = _grp2 addWaypoint [getMarkerPos "move_heli", 0];
[_grp2, 0] setWaypointType "TR UNLOAD";
_wp1 setWaypointStatements ["true", "_veh land 'LAND'; {_x setUnitPos 'middle'; _x setSpeedMode 'LIMITED'; _x setCombatMode 'YELLOW';}foreach units _grp1;"];
_wp2 = _grp2 addWaypoint [getMarkerPos "move_heli", 1];
[_grp2, 1] setWaypointType "LAND";
doStop _pilot;
waitUntil {{vehicle _x = _veh} forEach units group player && {vehicle _x = _veh} forEach units _grp1};

Share this post


Link to post
Share on other sites

Ok now I've got that:

_side = WEST; 
_grp2 = createGroup WEST; 
_pos = getMarkerPos "heli_start"; 
_pad = "Land_HelipadEmpty_F" createVehicle _pos;
_veh = createVehicle ["B_Heli_Transport_01_F", _pos, [], 270, "FLY"]; 
_pilot = _grp2 createUnit ["B_Pilot_F",_pos,[],0,"FORM"]; 
_pilot assignasdriver _veh; 
_pilot moveindriver _veh;
_veh flyinheight 150; 
_units = ["B_Soldier_SL_F","B_Soldier_F","B_Soldier_GL_F","B_Soldier_F"]; 
_grp = [_pos, _side, _units, [], [], 0.8] call BIS_fnc_spawnGroup; 
{_x moveincargo _veh;} foreach units _grp; 

_wp1 = _grp2 addWaypoint [getMarkerPos "move_heli", 0];
[_grp2, 0] setWaypointType "TR UNLOAD"; 
_wp1 setWaypointStatements ["true", "_veh land 'LAND'; {_x setUnitPos 'middle'; _x setSpeedMode 'LIMITED'; _x setCombatMode 'YELLOW';}foreach units _grp1;"]; 
_wp2 = _grp2 addWaypoint [getMarkerPos "move_heli", 1]; 
[_grp2, 1] setWaypointType "LAND"; 
_wp2 setWaypointStatements ["true", "doStop _pilot;"];
waitUntil {{vehicle _x = _veh} forEach units group player && {vehicle _x = _veh} forEach units _grp};

So the helicopter will move to the position but it doesn't land and the units inside don't get out....

Also how can I get a right door gunner and a copilot in the helicopter ? With the command "MoveInGunner" I only get a left door gunner...

Share this post


Link to post
Share on other sites

[_grp2, 1] setWaypointType "LAND";

This isn't a valid waypoint type. To make a land waypoint you must do:

_wp2 setWaypointType "SCRIPTED";

_wp2 setWaypointScript "A3\functions_f\waypoints\fn_wpLand.sqf";

Also note that waypoint 0 is always a waypoint at the position where a unit was created, so instead of [_grp2, 0] you should just use the variable you gave the waypoint.

Share this post


Link to post
Share on other sites

First: I had the same issue, and you may search around the forum a post of mine two months ago. There you may find the key: here. I'm at work, later on I may post the working script if you need.

The solution began by using BIS_fnc_spawnVehicle, which has a more reliable response to TR UNLOAD waypoints etc..

Second, this is not valid AFAIK: _wp1 setWaypointStatements ["true", "_veh land 'LAND'; {_x setUnitPos 'middle'; _x setSpeedMode 'LIMITED'; _x setCombatMode 'YELLOW';}foreach units _grp1;"];

_grp1 and _veh are local variables, the waypoint statements only understand global variables.

Same here:

_wp2 setWaypointStatements ["true", "doStop _pilot;"];

And regarding waypoint creation, the "LAND" waypoint does not exist and you are creating to the pilot group, instead of the cargo group, I suggest:

_wp2 = _grp addWaypoint [getMarkerPos "move_heli", 1];

_wp2 setWaypointType "GETOUT";

More, why you create the helipad on the _pos where you spawn the heli. What you want is to create it in the place you want the heli to land, so it won't land anywhere except where you want... So instead of that, I suggest:

_pad = "Land_HelipadEmpty_F" createVehicle (getMarkerPos "move_heli");

Share this post


Link to post
Share on other sites
...how can I get a right door gunner and a copilot in the helicopter ? With the command "MoveInGunner" I only get a left door gunner...
You'd have to create a unit for each position, then move them in.

In the following example, the units have been created with the ID's CoPilot1, Gunner1 and Gunner2.

	CoPilot1 moveInTurret [vehName,[0]];// CoPilot.
Gunner1 moveInTurret [vehName,[1]];// Leftside Gunner.
Gunner2 moveInTurret [vehName,[2]];// Rightside Gunner.

However, as barbolani says, you're better off using BIS_fnc_spawnVehicle function to create both the helo and the crew.

For example.

	_side = WEST;
_grp2 = createGroup WEST;
_pos = getMarkerPos "heli_start"; 
_pad = "Land_HelipadEmpty_F" createVehicle _pos;
_veh = [_pos, 270, "B_Heli_Transport_01_F", _grp2] call BIS_fnc_spawnVehicle;// This will create a UH80 with crew and gunners
vehName = _veh select 0;//Due to the fact we are now using BIS_fnc_spawnVehicle _veh is no longer the name of the spawned unit. We have to find it.
vehName flyInHeight 150;//With the Spawned vehicle's name we can assign properties i.e. it's flying height.
_units = ["B_Soldier_SL_F","B_Soldier_F","B_Soldier_GL_F","B_Soldier_F"];
_grp = [_pos, _side, _units, [], [], 0.8] call BIS_fnc_spawnGroup;
{_x moveincargo vehName;} foreach units _grp;//Note we are using the new name for spawned vehicle

Now add your waypoints.

Share this post


Link to post
Share on other sites

Ok thanks guys :) I took barbolani's script. So now I've got that:

// Starting
_side = WEST;
_pos = getMarkerPos "heli_start";
_landpos = getMarkerPos "move_heli";
_pad = createVehicle ["Land_HelipadEmpty_F", _landpos, [], 0, "NONE"];  
_movepos = [(_landpos select 0) + 1,(_landpos select 1) + 2,0]; 

//Creating helicopter
_vehicle = [_pos, 0, "B_Heli_Transport_01_F", WEST] call bis_fnc_spawnvehicle; 
_veh = _vehicle select 0; 
_vehCrew = _vehicle select 1; 
_grpheli = _vehicle select 2; 
_vehDriver = driver _veh; 
_veh setpos [getpos _veh select 0,getpos _veh select 1,0]; 

//Creating defensive group
_units = ["B_Soldier_SL_F","B_Soldier_F","B_Soldier_GL_F","B_Soldier_F"]; 
_grp = [_pos, _side, _units, [], [], 0.8] call BIS_fnc_spawnGroup; 
{_x assignAsCargo _veh; _x moveInCargo _veh;} forEach units _grp;

//Creating helicopter WPs
_Hwp0 = _grpheli addWaypoint [_landpos, 0]; 
_Hwp0 setWaypointType "TR UNLOAD"; 
_Hwp0 setWaypointStatements ["true", "doStop (driver this); (vehicle this) engineOn true;"]; 
_Hwp0 setWaypointBehaviour "CARELESS";   
_veh setBehaviour "CARELESS"; 
_veh disableAI "AUTOTARGET"; 

//Creating defensive group WPs
_Gwp0 = _grp addWaypoint [_landpos, 0]; 
_Gwp0 setWaypointType "GETOUT"; 
_Gwp0 synchronizeWaypoint [_grpheli, 0]; 
_Gwp1 = _grp addWaypoint [_landpos, 1]; 
_Gwp1 setWaypointType "MOVE"; 
_Gwp1 setWaypointStatements ["true", "(vehicle this) land 'land'; (vehicle this) engineOn true;"]; 

So up until there everything is working fine :) But now, I don't know if it is possible and how, I'd like to have the 4 units of the group getting out of the helicopter defending it. So I'd like to make move one of them in front of the helicopter, 1 on each side and 1 at the back off it. Is it possible to get those 4 positions related to the position of the helicopter ?

Share this post


Link to post
Share on other sites

Ok, I found a way of doing it ! But now I would like to select the units of the group one by one so I can make each one of them move to a different position. How do I do that ?

Also that part doesn't work:

{_x assignAsCargo _veh; [_x] orderGetIn true;} forEach units _grp;
waituntil {{_x in _veh}count units _grp == {alive _x} count units _grp};

I'm guessing it's a problem due to variables but how can I make it work ?

Share this post


Link to post
Share on other sites

Ahm the "dismount drill script". Yes! You can!

At the office, but let's do it because I'm bored as shit...

This is not the best way, but should work. The difficult thing here is the command doMove, which you use to say individual units to move here or there, after the unit reaches destination, unit goes back to formation, and that's ugly.

So, I recommend the execution of an external script from here.

First, delete the second waypoint for infantry, you don't need it. The statements on it you may put them in the "TR UNLOAD" heli waypoint.

Then, the last line of your script should be:

waitUntil {sleep 0.5; (count assignedCargo _veh == 0)};

from here you know all the units had disembark. Now call the script:

_nul = [_veh,_grp] execVM "dismountdrill.sqf";

And now let's make the script:

_veh = _this select 0;

_group = _this select 1;

_arrayunits = units _group;

_dir = getDir _veh;

_anginc = 360 / (count _arrayunits);

for "_i" from 0 to ((count _arrayunits) - 1) do

{

_grouptmp = createGroup WEST;

[_x] join _grouptmp;

_pos = [getPos _veh , 15, _dir] call BIS_fnc_relPos;

_x doMove _pos;

_dir = _dir + _anginc;

} forEach _arrayunits;

waitUntil {sleep 0.5; {({vehicle _x == _veh} count units group player) == ({alive _x} count units group player)};

{

_grouptmp = _group _x;

[_x] join _group;

deleteGroup _grouptmp;

} forEach _arrayunits;

_veh domove getMarkerPos "heli_start";// or whatever destination you want to give the heli

Share this post


Link to post
Share on other sites

Well your script didn't really work for me but I had made part of the moving script and took some part of yours. Now I've got that:

//Creating defensive group WPs
Gready = false;
_Gwp0 = _grp addWaypoint [_landpos, 0]; 
_Gwp0 setWaypointType "GETOUT"; 
_Gwp0 synchronizeWaypoint [_grpheli, 0];  
_Gwp0 setWaypointStatements ["true", "Gready = true;"]; 
_Gwp0 setWaypointBehaviour "AWARE"; 
_Gwp0 setWaypointCombatMode "GREEN";
_grp setCombatMode "GREEN";  
_grp setBehaviour "AWARE"; 

//Moving into defense position
waitUntil {Gready};
hint "ready";
_d = direction _veh;
_arrayunits = [];
_arrayunits = units _grp;
{
_grouptmp = createGroup WEST;
[_x] join _grouptmp;
_movepos = [_veh, 3, _d] call BIS_fnc_relPos;
_x doMove _movepos;
_d = _d + 90;
} forEach _arrayunits;
{
_timeout = time + 80;
waitUntil {moveToCompleted _x or moveToFailed _x or !alive _x or _timeout < time};
doStop _x;
_x setUnitPos "middle"; 
_x setSpeedMode "LIMITED";
_x setCombatMode "YELLOW";
sleep 1;
} forEach _arrayunits;

//Waiting for the player's group to get in
waituntil {{_x in _veh}count units group player == {alive _x} count units group player};
hint "group player ok";
//Boarding defensive group
{
_grouptmp = group _x;
[_x] join _grp;
deleteGroup _grouptmp;
_x assignAsCargo _veh;
[_x] orderGetIn true;
} forEach _arrayunits;
waituntil {{_x in _veh}count units _grp == {alive _x} count units _grp};
hint "group 2 ok";

There are now 2 problems. Half of the units of the group will wait for the "_timeout" to pass to kneel. And the second problem is once the group of the player has boarded the helicopter the other group still won't move and get in the helo...

Any ideas how to fix that ?!

Share this post


Link to post
Share on other sites

why waiting to lots of things on each unit before making the other unit to move? Make them move without waituntil and time out and look at the results.

Second issue.... uhm... maybe try to add a waypoint to them so they decide to board the vehicle to reach it....

Share this post


Link to post
Share on other sites
For the helicopter landing/takeoff, you could also use the unitCapture and unitPlay functions.

I could but I don't really need to, the IA does that job just fine!

But still can't solve the problem off the group getting back in the helicopter... It's weird that works:

//Creating defensive group
_side = WEST;
_pos = getMarkerPos "heli_start";
_units = ["B_Soldier_SL_F","B_Soldier_F","B_Soldier_GL_F","B_Soldier_F"]; 
_grp = [_pos, _side, _units, [], [], [0.8]] call BIS_fnc_spawnGroup; 
//Moving into defense position
_d = direction heli1;
_arrayunits = [];
_arrayunits = units _grp;
{
_grouptmp = createGroup WEST;
[_x] join _grouptmp;
_movepos = [heli1, 3, _d] call BIS_fnc_relPos;
_x doMove _movepos;
_d = _d + 90;
} forEach _arrayunits;
sleep 10;
{
doStop _x;
_x setUnitPos "middle"; 
_x setSpeedMode "LIMITED";
_x setCombatMode "YELLOW";
sleep 1;
} forEach _arrayunits;
waituntil {{_x in heli1}count units group player == {alive _x} count units group player};
hint "group player ok";
//Boarding defensive group
{
_grouptmp = group _x;
[_x] join _grp;
deleteGroup _grouptmp;
_x assignAsCargo heli1;
[_x] orderGetIn true;
} forEach _arrayunits;
waituntil {{_x in heli1}count units _grp == {alive _x} count units _grp};
hint "group 2 ok";

But in the full version it doesn't... :

// Starting
_initiate = _this select 0;
_smoke = _this select 1;

//initiate map click + smoke
if (_initiate && _smoke) exitWith {
hint "Click on the map or throw a smoke grenade to call the helicopter for extraction";
onMapSingleClick "nul=[false,false,_pos] execVM 'extract.sqf'; onMapSingleClick ''; player removeEventHandler ['fired',0];";
tabfumis = ["SmokeShellYellow","SmokeShellRed","SmokeShellGreen","SmokeShellPurple","SmokeShellBlue","SmokeShellOrange","1Rnd_SmokeRed_Grenade_shell","1Rnd_SmokeGreen_Grenade_shell", "1Rnd_SmokeYellow_Grenade_shell","1Rnd_SmokePurple_Grenade_shell","1Rnd_SmokeBlue_Grenade_shell","1Rnd_SmokeOrange_Grenade_shell","3Rnd_SmokeRed_Grenade_shell","3Rnd_SmokeGreen_Grenade_shell", "3Rnd_SmokeYellow_Grenade_shell","3Rnd_SmokePurple_Grenade_shell","3Rnd_SmokeBlue_Grenade_shell","3Rnd_SmokeOrange_Grenade_shell"];
player addEventHandler["fired", {
hint "fired";
  _mag = _this select 5;
  _obj = _this select 6;
  if (_mag in tabfumis) then {
  _positonfumi = [];
  sleep 8;
     _positionfumi = getpos _obj;
  nul=[false,true,_positionfumi] execVM "extract.sqf";
  hint "smoke detected";
  player removeEventHandler ["fired",0];
  onMapSingleClick "";
  };
}];
};

//initiate map click only
if (_initiate) exitWith {
hint "Click on the map to call the helicopter for extraction";
onMapSingleClick "nul=[false,false,_pos] execVM 'extract.sqf'; onMapSingleClick '';";
};

//initate done
if (! _initiate) then {
hint "Position recieved";
_landpos = [];
//finding suitable position
_center = _this select 2;
_findGoodSpot = true;
_maxdist = 50;  // max initial range from below position to search for LZ.
while {_findGoodSpot} do {
_posTemp = [_center, 0, _maxdist, 8, 0, 0.5, 0] call BIS_fnc_findSafePos;
_maxdist = _maxdist + 10;  // add to the range to check if no LZ found.
sleep 1;
_string = format _posTemp;
sleep 1;
if (!isNil ("_string")) then {
	_landpos = _posTemp;
	_findGoodSpot = false;
	hint "position found";
};
};

_side = WEST;
_pos = getMarkerPos "heli_start";
_marker = createMarker ["pickup", _landpos];
_marker setMarkerColor "ColorGreen";
_marker setMarkerType "mil_pickup";
_pad = createVehicle ["Land_HelipadEmpty_F", _landpos, [], 0, "NONE"];  


//Creating helicopter
_vehicle = [_pos, 0, "B_Heli_Transport_01_F", WEST] call bis_fnc_spawnvehicle; 
_veh = _vehicle select 0; 
_vehCrew = _vehicle select 1; 
_grpheli = _vehicle select 2; 
_vehDriver = driver _veh; 
_veh setpos [getpos _veh select 0,getpos _veh select 1,0]; 

//Creating defensive group
_units = ["B_Soldier_SL_F","B_Soldier_F","B_Soldier_GL_F","B_Soldier_F"]; 
_grp = [_pos, _side, _units, [], [], [0.8]] call BIS_fnc_spawnGroup; 
{_x assignAsCargo _veh; _x moveInCargo _veh;} forEach units _grp;

//Creating helicopter WPs
_Hwp0 = _grpheli addWaypoint [_landpos, 0]; 
_Hwp0 setWaypointType "TR UNLOAD"; 
_Hwp0 setWaypointStatements ["true", "doStop (driver this); (vehicle this) engineOn true;"]; 
_Hwp0 setWaypointBehaviour "AWARE";   
_Hwp0 setWaypointCombatMode "GREEN";
_veh setCombatMode "GREEN";
_veh setBehaviour "AWARE"; 


//Creating defensive group WPs
Gready = false;
_Gwp0 = _grp addWaypoint [_landpos, 0]; 
_Gwp0 setWaypointType "GETOUT"; 
_Gwp0 synchronizeWaypoint [_grpheli, 0];  
_Gwp0 setWaypointStatements ["true", "Gready = true;"]; 
_Gwp0 setWaypointBehaviour "AWARE"; 
_Gwp0 setWaypointCombatMode "GREEN";
_grp setCombatMode "GREEN";  
_grp setBehaviour "AWARE"; 

//Moving into defense position
waitUntil {Gready};
hint "ready";
_d = direction _veh;
_arrayunits = [];
_arrayunits = units _grp;
{
_grouptmp = createGroup WEST;
[_x] join _grouptmp;
_movepos = [_veh, 3, _d] call BIS_fnc_relPos;
_x doMove _movepos;
_d = _d + 90;
} forEach _arrayunits;
sleep 10;
{
doStop _x;
_x setUnitPos "middle"; 
_x setSpeedMode "LIMITED";
_x setCombatMode "YELLOW";
sleep 1;
} forEach _arrayunits;

//Waiting for the player's group to get in
waituntil {{_x in _veh}count units group player == {alive _x} count units group player};
hint "group player ok";
//Boarding defensive group
{
_grouptmp = group _x;
[_x] join _grp;
deleteGroup _grouptmp;
_x assignAsCargo _veh;
[_x] orderGetIn true;
} forEach _arrayunits;
waituntil {{_x in _veh}count units _grp == {alive _x} count units _grp};
hint "group 2 ok";
//Moving and unloading player's group

//Moving and deleting helicopter
};

Even if I replace "_x assignAsCargo _veh;" by "_x assignAsCargo heli1;"...

Help please !!! :(

Share this post


Link to post
Share on other sites

Ok I tried to change the way of getting the group in the helicopter by using a waypoint but it doesn't change anything. I tried to make the units of the group playable units so I can see if they get the order to get in but it doesn't work either... And I don't understand because I'm gettin the hint "group 2 ok" which I'm supposed to get once they're on board.

Here's the actuall full script:

// Starting
_initiate = _this select 0;
_smoke = _this select 1;

//initiate map click + smoke
if (_initiate && _smoke) exitWith {
hint "Click on the map or throw a smoke grenade to call the helicopter for extraction";
onMapSingleClick "nul=[false,false,_pos] execVM 'extract.sqf'; onMapSingleClick ''; player removeEventHandler ['fired',0];";
tabfumis = ["SmokeShellYellow","SmokeShellRed","SmokeShellGreen","SmokeShellPurple","SmokeShellBlue","SmokeShellOrange","1Rnd_SmokeRed_Grenade_shell","1Rnd_SmokeGreen_Grenade_shell", "1Rnd_SmokeYellow_Grenade_shell","1Rnd_SmokePurple_Grenade_shell","1Rnd_SmokeBlue_Grenade_shell","1Rnd_SmokeOrange_Grenade_shell","3Rnd_SmokeRed_Grenade_shell","3Rnd_SmokeGreen_Grenade_shell", "3Rnd_SmokeYellow_Grenade_shell","3Rnd_SmokePurple_Grenade_shell","3Rnd_SmokeBlue_Grenade_shell","3Rnd_SmokeOrange_Grenade_shell"];
player addEventHandler["fired", {
hint "fired";
  _mag = _this select 5;
  _obj = _this select 6;
  if (_mag in tabfumis) then {
    _positonfumi = [];
    sleep 8;
     _positionfumi = getpos _obj;
    nul=[false,true,_positionfumi] execVM "extract.sqf";
    hint "smoke detected";
    player removeEventHandler ["fired",0];
    onMapSingleClick "";
  };
}];
};

//initiate map click only
if (_initiate) exitWith {
hint "Click on the map to call the helicopter for extraction";
onMapSingleClick "nul=[false,false,_pos] execVM 'extract.sqf'; onMapSingleClick '';";
};

//initate done
if (! _initiate) then {
hint "Position recieved";
_landpos = [];
//finding suitable position
_center = _this select 2;
_findGoodSpot = true;
_maxdist = 50;  // max initial range from below position to search for LZ.
while {_findGoodSpot} do {
  _posTemp = [_center, 0, _maxdist, 8, 0, 0.5, 0] call BIS_fnc_findSafePos;
  _maxdist = _maxdist + 10;  // add to the range to check if no LZ found.
  sleep 1;
  _string = format _posTemp;
  sleep 1;
  if (!isNil ("_string")) then {
     _landpos = _posTemp;
     _findGoodSpot = false;
     hint "position found";
  };
};

_side = WEST;
_pos = getMarkerPos "heli_start";
_marker = createMarker ["pickup", _landpos];
_marker setMarkerColor "ColorGreen";
_marker setMarkerType "mil_pickup";
_pad = createVehicle ["Land_HelipadEmpty_F", _landpos, [], 0, "NONE"];  


//Creating helicopter
_vehicle = [_pos, 0, "B_Heli_Transport_01_F", WEST] call bis_fnc_spawnvehicle; 
_veh = _vehicle select 0; 
_vehCrew = _vehicle select 1; 
_grpheli = _vehicle select 2; 
_vehDriver = driver _veh; 
_veh setpos [getpos _veh select 0,getpos _veh select 1,0]; 

//Creating defensive group
_units = ["B_Soldier_SL_F","B_Soldier_F","B_Soldier_GL_F","B_Soldier_F"]; 
_grp = [_pos, _side, _units, [], [], [0.8]] call BIS_fnc_spawnGroup; 
{_x assignAsCargo _veh; _x moveInCargo _veh; setPlayable _x;} forEach units _grp;

//Creating helicopter WPs
_Hwp0 = _grpheli addWaypoint [_landpos, 0]; 
_Hwp0 setWaypointType "TR UNLOAD"; 
_Hwp0 setWaypointStatements ["true", "doStop (driver this); (vehicle this) engineOn true;"]; 
_Hwp0 setWaypointBehaviour "AWARE";   
_Hwp0 setWaypointCombatMode "GREEN";
_veh setCombatMode "GREEN";
_veh setBehaviour "AWARE"; 


//Creating defensive group WPs
Gready = false;
_Gwp0 = _grp addWaypoint [_landpos, 0]; 
_Gwp0 setWaypointType "GETOUT"; 
_Gwp0 synchronizeWaypoint [_grpheli, 0];  
_Gwp0 setWaypointStatements ["true", "Gready = true;"]; 
_Gwp0 setWaypointBehaviour "AWARE"; 
_Gwp0 setWaypointCombatMode "GREEN";
_grp setCombatMode "GREEN";  
_grp setBehaviour "AWARE"; 

//Moving into defense position
waitUntil {Gready};
hint "ready";
_d = direction _veh;
_arrayunits = [];
_arrayunits = units _grp;
{
_grouptmp = createGroup WEST;
[_x] join _grouptmp;
_movepos = [_veh, 3, _d] call BIS_fnc_relPos;
_x doMove _movepos;
_d = _d + 90;
} forEach _arrayunits;
sleep 10;
{
doStop _x;
_x setUnitPos "middle"; 
_x setSpeedMode "LIMITED";
_x setCombatMode "YELLOW";
sleep 1;
} forEach _arrayunits;

//Waiting for the player's group to get in
waituntil {{_x in _veh}count units group player == {alive _x} count units group player};
hint "group player ok";
//Boarding defensive group
{
_grouptmp = group _x;
[_x] join _grp;
deleteGroup _grouptmp;
} forEach _arrayunits;
_Gwp1 = _grp addWaypoint [_landpos, 1]; 
_Gwp1 setWaypointType "GETIN NEAREST"; 
waituntil {{_x in _veh}count units _grp == {alive _x} count units _grp};
hint "group 2 ok";
//Moving and unloading player's group

//Moving and deleting helicopter
};

Any ideas ?!:(

Share this post


Link to post
Share on other sites

Have you checked .rpt? Is your friend when you see everything should work and does not.

Minor thing: deleteGroup _grouptmp; after the foreach, you are trying to delete a group while it has units on it, so it won't delete and you are wasting code.

Check the .rpt file and let's see what it says (if says nothing, then we have to double think).

Glad to see my dismount drill script made in the office while I'm pretending to work is... working :)

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  

×