Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explosives - Add exclusion from dynamic defuse action #8171

Merged
merged 21 commits into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions addons/explosives/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ PREP(spawnFlare);
PREP(startDefuse);
PREP(startTimer);
PREP(triggerType);
PREP(allowDefuse);
PREP(isAllowedDefuse);
6 changes: 6 additions & 0 deletions addons/explosives/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
33 changes: 33 additions & 0 deletions addons/explosives/functions/fnc_allowDefuse.sqf
Original file line number Diff line number Diff line change
@@ -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 <OBJECT>
* 1: Allow defusal <BOOL>
*
* Return Value:
* Succes <BOOLEAN>
*
* Example:
* [_mine, false] call ace_explosives_fnc_allowDefuse
*
* Public: Yes
*/

params [["_mine", objNull, [objNull]], ["_allow", true, [true]]];
TRACE_1("params",_mine,_allow);
PabstMirror marked this conversation as resolved.
Show resolved Hide resolved

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
2 changes: 1 addition & 1 deletion addons/explosives/functions/fnc_interactEH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 21 additions & 0 deletions addons/explosives/functions/fnc_isAllowedDefuse.sqf
Original file line number Diff line number Diff line change
@@ -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 <OBJECT>
*
* Return Value:
* Allowed <BOOLEAN>
*
* Example:
* [_mine] call ace_explosives_fnc_isAllowedDefuse
*
* Public: Yes
*/

params [["_mine", objNull, [objNull]]];
TRACE_1("params",_mine);

!(_mine in GVAR(excludedMines))
1 change: 1 addition & 0 deletions docs/wiki/framework/events-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ MenuType: 0 = Interaction, 1 = Self Interaction

| Event Key | Parameters | Locality | Type | Description |
|----------|---------|---------|---------|---------|---------|
|`ace_allowDefuse` | [_mine, _allow] | Global | Callable | Set allowment of the dynamic defusal action on a mine
Walthzer marked this conversation as resolved.
Show resolved Hide resolved
Walthzer marked this conversation as resolved.
Show resolved Hide resolved
|`ace_tripflareTriggered` | [_flareObject, [_posX, _posY, _posZ]] | Global | Listen | Tripflare triggered
|`ace_explosives_clackerAdded` | [_unit, _explosive, _id] | Local | Listen | Clacker added to explosive

Expand Down