Add function and action to detonate all explosives on a detonator

This commit is contained in:
VKing 2016-01-05 23:40:27 +01:00
parent c042703786
commit cc8ac69feb
3 changed files with 49 additions and 1 deletions

View File

@ -28,6 +28,7 @@ PREP(canDefuse);
PREP(canDetonate);
PREP(defuseExplosive);
PREP(detonateExplosive);
PREP(detonateExplosiveAll);
PREP(dialPhone);
PREP(dialingPhone);

View File

@ -19,18 +19,21 @@
params ["_unit", "_detonator"];
TRACE_2("params",_unit,_detonator);
private ["_result", "_item", "_children", "_range", "_required"];
private ["_result", "_item", "_children", "_range", "_required","_explosivesList"];
_range = getNumber (ConfigFile >> "CfgWeapons" >> _detonator >> "ACE_Range");
_result = [_unit] call FUNC(getPlacedExplosives);
_children = [];
_explosivesList = [];
{
if (!isNull(_x select 0)) then {
_required = getArray (ConfigFile >> "ACE_Triggers" >> (_x select 4) >> "requires");
if (_detonator in _required) then {
_item = ConfigFile >> "CfgMagazines" >> (_x select 3);
_explosivesList pushBack _x;
_children pushBack
[
[
@ -49,4 +52,21 @@ _children = [];
};
} forEach _result;
// Add action to detonate all explosives tied to the detonator
if (count _explosivesList > 0) then {
_children pushBack [
[
"Explosive_All",
"Detonate All",
getText(ConfigFile >> "CfgWeapons" >> _detonator >> "picture"),
{(_this select 2) call FUNC(detonateExplosiveAll);},
{true},
{},
[ACE_player,_range,_explosivesList]
] call EFUNC(interact_menu,createAction),
[],
ACE_Player
];
};
_children

View File

@ -0,0 +1,27 @@
/*
* Author: VKing
* Causes the unit to detonate all passed explosives.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Range (-1 to ignore) <NUMBER>
* 2: Explosives to detonate <ARRAY>
* 0: Explosive <OBJECT>
* 1: Fuse time <NUMBER>
*
* Return Value:
* None
*
* Example:
* [player, -1, "Command"] call ACE_Explosives_fnc_detonateExplosive;
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_range", "_explosivesList"];
TRACE_3("Params",_unit,_range,_explosivesList);
{
[_unit,_range,_x] call FUNC(detonateExplosive);
} forEach _explosivesList;