diff --git a/addons/explosives/XEH_PREP.hpp b/addons/explosives/XEH_PREP.hpp index c04e0d3133..d549118623 100644 --- a/addons/explosives/XEH_PREP.hpp +++ b/addons/explosives/XEH_PREP.hpp @@ -37,3 +37,5 @@ PREP(spawnFlare); PREP(startDefuse); PREP(startTimer); PREP(triggerType); +PREP(allowDefuse); +PREP(isAllowedDefuse); diff --git a/addons/explosives/XEH_postInit.sqf b/addons/explosives/XEH_postInit.sqf index f01a3ad20d..d5bf418235 100644 --- a/addons/explosives/XEH_postInit.sqf +++ b/addons/explosives/XEH_postInit.sqf @@ -46,6 +46,7 @@ if (isServer) then { if (!hasInterface) exitWith {}; GVAR(PlacedCount) = 0; +GVAR(excludedMines) = []; GVAR(Setup) = objNull; GVAR(pfeh_running) = false; GVAR(CurrentSpeedDial) = 0; @@ -65,3 +66,8 @@ GVAR(CurrentSpeedDial) = 0; params ["_player"]; [_player, QGVAR(explosiveActions)] call EFUNC(common,eraseCache); }] call CBA_fnc_addPlayerEventHandler; + +["ace_allowDefuse", { + params["_mine", "_allow"]; + [_mine, _allow] call FUNC(allowDefuse); +}] call CBA_fnc_addEventHandler; diff --git a/addons/explosives/functions/fnc_allowDefuse.sqf b/addons/explosives/functions/fnc_allowDefuse.sqf new file mode 100644 index 0000000000..15042e4ca5 --- /dev/null +++ b/addons/explosives/functions/fnc_allowDefuse.sqf @@ -0,0 +1,33 @@ +#include "script_component.hpp" +/* + * Author: Walthzer + * Sets if a dynamic defuse action is allowed to be added to a mine. + * + * Arguments: + * 0: Mine + * 1: Allow defusal + * + * Return Value: + * Succes + * + * Example: + * [_mine, false] call ace_explosives_fnc_allowDefuse + * + * Public: Yes + */ + +params [["_mine", objNull, [objNull]], ["_allow", true, [true]]]; +TRACE_2("params",_mine,_allow); + +if !(_mine in allMines) exitWith {false}; + +if (_allow && {!([_mine] call FUNC(isAllowedDefuse))}) exitWith { + GVAR(excludedMines) = GVAR(excludedMines) - [_mine]; + true +}; + +if (!_allow) exitWith { + GVAR(excludedMines) pushBackUnique _mine != -1 +}; + +false diff --git a/addons/explosives/functions/fnc_interactEH.sqf b/addons/explosives/functions/fnc_interactEH.sqf index 950c376400..da7215bb81 100644 --- a/addons/explosives/functions/fnc_interactEH.sqf +++ b/addons/explosives/functions/fnc_interactEH.sqf @@ -47,7 +47,7 @@ if ( if (_playerPos distanceSqr _setPosition > 25) then { private _cfgAmmo = configFile >> "CfgAmmo"; { - if (_x distanceSqr _player < 225 && {!(_x in _minesHelped)} && {getModelInfo _x select 0 isNotEqualTo "empty.p3d"}) then { + if (_x distanceSqr _player < 225 && {!(_x in _minesHelped)} && {!(_x in GVAR(excludedMines))} && {getModelInfo _x select 0 isNotEqualTo "empty.p3d"}) then { private _config = _cfgAmmo >> typeOf _x; private _size = getNumber (_config >> QGVAR(size)); private _defuseClass = ["ACE_DefuseObject", "ACE_DefuseObject_Large"] select (_size == 1); diff --git a/addons/explosives/functions/fnc_isAllowedDefuse.sqf b/addons/explosives/functions/fnc_isAllowedDefuse.sqf new file mode 100644 index 0000000000..2d2846d27c --- /dev/null +++ b/addons/explosives/functions/fnc_isAllowedDefuse.sqf @@ -0,0 +1,21 @@ +#include "script_component.hpp" +/* + * Author: Walthzer + * Check if a mine is allowed to recieve a dynamic defuse action. + * + * Arguments: + * 0: Mine + * + * Return Value: + * Allowed + * + * Example: + * [_mine] call ace_explosives_fnc_isAllowedDefuse + * + * Public: Yes + */ + +params [["_mine", objNull, [objNull]]]; +TRACE_1("params",_mine); + +!(_mine in GVAR(excludedMines)) diff --git a/docs/wiki/framework/events-framework.md b/docs/wiki/framework/events-framework.md index c1c6b844f5..abaa06f4a7 100644 --- a/docs/wiki/framework/events-framework.md +++ b/docs/wiki/framework/events-framework.md @@ -83,6 +83,7 @@ MenuType: 0 = Interaction, 1 = Self Interaction | Event Key | Parameters | Locality | Type | Description | |----------|---------|---------|---------|---------|---------| +|`ace_allowDefuse` | [_mine, _allow] | Global or Target | Callable | Set allowance of the dynamic defusal action on a mine |`ace_tripflareTriggered` | [_flareObject, [_posX, _posY, _posZ]] | Global | Listen | Tripflare triggered |`ace_explosives_clackerAdded` | [_unit, _explosive, _id] | Local | Listen | Clacker added to explosive