Skip to content

Commit

Permalink
[Improve] - Zeus UI initialisation & Godmode (#180)
Browse files Browse the repository at this point in the history
* Godmode, QoL improvements, cleanup

- Fixed godmode only being applied once on initialisation (rather than everytime the curator display is opened)
- Moved initialisation code into fn_openZeus (replacing the now-redundant init loop polling curator display availability)
- Fixed custom Zeus UI not opening on the first use of the curator screen
- Added safeguard to giveUnitGodMode to ensure only one instance of the heal loop can run
  • Loading branch information
Cre8or authored Aug 14, 2023
1 parent 701cab5 commit 300b82e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 28 deletions.
16 changes: 11 additions & 5 deletions components/miscShared/fn_giveUnitGodmode.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@
*/

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

LOCAL_ONLY(_unit);

[_unit, false] remoteExec ["allowDamage", 0, true];
[_unit, false] remoteExecCall ["allowDamage", 0, true];
_unit setVariable ["ace_medical_allowDamage", false, true];

if (_keepHealthy) then
{
[_unit] spawn f_fnc_keepUnitHealthy;
// Prevent running multiple instances of the "keep-healthy" loop
if (isNil "handle_fnc_keepUnitHealthy") then {handle_fnc_keepUnitHealthy = scriptNull};
terminate handle_fnc_keepUnitHealthy;

if (_keepHealthy) then {
handle_fnc_keepUnitHealthy = [_unit] spawn f_fnc_keepUnitHealthy;
};
4 changes: 2 additions & 2 deletions components/zeus_ui/fn_addZeusActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if !(player getVariable ["f_var_isZeus",false]) exitWith {}; // Fallback in case

//ACRE actions

if (["acre_sys_radio"] call ace_common_fnc_isModLoaded) then
if (["acre_sys_radio"] call ace_common_fnc_isModLoaded) then
{
private _talkThroughZeus =
{
Expand Down Expand Up @@ -131,7 +131,7 @@ private _noTurnZeusInvisible =
{
_player setVariable ["f_var_turnZeusInvisible", false, true];

if (!cafe_ceasefire_active) then { // Disables AI seeing the Zeus player as hostile when talking in direct speech while hidden
if (!cafe_ceasefire_active) then {
_player setCaptive false;
};
[_player, true] remoteExecCall ["f_fnc_activatePlayer", 2];
Expand Down
24 changes: 19 additions & 5 deletions components/zeus_ui/fn_openZeus.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,26 @@

CLIENT_ONLY;

if !(player getVariable ["f_var_isZeus",false]) exitWith {}; //Fallback in case the script execution is run on the wrong machine
// Initialisation
if (!cafe_zeusUI_isInitialised) then {
cafe_zeusUI_isInitialised = true;

player setVariable ["f_var_isZeus", true, true];
player setVariable ["f_var_isKillLogRecipient", true, true];

player addCuratorEditableObjects [(vehicles + allUnits + allDeadMen), true];
player removeCuratorEditableObjects [player, true];

[] call f_fnc_addZeusActions;
};

// Godmode
[player, true] call f_fnc_giveUnitGodmode;

if (player getVariable ["f_var_turnZeusInvisible", true]) then
{
player setCaptive true; //Disables AI seeing the Zeus player as hostile when talking in direct speech while hidden
[player, false] remoteExecCall ["f_fnc_activatePlayer", 2];
[player, false] remoteExecCall ["f_fnc_activatePlayer", 2];
};

[] spawn //you need to wait for Zeus to actually be open to create the dialog
Expand All @@ -32,9 +46,9 @@ if (player getVariable ["f_var_turnZeusInvisible", true]) then

// Start the custom Zeus UI
["ui_init"] call f_fnc_zeusUI;
if (["acre_sys_radio"] call ace_common_fnc_isModLoaded) then

if (["acre_sys_radio"] call ace_common_fnc_isModLoaded) then
{
[] call acre_sys_zeus_fnc_handleZeusSpeakPress; //Fallback in case the variable goes missing.
};
};
};
17 changes: 1 addition & 16 deletions components/zeus_ui/init_component.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,4 @@ CLIENT_ONLY;

DEBUG_PRINT_LOG("[Zeus] Initting Zeus components")


waitUntil
{
sleep 1;
!isNull (findDisplay 312)
};

player setVariable ["f_var_isKillLogRecipient", true, true];
player setVariable ["f_var_isZeus", true, true];

[player, true] call f_fnc_giveUnitGodmode;

player addCuratorEditableObjects [(vehicles + allUnits), true];
player removeCuratorEditableObjects [player, true];

[] call f_fnc_addZeusActions;
cafe_zeusUI_isInitialised = false;

0 comments on commit 300b82e

Please sign in to comment.