Explosives - Add exclusion from dynamic defuse action (#8171)

* Add GVAR(noDefusalAction)

* add changes

* Prep functions

* Update addons/explosives/functions/fnc_excludeMine.sqf

Uhm, strange. Its clearly allMines, yet Allmines didn't only build it also worked properly. Undocumented variable?

Co-authored-by: BaerMitUmlaut <BaerMitUmlaut@users.noreply.github.com>

* Update addons/explosives/functions/fnc_stopExcludingMine.sqf

Co-authored-by: BaerMitUmlaut <BaerMitUmlaut@users.noreply.github.com>

* Header Fixes

Fix information in the function headers

Co-authored-by: jonpas <jonpas33@gmail.com>

* Remove Individual Functions

* Compacter Functions

* Event

* remove tab (facepalm)

* Jonpass' Review Fixes

Co-authored-by: jonpas <jonpas33@gmail.com>

* Fix exitWith mistake

* Refractor of allowDefuse

Co-authored-by: jonpas <jonpas33@gmail.com>

* Update addons/explosives/functions/fnc_allowDefuse.sqf

Co-authored-by: jonpas <jonpas33@gmail.com>

* Update Documentation

* Rephrase documentation

* Another rephrase

* Relabel Locality

* Update addons/explosives/functions/fnc_allowDefuse.sqf

Co-authored-by: BaerMitUmlaut <BaerMitUmlaut@users.noreply.github.com>
Co-authored-by: jonpas <jonpas33@gmail.com>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
Walthzer 2021-10-11 22:49:27 +02:00 committed by GitHub
parent 998f86f034
commit fad7f84625
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 1 deletions

View File

@ -37,3 +37,5 @@ PREP(spawnFlare);
PREP(startDefuse);
PREP(startTimer);
PREP(triggerType);
PREP(allowDefuse);
PREP(isAllowedDefuse);

View File

@ -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;

View File

@ -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_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

View File

@ -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);

View File

@ -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))

View File

@ -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