From c80c9a75ff91d84e8998619cb260b000408d9d38 Mon Sep 17 00:00:00 2001 From: ColinM9991 <57466042+ColinM9991@users.noreply.github.com> Date: Mon, 25 Jul 2022 22:13:41 +0100 Subject: [PATCH] Add delayed init (#164) Init code, when it depends on CBA settings, now executes when the CBA_SettingsInitialized event is triggered. --- addons/activities/XEH_postInit.sqf | 28 +++---- addons/cars/XEH_postInit.sqf | 10 ++- addons/common/XEH_postInit.sqf | 14 ++-- addons/diagnostics/XEH_postInit.sqf | 80 +++++++++---------- addons/gta/XEH_postInit.sqf | 16 ++-- addons/interact/XEH_postInit.sqf | 50 ++++++------ addons/lifecycle/XEH_postInit.sqf | 66 ++++++++-------- addons/loadout/XEH_postInit.sqf | 34 ++++---- addons/main/XEH_postInit.sqf | 11 +-- addons/mimikry/XEH_postInit.sqf | 62 ++++++++------- addons/patrol/XEH_postInit.sqf | 42 +++++----- addons/residents/XEH_postInit.sqf | 116 ++++++++++++++-------------- addons/transit/XEH_postInit.sqf | 28 +++---- addons/voyage/XEH_postInit.sqf | 38 ++++----- addons/zeus/XEH_postInit.sqf | 10 ++- 15 files changed, 317 insertions(+), 288 deletions(-) diff --git a/addons/activities/XEH_postInit.sqf b/addons/activities/XEH_postInit.sqf index e868983d..313bb0a8 100644 --- a/addons/activities/XEH_postInit.sqf +++ b/addons/activities/XEH_postInit.sqf @@ -1,18 +1,20 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith {}; +["CBA_SettingsInitialized", { + if (!(EGVAR(main,enabled))) exitWith {}; -[] call FUNC(initCommonEventhandlers); + [] call FUNC(initCommonEventhandlers); -if (isServer || CBA_isHeadlessClient) then { - ["lifecycle", ["lfc_life"], FUNC(sm_emotions)] call EFUNC(common,augmentStateMachine); - ["lifecycle", ["lfc_life"], FUNC(sm_activities)] call EFUNC(common,augmentStateMachine); - [ - QEGVAR(lifecycle,civ_added), - { + if (isServer || CBA_isHeadlessClient) then { + ["lifecycle", ["lfc_life"], FUNC(sm_emotions)] call EFUNC(common,augmentStateMachine); + ["lifecycle", ["lfc_life"], FUNC(sm_activities)] call EFUNC(common,augmentStateMachine); + [ + QEGVAR(lifecycle,civ_added), { - [_x] call FUNC(onCivAdded); - } forEach _this; - } - ] call CBA_fnc_addEventHandler; -}; + { + [_x] call FUNC(onCivAdded); + } forEach _this; + } + ] call CBA_fnc_addEventHandler; + }; +}] call CBA_fnc_addEventHandler; diff --git a/addons/cars/XEH_postInit.sqf b/addons/cars/XEH_postInit.sqf index e8399878..d32d016b 100644 --- a/addons/cars/XEH_postInit.sqf +++ b/addons/cars/XEH_postInit.sqf @@ -1,7 +1,9 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith {}; +["CBA_SettingsInitialized", { + if (!(EGVAR(main,enabled))) exitWith {}; -if (isServer || CBA_isHeadlessClient) then { - ["business", ["bus_rally"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine); -}; + if (isServer || CBA_isHeadlessClient) then { + ["business", ["bus_rally"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine); + }; +}] call CBA_fnc_addEventHandler; diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index e190c7b1..f1765452 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -1,9 +1,11 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith {}; +["CBA_SettingsInitialized", { + if (!(EGVAR(main,enabled))) exitWith {}; -[QGVAR(switchMove), { - params ["_unit", "_animation"]; - _unit switchMove _animation; - } -] call CBA_fnc_addEventHandler; + [QGVAR(switchMove), { + params ["_unit", "_animation"]; + _unit switchMove _animation; + } + ] call CBA_fnc_addEventHandler; +}] call CBA_fnc_addEventHandler; diff --git a/addons/diagnostics/XEH_postInit.sqf b/addons/diagnostics/XEH_postInit.sqf index b1cbc208..575451c9 100644 --- a/addons/diagnostics/XEH_postInit.sqf +++ b/addons/diagnostics/XEH_postInit.sqf @@ -1,48 +1,50 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith {}; +["CBA_SettingsInitialized", { + if (!(EGVAR(main,enabled))) exitWith {}; -if (hasInterface) then { - call FUNC(showOnMap); - call FUNC(showPointingHints); - call FUNC(showInfoLine); - call FUNC(showFps); -}; + if (hasInterface) then { + call FUNC(showOnMap); + call FUNC(showPointingHints); + call FUNC(showInfoLine); + call FUNC(showFps); + }; -if (isServer || CBA_isHeadlessClient) then { - GVAR(debugLoopHandle) = [{ - params ["", "_handle"]; - if (hasInterface && (!isGameFocused || isGamePaused)) exitWith {}; - if (call EGVAR(lifecycle,EXITON)) exitWith {[_handle] call CBA_fnc_removePerFrameHandler}; - if (GVAR(showInfoLine)) then { - { _x call FUNC(updateInfoLine); } forEach EGVAR(lifecycle,localCivs); - }; - }, 1, []] call CBA_fnc_addPerFrameHandler; - - [ - { - if (GVAR(showFps)) then { - [QGVAR(fps), [clientOwner, diag_fps, count EGVAR(lifecycle,localCivs)]] call CBA_fnc_globalEvent; + if (isServer || CBA_isHeadlessClient) then { + GVAR(debugLoopHandle) = [{ + params ["", "_handle"]; + if (hasInterface && (!isGameFocused || isGamePaused)) exitWith {}; + if (call EGVAR(lifecycle,EXITON)) exitWith {[_handle] call CBA_fnc_removePerFrameHandler}; + if (GVAR(showInfoLine)) then { + { _x call FUNC(updateInfoLine); } forEach EGVAR(lifecycle,localCivs); }; - }, - 2, - [] - ] call CBA_fnc_addPerFrameHandler; -}; + }, 1, []] call CBA_fnc_addPerFrameHandler; + + [ + { + if (GVAR(showFps)) then { + [QGVAR(fps), [clientOwner, diag_fps, count EGVAR(lifecycle,localCivs)]] call CBA_fnc_globalEvent; + }; + }, + 2, + [] + ] call CBA_fnc_addPerFrameHandler; + }; -if (isServer) then { - [ - QEGVAR(lifecycle,civ_added), - { + if (isServer) then { + [ + QEGVAR(lifecycle,civ_added), { - private _civ = _x; - _civ setVariable [QGVAR(localAt), owner _civ, true]; - _civ addEventHandler ["Local", { - params ["_civ", ""]; + { + private _civ = _x; _civ setVariable [QGVAR(localAt), owner _civ, true]; - }]; - } forEach _this; + _civ addEventHandler ["Local", { + params ["_civ", ""]; + _civ setVariable [QGVAR(localAt), owner _civ, true]; + }]; + } forEach _this; - } - ] call CBA_fnc_addEventHandler; -}; + } + ] call CBA_fnc_addEventHandler; + }; +}] call CBA_fnc_addEventHandler; diff --git a/addons/gta/XEH_postInit.sqf b/addons/gta/XEH_postInit.sqf index c75bc44d..263a0eed 100644 --- a/addons/gta/XEH_postInit.sqf +++ b/addons/gta/XEH_postInit.sqf @@ -1,11 +1,13 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith {}; +["CBA_SettingsInitialized", { + if (!(EGVAR(main,enabled))) exitWith {}; -if (!(GVAR(enabled))) exitWith {}; + if (!(GVAR(enabled))) exitWith {}; -if (hasInterface) then { - player addEventHandler ["GetInMan", FUNC(onGetInMan)]; - player addEventHandler ["GetOutMan", FUNC(onGetOutMan)]; - player addEventHandler ["SeatSwitchedMan", FUNC(onSeatSwitchedMan)]; -}; + if (hasInterface) then { + player addEventHandler ["GetInMan", FUNC(onGetInMan)]; + player addEventHandler ["GetOutMan", FUNC(onGetOutMan)]; + player addEventHandler ["SeatSwitchedMan", FUNC(onSeatSwitchedMan)]; + }; +}] call CBA_fnc_addEventHandler; diff --git a/addons/interact/XEH_postInit.sqf b/addons/interact/XEH_postInit.sqf index cda6f61d..ee737da5 100644 --- a/addons/interact/XEH_postInit.sqf +++ b/addons/interact/XEH_postInit.sqf @@ -1,31 +1,33 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith {}; +["CBA_SettingsInitialized", { + if (!(EGVAR(main,enabled))) exitWith {}; -if (hasInterface) then { - call FUNC(aceInteractWrapper); - if (isNil "ace_interact_menu_fnc_createAction") then { - WARNING("ACE interact not loaded - this limits interaction with civilians"); - } else { - call FUNC(addCivInteractions); - }; + if (hasInterface) then { + call FUNC(aceInteractWrapper); + if (isNil "ace_interact_menu_fnc_createAction") then { + WARNING("ACE interact not loaded - this limits interaction with civilians"); + } else { + call FUNC(addCivInteractions); + }; - [{ - if (!isGameFocused || isGamePaused) exitWith {}; - [] call FUNC(checkWeaponOnCivilianPointer); - }, 0.5, []] call CBA_fnc_addPerFrameHandler; - private _playerUnit = call CBA_fnc_currentUnit; - _playerUnit addEventHandler ["GetInMan", FUNC(vehicleSeatHandler)]; - _playerUnit addEventHandler ["SeatSwitchedMan", FUNC(vehicleSeatHandler)]; - _playerUnit addEventHandler ["GetOutMan", FUNC(vehicleSeatHandler)]; - _playerUnit addEventHandler ["Killed", { FUNC(vehicleSeatHandler) }]; - _playerUnit addEventHandler ["Respawn", { FUNC(vehicleSeatHandler) }]; - [] call FUNC(vehicleSeatHandler); -}; + [{ + if (!isGameFocused || isGamePaused) exitWith {}; + [] call FUNC(checkWeaponOnCivilianPointer); + }, 0.5, []] call CBA_fnc_addPerFrameHandler; + private _playerUnit = call CBA_fnc_currentUnit; + _playerUnit addEventHandler ["GetInMan", FUNC(vehicleSeatHandler)]; + _playerUnit addEventHandler ["SeatSwitchedMan", FUNC(vehicleSeatHandler)]; + _playerUnit addEventHandler ["GetOutMan", FUNC(vehicleSeatHandler)]; + _playerUnit addEventHandler ["Killed", { FUNC(vehicleSeatHandler) }]; + _playerUnit addEventHandler ["Respawn", { FUNC(vehicleSeatHandler) }]; + [] call FUNC(vehicleSeatHandler); + }; -[] call FUNC(addInteractEventHandlers); + [] call FUNC(addInteractEventHandlers); -if (isServer || CBA_isHeadlessClient) then { - ["activities", ["act_business"], FUNC(sm_activities)] call EFUNC(common,augmentStateMachine); -}; + if (isServer || CBA_isHeadlessClient) then { + ["activities", ["act_business"], FUNC(sm_activities)] call EFUNC(common,augmentStateMachine); + }; +}] call CBA_fnc_addEventHandler; diff --git a/addons/lifecycle/XEH_postInit.sqf b/addons/lifecycle/XEH_postInit.sqf index 86de0278..c2c5b21c 100644 --- a/addons/lifecycle/XEH_postInit.sqf +++ b/addons/lifecycle/XEH_postInit.sqf @@ -1,39 +1,41 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith {}; - -ISNILS(GVAR(EXITON), {false}); - -if (isServer || CBA_isHeadlessClient) then { - [] call FUNC(initHCs); -}; - -[ - QGVAR(do_dismiss_civ), - { +["CBA_SettingsInitialized", { + if (!(EGVAR(main,enabled))) exitWith {}; + + ISNILS(GVAR(EXITON), {false}); + + if (isServer || CBA_isHeadlessClient) then { + [] call FUNC(initHCs); + }; + + [ + QGVAR(do_dismiss_civ), + { + params [ + ["_object", objNull, [objNull, grpNull]] + ]; + if (!((leader _object) in GVAR(localCivs))) exitWith { + INFO_2("not dismissing %1 (%2) as it is not local civ led", _object, typeName _object); + }; + + if (_object isEqualType grpNull) then { + [_object] call FUNC(dismissGroup); + } else { + [_object] call FUNC(dismissCiv); + }; + } + ] call CBA_fnc_addEventHandler; + + + ["ace_unconscious", { params [ - ["_object", objNull, [objNull, grpNull]] + ["_unit", objNull, [objNull]], + ["_isUnconscious", true, [true]] ]; - if (!((leader _object) in GVAR(localCivs))) exitWith { - INFO_2("not dismissing %1 (%2) as it is not local civ led", _object, typeName _object); - }; - - if (_object isEqualType grpNull) then { - [_object] call FUNC(dismissGroup); - } else { - [_object] call FUNC(dismissCiv); - }; - } -] call CBA_fnc_addEventHandler; - - -["ace_unconscious", { - params [ - ["_unit", objNull, [objNull]], - ["_isUnconscious", true, [true]] - ]; - private _eventName = if (_isUnconscious) then {QGVAR(unconscious)} else {QGVAR(conscious)}; - [_eventName, [_unit], _unit] call CBA_fnc_targetEvent; + private _eventName = if (_isUnconscious) then {QGVAR(unconscious)} else {QGVAR(conscious)}; + [_eventName, [_unit], _unit] call CBA_fnc_targetEvent; + }] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler; diff --git a/addons/loadout/XEH_postInit.sqf b/addons/loadout/XEH_postInit.sqf index 138e8440..41ca6262 100644 --- a/addons/loadout/XEH_postInit.sqf +++ b/addons/loadout/XEH_postInit.sqf @@ -1,21 +1,23 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith {}; +["CBA_SettingsInitialized", { + if (!(EGVAR(main,enabled))) exitWith {}; -[QEGVAR(lifecycle,civ_added), { - { - private _civ = _x; - if (local _civ) then { - [_civ] call FUNC(civAddLoadout); - }; - } forEach _this; -}] call CBA_fnc_addEventHandler; + [QEGVAR(lifecycle,civ_added), { + { + private _civ = _x; + if (local _civ) then { + [_civ] call FUNC(civAddLoadout); + }; + } forEach _this; + }] call CBA_fnc_addEventHandler; -[QGVAR(broadcastFace), { - params [ - ["_unit", objNull, [objNull]], - ["_face", "", [""]] - ]; - if (isNull _unit) exitWith {}; - _unit setFace _face; + [QGVAR(broadcastFace), { + params [ + ["_unit", objNull, [objNull]], + ["_face", "", [""]] + ]; + if (isNull _unit) exitWith {}; + _unit setFace _face; + }] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler; diff --git a/addons/main/XEH_postInit.sqf b/addons/main/XEH_postInit.sqf index eabb1219..8fe47ea9 100644 --- a/addons/main/XEH_postInit.sqf +++ b/addons/main/XEH_postInit.sqf @@ -1,8 +1,9 @@ #include "script_component.hpp" +["CBA_SettingsInitialized", { + if (!(EGVAR(main,enabled))) exitWith { + INFO("GRAD civs is disabled. Good bye!"); + }; -if (!(EGVAR(main,enabled))) exitWith { - INFO("GRAD civs is disabled. Good bye!"); -}; - -INFO_3("I am a player: %1 | HC: %2 | Server: %3", hasInterface, CBA_isHeadlessClient, isServer); + INFO_3("I am a player: %1 | HC: %2 | Server: %3", hasInterface, CBA_isHeadlessClient, isServer); +}] call CBA_fnc_addEventHandler; diff --git a/addons/mimikry/XEH_postInit.sqf b/addons/mimikry/XEH_postInit.sqf index c7030bfb..5a37edde 100644 --- a/addons/mimikry/XEH_postInit.sqf +++ b/addons/mimikry/XEH_postInit.sqf @@ -1,38 +1,40 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith {}; +["CBA_SettingsInitialized", { + if (!(EGVAR(main,enabled))) exitWith {}; -if (!(GVAR(enabled))) exitWith { - INFO("module disabled. good bye."); -}; + if (!(GVAR(enabled))) exitWith { + INFO("module disabled. good bye."); + }; -if (hasInterface) then { - [] call FUNC(addEventHandlers); + if (hasInterface) then { + [] call FUNC(addEventHandlers); - GVAR(playerActsAsCiv) = false; - [ - { - if (!isGameFocused || isGamePaused) exitWith {}; - private _playerUnit = call CBA_fnc_currentUnit; - if !(alive _playerUnit) exitWith {}; - private _playerIsCiv = false; - private _playerIsCiv = (side _playerUnit) isEqualTo civilian; - if !((lifeState _playerUnit) in ["HEALTHY", "INJURED"]) then { - // NOTE: incapacitated players are side civ which we dont want - _playerIsCiv = false; - }; + GVAR(playerActsAsCiv) = false; + [ + { + if (!isGameFocused || isGamePaused) exitWith {}; + private _playerUnit = call CBA_fnc_currentUnit; + if !(alive _playerUnit) exitWith {}; + private _playerIsCiv = false; + private _playerIsCiv = (side _playerUnit) isEqualTo civilian; + if !((lifeState _playerUnit) in ["HEALTHY", "INJURED"]) then { + // NOTE: incapacitated players are side civ which we dont want + _playerIsCiv = false; + }; - if (GVAR(playerActsAsCiv) isEqualTo _playerIsCiv) exitWith {}; + if (GVAR(playerActsAsCiv) isEqualTo _playerIsCiv) exitWith {}; - if (_playerIsCiv) then { - ["you are CIVILIAN now"] call FUNC(showCivHint); - } else { if (GVAR(playerActsAsCiv)) then { - ["you are NO LONGER CIVILIAN"] call FUNC(showCivHint); - }}; - GVAR(playerActsAsCiv) = _playerIsCiv; - }, - 5, - [] - ] call CBA_fnc_addPerFrameHandler; + if (_playerIsCiv) then { + ["you are CIVILIAN now"] call FUNC(showCivHint); + } else { if (GVAR(playerActsAsCiv)) then { + ["you are NO LONGER CIVILIAN"] call FUNC(showCivHint); + }}; + GVAR(playerActsAsCiv) = _playerIsCiv; + }, + 5, + [] + ] call CBA_fnc_addPerFrameHandler; -}; + }; +}] call CBA_fnc_addEventHandler; diff --git a/addons/patrol/XEH_postInit.sqf b/addons/patrol/XEH_postInit.sqf index e0dce905..aaf4e66d 100644 --- a/addons/patrol/XEH_postInit.sqf +++ b/addons/patrol/XEH_postInit.sqf @@ -1,25 +1,27 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith {}; +["CBA_SettingsInitialized", { + if (!(EGVAR(main,enabled))) exitWith {}; -if (isServer || CBA_isHeadlessClient) then { - [ - QEGVAR(lifecycle,localSpawn), - { - ISNILS(GVAR(maxCivsOnFoot), GVAR(maxCivsOnFoot)); - LOG("checking for maxCivsOnFoot / whether i am allowed to spawn more patrols"); - if ((count (["patrol"] call EFUNC(lifecycle,getGlobalCivs))) < GVAR(maxCivsOnFoot)) then { - LOG("calling addFootsy"); - [ALL_HUMAN_PLAYERS] call FUNC(addFootsy); - }; - } - ] call CBA_fnc_addEventHandler; + if (isServer || CBA_isHeadlessClient) then { + [ + QEGVAR(lifecycle,localSpawn), + { + ISNILS(GVAR(maxCivsOnFoot), GVAR(maxCivsOnFoot)); + LOG("checking for maxCivsOnFoot / whether i am allowed to spawn more patrols"); + if ((count (["patrol"] call EFUNC(lifecycle,getGlobalCivs))) < GVAR(maxCivsOnFoot)) then { + LOG("calling addFootsy"); + [ALL_HUMAN_PLAYERS] call FUNC(addFootsy); + }; + } + ] call CBA_fnc_addEventHandler; - private _spawnDistances = [GVAR(spawnDistancesOnFoot)] call EFUNC(common,parseCsv); - [ - "patrol", - _spawnDistances#1 * 1.5 - ] call EFUNC(common,registerCivTaskType); + private _spawnDistances = [GVAR(spawnDistancesOnFoot)] call EFUNC(common,parseCsv); + [ + "patrol", + _spawnDistances#1 * 1.5 + ] call EFUNC(common,registerCivTaskType); - ["business", ["bus_rally"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine); -}; + ["business", ["bus_rally"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine); + }; +}] call CBA_fnc_addEventHandler; diff --git a/addons/residents/XEH_postInit.sqf b/addons/residents/XEH_postInit.sqf index d834a28a..7a15cac7 100644 --- a/addons/residents/XEH_postInit.sqf +++ b/addons/residents/XEH_postInit.sqf @@ -1,59 +1,61 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith {}; - -GVAR(houseworkAnimationSetsInhouseNight) = [ - "PRONE_INJURED_U1", // lies on back - "PRONE_INJURED_U2", // lies on back - "SIT_LOW_U" // sit on floor -]; - -GVAR(houseworkAnimationSetsInhouseDay) = [ - "STAND_U1", // stands bored - "STAND_U2", // stands bored - "STAND_U3", // stands bored - "GUARD", // hands back - "LISTEN_BRIEFING", // hands back - "REPAIR_VEH_KNEEL", - "REPAIR_VEH_STAND", - "KNEEL_TREAT", - "BRIEFING", - "BRIEFING_POINT_TABLE", - "REPAIR_VEH_PRONE", // lies on back - "SIT_LOW_U" // sit on floor -]; - -GVAR(houseworkAnimationSetsOutdoors) = [ - "STAND_U1", // stands bored - "STAND_U2", // stands bored - "STAND_U3", // stands bored - "WATCH", // looking left to right - "WATCH2", // more straight ahead - "GUARD", // hands back - "LISTEN_BRIEFING", // hands back - "REPAIR_VEH_KNEEL", - "KNEEL_TREAT" -]; - -GVAR(houseworkTimesDay) = [5, 30, 120]; -GVAR(houseworkTimesNight) = [120, 240, 900]; - -if (isServer || CBA_isHeadlessClient) then { - [ - QEGVAR(lifecycle,localSpawn), - { - ISNILS(GVAR(maxCivsResidents), GVAR(maxCivsResidents)); - if ((count (["reside"] call EFUNC(lifecycle,getGlobalCivs))) < GVAR(maxCivsResidents)) then { - [ALL_HUMAN_PLAYERS] call FUNC(addResident); - }; - } - ] call CBA_fnc_addEventHandler; - - private _spawnDistances = [GVAR(spawnDistancesResidents)] call EFUNC(common,parseCsv); - [ - "reside", - _spawnDistances#1 * 1.2 - ] call EFUNC(common,registerCivTaskType); - - ["business", ["bus_rally"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine); -}; +["CBA_SettingsInitialized", { + if (!(EGVAR(main,enabled))) exitWith {}; + + GVAR(houseworkAnimationSetsInhouseNight) = [ + "PRONE_INJURED_U1", // lies on back + "PRONE_INJURED_U2", // lies on back + "SIT_LOW_U" // sit on floor + ]; + + GVAR(houseworkAnimationSetsInhouseDay) = [ + "STAND_U1", // stands bored + "STAND_U2", // stands bored + "STAND_U3", // stands bored + "GUARD", // hands back + "LISTEN_BRIEFING", // hands back + "REPAIR_VEH_KNEEL", + "REPAIR_VEH_STAND", + "KNEEL_TREAT", + "BRIEFING", + "BRIEFING_POINT_TABLE", + "REPAIR_VEH_PRONE", // lies on back + "SIT_LOW_U" // sit on floor + ]; + + GVAR(houseworkAnimationSetsOutdoors) = [ + "STAND_U1", // stands bored + "STAND_U2", // stands bored + "STAND_U3", // stands bored + "WATCH", // looking left to right + "WATCH2", // more straight ahead + "GUARD", // hands back + "LISTEN_BRIEFING", // hands back + "REPAIR_VEH_KNEEL", + "KNEEL_TREAT" + ]; + + GVAR(houseworkTimesDay) = [5, 30, 120]; + GVAR(houseworkTimesNight) = [120, 240, 900]; + + if (isServer || CBA_isHeadlessClient) then { + [ + QEGVAR(lifecycle,localSpawn), + { + ISNILS(GVAR(maxCivsResidents), GVAR(maxCivsResidents)); + if ((count (["reside"] call EFUNC(lifecycle,getGlobalCivs))) < GVAR(maxCivsResidents)) then { + [ALL_HUMAN_PLAYERS] call FUNC(addResident); + }; + } + ] call CBA_fnc_addEventHandler; + + private _spawnDistances = [GVAR(spawnDistancesResidents)] call EFUNC(common,parseCsv); + [ + "reside", + _spawnDistances#1 * 1.2 + ] call EFUNC(common,registerCivTaskType); + + ["business", ["bus_rally"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine); + }; +}] call CBA_fnc_addEventHandler; diff --git a/addons/transit/XEH_postInit.sqf b/addons/transit/XEH_postInit.sqf index bb882a10..34456a3e 100644 --- a/addons/transit/XEH_postInit.sqf +++ b/addons/transit/XEH_postInit.sqf @@ -1,17 +1,19 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith {}; +["CBA_SettingsInitialized", { + if (!(EGVAR(main,enabled))) exitWith {}; -if (isServer || CBA_isHeadlessClient) then { - [ - QEGVAR(lifecycle,localSpawn), - { - if ((count (["transit"] call EFUNC(cars,getGlobalVehicles))) < GVAR(maxVehiclesInTransit)) then { - [] call FUNC(spawnSomething); - }; - } - ] call CBA_fnc_addEventHandler; + if (isServer || CBA_isHeadlessClient) then { + [ + QEGVAR(lifecycle,localSpawn), + { + if ((count (["transit"] call EFUNC(cars,getGlobalVehicles))) < GVAR(maxVehiclesInTransit)) then { + [] call FUNC(spawnSomething); + }; + } + ] call CBA_fnc_addEventHandler; - ["business", ["bus_mountUp"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine); - ["lifecycle", ["lfc_life", "lfc_despawn"], FUNC(sm_lifecycle)] call EFUNC(common,augmentStateMachine); -}; + ["business", ["bus_mountUp"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine); + ["lifecycle", ["lfc_life", "lfc_despawn"], FUNC(sm_lifecycle)] call EFUNC(common,augmentStateMachine); + }; +}] call CBA_fnc_addEventHandler; diff --git a/addons/voyage/XEH_postInit.sqf b/addons/voyage/XEH_postInit.sqf index 41f67e89..30b2c39e 100644 --- a/addons/voyage/XEH_postInit.sqf +++ b/addons/voyage/XEH_postInit.sqf @@ -1,23 +1,25 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith {}; +["CBA_SettingsInitialized", { + if (!(EGVAR(main,enabled))) exitWith {}; -if (isServer || CBA_isHeadlessClient) then { - [ - QEGVAR(lifecycle,localSpawn), - { - private _maxCivsInVehicles = GVAR(maxCivsInVehicles); - if ((count (["voyage"] call EFUNC(lifecycle,getGlobalCivs))) < _maxCivsInVehicles) then { - [ALL_HUMAN_PLAYERS] call FUNC(addCarCrew); - }; - } - ] call CBA_fnc_addEventHandler; + if (isServer || CBA_isHeadlessClient) then { + [ + QEGVAR(lifecycle,localSpawn), + { + private _maxCivsInVehicles = GVAR(maxCivsInVehicles); + if ((count (["voyage"] call EFUNC(lifecycle,getGlobalCivs))) < _maxCivsInVehicles) then { + [ALL_HUMAN_PLAYERS] call FUNC(addCarCrew); + }; + } + ] call CBA_fnc_addEventHandler; - private _spawnDistances = [GVAR(spawnDistancesInVehicles)] call EFUNC(common,parseCsv); - [ - "voyage", - _spawnDistances#1 * 1.5 - ] call EFUNC(common,registerCivTaskType); + private _spawnDistances = [GVAR(spawnDistancesInVehicles)] call EFUNC(common,parseCsv); + [ + "voyage", + _spawnDistances#1 * 1.5 + ] call EFUNC(common,registerCivTaskType); - ["business", ["bus_mountUp"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine); -}; + ["business", ["bus_mountUp"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine); + }; +}] call CBA_fnc_addEventHandler; diff --git a/addons/zeus/XEH_postInit.sqf b/addons/zeus/XEH_postInit.sqf index b38df62a..167c6625 100644 --- a/addons/zeus/XEH_postInit.sqf +++ b/addons/zeus/XEH_postInit.sqf @@ -1,7 +1,9 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith {}; +["CBA_SettingsInitialized", { + if (!(EGVAR(main,enabled))) exitWith {}; -if (hasInterface) then { - [] call FUNC(setupZeusModules); -}; + if (hasInterface) then { + [] call FUNC(setupZeusModules); + }; +}] call CBA_fnc_addEventHandler;