2016-07-25 23:01:42 +00:00
//diag_log format["createPickupLZ called, _this: %1", _this];
2016-07-24 20:17:24 +00:00
private _lzLocation = _this select 0;
private _assignExtra = _this select 1;
private _squad = [_lzLocation] call createSquad;
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;
};
2016-07-26 01:16:03 +00:00
private _taskType = "meet";
2016-07-24 21:32:45 +00:00
if (_lzhot) then
2016-07-24 20:17:24 +00:00
{
2016-07-25 23:01:42 +00:00
_taskType = "defend";
2016-07-24 20:17:24 +00:00
_enemies = _enemies + ([_lzLocation, _lzAA] call createEnemySquads);
};
lzCounter = lzCounter + 1;
publicVariable "lzCounter";
2016-07-25 21:58:29 +00:00
private _side = side _squad;
private _squadCmdr = (units _squad) select 0;
private _lzLocationName = text ((nearestLocations [getPos _lzLocation, ["NameCityCapital", "NameCity", "NameVillage"], 1500]) select 0);
2021-06-13 14:00:05 +00:00
[[_side, "HQ"], format["%1 is requesting pickup for %2 from near %3", groupId _squad, count units _squad, _lzLocationName]] remoteExec ["sideChat", _side];
2016-07-25 21:58:29 +00:00
2016-07-24 20:17:24 +00:00
private _shortestDesc = format["LZ %1", lzCounter];
private _longdesc = format["%1 wants a pickup from this location", _squad];
private _shortdesc = format["Pick up %1", _squad];
if (_lzAA and _lzhot) then
{
_longdesc = _longdesc + "<br/><strong>Be advised:</strong> Intel reports heavy enemy activity with AA assets at the location";
2016-07-25 21:58:29 +00:00
[_squadCmdr, "Be advised, LZ is very hot with AA assets present"] remoteExec ["sideChat", _side];
2016-07-24 20:17:24 +00:00
};
if (!_lzAA and _lzhot) then
{
_longdesc = _longdesc + "<br/><strong>Be advised:</strong> Intel reports enemy activity at the location";
2016-07-25 21:58:29 +00:00
[_squadCmdr, "Be advised, LZ is hot"] remoteExec ["sideChat", _side];
2016-07-24 20:17:24 +00:00
};
2016-07-26 01:16:03 +00:00
private _taskState = "AUTOASSIGNED";
2016-07-24 20:17:24 +00:00
private _assignTo = [west];
if (!(_assignExtra isEqualTo false)) then
{
2016-07-26 01:16:03 +00:00
_longdesc = _longdesc + format["<br/>Created for %1", _assignExtra];
2016-07-24 20:17:24 +00:00
_assignTo = _assignTo + _assignExtra;
2016-07-26 08:31:28 +00:00
_taskState = "CREATED";
2016-07-24 20:17:24 +00:00
};
2016-07-25 21:58:29 +00:00
2016-07-24 20:17:24 +00:00
// PONDER: make a parent task "ferry squad X" ??
private _taskid = format["pickup_%1", lzCounter];
2016-07-26 01:16:03 +00:00
[_assignTo,[_taskid],[_longdesc, _shortdesc, _shortestDesc],getPos _lzLocation,_taskState,(STARTPRIORITY-lzCounter),true, _taskType, true] call BIS_fnc_taskCreate;
2016-07-25 23:01:42 +00:00
if (!(_assignExtra isEqualTo false)) then
{
2016-07-26 10:34:48 +00:00
[_taskid,_assignExtra,[_longdesc, _shortdesc, _shortestDesc],getPos _lzLocation,"ASSIGNED"] call BIS_fnc_setTask;
2016-07-25 23:01:42 +00:00
};
2016-07-31 15:32:48 +00:00
taskIds pushBackUnique _taskid;
publicVariable "taskIds";
2016-07-24 23:28:26 +00:00
2016-07-25 00:36:48 +00:00
if (bSmoke) then
{
[_squad, _lzLocation, 'green'] spawn spawnSmokeBySquad;
};
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-24 23:28:26 +00:00
_trg setTriggerStatements["([thisList] call playerVehicleInListBool)", "", ""];
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["createPickupLZ: ticking %1", _this];
2016-07-25 00:36:48 +00:00
if (( _taskid call BIS_fnc_taskCompleted)) then
{
diag_log format["createPickupLZ: task %1 was marked complete", _taskid];
breakOut "mainloop";
};
2016-07-24 20:17:24 +00:00
if ({alive _x} count units _squad == 0) then
{
2016-07-24 23:28:26 +00:00
diag_log format["createPickupLZ: Everyone from %1 is dead!", _squad];
2016-07-24 20:17:24 +00:00
// Everybody died before we got 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-24 23:28:26 +00:00
diag_log format["createPickupLZ: triggedred, loading up %1", _squad];
2016-07-25 23:01:42 +00:00
2016-07-24 20:17:24 +00:00
private _veh = [list _trg] call playerVehicleInList;
2016-07-24 21:35:04 +00:00
private _handle = [_veh, _squad, _taskid] spawn loadSquad;
2016-07-24 20:17:24 +00:00
waitUntil {isNull _handle};
2016-07-31 16:47:03 +00:00
// TODO check that the return value is not false (could not choose LZ due to constraints)
private _newLZLocation = [[_lzLocation]] call selectLZ;
2016-07-24 21:35:04 +00:00
private _handle = [_newLZLocation, _veh, _squad, _taskid] spawn createDropoffLZ;
2016-07-24 20:17:24 +00:00
waitUntil {isNull _handle};
breakOut "mainloop";
};
2016-07-24 23:28:26 +00:00
sleep 2;
2016-07-24 20:17:24 +00:00
};
deleteVehicle _trg;
2016-07-31 17:06:14 +00:00
sleep squadsLinger;
2016-07-24 20:17:24 +00:00
// Make sure there are no lingering enemy or own units
[_enemies + [_squad]] call deleteSquads;