Skip to content

Commit

Permalink
fix: Fixed Triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
cow-co committed Jan 14, 2025
1 parent 41b6241 commit 28453c7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
3 changes: 2 additions & 1 deletion components/ied/fn_addIEDToObject.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
*/
#include "macros.hpp"

// TODO Handle the case where we run this twice against the same object (set a var on the object saying "isIED"?)
// TODO On dedi server, verify that others can set it off
params ["_object", "_isLarge", "_isProxy", "_proxySide", "_proxyRange"];
[_object, _isLarge] call f_fnc_addDefuseActionsToObject;
[_object, _isLarge] call f_fnc_addZeusDetonationToIED;
_object setVariable ["isIED", true];

if (_isProxy == true) then {
[_object, _isLarge, _proxySide, _proxyRange] call f_fnc_addProxyFuseTriggerToIED;
Expand Down
2 changes: 1 addition & 1 deletion components/ied/fn_addProxyFuseTriggerToIED.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#include "macros.hpp"
params ["_object", "_isLarge", "_proxySide", "_proxyRange"];
private _proxy = createTrigger ["EmptyDetector", getPos _object];
// TODO Test when multiplee proxy-fused IEDs are on field
_proxy setVariable ["iedObj", _object];
_proxy setTriggerActivation [str _proxySide, "PRESENT", false];
_proxy setTriggerArea [_proxyRange, _proxyRange, 0, false, _proxyRange * 2]; // *2 because the z axis goes above and below the ground
_proxy attachTo [_object];
private _onAct = "thisTrigger getVariable ""iedObj"" setDamage 1;";
private _cond = "thisList findIf {_x != thisTrigger getVariable ""iedObj""} > -1";
_proxy setTriggerStatements [_cond, _onAct, ""];
12 changes: 7 additions & 5 deletions components/ied/fn_addZeusDetonationToIED.sqf
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Allows Zeus to detonate the IED by setting its HP to 0 (done by way of a trigger)
// In so doing, also prevents the object from taking damage (so that stray bullets don't detonate it!)

#include "macros.hpp"
params ["_object", "_isLarge"];
SERVER_ONLY;
_object allowDamage false;
_object setVariable ["isLargeIED", _isLarge];
_object addEventHandler ["Killed", {
params ["_unit", "_killer"];
[_unit, _unit getVariable ["isLargeIED", false]] call f_fnc_iedBoom;
}];
private _trg = createTrigger ["EmptyDetector", getPos _object];
_trg setVariable ["iedObj", _object];
private _onAct = "private _obj = thisTrigger getVariable ""iedObj""; [_obj, _obj getVariable ""isLargeIED""] call f_fnc_iedBoom;";
private _cond = "private _obj = thisTrigger getVariable ""iedObj""; damage _obj >= 1;";
_trg setTriggerStatements [_cond, _onAct, ""];
9 changes: 7 additions & 2 deletions components/ied/zen/fn_zen_makeIED.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ if (isNull _object) then
params ["_dialogValues", "_args"];
_dialogValues params ["_isLarge", "_isProxy", "_proxySide", "_proxyRange"];
_args params ["_object"];
[_object, _isLarge, _isProxy, _proxySide, _proxyRange] remoteExec ["f_fnc_addIEDToObject", 2];
["Adding IED to '%1'.", _object] call zen_common_fnc_showMessage;
private _isAlreadyIED = _object getVariable ["isIED", false];
if (_isAlreadyIED) then {
["Object is already an IED", _object] call zen_common_fnc_showMessage;
} else {
[_object, _isLarge, _isProxy, _proxySide, _proxyRange] remoteExec ["f_fnc_addIEDToObject", 2];
["Added IED to '%1'.", _object] call zen_common_fnc_showMessage;
};
},
{},
[_object]] call zen_dialog_fnc_create;
Expand Down

0 comments on commit 28453c7

Please sign in to comment.