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 14 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;
30 changes: 30 additions & 0 deletions addons/explosives/functions/fnc_allowDefuse.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "script_component.hpp"
/*
* Author: Walthzer
* Excludes a passed mine from the dynamic defuse action.
*
* 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) then {
if ([_mine] call FUNC(isAllowedDefuse)) exitWith {false};
jonpas marked this conversation as resolved.
Show resolved Hide resolved
GVAR(excludedMines) = GVAR(excludedMines) - [_mine];
true
} else {
not ((GVAR(excludedMines) pushBackUnique _mine) == -1);
};
Walthzer marked this conversation as resolved.
Show resolved Hide resolved
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 Ace is allowed to add a defusal action to a mine.
*
* 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))