2015-01-12 09:48:26 +00:00
|
|
|
/*
|
2015-02-02 08:35:17 +00:00
|
|
|
* Author: Garth 'L-H' de Wet
|
|
|
|
* Opens the UI for explosive detonation selection
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Trigger classname <STRING>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2015-04-01 17:09:19 +00:00
|
|
|
* [player, "ACE_M26_Clacker"] call ACE_Explosives_fnc_addDetonateActions;
|
2015-02-02 08:35:17 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-13 21:21:31 +00:00
|
|
|
#include "script_component.hpp"
|
2015-08-15 19:35:33 +00:00
|
|
|
|
|
|
|
params ["_unit", "_detonator"];
|
|
|
|
TRACE_2("params",_unit,_detonator);
|
|
|
|
|
2016-01-05 22:40:27 +00:00
|
|
|
private ["_result", "_item", "_children", "_range", "_required","_explosivesList"];
|
2015-04-10 03:46:19 +00:00
|
|
|
|
2016-01-14 22:05:56 +00:00
|
|
|
_range = getNumber (ConfigFile >> "CfgWeapons" >> _detonator >> QGVAR(Range));
|
2015-01-12 09:48:26 +00:00
|
|
|
|
|
|
|
_result = [_unit] call FUNC(getPlacedExplosives);
|
2015-03-31 21:20:32 +00:00
|
|
|
_children = [];
|
2016-01-05 22:40:27 +00:00
|
|
|
_explosivesList = [];
|
2015-01-12 09:48:26 +00:00
|
|
|
{
|
2015-04-06 20:20:11 +00:00
|
|
|
if (!isNull(_x select 0)) then {
|
2015-04-10 03:56:19 +00:00
|
|
|
_required = getArray (ConfigFile >> "ACE_Triggers" >> (_x select 4) >> "requires");
|
2015-04-06 20:20:11 +00:00
|
|
|
if (_detonator in _required) then {
|
|
|
|
_item = ConfigFile >> "CfgMagazines" >> (_x select 3);
|
2015-03-31 21:20:32 +00:00
|
|
|
|
2016-01-05 22:40:27 +00:00
|
|
|
_explosivesList pushBack _x;
|
|
|
|
|
2015-04-06 20:20:11 +00:00
|
|
|
_children pushBack
|
|
|
|
[
|
|
|
|
[
|
|
|
|
format ["Explosive_%1", _forEachIndex],
|
|
|
|
_x select 2,
|
|
|
|
getText(_item >> "picture"),
|
|
|
|
{(_this select 2) call FUNC(detonateExplosive);},
|
|
|
|
{true},
|
|
|
|
{},
|
2016-01-06 17:05:06 +00:00
|
|
|
[_unit,_range,_x]
|
2015-04-06 20:20:11 +00:00
|
|
|
] call EFUNC(interact_menu,createAction),
|
|
|
|
[],
|
2016-01-06 17:05:06 +00:00
|
|
|
_unit
|
2015-04-06 20:20:11 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2015-08-15 19:35:33 +00:00
|
|
|
} forEach _result;
|
2016-02-05 05:55:29 +00:00
|
|
|
if (_detonator != "ACE_DeadManSwitch") then {
|
|
|
|
// Add action to detonate all explosives tied to the detonator
|
|
|
|
if (count _explosivesList > 0) then {
|
|
|
|
_children pushBack [
|
2016-01-05 22:40:27 +00:00
|
|
|
[
|
|
|
|
"Explosive_All",
|
2016-02-05 05:55:29 +00:00
|
|
|
localize LSTRING(DetonateAll),
|
2016-01-05 22:40:27 +00:00
|
|
|
getText(ConfigFile >> "CfgWeapons" >> _detonator >> "picture"),
|
|
|
|
{(_this select 2) call FUNC(detonateExplosiveAll);},
|
|
|
|
{true},
|
|
|
|
{},
|
2016-01-06 17:05:06 +00:00
|
|
|
[_unit,_range,_explosivesList]
|
2016-02-05 05:55:29 +00:00
|
|
|
] call EFUNC(interact_menu,createAction),
|
|
|
|
[],
|
|
|
|
_unit
|
|
|
|
];
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
//Add action to detonate all explosives (including the inventory explosive):
|
|
|
|
_children pushBack [
|
|
|
|
[
|
|
|
|
"Explosive_All_Deadman",
|
|
|
|
localize LSTRING(DetonateAll),
|
|
|
|
getText(ConfigFile >> "CfgWeapons" >> _detonator >> "picture"),
|
|
|
|
{[_player] call FUNC(onIncapacitated)},
|
|
|
|
{true}
|
|
|
|
] call EFUNC(interact_menu,createAction),
|
|
|
|
[],
|
|
|
|
_unit
|
2016-01-05 22:40:27 +00:00
|
|
|
];
|
2016-02-05 05:55:29 +00:00
|
|
|
|
|
|
|
//Adds actions for the explosives you can connect to the deadman switch.
|
|
|
|
private _connectedInventoryExplosive = _unit getVariable [QGVAR(deadmanInvExplosive), ""];
|
|
|
|
if ((_connectedInventoryExplosive != "") && {!(_connectedInventoryExplosive in (magazines _unit))}) then {
|
|
|
|
TRACE_1("set, but missing in inventory",_connectedInventoryExplosive);
|
|
|
|
_unit setVariable [QGVAR(deadmanInvExplosive), "", true];
|
|
|
|
};
|
|
|
|
|
|
|
|
_connectedInventoryExplosive = _unit getVariable [QGVAR(deadmanInvExplosive), ""];
|
|
|
|
if (_connectedInventoryExplosive != "") then {
|
|
|
|
//Add the disconect action
|
|
|
|
private _magConfig = configFile >> "CfgMagazines" >> _connectedInventoryExplosive;
|
|
|
|
private _name = if ((getText (_magConfig >> "displayNameShort")) != "") then {
|
|
|
|
getText (_magConfig >> "displayNameShort")
|
|
|
|
} else {
|
|
|
|
getText(_magConfig >> "displayName")
|
|
|
|
};
|
|
|
|
private _picture = getText (_magConfig >> "picture");
|
|
|
|
|
|
|
|
_children pushBack [
|
|
|
|
([
|
|
|
|
"Deadman_disconnect",
|
|
|
|
format ["%1 %2", localize "str_disp_disconnect", _name],
|
|
|
|
_picture,
|
|
|
|
{
|
|
|
|
params ["_player"];
|
|
|
|
TRACE_1("clear",_player);
|
|
|
|
_player setVariable [QGVAR(deadmanInvExplosive), "", true];
|
|
|
|
},
|
|
|
|
{true}
|
|
|
|
] call EFUNC(interact_menu,createAction)), [], _unit];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
//Add all magazines that would work with the deadman switch
|
|
|
|
private _procressedMags = [];
|
|
|
|
{
|
|
|
|
private _mag = _x;
|
|
|
|
if (!(_mag in _procressedMags)) then {
|
|
|
|
_procressedMags pushBack _x;
|
|
|
|
private _magConfig = configFile >> "CfgMagazines" >> _mag;
|
|
|
|
private _supportedTriggers = getArray (_magConfig >> "ACE_Triggers" >> "SupportedTriggers");
|
|
|
|
if (({_x == "DeadmanSwitch"} count _supportedTriggers) == 1) then { //case insensitive search
|
|
|
|
private _name = if ((getText (_magConfig >> "displayNameShort")) != "") then {
|
|
|
|
getText (_magConfig >> "displayNameShort")
|
|
|
|
} else {
|
|
|
|
getText(_magConfig >> "displayName")
|
|
|
|
};
|
|
|
|
private _picture = getText (_magConfig >> "picture");
|
|
|
|
|
|
|
|
_children pushBack [
|
|
|
|
([
|
|
|
|
format ["Deadman_exp_%1", _mag],
|
|
|
|
format [localize LSTRING(connectInventoryExplosiveToDeadman), _name],
|
|
|
|
_picture,
|
|
|
|
{
|
|
|
|
params ["_player", "", "_mag"];
|
|
|
|
TRACE_2("set new",_player,_mag);
|
|
|
|
_player setVariable [QGVAR(deadmanInvExplosive), _mag, true];
|
|
|
|
},
|
|
|
|
{(_this select 2) in (magazines _player)},
|
|
|
|
{},
|
|
|
|
(_mag)
|
|
|
|
] call EFUNC(interact_menu,createAction)), [], _unit];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} forEach (magazines _unit);
|
|
|
|
};
|
2016-01-05 22:40:27 +00:00
|
|
|
};
|
|
|
|
|
2015-03-31 21:20:32 +00:00
|
|
|
_children
|