Skip to content

Commit

Permalink
Explosives - Use detonator icon for consolidated detonate actions (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
mrschick authored Oct 15, 2024
1 parent ee1a0c2 commit 54150b9
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions addons/explosives/functions/fnc_addDetonateActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
params ["_unit", "_detonator"];
TRACE_2("params",_unit,_detonator);

private _range = getNumber (configFile >> "CfgWeapons" >> _detonator >> QGVAR(Range));
private _detonatorConfig = configFile >> "CfgWeapons" >> _detonator;
private _range = getNumber (_detonatorConfig >> QGVAR(Range));

private _result = [_unit] call FUNC(getPlacedExplosives);
private _children = [];
Expand All @@ -32,20 +33,30 @@ private _explosivesList = [];

_explosivesList pushBack _x;

_children pushBack
// Prevent consolidated detonate actions from having the same icon as consolidated place actions of the same explosive type
private _icon = if (
EGVAR(interact_menu,consolidateSingleChild) &&
{_detonator == GVAR(activeTrigger)} &&
{count (_result select {(_x select 4) == getText (_detonatorConfig >> QGVAR(triggerType))}) < 2}
) then {
getText (_detonatorConfig >> "picture")
} else {
getText (_item >> "picture")
};

_children pushBack [
[
[
format ["Explosive_%1", _forEachIndex],
_x select 2,
getText(_item >> "picture"),
{(_this select 2) call FUNC(detonateExplosive);},
{true},
{},
[_unit,_range,_x,_detonator]
] call EFUNC(interact_menu,createAction),
[],
_unit
];
format ["Explosive_%1", _forEachIndex],
_x select 2,
_icon,
{(_this select 2) call FUNC(detonateExplosive);},
{true},
{},
[_unit,_range,_x,_detonator]
] call EFUNC(interact_menu,createAction),
[],
_unit
];
};
};
} forEach _result;
Expand Down Expand Up @@ -81,7 +92,7 @@ if (_detonator != "ACE_DeadManSwitch") then {
[
"Explosive_All",
LLSTRING(DetonateAll),
getText (configFile >> "CfgWeapons" >> _detonator >> "picture"),
getText (_detonatorConfig >> "picture"),
{(_this select 2) call FUNC(detonateExplosiveAll);},
{true},
{},
Expand All @@ -107,7 +118,7 @@ if (_detonator != "ACE_DeadManSwitch") then {
[
"Explosive_All_Deadman",
LLSTRING(DetonateAll),
getText (configFile >> "CfgWeapons" >> _detonator >> "picture"),
getText (_detonatorConfig >> "picture"),
{[_player] call FUNC(onIncapacitated)},
{true}
] call EFUNC(interact_menu,createAction),
Expand Down

0 comments on commit 54150b9

Please sign in to comment.