-
Notifications
You must be signed in to change notification settings - Fork 736
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explosives - Add Cellphone/Detonator Keybinds (#9687)
Co-authored-by: Grim <[email protected]> Co-authored-by: johnb432 <[email protected]>
- Loading branch information
1 parent
28e45c2
commit 2f9b700
Showing
8 changed files
with
195 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: mrschick | ||
* Cycles the "Active Trigger" of a unit and shows a CBA Hint that displays the new Active Trigger. | ||
* | ||
* Arguments: | ||
* 0: Unit <OBJECT> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [ACE_player] call ace_explosives_fnc_cycleActiveTrigger; | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_unit"]; | ||
TRACE_1("params",_unit); | ||
|
||
private _detonators = _unit call FUNC(getDetonators); | ||
|
||
// Remove ACE_Cellphone from list, as it should never be the active trigger due to having its own keybind | ||
_detonators deleteAt (_detonators findIf {_x == "ACE_Cellphone"}); | ||
|
||
// Reset Active Trigger if none available | ||
if (_detonators isEqualTo []) exitWith { | ||
GVAR(activeTrigger) = ""; | ||
}; | ||
|
||
private _activeTrigger = GVAR(activeTrigger); | ||
private _index = _detonators findIf {_x == _activeTrigger}; | ||
private _count = count _detonators; | ||
|
||
if (_activeTrigger != "" && {_index != -1} && {_count > 1}) then { | ||
// If active trigger is set and among current detonators, switch to the next one | ||
if (_index < _count - 1) then { | ||
_index = _index + 1; | ||
} else { | ||
_index = 0; | ||
}; | ||
_activeTrigger = _detonators select _index; | ||
} else { | ||
// Assign first detonator in list as the active one | ||
_activeTrigger = _detonators select 0; | ||
}; | ||
|
||
GVAR(activeTrigger) = _activeTrigger; | ||
private _triggerConfig = configFile >> "CfgWeapons" >> _activeTrigger; | ||
private _triggerName = getText (_triggerConfig >> "displayName"); | ||
private _triggerIcon = getText (_triggerConfig >> "picture"); | ||
|
||
[format ["%1: %2", LLSTRING(ActiveTrigger), _triggerName], _triggerIcon] call EFUNC(common,displayTextPicture); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "\a3\ui_f\hpp\defineDIKCodes.inc" | ||
|
||
["ACE3 Equipment", QGVAR(openCellphone), LLSTRING(cellphone_displayName), { | ||
if ( | ||
!([ACE_player, "ACE_Cellphone"] call EFUNC(common,hasItem)) || | ||
!([ACE_player, objNull, ["isNotSwimming", "isNotInside", "isNotSitting"]] call EFUNC(common,canInteractWith)) | ||
) exitWith {}; | ||
|
||
closeDialog 0; | ||
createDialog "Rsc_ACE_PhoneInterface"; | ||
|
||
true | ||
}] call CBA_fnc_addKeybind; // Unbound | ||
|
||
["ACE3 Equipment", QGVAR(detonateActiveClacker), LLSTRING(DetonateAllOnActive), { | ||
// Prevent use of keybind while surrendering or captive | ||
if !([ACE_player, objNull, ["isNotSwimming", "isNotInside", "isNotSitting"]] call EFUNC(common,canInteractWith)) exitWith {}; | ||
|
||
private _detonator = GVAR(activeTrigger); | ||
if (_detonator == "" || !(_detonator in ([ACE_player] call FUNC(getDetonators)))) exitWith {}; | ||
|
||
// When using a Dead Man's Switch, skip all other logic and just call fnc_onIncapacitated, since it already handles everything that is required to detonate all connected explosives | ||
if (_detonator == "ACE_DeadManSwitch") exitWith { | ||
[ACE_player] call FUNC(onIncapacitated); | ||
}; | ||
|
||
private _range = getNumber (configFile >> "CfgWeapons" >> _detonator >> QGVAR(Range)); | ||
|
||
private _explosivesList = []; | ||
{ | ||
if (!isNull (_x select 0)) then { | ||
private _required = getArray (configFile >> "ACE_Triggers" >> _x select 4 >> "requires"); | ||
if (_detonator in _required) then { | ||
_explosivesList pushBack _x; | ||
}; | ||
}; | ||
} forEach ([ACE_player] call FUNC(getPlacedExplosives)); | ||
|
||
[ACE_player, _range, _explosivesList, _detonator] call FUNC(detonateExplosiveAll); | ||
|
||
true | ||
}] call CBA_fnc_addKeybind; // Unbound | ||
|
||
["ACE3 Equipment", QGVAR(cycleActiveClacker), LLSTRING(CycleActiveTrigger), { | ||
if !([ACE_player, objNull, ["isNotSwimming", "isNotInside", "isNotSitting"]] call EFUNC(common,canInteractWith)) exitWith {}; | ||
|
||
[ACE_player] call FUNC(cycleActiveTrigger); | ||
|
||
true | ||
}] call CBA_fnc_addKeybind; // Unbound |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters