Skip to content

Commit

Permalink
Added event system for the opening and closing of the crate (#1061)
Browse files Browse the repository at this point in the history
* Fixed issues were the crate was destroyed prematurely

* Added event system to detect opening and closing of cav arsenal
  • Loading branch information
AndreasBrostrom authored Nov 5, 2023
1 parent 04ef271 commit 16380bc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 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
18 changes: 6 additions & 12 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 @@ -46,13 +49,4 @@ private _arsenalStatement = {

INFO_2("Staging Arsenal", "Adding staging arsenal action to %1 (%2)", player, typeOf player);
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;
[player, 1, _category, _arsenalAction] call ace_interact_menu_fnc_addActionToObject;

0 comments on commit 16380bc

Please sign in to comment.