Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added event system for the opening and closing of the crate #1061

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;