From a8a91f7483bc2c9ebf963a5c36f2bcf5ab6fd9b6 Mon Sep 17 00:00:00 2001 From: Eero af Heurlin Date: Mon, 25 Jul 2016 03:36:48 +0300 Subject: [PATCH] fixing triggers --- .../createDropoffLZ.sqf | 27 ++++++++++++------- helotraining_rewrite.Altis/createPickupLZ.sqf | 13 +++++++-- helotraining_rewrite.Altis/ejectSquad.sqf | 3 ++- helotraining_rewrite.Altis/loadSquad.sqf | 1 + .../spawnSmokeBySquad.sqf | 26 +++++++++++------- 5 files changed, 48 insertions(+), 22 deletions(-) diff --git a/helotraining_rewrite.Altis/createDropoffLZ.sqf b/helotraining_rewrite.Altis/createDropoffLZ.sqf index 2ac2f00..c4d98f9 100644 --- a/helotraining_rewrite.Altis/createDropoffLZ.sqf +++ b/helotraining_rewrite.Altis/createDropoffLZ.sqf @@ -29,8 +29,8 @@ lzCounter = lzCounter + 1; publicVariable "lzCounter"; private _shortestDesc = format["LZ %1", lzCounter]; -private _longdesc = format["%1 wants to fly to this location", _squad]; -private _shortdesc = format["Drop off %1", _squad]; +private _longdesc = format["%1 wants to fly to this location", _bindToSquad]; +private _shortdesc = format["Drop off %1", _bindToSquad]; if (_lzAA and _lzhot) then { _longdesc = _longdesc + "
Be advised: Intel reports heavy enemy activity with AA assets at the location"; @@ -50,18 +50,27 @@ private _trg = createTrigger["EmptyDetector",getPos _lzLocation, true]; _trg setTriggerArea[lzSize,lzSize,0,false]; _trg setTriggerActivation["WEST","PRESENT",false]; _trg setTriggerTimeout [2.5, 2.5, 2.5, true]; -_trg setTriggerStatements[ format["((%1 in thisList) && (isTouchingGround %1))", _bindToVehicle], "", ""]; +private _trgCond = format["((%1 in thisList) && (isTouchingGround %1))", _bindToVehicle]; +diag_log format["createDropoffLZ: _trgCond %s", _trgCond]; +_trg setTriggerStatements[_trgCond , "", ""]; // TODO: implement deadline so the task doesn't linger forever scopeName "main"; while {true} do { scopeName "mainloop"; - diag_log "createDropoffLZ: ticking"; + diag_log format["createDropoffLZ: ticking %1", _this]; - if ({alive _x} count units _squad == 0) then + if (( _taskid call BIS_fnc_taskCompleted)) then { - diag_log format["createDropoffLZ: Everyone from %1 is dead!", _squad]; + 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]; // Everybody died before getting there :( [_taskid, "FAILED" ,true] spawn BIS_fnc_taskSetState; breakOut "mainloop"; @@ -69,9 +78,9 @@ while {true} do if (triggerActivated _trg) then { - diag_log format["createDropoffLZ: triggered, unloading %1", _squad]; + diag_log format["createDropoffLZ: triggered, unloading %1", _bindToSquad]; private _veh = [list _trg] call playerVehicleInList; - private _handle = [_lzLocation, _veh, _squad, _taskid] spawn ejectSquad; + private _handle = [_lzLocation, _veh, _bindToSquad, _taskid] spawn ejectSquad; waitUntil {isNull _handle}; breakOut "mainloop"; }; @@ -80,4 +89,4 @@ while {true} do deleteVehicle _trg; // Make sure there are no lingering enemy or own units -[_enemies + [_squad]] call deleteSquads; +[_enemies + [_bindToSquad]] call deleteSquads; diff --git a/helotraining_rewrite.Altis/createPickupLZ.sqf b/helotraining_rewrite.Altis/createPickupLZ.sqf index 7172c55..46ee1e4 100644 --- a/helotraining_rewrite.Altis/createPickupLZ.sqf +++ b/helotraining_rewrite.Altis/createPickupLZ.sqf @@ -46,8 +46,11 @@ if (!(_assignExtra isEqualTo false)) then // PONDER: make a parent task "ferry squad X" ?? private _taskid = format["pickup_%1", lzCounter]; [_assignTo,[_taskid],[_longdesc, _shortdesc, _shortestDesc],_lzLocation,"AUTOASSIGNED",1,true, "move", true] call BIS_fnc_taskCreate; -[_squad, _lzLocation, 'green'] spawn spawnSmokeBySquad; +if (bSmoke) then +{ + [_squad, _lzLocation, 'green'] spawn spawnSmokeBySquad; +}; private _trg = createTrigger["EmptyDetector",getPos _lzLocation, true]; _trg setTriggerArea[lzSize,lzSize,0,false]; @@ -61,7 +64,13 @@ scopeName "main"; while {true} do { scopeName "mainloop"; - diag_log "createPickupLZ: ticking"; + diag_log format["createPickupLZ: ticking %1", _this]; + + if (( _taskid call BIS_fnc_taskCompleted)) then + { + diag_log format["createPickupLZ: task %1 was marked complete", _taskid]; + breakOut "mainloop"; + }; if ({alive _x} count units _squad == 0) then { diff --git a/helotraining_rewrite.Altis/ejectSquad.sqf b/helotraining_rewrite.Altis/ejectSquad.sqf index 290a718..ae5cf2b 100644 --- a/helotraining_rewrite.Altis/ejectSquad.sqf +++ b/helotraining_rewrite.Altis/ejectSquad.sqf @@ -17,7 +17,8 @@ scopeName "main"; while {true} do { scopeName "ejectloop"; - if (({(_x in _vehicle) && (alive _x)} count units _group) == 0) then + diag_log format["ejectSquad: ticking %1", _this]; + if (({(_x in _vehicle) && (alive _x)} count units _squad) == 0) then { // No squad units left alive inside [_fromTaskId, "SUCCEEDED" ,true] spawn BIS_fnc_taskSetState; diff --git a/helotraining_rewrite.Altis/loadSquad.sqf b/helotraining_rewrite.Altis/loadSquad.sqf index dace39a..234379b 100644 --- a/helotraining_rewrite.Altis/loadSquad.sqf +++ b/helotraining_rewrite.Altis/loadSquad.sqf @@ -14,6 +14,7 @@ scopeName "main"; while {true} do { scopeName "loadingLoop"; + diag_log format["loadSquad: ticking %1", _this]; if ({alive _x} count units _squad == 0) then { // Everybody died before boarding :( diff --git a/helotraining_rewrite.Altis/spawnSmokeBySquad.sqf b/helotraining_rewrite.Altis/spawnSmokeBySquad.sqf index 46f00f7..1d0f209 100644 --- a/helotraining_rewrite.Altis/spawnSmokeBySquad.sqf +++ b/helotraining_rewrite.Altis/spawnSmokeBySquad.sqf @@ -1,34 +1,40 @@ diag_log format["spawnSmokeBySquad called, _this: %1", _this]; private _bindToSquad = _this select 0; -private _smokeLozation = _this select 1; +private _smokeTgt = _this select 1; +private _smokeLocation = getPos _smokeTgt; private _smokeColor = _this select 2; -private _trg = createTrigger["EmptyDetector",getPos _smokeLozation, true]; +private _trg = createTrigger["EmptyDetector", _smokeLocation, true]; _trg setTriggerArea[50,50,0,false]; _trg setTriggerActivation["WEST","PRESENT",false]; -private _trgCond = format["count (%1 arrayIntersect thisList) > 0", units _squad]; -diag_log format["spawnSmokeBySquad _trgCond: %1", _trgCond]; -_trg setTriggerStatements[_trgCond, "", ""]; +private _keepSpawning = true; // TODO: switch color based on arguments -while {triggerActivated _trg} do +while {_keepSpawning} do { + diag_log format["spawnSmokeBySquad: spawning smoke to %1", _smokeLocation]; _hour = daytime; if (_hour > 5 && _hour < 19) then { - _smoke= "SmokeShellGreen" createVehicle _smokeLozation; + _smoke= "SmokeShellGreen" createVehicle _smokeLocation; sleep 40; deleteVehicle _smoke; } else { - _chemlight= "Chemlight_green" createVehicle _smokeLozation; - _smoke= "SmokeShellGreen" createVehicle _smokeLozation; + _chemlight= "Chemlight_green" createVehicle _smokeLocation; + _smoke= "SmokeShellGreen" createVehicle _smokeLocation; sleep 40; deleteVehicle _chemlight; deleteVehicle _smoke; }; - diag_log format["spawnSmokeBySquad: spawned smoke to %1", _smokeLoc]; + _keepSpawning = false; + { + if (_x inArea _trg && alive _x) then + { + _keepSpawning = true; + }; + } forEach (units _bindToSquad); }; diag_log format["spawnSmokeBySquad done, _this: %1", _this]; deleteVehicle _trg;