From 28453c7fe6b320bbda542c192808df5a8e9ea51a Mon Sep 17 00:00:00 2001 From: cow Date: Tue, 14 Jan 2025 21:56:17 +0000 Subject: [PATCH] fix: Fixed Triggers --- components/ied/fn_addIEDToObject.sqf | 3 ++- components/ied/fn_addProxyFuseTriggerToIED.sqf | 2 +- components/ied/fn_addZeusDetonationToIED.sqf | 12 +++++++----- components/ied/zen/fn_zen_makeIED.sqf | 9 +++++++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/components/ied/fn_addIEDToObject.sqf b/components/ied/fn_addIEDToObject.sqf index 355d0f3..b67c9cd 100644 --- a/components/ied/fn_addIEDToObject.sqf +++ b/components/ied/fn_addIEDToObject.sqf @@ -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; diff --git a/components/ied/fn_addProxyFuseTriggerToIED.sqf b/components/ied/fn_addProxyFuseTriggerToIED.sqf index adb02e9..a1900ff 100644 --- a/components/ied/fn_addProxyFuseTriggerToIED.sqf +++ b/components/ied/fn_addProxyFuseTriggerToIED.sqf @@ -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, ""]; \ No newline at end of file diff --git a/components/ied/fn_addZeusDetonationToIED.sqf b/components/ied/fn_addZeusDetonationToIED.sqf index 6ae5ff9..70aa329 100644 --- a/components/ied/fn_addZeusDetonationToIED.sqf +++ b/components/ied/fn_addZeusDetonationToIED.sqf @@ -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; -}]; \ No newline at end of file +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, ""]; \ No newline at end of file diff --git a/components/ied/zen/fn_zen_makeIED.sqf b/components/ied/zen/fn_zen_makeIED.sqf index a255d7f..db8f639 100644 --- a/components/ied/zen/fn_zen_makeIED.sqf +++ b/components/ied/zen/fn_zen_makeIED.sqf @@ -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;