From 62679832dffe59fa48385b608e005ddd4c766cc3 Mon Sep 17 00:00:00 2001 From: Kyle Mckay <5459452+kymckay@users.noreply.github.com> Date: Mon, 16 Aug 2021 12:01:50 +0100 Subject: [PATCH] Zeus - Move to native CBA Settings (#8381) * Zeus - Move to CBA settings * Zeus - Update BI module functions to 2.04 versions --- addons/zeus/ACE_Settings.hpp | 37 ++-------- addons/zeus/XEH_postInit.sqf | 7 -- addons/zeus/XEH_preInit.sqf | 7 ++ addons/zeus/functions/fnc_bi_moduleMine.sqf | 4 +- .../functions/fnc_bi_moduleProjectile.sqf | 7 +- addons/zeus/initSettings.sqf | 68 +++++++++++++++++++ addons/zeus/script_component.hpp | 4 ++ 7 files changed, 90 insertions(+), 44 deletions(-) diff --git a/addons/zeus/ACE_Settings.hpp b/addons/zeus/ACE_Settings.hpp index 0955fb135aa..4b027d20a8e 100644 --- a/addons/zeus/ACE_Settings.hpp +++ b/addons/zeus/ACE_Settings.hpp @@ -1,45 +1,20 @@ class ACE_Settings { class GVAR(zeusAscension) { - category = CSTRING(DisplayName); - displayName = CSTRING(ascension_DisplayName); - description = CSTRING(ascension_Description); - typeName = "BOOL"; - value = 0; + movedToSQF = 1; }; class GVAR(zeusBird) { - category = CSTRING(DisplayName); - displayName = CSTRING(bird_DisplayName); - description = CSTRING(bird_Description); - typeName = "BOOL"; - value = 0; + movedToSQF = 1; }; class GVAR(remoteWind) { - category = CSTRING(DisplayName); - displayName = CSTRING(remoteWind_DisplayName); - description = CSTRING(remoteWind_Description); - typeName = "BOOL"; - value = 0; + movedToSQF = 1; }; class GVAR(radioOrdnance) { - category = CSTRING(DisplayName); - displayName = CSTRING(radioOrdnance_DisplayName); - description = CSTRING(radioOrdnance_Description); - typeName = "BOOL"; - value = 0; + movedToSQF = 1; }; class GVAR(revealMines) { - category = CSTRING(DisplayName); - displayName = CSTRING(revealMines_DisplayName); - description = CSTRING(revealMines_Description); - typeName = "SCALAR"; - value = 0; - values[] = {"$STR_A3_OPTIONS_DISABLED", CSTRING(revealMines_partial), CSTRING(revealMines_full)}; + movedToSQF = 1; }; class GVAR(autoAddObjects) { - category = CSTRING(DisplayName); - typeName = "BOOL"; - value = 0; - displayName = CSTRING(AddObjectsToCurator); - description = CSTRING(AddObjectsToCurator_desc); + movedToSQF = 1; }; }; diff --git a/addons/zeus/XEH_postInit.sqf b/addons/zeus/XEH_postInit.sqf index 6de64b6d999..c1dba7e0e48 100644 --- a/addons/zeus/XEH_postInit.sqf +++ b/addons/zeus/XEH_postInit.sqf @@ -2,13 +2,6 @@ #define IDD_DISPLAY3DEN 313 -["ace_settingsInitialized",{ - // Only add an InitPost EH if setting is enabled (and apply retroactively) - if (isServer && {GVAR(autoAddObjects)}) then { - ["AllVehicles", "InitPost", FUNC(addObjectToCurator), true, [], true] call CBA_fnc_addClassEventHandler; - }; -}] call CBA_fnc_addEventHandler; - // Global skill module PVs values for persistence, just listen for the PV QGVAR(GlobalSkillAI) addPublicVariableEventHandler FUNC(moduleGlobalSetSkill); diff --git a/addons/zeus/XEH_preInit.sqf b/addons/zeus/XEH_preInit.sqf index 909005e73e4..c1bea7c581b 100644 --- a/addons/zeus/XEH_preInit.sqf +++ b/addons/zeus/XEH_preInit.sqf @@ -8,6 +8,13 @@ PREP_RECOMPILE_END; if (isServer) then { [QGVAR(zeusUnitAssigned), FUNC(handleZeusUnitAssigned)] call CBA_fnc_addEventHandler; + + // Only add an InitPost EH if setting is enabled (and apply retroactively) + ["CBA_settingsInitialized", { + if (GVAR(autoAddObjects)) then { + ["AllVehicles", "InitPost", FUNC(addObjectToCurator), true, [], true] call CBA_fnc_addClassEventHandler; + }; + }] call CBA_fnc_addEventHandler; }; GVAR(GlobalSkillAI) = [0.5,0.5,0.5,0.5,true,true]; diff --git a/addons/zeus/functions/fnc_bi_moduleMine.sqf b/addons/zeus/functions/fnc_bi_moduleMine.sqf index 40fce2d2ee9..94f4946c43e 100644 --- a/addons/zeus/functions/fnc_bi_moduleMine.sqf +++ b/addons/zeus/functions/fnc_bi_moduleMine.sqf @@ -27,14 +27,14 @@ if (_activated) then { _explosive attachto [_logic]; // Added by ace_zeus to control if mines are revealed - if (GVAR(revealMines) > 0) then { + if (GVAR(revealMines) > MINE_REVEAL_NONE) then { //--- Reveal the mine to curator's side { _side = (getassignedcuratorunit _x) call bis_fnc_objectSide; _side revealmine _explosive; } forEach (objectcurators _logic); - if (GVAR(revealMines) > 1) then { + if (GVAR(revealMines) == MINE_REVEAL_FULL) then { //--- Mark minefields in the map [] spawn bis_fnc_drawMinefields; }; diff --git a/addons/zeus/functions/fnc_bi_moduleProjectile.sqf b/addons/zeus/functions/fnc_bi_moduleProjectile.sqf index a450b105c0d..05d66380ff2 100644 --- a/addons/zeus/functions/fnc_bi_moduleProjectile.sqf +++ b/addons/zeus/functions/fnc_bi_moduleProjectile.sqf @@ -90,10 +90,9 @@ if (_activated) then { }; _fnc_playRadio = { if (_radio != "") then { - _entities = (getposatl _logic) nearentities ["All",100]; _sides = []; { - if (isplayer _x) then { + if (_x distance2D _logic < 100) then { _side = side group _x; if (_side in [east,west,resistance,civilian]) then { //--- Play radio (only if it wasn't played recently) @@ -103,14 +102,14 @@ if (_activated) then { }; }; }; - } foreach _entities; + } foreach allPlayers; }; }; if (count _hint > 0 && {count objectcurators _logic > 0}) then { [[_hint,nil,nil,nil,nil,nil,nil,true],"bis_fnc_advHint",objectcurators _logic] call bis_fnc_mp; }; if (count _velocity == 3) then { - _altitude = (_logic getvariable ["altitude",_altitude]) call bis_fnc_parsenumber; + _altitude = (_logic getvariable ["altitude",_altitude]) call BIS_fnc_parseNumberSafe; _radio = _logic getvariable ["radio",_radio]; //--- Create projectile diff --git a/addons/zeus/initSettings.sqf b/addons/zeus/initSettings.sqf index a9645b59172..cf4722c5c31 100644 --- a/addons/zeus/initSettings.sqf +++ b/addons/zeus/initSettings.sqf @@ -1,3 +1,71 @@ +[ + QGVAR(zeusAscension), + "CHECKBOX", + [LLSTRING(ascension_DisplayName), LLSTRING(ascension_Description)], + format ["ACE %1", LLSTRING(DisplayName)], + false, + true +] call CBA_fnc_addSetting; + +[ + QGVAR(zeusBird), + "CHECKBOX", + [LLSTRING(bird_DisplayName), LLSTRING(bird_Description)], + format ["ACE %1", LLSTRING(DisplayName)], + false, + true +] call CBA_fnc_addSetting; + +[ + QGVAR(remoteWind), + "CHECKBOX", + [LLSTRING(remoteWind_DisplayName), LLSTRING(remoteWind_Description)], + format ["ACE %1", LLSTRING(DisplayName)], + false, + true +] call CBA_fnc_addSetting; + +[ + QGVAR(radioOrdnance), + "CHECKBOX", + [LLSTRING(radioOrdnance_DisplayName), LLSTRING(radioOrdnance_Description)], + format ["ACE %1", LLSTRING(DisplayName)], + false, + true +] call CBA_fnc_addSetting; + +[ + QGVAR(revealMines), + "LIST", + [LLSTRING(revealMines_DisplayName), LLSTRING(revealMines_Description)], + format ["ACE %1", LLSTRING(DisplayName)], + [ + [ + MINE_REVEAL_NONE, + MINE_REVEAL_TO_SIDE, + MINE_REVEAL_FULL + ], + [ + localize "STR_A3_OPTIONS_DISABLED", + LLSTRING(revealMines_partial), + LLSTRING(revealMines_full) + ], + 0 + ], + true +] call CBA_fnc_addSetting; + +[ + QGVAR(autoAddObjects), + "CHECKBOX", + [LLSTRING(AddObjectsToCurator), LLSTRING(AddObjectsToCurator_desc)], + format ["ACE %1", LLSTRING(DisplayName)], + false, + true, + {}, + true // XEH class EH cannot be removed, requires mission restart +] call CBA_fnc_addSetting; + [ QGVAR(canCreateZeus), "LIST", diff --git a/addons/zeus/script_component.hpp b/addons/zeus/script_component.hpp index 957c7699d3b..8b59ac1032e 100644 --- a/addons/zeus/script_component.hpp +++ b/addons/zeus/script_component.hpp @@ -28,3 +28,7 @@ #define CAN_CREATE_ADMIN 0 #define CAN_CREATE_CONSOLE 1 #define CAN_CREATE_ALL 2 + +#define MINE_REVEAL_NONE 0 +#define MINE_REVEAL_TO_SIDE 1 +#define MINE_REVEAL_FULL 2