Skip to content

Commit

Permalink
Added event system to detect opening and closing of cav arsenal
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBrostrom committed Oct 28, 2023
1 parent 4bff292 commit 0b31c27
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
24 changes: 24 additions & 0 deletions cScripts/functions/init/fn_init_eventHandlers.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,30 @@ if (GVAR(isPlayer)) then {
//["zen_common_createZeus", {
// _this params ["_zeus"];
//}] call CBA_fnc_addEventHandler;


// CavArsenal
["ace_arsenal_displayClosed", {
if (GVAR(StagingArsenalOpen)) then {
[QEGVAR(EH_StagingArsenal,displayClose)] call CBA_fnc_localEvent;
};
}] call CBA_fnc_addEventHandler;

[QEGVAR(EH_StagingArsenal,displayOpen), {
GVAR(StagingArsenalOpen) = true;
}] call CBA_fnc_addEventHandler;

[QEGVAR(EH_StagingArsenal,displayClosed), {
[player, true] call ace_arsenal_fnc_removeBox;
GVAR(StagingArsenalOpen) = false;

// Reset default loadouts
call EFUNC(init,aceArsenalDefault);

}] call CBA_fnc_addEventHandler;



};


Expand Down
15 changes: 5 additions & 10 deletions cScripts/functions/systems/fn_addArsenal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ private _arsenalStatement = {
INFO_2("Staging Arsenal", "Creating staging arsenal for %1 (%2)", player, typeOf player);

ace_arsenal_defaultLoadoutsList = [];
[] call FUNC(getUnitArsenalDefault);
call FUNC(getUnitArsenalDefault);

private _items = call FUNC(getArsenalWhitelist);
[player, _items] call ace_arsenal_fnc_initBox;
if (count _items == 0) exitWith {
[
[],
Expand All @@ -32,9 +31,13 @@ private _arsenalStatement = {
[""]
] call CBA_fnc_notify;
};

[player, _items] call ace_arsenal_fnc_initBox;

[{
INFO_2("Staging Arsenal", "Opening Staging Arsenal for %1 (%2)", player, typeOf player);
[player, player, false] call ace_arsenal_fnc_openBox;
[QEGVAR(EH_StagingArsenal,displayOpen)] call CBA_fnc_localEvent;
[{
private _loadout = [player] call EFUNC(gear,getCurrentLoadout);
private _name = getText (missionConfigFile >> "CfgLoadouts" >> _loadout >> "displayName");
Expand All @@ -48,11 +51,3 @@ INFO_2("Staging Arsenal", "Adding staging arsenal action to %1 (%2)", player, ty
private _arsenalAction = [QEGVAR(Actions,ArsenalAction), "Arsenal", _icon, _arsenalStatement, {true}] call ace_interact_menu_fnc_createAction;
[player, 1, _category, _arsenalAction] call ace_interact_menu_fnc_addActionToObject;

// Recreate after closing
["ace_arsenal_displayClosed", {
INFO_2("Arsenal", "Destroying %1 (%2) personal arsenal box.", player, typeOf player);
[player, true] call ace_arsenal_fnc_removeBox;

// Resetting loadouts
call EFUNC(init,aceArsenalDefault);
}] call CBA_fnc_addEventHandler;

0 comments on commit 0b31c27

Please sign in to comment.