arma3_missions/helotraining_rewrite.Altis/loadSquad.sqf
2016-07-24 23:17:24 +03:00

32 lines
987 B
Plaintext

diag_log format["loadSquad called, _this: %1", _this];
private _vehicle = _this select 0;
private _squad = _this select 1;
private _fromTaskId = _this select 2;
{_x assignAsCargo _vehicle} foreach units _squad;
{[_x] ordergetin true} foreach units _squad;
{_x disableAI "TARGET"; _x disableAI "AUTOTARGET";} foreach units _squad;
private wp = _squad addwaypoint [_vehicle,5,1];
wp setwaypointType "GETIN";
scopeName "main";
while {true} do
{
scopeName "loadingLoop";
if ({alive _x} count units _squad == 0) then
{
// Everybody died before boarding :(
[_fromTaskId, "FAILED" ,true] spawn BIS_fnc_taskSetState;
breakOut "loadingLoop";
}
if ({alive _x} count units _squad == {(_x in _vehicle) && (alive _x)} count units _squad) then
{
// Boarded
[_fromTaskId, "SUCCEEDED" ,true] spawn BIS_fnc_taskSetState;
breakOut "loadingLoop";
};
sleep 2;
};
diag_log format["loadSquad done, _this: %1", _this];