2016-07-25 23:01:42 +00:00
|
|
|
//diag_log format["createDropoffLZ called, _this: %1", _this];
|
2016-07-24 20:17:24 +00:00
|
|
|
private _lzLocation = _this select 0;
|
|
|
|
private _bindToVehicle = _this select 1;
|
|
|
|
private _bindToSquad = _this select 2;
|
|
|
|
private _fromTaskId = _this select 3;
|
|
|
|
private _assignToPlayer = driver _bindToVehicle;
|
|
|
|
|
|
|
|
private _enemies = [];
|
|
|
|
private _lzhot = false;
|
|
|
|
//Make the LZ hot if the roll demands it
|
|
|
|
if ((random 1) < hotLZChance) then
|
|
|
|
{
|
|
|
|
_lzhot = true
|
|
|
|
};
|
|
|
|
private _lzAA = false;
|
|
|
|
if ((random 1) < AAChance) then
|
|
|
|
{
|
|
|
|
_lzhot = true;
|
|
|
|
_lzAA = true;
|
|
|
|
};
|
|
|
|
private _taskType = "move";
|
|
|
|
if (_lzhot) then
|
|
|
|
{
|
|
|
|
_taskType = "attack";
|
|
|
|
_enemies = _enemies + ([_lzLocation, _lzAA] call createEnemySquads);
|
|
|
|
};
|
|
|
|
|
|
|
|
lzCounter = lzCounter + 1;
|
|
|
|
publicVariable "lzCounter";
|
|
|
|
|
|
|
|
private _shortestDesc = format["LZ %1", lzCounter];
|
2016-07-25 00:36:48 +00:00
|
|
|
private _longdesc = format["%1 wants to fly to this location", _bindToSquad];
|
|
|
|
private _shortdesc = format["Drop off %1", _bindToSquad];
|
2016-07-24 20:17:24 +00:00
|
|
|
if (_lzAA and _lzhot) then
|
|
|
|
{
|
|
|
|
_longdesc = _longdesc + "<br/><strong>Be advised:</strong> Intel reports heavy enemy activity with AA assets at the location";
|
|
|
|
};
|
|
|
|
if (!_lzAA and _lzhot) then
|
|
|
|
{
|
|
|
|
_longdesc = _longdesc + "<br/><strong>Be advised:</strong> Intel reports enemy activity at the location";
|
|
|
|
};
|
|
|
|
|
2016-07-26 01:16:03 +00:00
|
|
|
_longdesc = _longdesc + format["<br/>Created for %1", _assignToPlayer];
|
2016-07-24 20:17:24 +00:00
|
|
|
private _assignTo = [_assignToPlayer, west];
|
|
|
|
|
|
|
|
private _taskid = format["dropoff_%1", lzCounter];
|
2016-07-26 08:31:28 +00:00
|
|
|
// Create the task for everyone
|
|
|
|
[_assignTo,[_taskid],[_longdesc, _shortdesc, _shortestDesc],getPos _lzLocation,"CREATED",(STARTPRIORITY-lzCounter),true, _taskType, true] call BIS_fnc_taskCreate;
|
|
|
|
// Assign to the player
|
|
|
|
[[_assignToPlayer],[_taskid],[_longdesc, _shortdesc, _shortestDesc],getPos _lzLocation,"ASSIGNED",(STARTPRIORITY-lzCounter),true, _taskType, true] call BIS_fnc_setTask;
|
2016-07-24 20:17:24 +00:00
|
|
|
|
2016-07-25 17:49:54 +00:00
|
|
|
private _trg = createTrigger["EmptyDetector",getPos _lzLocation, false];
|
2016-07-24 20:17:24 +00:00
|
|
|
_trg setTriggerArea[lzSize,lzSize,0,false];
|
|
|
|
_trg setTriggerActivation["WEST","PRESENT",false];
|
|
|
|
_trg setTriggerTimeout [2.5, 2.5, 2.5, true];
|
2016-07-26 08:33:08 +00:00
|
|
|
private _trgCond = format["((%1 in thisList) && ([%1] call isLanded))", _bindToVehicle];
|
2016-07-25 00:36:48 +00:00
|
|
|
diag_log format["createDropoffLZ: _trgCond %s", _trgCond];
|
|
|
|
_trg setTriggerStatements[_trgCond , "", ""];
|
2016-07-24 20:17:24 +00:00
|
|
|
|
|
|
|
// TODO: implement deadline so the task doesn't linger forever
|
|
|
|
scopeName "main";
|
|
|
|
while {true} do
|
|
|
|
{
|
|
|
|
scopeName "mainloop";
|
2016-07-25 23:01:42 +00:00
|
|
|
//diag_log format["createDropoffLZ: ticking %1", _this];
|
2016-07-24 20:17:24 +00:00
|
|
|
|
2016-07-25 00:36:48 +00:00
|
|
|
if (( _taskid call BIS_fnc_taskCompleted)) then
|
2016-07-24 20:17:24 +00:00
|
|
|
{
|
2016-07-25 00:36:48 +00:00
|
|
|
diag_log format["createPickupLZ: task %1 was marked complete", _taskid];
|
|
|
|
breakOut "mainloop";
|
|
|
|
};
|
|
|
|
|
|
|
|
private _squadAliveCount = {alive _x} count units _bindToSquad;
|
|
|
|
if ((_squadAliveCount < 1)) then
|
|
|
|
{
|
|
|
|
diag_log format["createDropoffLZ: Everyone from %1 is dead!", _bindToSquad];
|
2016-07-24 20:17:24 +00:00
|
|
|
// Everybody died before getting there :(
|
|
|
|
[_taskid, "FAILED" ,true] spawn BIS_fnc_taskSetState;
|
|
|
|
breakOut "mainloop";
|
2016-07-24 21:14:41 +00:00
|
|
|
};
|
2016-07-24 20:17:24 +00:00
|
|
|
|
2016-07-24 23:28:26 +00:00
|
|
|
if (triggerActivated _trg) then
|
2016-07-24 20:17:24 +00:00
|
|
|
{
|
2016-07-25 00:36:48 +00:00
|
|
|
diag_log format["createDropoffLZ: triggered, unloading %1", _bindToSquad];
|
2016-07-24 20:17:24 +00:00
|
|
|
private _veh = [list _trg] call playerVehicleInList;
|
2016-07-25 00:36:48 +00:00
|
|
|
private _handle = [_lzLocation, _veh, _bindToSquad, _taskid] spawn ejectSquad;
|
2016-07-24 20:17:24 +00:00
|
|
|
waitUntil {isNull _handle};
|
|
|
|
breakOut "mainloop";
|
|
|
|
};
|
|
|
|
sleep 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
deleteVehicle _trg;
|
|
|
|
// Make sure there are no lingering enemy or own units
|
2016-07-25 00:36:48 +00:00
|
|
|
[_enemies + [_bindToSquad]] call deleteSquads;
|