Skip to content

Commit

Permalink
Updated and adjusted the eventhandler setup and fixed arsenal (#1093)
Browse files Browse the repository at this point in the history
* Improved and adjusted the eventhandler setup and arsenal

Moved eventhandlers to respective init functions
Added new handling for Ace Arsenal and default loadous.
Zeus and Debug now have access to all gear as well as all loadouts
Improved documentation

* Added missing function

* Fixed function call

* Updated and fixed arsenal

* Removed Dewbugging
  • Loading branch information
AndreasBrostrom authored Dec 7, 2023
1 parent eb229ea commit 270d409
Show file tree
Hide file tree
Showing 15 changed files with 142 additions and 62 deletions.
13 changes: 10 additions & 3 deletions cScripts/CfgFunctions.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class cScripts {
class init {
file = "cScripts\functions\init";
class init_aceArsenalDefault {};
class init_aceArsenal {};
class init_aceTagging {};
class init_aceItemReplace {};

Expand Down Expand Up @@ -64,6 +64,8 @@ class cScripts {
class player_setRank {};
class player_getRole {};

class player_isCurator {};

class unit_setTeamColor {};

class unit_getName {};
Expand All @@ -76,6 +78,7 @@ class cScripts {
class setRadioChannel {};
class setActiveRadio {};

class player_getCompany {};
class player_setCompany {};

// Other Functions
Expand Down Expand Up @@ -111,6 +114,12 @@ class cScripts {
class setupLoadoutCategories {};
class addLoadoutSelection {};

// Arsenal releated
class getArsenalWhitelist {};
class addDefaultArsenalLoadout {};
class addDefaultArsenalLoadouts {};
class clearDefaultArsenalLoadouts {};

class checkStagingZone {};

class deleteDroppedObjects {};
Expand All @@ -129,8 +138,6 @@ class cScripts {
class addReGear {};
class addHeal {};
class addArsenal {};
class getArsenalWhitelist {};
class getUnitArsenalDefault {};

class createActionCategory {};

Expand Down
2 changes: 1 addition & 1 deletion cScripts/cScripts_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ private _cScriptSettings = "cScripts Mission Settings";
INFO(if (is3DEN) then {"EDEN"} else {"preInit"}, "Initialization of CBA Settings completed...");

// Ace Arsenal
call EFUNC(init,aceArsenalDefault);
call EFUNC(init,aceArsenal);


// Load preInit mission settings
Expand Down
3 changes: 2 additions & 1 deletion cScripts/functions/gear/fn_gear_getLoadoutName.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

params [["_unit", objNull, [objNull]]];

private _return = GETVAR(_unit,EGVAR(Gear,loadoutClass),typeOf player);

private _return = GETVAR(_unit,EGVAR(Gear,loadoutClass), typeOf player);

_return
37 changes: 37 additions & 0 deletions cScripts/functions/init/fn_init_aceArsenal.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "..\script_component.hpp";
/*
* Author: CPL.Brostrom.A
* This function initzialise ace arsenal default loadouts in eden and in mission.
*
* Example:
* call cScripts_fnc_init_aceArsenal
*
* Public: No
*/

if (!EGVAR(patches,usesACEArsenal)) exitWith {};

call FUNC(addDefaultArsenalLoadouts);

if (is3DEN) exitWith {};

GVAR(StagingArsenalOpen) = false;

// Event Handlers
["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 FUNC(addDefaultArsenalLoadouts);
}] call CBA_fnc_addEventHandler;
32 changes: 0 additions & 32 deletions cScripts/functions/init/fn_init_eventHandlers.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@ INFO("InitEventHandlers","Creating Global EventHandlers");
call FUNC(getAttendance);
}] call CBA_fnc_addEventHandler;

[QEGVAR(EH_Vehicle,addFunctions), {
params ["_vehicle"];
INFO_2("EH_InitVehicle_addFunctions", "Applying function to %1 [%2]", _vehicle, typeOf _vehicle);
_vehicle call EFUNC(vehicle,addFunctions);
}] call CBA_fnc_addEventHandler;

[QEGVAR(EH_Vehicle,addStagingActions), {
params ["_vehicle"];
INFO_2("EH_InitVehicle_addStagingActions", "Applying function to %1 [%2]", _vehicle, typeOf _vehicle);
_vehicle call EFUNC(vehicle,addStagingActions);
}] call CBA_fnc_addEventHandler;


// Player Events
if (GVAR(isPlayer)) then {
Expand All @@ -40,26 +28,6 @@ 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
3 changes: 3 additions & 0 deletions cScripts/functions/init/fn_init_staging.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ private _stagingZoneMarkers = [];
[_zone, _size] call FUNC(addStagingZone);
} forEach _stagingZoneMarkers;


// Player specific actions
if !(GVAR(isPlayer)) exitWith {};

// Interaction system
private _condition = { call FUNC(checkStagingZone) };
private _stagingCat = [QEGVAR(Actions,StagingCategory), "Staging Zone", "cScripts\Data\Icon\icon_00.paa", {true}, _condition] call ace_interact_menu_fnc_createAction;
[player, 1, ["ACE_SelfActions"], _stagingCat] call ace_interact_menu_fnc_addActionToObject;
Expand Down
15 changes: 15 additions & 0 deletions cScripts/functions/init/fn_init_vehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ INFO("InitVehicle","Applying Event Handers (init) to vehicles for function expan

if !(EGVAR(Settings,enableVehicleSystem)) exitWith {};

// Event Handlers
[QEGVAR(EH_Vehicle,addFunctions), {
params ["_vehicle"];
INFO_2("EH_InitVehicle_addFunctions", "Applying function to %1 [%2]", _vehicle, typeOf _vehicle);
_vehicle call EFUNC(vehicle,addFunctions);
}] call CBA_fnc_addEventHandler;

[QEGVAR(EH_Vehicle,addStagingActions), {
params ["_vehicle"];
INFO_2("EH_InitVehicle_addStagingActions", "Applying function to %1 [%2]", _vehicle, typeOf _vehicle);
_vehicle call EFUNC(vehicle,addStagingActions);
}] call CBA_fnc_addEventHandler;


// Vehicle init
["AllVehicles", "init", {
params ["_vehicle"];
INFO_2("VehicleInit", "Applying Init to %1 [%2]...", _vehicle, typeOf _vehicle);
Expand Down
2 changes: 1 addition & 1 deletion cScripts/functions/players/fn_player_getCompany.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Public: No
*/

private _company = GETVAR(player,EGVAR(Player,Company),"");
private _company = GETVAR(player,EGVAR(Player,Company), "");
_company = toLower _company;

_company
24 changes: 24 additions & 0 deletions cScripts/functions/players/fn_player_isCurator.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "..\script_component.hpp";
/*
* Author: SGT.Brostrom.A
* This function return true if a player is curator
*
* Arguments:
* None
*
* Return Value:
* true/False <BOOLEAN>
*
* Example:
* call cScripts_fnc_unit_setInsignia
*
*/

private _curator = player getVariable [QEGVAR(Player,Unit), ""];
_curator = toLower _curator;
if (_curator == "s3") exitWith {true};
if (_curator == "zeus") exitWith {true};
if (_curator == "curator") exitWith {true};
if (_curator == "debug") exitWith {true};

false
8 changes: 6 additions & 2 deletions cScripts/functions/systems/fn_addArsenal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ private _icon = "cScripts\Data\Icon\icon_arsenal_ca.paa";
private _arsenalStatement = {
INFO_2("Staging Arsenal", "Creating staging arsenal for %1 (%2)", player, typeOf player);

ace_arsenal_defaultLoadoutsList = [];
call FUNC(getUnitArsenalDefault);
call FUNC(clearDefaultArsenalLoadouts);
waitUntil { count ace_arsenal_defaultLoadoutsList == 0 };
call FUNC(addDefaultArsenalLoadout);
waitUntil { count ace_arsenal_defaultLoadoutsList != 0 };

private _items = call FUNC(getArsenalWhitelist);
INFO_3("Staging Arsenal", "Whitleist containing %1 items added to %2 (%3)", count _items, player, typeOf player);
if (count _items == 0) exitWith {
[
[],
Expand All @@ -32,6 +35,7 @@ private _arsenalStatement = {
] call CBA_fnc_notify;
};


[player, _items] call ace_arsenal_fnc_initBox;

[{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
#include "..\script_component.hpp";
/*
* Author: CPL.Brostrom.A
* This function creates a defualt loadout based on your current selected loadout class
* Author: SGT.Brostrom.A
* This function creates a default loadouts and adds it to the arsenal based on the config loadout name.
* The loadout is added to the players arsenal.
*
* Arguments:
* None
*
* Return:
* Nothing
* True on success
*
* Example:
* [] call cScripts_fnc_getUnitArsenalDefault;
* call cScripts_fnc_addDefaultArsenalLoadout
*/

if (!EGVAR(patches,usesACEArsenal)) exitWith {};

INFO("Default Arsenal", "Setting up default arsenal loadout for unit...");

private _empty = [[],[],[],[],[],[],"","",[],["","","","","",""]];
["<empty>", _empty, false] call ace_arsenal_fnc_addDefaultLoadout;

private _loadout = [player] call EFUNC(gear,getLoadoutName);
if !(isClass (missionConfigFile >> "CfgLoadouts" >> _loadout)) exitWith {
SHOW_CHAT_WARNING_1("ArsenalDefault", "Loadout '%1' does not exist inside of mission config. No default arsenal will be created.", _loadout);
SHOW_CHAT_WARNING_1("Default Arsenal", "Loadout '%1' does not exist inside of mission config. No default arsenal will be created.", _loadout);
};

private _name = getText (missionConfigFile >> "CfgLoadouts" >> _loadout >> "displayName");
Expand All @@ -30,4 +35,7 @@ _name = format["[7CAV] %1 %2 (Default)", _company, _name];
private _loadout = parseSimpleArray getText (missionConfigFile >> "CfgLoadouts" >> _loadout >> "loadout");
if (EGVAR(patches,usesACRE)) then { _loadout = [_loadout] call acre_api_fnc_filterUnitLoadout };

[_name, _loadout, false] call ace_arsenal_fnc_addDefaultLoadout;
[_name, _loadout, false] call ace_arsenal_fnc_addDefaultLoadout;
INFO_1("Default Arsenal", "Loadout name %1 created for player arsenal", _name);

true
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
#include "..\script_component.hpp";
/*
* Author: CPL.Brostrom.A
* This function initzialise ace arsenal default loadouts in eden and in mission.
* Author: SGT.Brostrom.A
* This adds default arsenal loadouts based on cfgLoadouts gear system loadouts.
*
* Arguments:
* None
*
* Return:
* True on success
*
* Example:
* call cScripts_fnc_init_aceArsenalDefault
* call cScripts_fnc_addDefaultArsenalLoadouts
*
* Public: No
*/

if (isServer) exitWith {};
if (!EGVAR(patches,usesACEArsenal)) exitWith {};

INFO(if (is3DEN) then {"EDENArsenal"} else {"Arsenal"}, "Setting up Default ACE Arsenal loadouts.");
INFO(if (is3DEN) then {"EDEN Default Arsenal"} else {"Default Arsenal"}, "Setting up default arsenal loadouts...");

private _empty = [[],[],[],[],[],[],"","",[],["","","","","",""]];
["<empty>", _empty] call ace_arsenal_fnc_addDefaultLoadout;
Expand All @@ -29,14 +34,14 @@ private _classnameList = configProperties [missionconfigfile >> "CfgLoadouts", "
if (EGVAR(patches,usesACRE)) then { _loadout = [_loadout] call acre_api_fnc_filterUnitLoadout };
private _name = format["[%1] %2 - %3", EGVAR(Settings,primaryClanTag), _company, _displayName];

INFO_1(if (is3DEN) then {"EDENArsenal"} else {"Arsenal"}, "Setting up default arsenal loadout '%1'.", _displayName);
INFO_1(if (is3DEN) then {"EDEN Default Arsenal"} else {"Default Arsenal"}, "Setting up default arsenal loadout '%1'.", _displayName);

// Error if
if (_displayName == "") exitWith {
private _scope = getNumber (missionConfigFile >> 'CfgLoadouts' >> _class >> "scope");
SHOW_ERROR_2(if (is3DEN) then {"EDENArsenal"} else {"Arsenal"}, "No displayName for %1 with scope %2.", _class, _scope);
SHOW_ERROR_2(if (is3DEN) then {"EDEN Default Arsenal"} else {"Default Arsenal"}, "No displayName for %1 with scope %2.", _class, _scope);
};
[_name, _loadout] call ace_arsenal_fnc_addDefaultLoadout;
} forEach _classnameList;

INFO(if (is3DEN) then { "EDENArsenal"} else {"Arsenal"}, "Default ACE Arsenal loadouts setup completed.");
true
8 changes: 1 addition & 7 deletions cScripts/functions/systems/fn_allowLoadout.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@ if (EGVAR(Staging,showAllLoadouts)) exitWith {true};


// Check if player is Zeus or Debug
private _curator = player getVariable [QEGVAR(Player,Unit), ""];
_curator = toLower _curator;
if (_curator == "s3") exitWith {true};
if (_curator == "zeus") exitWith {true};
if (_curator == "curator") exitWith {true};
if (_curator == "debug") exitWith {true};

if (call EFUNC(player,isCurator)) exitWith {true};

// Check if does not have any company
private _playerCompany = call EFUNC(player,getCompany);
Expand Down
14 changes: 14 additions & 0 deletions cScripts/functions/systems/fn_clearDefaultArsenalLoadouts.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "..\script_component.hpp";
/*
* Author: SGT.Brostrom.A
* This function remove all ace arsenal default loadouts.
*
* Example:
* call cScripts_fnc_removeDefaultArsenalLoadouts
*
* Public: No
*/

if (!EGVAR(patches,usesACEArsenal)) exitWith {};

ace_arsenal_defaultLoadoutsList = [];
2 changes: 1 addition & 1 deletion cScripts/functions/systems/fn_getArsenalWhitelist.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* ARRAY of items
*
* Example:
* [] call cScripts_fnc_getArsenalWhitelist;
* call cScripts_fnc_getArsenalWhitelist;
*/

private _classname = [player] call EFUNC(gear,getLoadoutName);
Expand Down

0 comments on commit 270d409

Please sign in to comment.