From d049e782d559eb997f8d1eb3cf2510f7416a95e3 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Thu, 23 Jul 2020 19:16:40 +0200 Subject: [PATCH 01/55] call setCurrentlyThinking less often dont do it in loops (unless debug mode is baked in) --- addons/cars/script_component.hpp | 2 +- .../functions/fnc_customActivity_reverse.sqf | 2 +- addons/legacy/functions/fnc_sm_activities.sqf | 2 +- addons/legacy/functions/fnc_sm_emotions.sqf | 31 +++++++++++++------ .../fnc_sm_business_state_transit_loop.sqf | 4 ++- .../fnc_sm_business_state_voyage_loop.sqf | 4 ++- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/addons/cars/script_component.hpp b/addons/cars/script_component.hpp index 85de76e6..a6005360 100644 --- a/addons/cars/script_component.hpp +++ b/addons/cars/script_component.hpp @@ -7,7 +7,7 @@ #ifdef DEBUG_ENABLED_MAIN #define DEBUG_MODE_FULL #endif - #ifdef DEBUG_SETTINGS_MAIN +#ifdef DEBUG_SETTINGS_MAIN #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN #endif diff --git a/addons/legacy/functions/fnc_customActivity_reverse.sqf b/addons/legacy/functions/fnc_customActivity_reverse.sqf index a769fe7c..2c77f1ae 100644 --- a/addons/legacy/functions/fnc_customActivity_reverse.sqf +++ b/addons/legacy/functions/fnc_customActivity_reverse.sqf @@ -20,7 +20,7 @@ params [ 60, { // onDone params ["_vehicle"]; - [leader group driver _vehicle, "custom activity: waiting for players to go away"] call FUNC(setCurrentlyThinking); + [leader group driver _vehicle, "I'm waiting for people to go away"] call FUNC(setCurrentlyThinking); } ] call FUNC(reverse); diff --git a/addons/legacy/functions/fnc_sm_activities.sqf b/addons/legacy/functions/fnc_sm_activities.sqf index d0fa4e18..d94fdf6f 100644 --- a/addons/legacy/functions/fnc_sm_activities.sqf +++ b/addons/legacy/functions/fnc_sm_activities.sqf @@ -41,7 +41,7 @@ private _panic = [] call FUNC(sm_panic); _waitTime, [], "ace_interaction_getDown", - format["am told to get down, will resume activity at %1", _waitTime call FUNC(formatNowPlusSeconds)] + format["I will keep my head down until %1", _waitTime call FUNC(formatNowPlusSeconds)] ] call FUNC(doCustomActivity); } ] call CBA_fnc_addEventHandler; diff --git a/addons/legacy/functions/fnc_sm_emotions.sqf b/addons/legacy/functions/fnc_sm_emotions.sqf index 50f3e1c1..94f067ed 100644 --- a/addons/legacy/functions/fnc_sm_emotions.sqf +++ b/addons/legacy/functions/fnc_sm_emotions.sqf @@ -47,14 +47,20 @@ assert ([ _emotions, _emo_panic, _emo_wary, { - private _cooldown = _this getVariable["GRAD_CIVS_PANICCOOLDOWN", 60]; - private _timeUntilCooldown = _thisStateTime + _cooldown - CBA_missionTime; - - [_this, format["%1 seconds until cooldown", round _timeUntilCooldown]] call FUNC(setCurrentlyThinking); - _timeUntilCooldown <= 0 + (_this getVariable [QGVAR("cooldownAt"), 0]) < CBA_missionTime }, { _this call FUNC(forceEmotionSpeed); + + private _cooldownAt = _this getVariable["GRAD_CIVS_PANICCOOLDOWN", 60] + CBA_missionTime; + _this setVariable [QGVAR("cooldownAt"), _cooldownAt]); + [ + _this, + format[ + "I need until %1 to get a bit calmer", + _cooldownAt call FUNC(formatNowPlusSeconds) + ] + ] call FUNC(setCurrentlyThinking); }, _emo_panic + _emo_wary ] call EFUNC(cba_statemachine,addTransition)); @@ -64,14 +70,21 @@ assert ([ _emotions, _emo_wary, _emo_relaxed, { - private _cooldown = _this getVariable["GRAD_CIVS_PANICCOOLDOWN", 60]; - private _timeUntilCooldown = _thisStateTime + _cooldown - CBA_missionTime; + (_this getVariable [QGVAR("cooldownAt"), 0]) < CBA_missionTime - [_this, format["%1 seconds until cooldown", round _timeUntilCooldown]] call FUNC(setCurrentlyThinking); - _timeUntilCooldown <= 0 }, { _this call FUNC(forceEmotionSpeed); + + private _cooldownAt = _this getVariable["GRAD_CIVS_PANICCOOLDOWN", 60] + CBA_missionTime; + _this setVariable [QGVAR("cooldownAt"), _cooldownAt]); + [ + _this, + format[ + "I need until %1 to calm down completely", + _cooldownAt call FUNC(formatNowPlusSeconds) + ] + ] call FUNC(setCurrentlyThinking); }, _emo_wary + _emo_relaxed ] call EFUNC(cba_statemachine,addTransition)); diff --git a/addons/transit/functions/fnc_sm_business_state_transit_loop.sqf b/addons/transit/functions/fnc_sm_business_state_transit_loop.sqf index 4fe807aa..dccfa39c 100644 --- a/addons/transit/functions/fnc_sm_business_state_transit_loop.sqf +++ b/addons/transit/functions/fnc_sm_business_state_transit_loop.sqf @@ -14,4 +14,6 @@ private _wpidx = currentWaypoint _group; private _wps = waypoints _group; private _wppos = waypointPosition (_wps select _wpidx); -[_this, format ["traveling to transit sink %1, %2 (%3m left)", _wpidx, _wppos, _this distance _wppos]] call EFUNC(legacy,setCurrentlyThinking); +#ifdef DEBUG_MODE_FULL + [_this, format ["traveling to transit sink %1, %2 (%3m left)", _wpidx, _wppos, _this distance _wppos]] call EFUNC(legacy,setCurrentlyThinking); +#endif diff --git a/addons/voyage/functions/fnc_sm_business_state_voyage_loop.sqf b/addons/voyage/functions/fnc_sm_business_state_voyage_loop.sqf index b9d76046..8bbf16f2 100644 --- a/addons/voyage/functions/fnc_sm_business_state_voyage_loop.sqf +++ b/addons/voyage/functions/fnc_sm_business_state_voyage_loop.sqf @@ -8,4 +8,6 @@ if (isNull _group) exitWith { private _wps = waypoints _group; private _wppos = waypointPosition (_wps select (currentWaypoint _group)); -[_this, format ["traveling to waypoint %1, %2 (%3m left)", currentWaypoint _group, _wppos, _this distance _wppos]] call EFUNC(legacy,setCurrentlyThinking); +#ifdef DEBUG_MODE_FULL + [_this, format ["traveling to waypoint %1, %2 (%3m left)", currentWaypoint _group, _wppos, _this distance _wppos]] call EFUNC(legacy,setCurrentlyThinking); +#endif From a6642bf7bf5e595f05646a185c0dd6e3bd67e8f8 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Thu, 23 Jul 2020 19:31:43 +0200 Subject: [PATCH 02/55] whitespace formatting --- addons/cba_statemachine/script_component.hpp | 2 +- addons/common/script_component.hpp | 2 +- addons/gta/script_component.hpp | 2 +- addons/legacy/script_component.hpp | 2 +- addons/loadout/script_component.hpp | 2 +- addons/main/script_component.hpp | 2 +- addons/mimikry/script_component.hpp | 2 +- addons/patrol/script_component.hpp | 2 +- addons/residents/script_component.hpp | 2 +- addons/transit/script_component.hpp | 2 +- addons/voyage/script_component.hpp | 2 +- addons/zeus/script_component.hpp | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/addons/cba_statemachine/script_component.hpp b/addons/cba_statemachine/script_component.hpp index 9b5b83f6..7af0c18e 100644 --- a/addons/cba_statemachine/script_component.hpp +++ b/addons/cba_statemachine/script_component.hpp @@ -7,7 +7,7 @@ #ifdef DEBUG_ENABLED_MAIN #define DEBUG_MODE_FULL #endif - #ifdef DEBUG_SETTINGS_MAIN +#ifdef DEBUG_SETTINGS_MAIN #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN #endif diff --git a/addons/common/script_component.hpp b/addons/common/script_component.hpp index 65790baf..2bde489f 100644 --- a/addons/common/script_component.hpp +++ b/addons/common/script_component.hpp @@ -7,7 +7,7 @@ #ifdef DEBUG_ENABLED_MAIN #define DEBUG_MODE_FULL #endif - #ifdef DEBUG_SETTINGS_MAIN +#ifdef DEBUG_SETTINGS_MAIN #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN #endif diff --git a/addons/gta/script_component.hpp b/addons/gta/script_component.hpp index 3f8f4109..06d469f4 100644 --- a/addons/gta/script_component.hpp +++ b/addons/gta/script_component.hpp @@ -7,7 +7,7 @@ #ifdef DEBUG_ENABLED_MAIN #define DEBUG_MODE_FULL #endif - #ifdef DEBUG_SETTINGS_MAIN +#ifdef DEBUG_SETTINGS_MAIN #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN #endif diff --git a/addons/legacy/script_component.hpp b/addons/legacy/script_component.hpp index a17fca81..46c1132c 100644 --- a/addons/legacy/script_component.hpp +++ b/addons/legacy/script_component.hpp @@ -7,7 +7,7 @@ #ifdef DEBUG_ENABLED_MAIN #define DEBUG_MODE_FULL #endif - #ifdef DEBUG_SETTINGS_MAIN +#ifdef DEBUG_SETTINGS_MAIN #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN #endif diff --git a/addons/loadout/script_component.hpp b/addons/loadout/script_component.hpp index 7233a5e0..e70786c0 100644 --- a/addons/loadout/script_component.hpp +++ b/addons/loadout/script_component.hpp @@ -7,7 +7,7 @@ #ifdef DEBUG_ENABLED_MAIN #define DEBUG_MODE_FULL #endif - #ifdef DEBUG_SETTINGS_MAIN +#ifdef DEBUG_SETTINGS_MAIN #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN #endif diff --git a/addons/main/script_component.hpp b/addons/main/script_component.hpp index 054bfd92..ed5295d7 100644 --- a/addons/main/script_component.hpp +++ b/addons/main/script_component.hpp @@ -7,7 +7,7 @@ #ifdef DEBUG_ENABLED_MAIN #define DEBUG_MODE_FULL #endif - #ifdef DEBUG_SETTINGS_MAIN +#ifdef DEBUG_SETTINGS_MAIN #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN #endif diff --git a/addons/mimikry/script_component.hpp b/addons/mimikry/script_component.hpp index f79ad140..4cab4490 100644 --- a/addons/mimikry/script_component.hpp +++ b/addons/mimikry/script_component.hpp @@ -7,7 +7,7 @@ #ifdef DEBUG_ENABLED_MAIN #define DEBUG_MODE_FULL #endif - #ifdef DEBUG_SETTINGS_MAIN +#ifdef DEBUG_SETTINGS_MAIN #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN #endif diff --git a/addons/patrol/script_component.hpp b/addons/patrol/script_component.hpp index 90459a2e..7d6fba93 100644 --- a/addons/patrol/script_component.hpp +++ b/addons/patrol/script_component.hpp @@ -7,7 +7,7 @@ #ifdef DEBUG_ENABLED_MAIN #define DEBUG_MODE_FULL #endif - #ifdef DEBUG_SETTINGS_MAIN +#ifdef DEBUG_SETTINGS_MAIN #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN #endif diff --git a/addons/residents/script_component.hpp b/addons/residents/script_component.hpp index 89069639..2d929dba 100644 --- a/addons/residents/script_component.hpp +++ b/addons/residents/script_component.hpp @@ -7,7 +7,7 @@ #ifdef DEBUG_ENABLED_MAIN #define DEBUG_MODE_FULL #endif - #ifdef DEBUG_SETTINGS_MAIN +#ifdef DEBUG_SETTINGS_MAIN #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN #endif diff --git a/addons/transit/script_component.hpp b/addons/transit/script_component.hpp index dfd69899..cc1778ca 100644 --- a/addons/transit/script_component.hpp +++ b/addons/transit/script_component.hpp @@ -7,7 +7,7 @@ #ifdef DEBUG_ENABLED_MAIN #define DEBUG_MODE_FULL #endif - #ifdef DEBUG_SETTINGS_MAIN +#ifdef DEBUG_SETTINGS_MAIN #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN #endif diff --git a/addons/voyage/script_component.hpp b/addons/voyage/script_component.hpp index 7a21e4f3..b16b0232 100644 --- a/addons/voyage/script_component.hpp +++ b/addons/voyage/script_component.hpp @@ -7,7 +7,7 @@ #ifdef DEBUG_ENABLED_MAIN #define DEBUG_MODE_FULL #endif - #ifdef DEBUG_SETTINGS_MAIN +#ifdef DEBUG_SETTINGS_MAIN #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN #endif diff --git a/addons/zeus/script_component.hpp b/addons/zeus/script_component.hpp index c4e4c0ee..8697f974 100644 --- a/addons/zeus/script_component.hpp +++ b/addons/zeus/script_component.hpp @@ -7,7 +7,7 @@ #ifdef DEBUG_ENABLED_MAIN #define DEBUG_MODE_FULL #endif - #ifdef DEBUG_SETTINGS_MAIN +#ifdef DEBUG_SETTINGS_MAIN #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN #endif From c02b4c9d4c247c82c5d814c87bc4ac6fd188474b Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Thu, 23 Jul 2020 19:32:01 +0200 Subject: [PATCH 03/55] currentlythinking on voyage enter --- addons/voyage/functions/fnc_sm_business_state_voyage_enter.sqf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/voyage/functions/fnc_sm_business_state_voyage_enter.sqf b/addons/voyage/functions/fnc_sm_business_state_voyage_enter.sqf index bcf1df2b..314fa115 100644 --- a/addons/voyage/functions/fnc_sm_business_state_voyage_enter.sqf +++ b/addons/voyage/functions/fnc_sm_business_state_voyage_enter.sqf @@ -11,3 +11,5 @@ _this setSpeedMode "LIMITED"; _this forceSpeed -1; _this enableDynamicSimulation true; _this doFollow _this; + +[_this, format ["I'm on a %1 km voyage to %2", floor((_this distance _wppos) / 100)/10, _wppos]] call EFUNC(legacy,setCurrentlyThinking); From 97fe6b7df9916395436591ae76a8207e20a86364 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Thu, 23 Jul 2020 20:09:56 +0200 Subject: [PATCH 04/55] remove redundant braces --- .../legacy/functions/fnc_checkWeaponOnCivilianPointer.sqf | 6 +++--- addons/legacy/functions/fnc_clearCurrentlyThinking.sqf | 2 +- addons/legacy/functions/fnc_getCurrentlyThinking.sqf | 2 +- addons/legacy/functions/fnc_initPlayer.sqf | 2 +- addons/legacy/functions/fnc_serverLoop.sqf | 2 +- addons/legacy/functions/fnc_setCurrentlyThinking.sqf | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/legacy/functions/fnc_checkWeaponOnCivilianPointer.sqf b/addons/legacy/functions/fnc_checkWeaponOnCivilianPointer.sqf index 9881e3ef..f8573a8c 100644 --- a/addons/legacy/functions/fnc_checkWeaponOnCivilianPointer.sqf +++ b/addons/legacy/functions/fnc_checkWeaponOnCivilianPointer.sqf @@ -18,7 +18,7 @@ if ( if !((_currentCiv isEqualTo _possibleCiv) || (cursorTarget isEqualTo (_currentCiv call EFUNC(cars,getGroupVehicle)))) then { // TODO resolve circular dependency // maybe use `vehicle _currentCiv` instead? if (!isNull _currentCiv) then { player setVariable ["GRAD_isPointingAtObj", objNull]; - if ((GVAR(debugCivState))) then { hint format ["depointing %1", _currentCiv]; }; + if (GVAR(debugCivState)) then { hint format ["depointing %1", _currentCiv]; }; [QEGVAR(common,pointed_at_dec), [_currentCiv], [_currentCiv]] call CBA_fnc_targetEvent; }; } else { @@ -31,7 +31,7 @@ if ( if ((side _possibleCiv) == civilian && (alive _possibleCiv)) then { if ([player, _possibleCiv] call FUNC(checkWeaponOnCivilianPerception)) then { player setVariable ["GRAD_isPointingAtObj", _possibleCiv]; - if ((GVAR(debugCivState))) then { hint format ["pointing at %1", _possibleCiv]; }; + if (GVAR(debugCivState)) then { hint format ["pointing at %1", _possibleCiv]; }; [QEGVAR(common,pointed_at_inc), [_possibleCiv], [_possibleCiv]] call CBA_fnc_targetEvent; }; }; @@ -42,7 +42,7 @@ if ( if (!isNull _currentCiv) then { player setVariable ["GRAD_isPointingAtObj", objNull]; - if ((GVAR(debugCivState))) then { hint format ["depointing %1", _currentCiv]; }; + if (GVAR(debugCivState)) then { hint format ["depointing %1", _currentCiv]; }; [QEGVAR(common,pointed_at_dec), [_currentCiv], [_currentCiv]] call CBA_fnc_targetEvent; }; }; diff --git a/addons/legacy/functions/fnc_clearCurrentlyThinking.sqf b/addons/legacy/functions/fnc_clearCurrentlyThinking.sqf index d4c26d0e..3d10ef9d 100644 --- a/addons/legacy/functions/fnc_clearCurrentlyThinking.sqf +++ b/addons/legacy/functions/fnc_clearCurrentlyThinking.sqf @@ -1,5 +1,5 @@ #include "..\script_component.hpp" -if ((GVAR(debugCivState))) then { +if (GVAR(debugCivState)) then { _this setVariable ["grad_civs_currentlyThinking", nil, true]; }; diff --git a/addons/legacy/functions/fnc_getCurrentlyThinking.sqf b/addons/legacy/functions/fnc_getCurrentlyThinking.sqf index 6352f7b5..a10d3bd3 100644 --- a/addons/legacy/functions/fnc_getCurrentlyThinking.sqf +++ b/addons/legacy/functions/fnc_getCurrentlyThinking.sqf @@ -1,6 +1,6 @@ #include "..\script_component.hpp" -if ((GVAR(debugCivState))) then { +if (GVAR(debugCivState)) then { _this getVariable ["grad_civs_currentlyThinking", "dumdidum"]; } else { "" diff --git a/addons/legacy/functions/fnc_initPlayer.sqf b/addons/legacy/functions/fnc_initPlayer.sqf index c294dedf..a645cb4a 100644 --- a/addons/legacy/functions/fnc_initPlayer.sqf +++ b/addons/legacy/functions/fnc_initPlayer.sqf @@ -4,7 +4,7 @@ if (hasInterface) then { [] call FUNC(playerLoop); [] call FUNC(addCivInteractions); - if ((GVAR(debugCivState))) then { + if (GVAR(debugCivState)) then { [] call FUNC(showWhatTheyThink); [{!isNull (findDisplay 12)}, {[] call FUNC(mapMarkers)}, []] call CBA_fnc_waitUntilAndExecute; diff --git a/addons/legacy/functions/fnc_serverLoop.sqf b/addons/legacy/functions/fnc_serverLoop.sqf index 9a61d6bb..f50d5f00 100644 --- a/addons/legacy/functions/fnc_serverLoop.sqf +++ b/addons/legacy/functions/fnc_serverLoop.sqf @@ -35,7 +35,7 @@ GVAR(debugLoopHandle) = [{ params ["_args", "_handle"]; if (!isGameFocused || isGamePaused) exitWith {}; if (call GVAR(EXITON)) exitWith {[_handle] call CBA_fnc_removePerFrameHandler}; - if ((GVAR(debugCivState))) then { + if (GVAR(debugCivState)) then { { _x call FUNC(updateInfoLine); } forEach GVAR(localCivs); }; }, 0.1, []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/legacy/functions/fnc_setCurrentlyThinking.sqf b/addons/legacy/functions/fnc_setCurrentlyThinking.sqf index bc8d4efa..8c5b2011 100644 --- a/addons/legacy/functions/fnc_setCurrentlyThinking.sqf +++ b/addons/legacy/functions/fnc_setCurrentlyThinking.sqf @@ -5,6 +5,6 @@ params [ ["_thoughts", ""] ]; -if ((GVAR(debugCivState))) then { +if (GVAR(debugCivState)) then { _unit setVariable ["grad_civs_currentlyThinking", _thoughts]; }; From e70670379b7a70100afa22495454a39faab99d83 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Thu, 23 Jul 2020 20:49:05 +0200 Subject: [PATCH 05/55] clean up. move civ_added / civ_removed events to common. fix at least one usage. --- addons/common/functions/fnc_dismissCiv.sqf | 2 +- addons/diagnostics/$PBOPREFIX$ | 1 + addons/diagnostics/CfgEventHandlers.hpp | 14 ++++ addons/diagnostics/XEH_PREP.hpp | 5 ++ addons/diagnostics/XEH_postInit.sqf | 11 +++ addons/diagnostics/XEH_preInit.sqf | 12 ++++ addons/diagnostics/config.cpp | 15 ++++ .../diagnostics/functions/fnc_initConfig.sqf | 38 +++++++++++ .../functions/fnc_showInfoLine.sqf} | 68 +++++++------------ .../functions/fnc_showOnMap.sqf} | 20 +++--- .../functions/fnc_showOnMap_drawCivs.sqf} | 0 .../functions/fnc_showPinkArrows.sqf | 34 ++++++++++ addons/diagnostics/script_component.hpp | 14 ++++ .../functions/fnc_registerCivAddedHandler.sqf | 2 +- addons/legacy/XEH_PREP.hpp | 2 - addons/legacy/functions/fnc_getGlobalCivs.sqf | 4 +- .../fnc_sm_lifecycle_state_death_enter.sqf | 2 +- .../fnc_sm_lifecycle_state_despawn_enter.sqf | 4 +- addons/legacy/functions/fnc_spawnCivilian.sqf | 2 +- addons/loadout/XEH_postInit.sqf | 4 +- 20 files changed, 185 insertions(+), 69 deletions(-) create mode 100644 addons/diagnostics/$PBOPREFIX$ create mode 100644 addons/diagnostics/CfgEventHandlers.hpp create mode 100644 addons/diagnostics/XEH_PREP.hpp create mode 100644 addons/diagnostics/XEH_postInit.sqf create mode 100644 addons/diagnostics/XEH_preInit.sqf create mode 100644 addons/diagnostics/config.cpp create mode 100644 addons/diagnostics/functions/fnc_initConfig.sqf rename addons/{legacy/functions/fnc_showWhatTheyThink.sqf => diagnostics/functions/fnc_showInfoLine.sqf} (59%) rename addons/{legacy/functions/fnc_mapMarkers.sqf => diagnostics/functions/fnc_showOnMap.sqf} (62%) rename addons/{legacy/functions/fnc_drawCivs.sqf => diagnostics/functions/fnc_showOnMap_drawCivs.sqf} (100%) create mode 100644 addons/diagnostics/functions/fnc_showPinkArrows.sqf create mode 100644 addons/diagnostics/script_component.hpp diff --git a/addons/common/functions/fnc_dismissCiv.sqf b/addons/common/functions/fnc_dismissCiv.sqf index 993f50a8..576ff430 100644 --- a/addons/common/functions/fnc_dismissCiv.sqf +++ b/addons/common/functions/fnc_dismissCiv.sqf @@ -35,6 +35,6 @@ _civ enableAI "MOVE"; } forEach allVariables _civ; // trigger event last -["grad_civs_civ_removed", [_civ]] call CBA_fnc_globalEvent; +[QGVAR(civ_removed), [_civ]] call CBA_fnc_globalEvent; INFO_1("dismissed civ %1", _civ); diff --git a/addons/diagnostics/$PBOPREFIX$ b/addons/diagnostics/$PBOPREFIX$ new file mode 100644 index 00000000..d20b7a26 --- /dev/null +++ b/addons/diagnostics/$PBOPREFIX$ @@ -0,0 +1 @@ +z\grad_civs\addons\diagnostics diff --git a/addons/diagnostics/CfgEventHandlers.hpp b/addons/diagnostics/CfgEventHandlers.hpp new file mode 100644 index 00000000..770e715f --- /dev/null +++ b/addons/diagnostics/CfgEventHandlers.hpp @@ -0,0 +1,14 @@ +class Extended_PostInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; +class Extended_PreInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/diagnostics/XEH_PREP.hpp b/addons/diagnostics/XEH_PREP.hpp new file mode 100644 index 00000000..9a48f260 --- /dev/null +++ b/addons/diagnostics/XEH_PREP.hpp @@ -0,0 +1,5 @@ +PREP(initConfig); +PREP(showInfoLine); +PREP(showOnMap); +PREP(showOnMap_drawCivs); +PREP(showPinkArrows); diff --git a/addons/diagnostics/XEH_postInit.sqf b/addons/diagnostics/XEH_postInit.sqf new file mode 100644 index 00000000..b9c3f5bc --- /dev/null +++ b/addons/diagnostics/XEH_postInit.sqf @@ -0,0 +1,11 @@ +#include "script_component.hpp" + +if (!(EGVAR(main,enabled))) exitWith { + INFO("GRAD civs is disabled. Good bye!"); +}; + +if (hasInterface) then { + call FUNC(showOnMap); + call FUNC(showPinkArrows); + call FUNC(showInfoLine); +}; diff --git a/addons/diagnostics/XEH_preInit.sqf b/addons/diagnostics/XEH_preInit.sqf new file mode 100644 index 00000000..f7edd58d --- /dev/null +++ b/addons/diagnostics/XEH_preInit.sqf @@ -0,0 +1,12 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +ADDON = true; + + +[] call FUNC(initConfig); diff --git a/addons/diagnostics/config.cpp b/addons/diagnostics/config.cpp new file mode 100644 index 00000000..05f02bfa --- /dev/null +++ b/addons/diagnostics/config.cpp @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = QUOTE(COMPONENT); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"grad_civs_main", "grad_civs_legacy"}; + author = "AUTHOR"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" diff --git a/addons/diagnostics/functions/fnc_initConfig.sqf b/addons/diagnostics/functions/fnc_initConfig.sqf new file mode 100644 index 00000000..37a6d055 --- /dev/null +++ b/addons/diagnostics/functions/fnc_initConfig.sqf @@ -0,0 +1,38 @@ +#include "..\script_component.hpp" + +INFO("initConfig running..."); + +private _settingsGroup = ["GRAD Civs", "9) diagnostics"]; + +[ + QGVAR(showOnMap), + "CHECKBOX", + "Show civs on map", + _settingsGroup, + false, + true, + FUNC(showOnMap), + false +] call CBA_fnc_addSetting; + +[ + QGVAR(showInfoLine), + "CHECKBOX", + "Show info line", + _settingsGroup, + false, + true, + FUNC(showInfoLine), + false +] call CBA_fnc_addSetting; + +[ + QGVAR(showPinkArrows), + "CHECKBOX", + "Helpfully hover arrows", + _settingsGroup, + false, + true, + FUNC(showPinkArrows), + false +] call CBA_fnc_addSetting; diff --git a/addons/legacy/functions/fnc_showWhatTheyThink.sqf b/addons/diagnostics/functions/fnc_showInfoLine.sqf similarity index 59% rename from addons/legacy/functions/fnc_showWhatTheyThink.sqf rename to addons/diagnostics/functions/fnc_showInfoLine.sqf index a7410388..a5710018 100644 --- a/addons/legacy/functions/fnc_showWhatTheyThink.sqf +++ b/addons/diagnostics/functions/fnc_showInfoLine.sqf @@ -1,15 +1,14 @@ #include "..\script_component.hpp" -ASSERT_PLAYER(""); - -GVAR(civStateFormat) = 0; +ISNILS(GVAR(civStateFormat), 0); +ISNILS(GVAR(actionIds), []); [{ params [ ["_args", [], [[]]], ["_handle", 0, [0]] ]; - if (!(GVAR(debugCivState))) exitWith {[_handle] call CBA_fnc_removePerFrameHandler}; + if (!(GVAR(showInfoLine))) exitWith {[_handle] call CBA_fnc_removePerFrameHandler}; if (!isGameFocused || isGamePaused) exitWith {}; @@ -57,7 +56,7 @@ GVAR(civStateFormat) = 0; 1, 1, 0, _text, 0, 0.03, "EtelkaNarrowMediumPro", "center", true ]; - } forEach ([] call FUNC(getGlobalCivs)); + } forEach ([] call EFUNC(legacy,getGlobalCivs)); // show the honked_at "danger zone" in front of the vehicle private _poly = player getVariable ["grad_civs_dangerPolyInPlayerHeight", []]; @@ -67,9 +66,11 @@ GVAR(civStateFormat) = 0; drawLine3D [_from, _to, [1, 0.3, 0.5, 1]]; } forEach _poly; -} , 0, []] call CBA_fnc_addPerFrameHandler; +}, 0, []] call CBA_fnc_addPerFrameHandler; + +if (GVAR(showInfoLine)) then { + if (!(GVAR(actionIds) isEqualTo [])) exitWith {}; -if (GVAR(debugCivState)) then { private _addCivAction = { params [ ["_title", ""], @@ -84,46 +85,23 @@ if (GVAR(debugCivState)) then { false, false, "", - QUOTE([QQGVAR(debugCivState)] call CBA_settings_fnc_get) + QGVAR(showInfoLine) ]; }; - ["civstate format: infoLine", 0] call _addCivAction; - ["civstate format: speedmode", 1] call _addCivAction; - ["civstate format: guns", 2] call _addCivAction; - ["civstate format: locality", 3] call _addCivAction; - ["civstate format: behaviour", 4] call _addCivAction; - ["civstate format: state times", 5] call _addCivAction; - ["civstate format: waypoints", 6] call _addCivAction; - ["civstate format: empty", 7] call _addCivAction; -}; - -ISNILS(GVAR(showWhatTheyThink_civ_added), 0); -ISNILS(GVAR(showWhatTheyThinkciv_removed), 0); -if ((GVAR(debugCivState))) then { - GVAR(showWhatTheyThink_civ_added) = [ - QGVAR(civ_added), - { - SCRIPT("showWhatTheyThink_civ_added"); - { - private _arrow = createSimpleObject ["Sign_Arrow_Large_Pink_F", [0, 0, 0]]; - _arrow attachTo [_x, [0, 0, 5]]; - } forEach _this; - } - ] call CBA_fnc_addEventHandler; - GVAR(showWhatTheyThinkciv_removed) = [ - QGVAR(civ_removed), - { - SCRIPT("showWhatTheyThink_civ_removed"); - { - private _civ = _x; - { - deleteVehicle _x; - } forEach (attachedObjects _civ); - } forEach _this; - } - ] call CBA_fnc_addEventHandler; + GVAR(actionIds) = [ + ["civstate format: infoLine", 0] call _addCivAction, + ["civstate format: speedmode", 1] call _addCivAction, + ["civstate format: guns", 2] call _addCivAction, + ["civstate format: locality", 3] call _addCivAction, + ["civstate format: behaviour", 4] call _addCivAction, + ["civstate format: state times", 5] call _addCivAction, + ["civstate format: waypoints", 6] call _addCivAction, + ["civstate format: empty", 7] call _addCivAction + ]; } else { - [QGVAR(civ_added), GVAR(showWhatTheyThink_civ_added)] call CBA_fnc_removeEventHandler; - [QGVAR(civ_removed), GVAR(showWhatTheyThinkciv_removed)] call CBA_fnc_removeEventHandler; + { + player removeAction _x; + } forEach GVAR(actionIds); + GVAR(actionIds) = []; }; diff --git a/addons/legacy/functions/fnc_mapMarkers.sqf b/addons/diagnostics/functions/fnc_showOnMap.sqf similarity index 62% rename from addons/legacy/functions/fnc_mapMarkers.sqf rename to addons/diagnostics/functions/fnc_showOnMap.sqf index 580d6460..2423b8c2 100644 --- a/addons/legacy/functions/fnc_mapMarkers.sqf +++ b/addons/diagnostics/functions/fnc_showOnMap.sqf @@ -1,17 +1,12 @@ #include "..\script_component.hpp" -params [ - ["_onOff", GVAR(debugCivState)] -]; +ISNILS(GVAR(DRAWUNITSEH), -1); +if (GVAR(showOnMap)) then { + if (GVAR(DRAWUNITSEH) != -1) exitWith {}; -ASSERT_PLAYER(""); - -GVAR(debugCivState) = _onOff; - -if (_onOff) then { GVAR(DRAWUNITSEH) = ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", { - private _civs = [] call FUNC(getGlobalCivs); + private _civs = [] call EFUNC(legacy,getGlobalCivs); private _civsInCarDrivers = _civs select { private _vec = vehicle _x; _vec != _x && driver _vec == _x @@ -20,11 +15,12 @@ if (_onOff) then { vehicle _x == _x }; - [_this select 0, _civsOnFoot, "iconMan"] call FUNC(drawCivs); - [_this select 0, _civsInCarDrivers, "iconCar"] call FUNC(drawCivs); + [_this select 0, _civsOnFoot, "iconMan"] call FUNC(showOnMap_drawCivs); + [_this select 0, _civsInCarDrivers, "iconCar"] call FUNC(showOnMap_drawCivs); //one day: iconHelicopter }]; } else { - ISNILS(GVAR(DRAWUNITSEH), -1); + if (GVAR(DRAWUNITSEH) == -1) exitWith {}; ((findDisplay 12) displayCtrl 51) ctrlRemoveEventHandler ["Draw", GVAR(DRAWUNITSEH)]; + GVAR(DRAWUNITSEH) = -1; }; diff --git a/addons/legacy/functions/fnc_drawCivs.sqf b/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf similarity index 100% rename from addons/legacy/functions/fnc_drawCivs.sqf rename to addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf diff --git a/addons/diagnostics/functions/fnc_showPinkArrows.sqf b/addons/diagnostics/functions/fnc_showPinkArrows.sqf new file mode 100644 index 00000000..cbbc5626 --- /dev/null +++ b/addons/diagnostics/functions/fnc_showPinkArrows.sqf @@ -0,0 +1,34 @@ +#include "..\script_component.hpp" + +ISNILS(GVAR(showWhatTheyThink_civ_added), 0); +ISNILS(GVAR(showWhatTheyThinkciv_removed), 0); + +if (GVAR(showPinkArrows)) then { + if (GVAR(showWhatTheyThink_civ_added) != 0) exitWith {}; + + GVAR(showWhatTheyThink_civ_added) = [ + QEGVAR(common,civ_added), + { + SCRIPT("showWhatTheyThink_civ_added"); + { + private _arrow = createSimpleObject ["Sign_Arrow_Large_Pink_F", [0, 0, 0]]; + _arrow attachTo [_x, [0, 0, 5]]; + } forEach _this; + } + ] call CBA_fnc_addEventHandler; + GVAR(showWhatTheyThinkciv_removed) = [ + QEGVAR(common,civ_removed), + { + SCRIPT("showWhatTheyThink_civ_removed"); + { + private _civ = _x; + { + deleteVehicle _x; + } forEach (attachedObjects _civ); + } forEach _this; + } + ] call CBA_fnc_addEventHandler; +} else { + [QEGVAR(common,civ_added), GVAR(showWhatTheyThink_civ_added)] call CBA_fnc_removeEventHandler; + [QEGVAR(common,civ_removed), GVAR(showWhatTheyThinkciv_removed)] call CBA_fnc_removeEventHandler; +}; diff --git a/addons/diagnostics/script_component.hpp b/addons/diagnostics/script_component.hpp new file mode 100644 index 00000000..ccc5805a --- /dev/null +++ b/addons/diagnostics/script_component.hpp @@ -0,0 +1,14 @@ +#define COMPONENT diagnostics +#include "\z\grad_civs\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE + +#ifdef DEBUG_ENABLED_MAIN + #define DEBUG_MODE_FULL +#endif +#ifdef DEBUG_SETTINGS_MAIN + #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN +#endif + +#include "\z\grad_civs\addons\main\script_macros.hpp" diff --git a/addons/gta/functions/fnc_registerCivAddedHandler.sqf b/addons/gta/functions/fnc_registerCivAddedHandler.sqf index 00936209..765627a4 100644 --- a/addons/gta/functions/fnc_registerCivAddedHandler.sqf +++ b/addons/gta/functions/fnc_registerCivAddedHandler.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" [ - QEGVAR(legacy,civ_added), + QEGVAR(common,civ_added), { params [ ["_civ", objNull, [objNull]] diff --git a/addons/legacy/XEH_PREP.hpp b/addons/legacy/XEH_PREP.hpp index b3940217..52b0377f 100644 --- a/addons/legacy/XEH_PREP.hpp +++ b/addons/legacy/XEH_PREP.hpp @@ -42,7 +42,6 @@ PREP(interact_carryOnCondition); PREP(isInDistanceFromOtherPlayers); PREP(isInHouse); PREP(isPlayerHonking); -PREP(mapMarkers); PREP(nowPlusSeconds); PREP(playerLoop); PREP(reverse_abort); @@ -54,7 +53,6 @@ PREP(reverse); PREP(serverLoop); PREP(setCurrentlyThinking); PREP(setDebugMode); -PREP(showWhatTheyThink); PREP(sm_activities_helper_freeCondition); PREP(sm_activities_helper_surrenderCondition); PREP(sm_activities); diff --git a/addons/legacy/functions/fnc_getGlobalCivs.sqf b/addons/legacy/functions/fnc_getGlobalCivs.sqf index 6a8d816a..b9cce90b 100644 --- a/addons/legacy/functions/fnc_getGlobalCivs.sqf +++ b/addons/legacy/functions/fnc_getGlobalCivs.sqf @@ -13,14 +13,14 @@ if (isNil QFUNC(getGlobalCivs_arr)) then { // then, register event handler to update the array appropriately to always include all living civs [ - QGVAR(civ_added), + QEGVAR(common,civ_added), { SCRIPT("getGlobalCivs_civ_added"); FUNC(getGlobalCivs_arr) = FUNC(getGlobalCivs_arr) + _this; } ] call CBA_fnc_addEventHandler; [ - QGVAR(civ_removed), + QEGVAR(common,civ_removed), { SCRIPT("getGlobalCivs_civ_removed"); FUNC(getGlobalCivs_arr) = FUNC(getGlobalCivs_arr) - _this; diff --git a/addons/legacy/functions/fnc_sm_lifecycle_state_death_enter.sqf b/addons/legacy/functions/fnc_sm_lifecycle_state_death_enter.sqf index 0edc0a47..1a2f1335 100644 --- a/addons/legacy/functions/fnc_sm_lifecycle_state_death_enter.sqf +++ b/addons/legacy/functions/fnc_sm_lifecycle_state_death_enter.sqf @@ -9,7 +9,7 @@ INFO_3("releasing civ %1 killed at %2 by %3", _this, _deathPos, _killer); ["grad_civs_civKilled", [_deathPos, _killer]] call CBA_fnc_globalEvent; GVAR(localCivs) = GVAR(localCivs) - [_this]; -["grad_civs_civ_removed", [_this]] call CBA_fnc_globalEvent; +[QEGVAR(common,civ_removed), [_this]] call CBA_fnc_globalEvent; if (GVAR(cleanupCorpses)) then { addToRemainsCollector [_this]; diff --git a/addons/legacy/functions/fnc_sm_lifecycle_state_despawn_enter.sqf b/addons/legacy/functions/fnc_sm_lifecycle_state_despawn_enter.sqf index 40add3c2..4b9dd768 100644 --- a/addons/legacy/functions/fnc_sm_lifecycle_state_despawn_enter.sqf +++ b/addons/legacy/functions/fnc_sm_lifecycle_state_despawn_enter.sqf @@ -3,7 +3,7 @@ private _vec = vehicle _this; if (_vec != _this) then { GVAR(localCivs) = GVAR(localCivs) - (crew _vec); - [QGVAR(civ_removed), (crew _vec)] call CBA_fnc_globalEvent; + [QEGVAR(common,civ_removed), (crew _vec)] call CBA_fnc_globalEvent; private _count = { _vec deleteVehicleCrew _x; true @@ -12,7 +12,7 @@ if (_vec != _this) then { INFO_1("vehicle with %1 civs was despawned", _count); } else { GVAR(localCivs) = GVAR(localCivs) - [_this]; - [QGVAR(civ_removed), [_this]] call CBA_fnc_globalEvent; + [QEGVAR(common,civ_removed), [_this]] call CBA_fnc_globalEvent; deleteVehicle _this; INFO("1 civ was despawned"); }; diff --git a/addons/legacy/functions/fnc_spawnCivilian.sqf b/addons/legacy/functions/fnc_spawnCivilian.sqf index a85882aa..f8ccb681 100644 --- a/addons/legacy/functions/fnc_spawnCivilian.sqf +++ b/addons/legacy/functions/fnc_spawnCivilian.sqf @@ -14,6 +14,6 @@ GVAR(localCivs) = GVAR(localCivs) + [_civ]; _civ setVariable ["grad_civs_primaryTask", _primaryTask, true]; _civ setVariable ["acex_headless_blacklist", true, true]; -[QGVAR(civ_added), [_civ]] call CBA_fnc_globalEvent; +[QEGVAR(common,civ_added), [_civ]] call CBA_fnc_globalEvent; _civ diff --git a/addons/loadout/XEH_postInit.sqf b/addons/loadout/XEH_postInit.sqf index f06531fd..d187f9d2 100644 --- a/addons/loadout/XEH_postInit.sqf +++ b/addons/loadout/XEH_postInit.sqf @@ -1,10 +1,10 @@ #include "script_component.hpp" if (!(EGVAR(main,enabled))) exitWith { - INFO("GRAD civs is disabled. Good bye!"); + INFO("GRAD Civs is disabled. Good bye!"); }; -[QEGVAR(legacy,civ_added), { +[QEGVAR(common,civ_added), { params [["_civ", objNull, [objNull]]]; assert(!isNull _civ); if (local _civ) then { From 4a2bf15d699f9394f8466c5d13b478287d7e5f77 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Thu, 23 Jul 2020 22:16:53 +0200 Subject: [PATCH 06/55] honked_at debug -> diagnostics addon, also fix honked_at for mimikry --- addons/diagnostics/XEH_PREP.hpp | 1 + addons/diagnostics/XEH_postInit.sqf | 1 + .../diagnostics/functions/fnc_initConfig.sqf | 11 ++++++ .../functions/fnc_showHonkAtArea.sqf | 35 +++++++++++++++++++ .../functions/fnc_showInfoLine.sqf | 8 ----- .../functions/fnc_checkHonkingOnCivilian.sqf | 10 ++---- addons/legacy/functions/fnc_sm_activities.sqf | 2 +- 7 files changed, 52 insertions(+), 16 deletions(-) create mode 100644 addons/diagnostics/functions/fnc_showHonkAtArea.sqf diff --git a/addons/diagnostics/XEH_PREP.hpp b/addons/diagnostics/XEH_PREP.hpp index 9a48f260..61493c15 100644 --- a/addons/diagnostics/XEH_PREP.hpp +++ b/addons/diagnostics/XEH_PREP.hpp @@ -1,4 +1,5 @@ PREP(initConfig); +PREP(showHonkAtArea); PREP(showInfoLine); PREP(showOnMap); PREP(showOnMap_drawCivs); diff --git a/addons/diagnostics/XEH_postInit.sqf b/addons/diagnostics/XEH_postInit.sqf index b9c3f5bc..93beae88 100644 --- a/addons/diagnostics/XEH_postInit.sqf +++ b/addons/diagnostics/XEH_postInit.sqf @@ -5,6 +5,7 @@ if (!(EGVAR(main,enabled))) exitWith { }; if (hasInterface) then { + call FUNC(showHonkAtArea); call FUNC(showOnMap); call FUNC(showPinkArrows); call FUNC(showInfoLine); diff --git a/addons/diagnostics/functions/fnc_initConfig.sqf b/addons/diagnostics/functions/fnc_initConfig.sqf index 37a6d055..a248185d 100644 --- a/addons/diagnostics/functions/fnc_initConfig.sqf +++ b/addons/diagnostics/functions/fnc_initConfig.sqf @@ -36,3 +36,14 @@ private _settingsGroup = ["GRAD Civs", "9) diagnostics"]; FUNC(showPinkArrows), false ] call CBA_fnc_addSetting; + +[ + QGVAR(showHonkAtArea), + "CHECKBOX", + "Draw honked at area", + _settingsGroup, + false, + true, + FUNC(showHonkAtArea), + false +] call CBA_fnc_addSetting; diff --git a/addons/diagnostics/functions/fnc_showHonkAtArea.sqf b/addons/diagnostics/functions/fnc_showHonkAtArea.sqf new file mode 100644 index 00000000..d8653fe5 --- /dev/null +++ b/addons/diagnostics/functions/fnc_showHonkAtArea.sqf @@ -0,0 +1,35 @@ +#include "..\script_component.hpp" + +ISNILS(GVAR(honkHandler), -1); +if (GVAR(showHonkAtArea)) then { + if (GVAR(honkHandler) > -1) exitWith {}; + + GVAR(honkHandler) = [QEGVAR(legacy,honking_at_poly), { + [ + { + params [ + ["_args", [], [[]]], + ["_handle", 0, [0]] + ]; + _args params [ + ["_endTime", 0, [0]], + ["_poly", [], [[]]] + ]; + if (CBA_missionTime >= _endTime) exitWith { + [_handle] call CBA_fnc_removePerFrameHandler; + }; + + { // show the honked_at "danger zone" in front of the vehicle + private _from = _poly select _forEachIndex; + private _to = _poly select ((_forEachIndex + 1) mod (count _poly)); + drawLine3D [_from, _to, [1, 0.3, 0.5, 1]]; + } forEach _poly; + }, + [CBA_missionTime + 3, _this], + 0 + ] call CBA_fnc_addPerFrameHandler; + }] call CBA_fnc_addEventHandler; +} else { + [QEGVAR(legacy,honking_at_poly), GVAR(honkHandler)] call CBA_fnc_removeEventHandler; + GVAR(honkHandler) = -1; +}; diff --git a/addons/diagnostics/functions/fnc_showInfoLine.sqf b/addons/diagnostics/functions/fnc_showInfoLine.sqf index a5710018..08934f70 100644 --- a/addons/diagnostics/functions/fnc_showInfoLine.sqf +++ b/addons/diagnostics/functions/fnc_showInfoLine.sqf @@ -58,14 +58,6 @@ ISNILS(GVAR(actionIds), []); ]; } forEach ([] call EFUNC(legacy,getGlobalCivs)); - // show the honked_at "danger zone" in front of the vehicle - private _poly = player getVariable ["grad_civs_dangerPolyInPlayerHeight", []]; - { - private _from = _poly select _forEachIndex; - private _to = _poly select ((_forEachIndex + 1) mod (count _poly)); - drawLine3D [_from, _to, [1, 0.3, 0.5, 1]]; - } forEach _poly; - }, 0, []] call CBA_fnc_addPerFrameHandler; if (GVAR(showInfoLine)) then { diff --git a/addons/legacy/functions/fnc_checkHonkingOnCivilian.sqf b/addons/legacy/functions/fnc_checkHonkingOnCivilian.sqf index bff35b15..92dbed49 100644 --- a/addons/legacy/functions/fnc_checkHonkingOnCivilian.sqf +++ b/addons/legacy/functions/fnc_checkHonkingOnCivilian.sqf @@ -3,8 +3,6 @@ private _playerPos = getPosATL player; private _nearCivs = (_playerPos nearEntities [["Man"], 200]) arrayIntersect ([] call FUNC(getGlobalCivs)); -if (!(GVAR(debugCivState)) && (count _nearCivs) == 0) exitWith {}; - private _playerVelocity = velocity player; private _speed = vectorMagnitude _playerVelocity; if (_speed < 4) then { @@ -42,16 +40,14 @@ private _dangerPolyInPlayerHeight = _dangerPoly apply { [_x select 0, _x select 1, _playerPos select 2] }; -if (GVAR(debugCivState)) then { - player setVariable ["grad_civs_dangerPolyInPlayerHeight", _dangerPolyInPlayerHeight]; -}; - { private _civPos = getPosATL _x; private _civPosInPlayerHeight = [_civPos select 0, _civPos select 1, _playerPos select 2]; if (isOnRoad _civPos || !_playerIsOnRoad) then { if (_civPosInPlayerHeight inPolygon _dangerPolyInPlayerHeight) then { - ["honked_at", [_x, _playerPos, _playerVelocity], [_x]] call CBA_fnc_targetEvent; + [QEGVAR(common,honked_at), [_x, _playerPos, _playerVelocity], [_x]] call CBA_fnc_targetEvent; }; }; } forEach _nearCivs; + +[QGVAR(honking_at_poly), _dangerPolyInPlayerHeight] call CBA_fnc_localEvent; diff --git a/addons/legacy/functions/fnc_sm_activities.sqf b/addons/legacy/functions/fnc_sm_activities.sqf index d94fdf6f..fac64679 100644 --- a/addons/legacy/functions/fnc_sm_activities.sqf +++ b/addons/legacy/functions/fnc_sm_activities.sqf @@ -70,7 +70,7 @@ private _panic = [] call FUNC(sm_panic); ] call CBA_fnc_addEventHandler; [ - "honked_at", + QEGVAR(common,honked_at), { params [ ["_target", objNull], From 8720ccaeba4ada4a40c21dc07f8a3852803c2803 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Thu, 23 Jul 2020 23:39:11 +0200 Subject: [PATCH 07/55] fixup various stuff --- addons/legacy/XEH_PREP.hpp | 1 - addons/legacy/functions/fnc_sm_emotions.sqf | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/legacy/XEH_PREP.hpp b/addons/legacy/XEH_PREP.hpp index 52b0377f..ea25a321 100644 --- a/addons/legacy/XEH_PREP.hpp +++ b/addons/legacy/XEH_PREP.hpp @@ -7,7 +7,6 @@ PREP(compare); PREP(customActivity_reverse); PREP(deleteIfDamaged); PREP(doCustomActivity); -PREP(drawCivs); PREP(doStop); PREP(isStopped); diff --git a/addons/legacy/functions/fnc_sm_emotions.sqf b/addons/legacy/functions/fnc_sm_emotions.sqf index 94f067ed..b381d10f 100644 --- a/addons/legacy/functions/fnc_sm_emotions.sqf +++ b/addons/legacy/functions/fnc_sm_emotions.sqf @@ -47,13 +47,13 @@ assert ([ _emotions, _emo_panic, _emo_wary, { - (_this getVariable [QGVAR("cooldownAt"), 0]) < CBA_missionTime + (_this getVariable [QGVAR(cooldownAt), 0]) < CBA_missionTime }, { _this call FUNC(forceEmotionSpeed); private _cooldownAt = _this getVariable["GRAD_CIVS_PANICCOOLDOWN", 60] + CBA_missionTime; - _this setVariable [QGVAR("cooldownAt"), _cooldownAt]); + _this setVariable [QGVAR(cooldownAt), _cooldownAt]); [ _this, format[ @@ -70,14 +70,14 @@ assert ([ _emotions, _emo_wary, _emo_relaxed, { - (_this getVariable [QGVAR("cooldownAt"), 0]) < CBA_missionTime + (_this getVariable [QGVAR(cooldownAt), 0]) < CBA_missionTime }, { _this call FUNC(forceEmotionSpeed); private _cooldownAt = _this getVariable["GRAD_CIVS_PANICCOOLDOWN", 60] + CBA_missionTime; - _this setVariable [QGVAR("cooldownAt"), _cooldownAt]); + _this setVariable [QGVAR(cooldownAt), _cooldownAt]); [ _this, format[ From 7a4d570dee9175975a6c61b19fc796ef26aebae3 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Thu, 23 Jul 2020 23:42:25 +0200 Subject: [PATCH 08/55] Update fnc_sm_emotions.sqf --- addons/legacy/functions/fnc_sm_emotions.sqf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/legacy/functions/fnc_sm_emotions.sqf b/addons/legacy/functions/fnc_sm_emotions.sqf index b381d10f..3b2c33b0 100644 --- a/addons/legacy/functions/fnc_sm_emotions.sqf +++ b/addons/legacy/functions/fnc_sm_emotions.sqf @@ -13,7 +13,7 @@ private _emo_relaxed = [ { }, "emo_relaxed" -] call EFUNC(cba_statemachine,addState);; +] call EFUNC(cba_statemachine,addState); private _emo_wary = [ _emotions, @@ -24,7 +24,7 @@ private _emo_wary = [ { }, "emo_wary" -] call EFUNC(cba_statemachine,addState);; +] call EFUNC(cba_statemachine,addState); private _emo_panic = [ _emotions, @@ -37,7 +37,7 @@ private _emo_panic = [ ["grad_civs_panicking_end", [_this], [_this]] call CBA_fnc_targetEvent; }, "emo_panic" -] call EFUNC(cba_statemachine,addState);; +] call EFUNC(cba_statemachine,addState); // TRANSITIONS @@ -53,7 +53,7 @@ assert ([ _this call FUNC(forceEmotionSpeed); private _cooldownAt = _this getVariable["GRAD_CIVS_PANICCOOLDOWN", 60] + CBA_missionTime; - _this setVariable [QGVAR(cooldownAt), _cooldownAt]); + _this setVariable [QGVAR(cooldownAt), _cooldownAt]; [ _this, format[ @@ -77,7 +77,7 @@ assert ([ _this call FUNC(forceEmotionSpeed); private _cooldownAt = _this getVariable["GRAD_CIVS_PANICCOOLDOWN", 60] + CBA_missionTime; - _this setVariable [QGVAR(cooldownAt), _cooldownAt]); + _this setVariable [QGVAR(cooldownAt), _cooldownAt]; [ _this, format[ From a46ea92d92fa1dcc96e492e8b428e0fa75911ade Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Thu, 23 Jul 2020 23:28:03 +0200 Subject: [PATCH 09/55] complete refactor pointing logic * supports multiple targets * doesnt depoint immediately if cursor moves (checks angles before depointing) --- .../fnc_checkWeaponOnCivilianPointer.sqf | 78 ++++++++++--------- 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/addons/legacy/functions/fnc_checkWeaponOnCivilianPointer.sqf b/addons/legacy/functions/fnc_checkWeaponOnCivilianPointer.sqf index f8573a8c..bada425d 100644 --- a/addons/legacy/functions/fnc_checkWeaponOnCivilianPointer.sqf +++ b/addons/legacy/functions/fnc_checkWeaponOnCivilianPointer.sqf @@ -1,48 +1,54 @@ #include "..\script_component.hpp" -scopeName "checkPointer_main"; +private _depoint = { + private _pointees = player getVariable [QGVAR(gunpointees), []]; + { + _pointees deleteAt (_pointees find _x); + [QEGVAR(common,pointed_at_dec), [_x], [_x]] call CBA_fnc_targetEvent; + } forEach _this; + if (GVAR(debugCivState) && {count _this > 0}) then { systemChat format ["depointing %1", _this]; }; +}; +private _point = { + private _pointees = player getVariable [QGVAR(gunpointees), false]; + if (_pointees isEqualTo false) then { + _pointees = []; + player setVariable [QGVAR(gunpointees), _pointees]; + }; + { + _pointees pushBackUnique _x; + [QEGVAR(common,pointed_at_inc), [_x], [_x]] call CBA_fnc_targetEvent; + } forEach _this; + if (GVAR(debugCivState) && {count _this > 0}) then { systemChat format ["pointing at %1", _this]; }; +}; // NOTE: we need to use animationState, as !weaponLowered does *not* mean "weaponRaised" -if ( - (alive player) && +private _weaponRaisedOnFoot = (alive player) && {!weaponLowered player} && {vehicle player == player} && - {"sras" in (animationState player)} -) then { - - _currentCiv = player getVariable ["GRAD_isPointingAtObj", objNull]; - _possibleCiv = driver cursorTarget; - - /* remove my marker on civ, if i dont target him anymore */ - if !((_currentCiv isEqualTo _possibleCiv) || (cursorTarget isEqualTo (_currentCiv call EFUNC(cars,getGroupVehicle)))) then { // TODO resolve circular dependency // maybe use `vehicle _currentCiv` instead? - if (!isNull _currentCiv) then { - player setVariable ["GRAD_isPointingAtObj", objNull]; - if (GVAR(debugCivState)) then { hint format ["depointing %1", _currentCiv]; }; - [QEGVAR(common,pointed_at_dec), [_currentCiv], [_currentCiv]] call CBA_fnc_targetEvent; - }; - } else { - breakTo "checkPointer_main"; - }; - - if (!(_possibleCiv isKindOf "Man") && {!(_possibleCiv isKindOf "Car")}) exitWith {}; + {"sras" in (animationState player)}; - /* if civ is civ, alive and they perceive you as a threat, make them a target */ - if ((side _possibleCiv) == civilian && (alive _possibleCiv)) then { - if ([player, _possibleCiv] call FUNC(checkWeaponOnCivilianPerception)) then { - player setVariable ["GRAD_isPointingAtObj", _possibleCiv]; - if (GVAR(debugCivState)) then { hint format ["pointing at %1", _possibleCiv]; }; - [QEGVAR(common,pointed_at_inc), [_possibleCiv], [_possibleCiv]] call CBA_fnc_targetEvent; - }; - }; +private _pointees = player getVariable [QGVAR(gunpointees), []]; -} else { - /* lowering weapon should remove civ pointer as well */ - _currentCiv = player getVariable ["GRAD_isPointingAtObj", objNull]; +if (!_weaponRaisedOnFoot) exitWith { + // I lowered my weapon. Everyone feels free to go. No one is added. + _pointees call _depoint; +}; - if (!isNull _currentCiv) then { - player setVariable ["GRAD_isPointingAtObj", objNull]; - if (GVAR(debugCivState)) then { hint format ["depointing %1", _currentCiv]; }; - [QEGVAR(common,pointed_at_dec), [_currentCiv], [_currentCiv]] call CBA_fnc_targetEvent; +// I have my weapon raised. Check existing targets if they still feel threatened +private _scaredPointees = _pointees select { + [player, _x] call FUNC(checkWeaponOnCivilianPerception); +}; +(_pointees - _scaredPointees) call _depoint; + +// maybe someone new here I can threaten? +private _possibleCiv = driver cursorTarget; +if (!(_possibleCiv in _pointees)) then { + if ( + ((side _possibleCiv) == civilian) && + {alive _possibleCiv} && + {[player, _possibleCiv] call FUNC(checkWeaponOnCivilianPerception)} + ) then { + [_possibleCiv] call _point; }; }; From b6aae4229e3e9ea19f5b94b26503cbba620c9c52 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Fri, 24 Jul 2020 08:46:01 +0200 Subject: [PATCH 10/55] move interact stuff into separate addon --- README.md | 3 - addons/common/XEH_PREP.hpp | 1 + .../functions/fnc_formatNowPlusSeconds.sqf | 0 .../functions/fnc_showHonkAtArea.sqf | 4 +- addons/interact/$PBOPREFIX$ | 1 + addons/interact/CfgEventHandlers.hpp | 14 ++ addons/interact/XEH_PREP.hpp | 16 +++ addons/interact/XEH_postInit.sqf | 26 ++++ addons/interact/XEH_preInit.sqf | 9 ++ addons/interact/config.cpp | 15 ++ .../functions/fnc_aceInteractWrapper.sqf | 49 +++++++ .../functions/fnc_addCivInteractions.sqf | 0 .../fnc_addInteractEventHandlers.sqf | 80 +++++++++++ .../functions/fnc_checkHonkingOnCivilian.sqf | 0 .../fnc_checkWeaponOnCivilianPerception.sqf | 0 .../fnc_checkWeaponOnCivilianPointer.sqf | 0 .../fnc_feelsAddressedByGesture.spec.sqf | 4 +- .../functions/fnc_feelsAddressedByGesture.sqf | 0 .../functions/fnc_handleAnimation.sqf | 0 .../functions/fnc_handleGestureGo.sqf | 0 .../functions/fnc_handleGestureStop.sqf | 0 .../functions/fnc_interact_backUpAction.sqf | 0 .../fnc_interact_backUpCondition.sqf | 0 .../functions/fnc_interact_carryOnAction.sqf | 3 + .../fnc_interact_carryOnCondition.sqf | 2 +- .../functions/fnc_isPlayerHonking.sqf | 0 addons/interact/script_component.hpp | 14 ++ addons/legacy/XEH_PREP.hpp | 21 +-- addons/legacy/XEH_postInit.sqf | 12 +- ...stomActivity_reverse.sqf => doReverse.sqf} | 0 addons/legacy/functions/fnc_doStop.sqf | 2 +- addons/legacy/functions/fnc_initPlayer.sqf | 12 -- .../functions/fnc_interact_carryOnAction.sqf | 3 - addons/legacy/functions/fnc_playerLoop.sqf | 22 --- addons/legacy/functions/fnc_sm_activities.sqf | 128 ------------------ addons/legacy/functions/fnc_sm_emotions.sqf | 4 +- 36 files changed, 250 insertions(+), 195 deletions(-) rename addons/{legacy => common}/functions/fnc_formatNowPlusSeconds.sqf (100%) create mode 100644 addons/interact/$PBOPREFIX$ create mode 100644 addons/interact/CfgEventHandlers.hpp create mode 100644 addons/interact/XEH_PREP.hpp create mode 100644 addons/interact/XEH_postInit.sqf create mode 100644 addons/interact/XEH_preInit.sqf create mode 100644 addons/interact/config.cpp create mode 100644 addons/interact/functions/fnc_aceInteractWrapper.sqf rename addons/{legacy => interact}/functions/fnc_addCivInteractions.sqf (100%) create mode 100644 addons/interact/functions/fnc_addInteractEventHandlers.sqf rename addons/{legacy => interact}/functions/fnc_checkHonkingOnCivilian.sqf (100%) rename addons/{legacy => interact}/functions/fnc_checkWeaponOnCivilianPerception.sqf (100%) rename addons/{legacy => interact}/functions/fnc_checkWeaponOnCivilianPointer.sqf (100%) rename addons/{legacy => interact}/functions/fnc_feelsAddressedByGesture.spec.sqf (95%) rename addons/{legacy => interact}/functions/fnc_feelsAddressedByGesture.sqf (100%) rename addons/{legacy => interact}/functions/fnc_handleAnimation.sqf (100%) rename addons/{legacy => interact}/functions/fnc_handleGestureGo.sqf (100%) rename addons/{legacy => interact}/functions/fnc_handleGestureStop.sqf (100%) rename addons/{legacy => interact}/functions/fnc_interact_backUpAction.sqf (100%) rename addons/{legacy => interact}/functions/fnc_interact_backUpCondition.sqf (100%) create mode 100644 addons/interact/functions/fnc_interact_carryOnAction.sqf rename addons/{legacy => interact}/functions/fnc_interact_carryOnCondition.sqf (54%) rename addons/{legacy => interact}/functions/fnc_isPlayerHonking.sqf (100%) create mode 100644 addons/interact/script_component.hpp rename addons/legacy/functions/{fnc_customActivity_reverse.sqf => doReverse.sqf} (100%) delete mode 100644 addons/legacy/functions/fnc_initPlayer.sqf delete mode 100644 addons/legacy/functions/fnc_interact_carryOnAction.sqf delete mode 100644 addons/legacy/functions/fnc_playerLoop.sqf diff --git a/README.md b/README.md index 5bad5b09..6421b2e6 100644 --- a/README.md +++ b/README.md @@ -184,9 +184,6 @@ Parameter | Explanation ----------|------------------------------------------------------------- vehicles | Array - All classnames of vehicles that civilians may drive. -### grad_civs_legacy_fnc_setDebugMode -Sets debug mode. Overwrites value from CBA settings. Execute local. - #### Syntax `[debugCivState] call grad_civs_legacy_fnc_setDebugMode` diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 6ae2a1eb..c001fdff 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -7,6 +7,7 @@ PREP(clearPopulationZones); PREP(dismissCiv); PREP(dismissGroup); PREP(config_getCivClasses); +PREP(formatNowPlusSeconds); PREP(getExclusionZones); PREP(getPopulationZones); PREP(initConfig); diff --git a/addons/legacy/functions/fnc_formatNowPlusSeconds.sqf b/addons/common/functions/fnc_formatNowPlusSeconds.sqf similarity index 100% rename from addons/legacy/functions/fnc_formatNowPlusSeconds.sqf rename to addons/common/functions/fnc_formatNowPlusSeconds.sqf diff --git a/addons/diagnostics/functions/fnc_showHonkAtArea.sqf b/addons/diagnostics/functions/fnc_showHonkAtArea.sqf index d8653fe5..3c880af4 100644 --- a/addons/diagnostics/functions/fnc_showHonkAtArea.sqf +++ b/addons/diagnostics/functions/fnc_showHonkAtArea.sqf @@ -4,7 +4,7 @@ ISNILS(GVAR(honkHandler), -1); if (GVAR(showHonkAtArea)) then { if (GVAR(honkHandler) > -1) exitWith {}; - GVAR(honkHandler) = [QEGVAR(legacy,honking_at_poly), { + GVAR(honkHandler) = [QEGVAR(interact,honking_at_poly), { [ { params [ @@ -30,6 +30,6 @@ if (GVAR(showHonkAtArea)) then { ] call CBA_fnc_addPerFrameHandler; }] call CBA_fnc_addEventHandler; } else { - [QEGVAR(legacy,honking_at_poly), GVAR(honkHandler)] call CBA_fnc_removeEventHandler; + [QEGVAR(interact,honking_at_poly), GVAR(honkHandler)] call CBA_fnc_removeEventHandler; GVAR(honkHandler) = -1; }; diff --git a/addons/interact/$PBOPREFIX$ b/addons/interact/$PBOPREFIX$ new file mode 100644 index 00000000..f80c0ac9 --- /dev/null +++ b/addons/interact/$PBOPREFIX$ @@ -0,0 +1 @@ +z\grad_civs\addons\interact diff --git a/addons/interact/CfgEventHandlers.hpp b/addons/interact/CfgEventHandlers.hpp new file mode 100644 index 00000000..770e715f --- /dev/null +++ b/addons/interact/CfgEventHandlers.hpp @@ -0,0 +1,14 @@ +class Extended_PostInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; +class Extended_PreInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/interact/XEH_PREP.hpp b/addons/interact/XEH_PREP.hpp new file mode 100644 index 00000000..68be4185 --- /dev/null +++ b/addons/interact/XEH_PREP.hpp @@ -0,0 +1,16 @@ +PREP(aceInteractWrapper); +PREP(addCivInteractions); +PREP(addInteractEventHandlers); +PREP(checkHonkingOnCivilian); +PREP(checkWeaponOnCivilianPerception); +PREP(checkWeaponOnCivilianPointer); +// PREP(feelsAddressedByGesture.spec); +PREP(feelsAddressedByGesture); +PREP(handleAnimation); +PREP(handleGestureGo); +PREP(handleGestureStop); +PREP(interact_backUpAction); +PREP(interact_backUpCondition); +PREP(interact_carryOnAction); +PREP(interact_carryOnCondition); +PREP(isPlayerHonking); diff --git a/addons/interact/XEH_postInit.sqf b/addons/interact/XEH_postInit.sqf new file mode 100644 index 00000000..09325737 --- /dev/null +++ b/addons/interact/XEH_postInit.sqf @@ -0,0 +1,26 @@ +#include "script_component.hpp" + +if (!(EGVAR(main,enabled))) exitWith { + INFO("GRAD civs is disabled. Good bye!"); +}; + +if (hasInterface) then { + call FUNC(aceInteractWrapper); + call FUNC(addInteractEventHandlers); + call FUNC(addCivInteractions); + + + [{ + if (!isGameFocused || isGamePaused) exitWith {}; + [] call FUNC(checkWeaponOnCivilianPointer); + }, 0.5, []] call CBA_fnc_addPerFrameHandler; + + [{ + if (!isGameFocused || isGamePaused) exitWith {}; + if ([] call FUNC(isPlayerHonking)) then { + [] call FUNC(checkHonkingOnCivilian); + }; + }, 0.1, []] call CBA_fnc_addPerFrameHandler; + + +}; diff --git a/addons/interact/XEH_preInit.sqf b/addons/interact/XEH_preInit.sqf new file mode 100644 index 00000000..b47cf662 --- /dev/null +++ b/addons/interact/XEH_preInit.sqf @@ -0,0 +1,9 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +ADDON = true; diff --git a/addons/interact/config.cpp b/addons/interact/config.cpp new file mode 100644 index 00000000..05f02bfa --- /dev/null +++ b/addons/interact/config.cpp @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = QUOTE(COMPONENT); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"grad_civs_main", "grad_civs_legacy"}; + author = "AUTHOR"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" diff --git a/addons/interact/functions/fnc_aceInteractWrapper.sqf b/addons/interact/functions/fnc_aceInteractWrapper.sqf new file mode 100644 index 00000000..652da9fc --- /dev/null +++ b/addons/interact/functions/fnc_aceInteractWrapper.sqf @@ -0,0 +1,49 @@ +#include "..\script_component.hpp" + +[ + "ace_interaction_getDown", + { + params [ + ["_target", objNull] + ]; + INFO_1("civ %1 is being sent down", _target); + + private _recklessness = _target getVariable ["grad_civs_recklessness", 5]; + private _waitTime = linearConversion [0, 10, _recklessness, 3600, 180, false]; + [ + _target, + {}, + { + params ["_target"]; + [_target, ""] call EFUNC(legacy,setCurrentlyThinking); + }, + _waitTime, + [], + "ace_interaction_getDown", + format["I will keep my head down until %1", _waitTime call EFUNC(common,formatNowPlusSeconds)] + ] call EFUNC(legacy,doCustomActivity); + } +] call CBA_fnc_addEventHandler; + +[ + "ace_interaction_sendAway", + { + params [ + ["_target", objNull], + ["_pos", [0, 0, 0]] + ]; + INFO_2("civ %1 is being sent away to %2", _target, _pos); + private _recklessness = _target getVariable ["grad_civs_recklessness", 5]; + private _waitTime = linearConversion [0, 10, _recklessness, 60, 5, false]; + [ + _target, + { + }, + {}, + _waitTime, + [], + "ace_interaction_sendAway", + format["am being sent away to %1, will resume activity at %2", _pos, _waitTime call EFUNC(common,formatNowPlusSeconds)] + ] call EFUNC(legacy,doCustomActivity); + } +] call CBA_fnc_addEventHandler; diff --git a/addons/legacy/functions/fnc_addCivInteractions.sqf b/addons/interact/functions/fnc_addCivInteractions.sqf similarity index 100% rename from addons/legacy/functions/fnc_addCivInteractions.sqf rename to addons/interact/functions/fnc_addCivInteractions.sqf diff --git a/addons/interact/functions/fnc_addInteractEventHandlers.sqf b/addons/interact/functions/fnc_addInteractEventHandlers.sqf new file mode 100644 index 00000000..7fb902ca --- /dev/null +++ b/addons/interact/functions/fnc_addInteractEventHandlers.sqf @@ -0,0 +1,80 @@ +#include "..\script_component.hpp" + +[QEGVAR(common,pointed_at_inc), { + params ["_civ"]; + if (_civ == ACE_player) exitWith {}; + private _currentCount = _civ getVariable ["grad_civs_isPointedAtCount", 0]; + _civ setVariable ["grad_civs_isPointedAtCount", _currentCount + 1]; +}] call CBA_fnc_addEventHandler; + +[QEGVAR(common,pointed_at_dec), { + params ["_civ"]; + if (_civ == ACE_player) exitWith {}; + private _currentCount = _civ getVariable ["grad_civs_isPointedAtCount", 0]; + assert(_currentCount > 0); + if (_currentCount < 1) then {_currentCount = 1;}; + _civ setVariable ["grad_civs_isPointedAtCount", _currentCount - 1, true]; +}] call CBA_fnc_addEventHandler; + +[ + QEGVAR(common,honked_at), + { + params [ + ["_target", objNull], + ["_carPos", [0, 0, 0]], + ["_carVelocity", [0, 0, 0]] + ]; + if (_target == ACE_player) exitWith {}; + INFO_1("civ %1 is being honked at", _target); + + private _recklessness = _target getVariable ["grad_civs_recklessness", 5]; + private _waitTime = linearConversion [0, 10, _recklessness, 15, 1, false]; + + [ + _target, + { + params ["_target", "_carPos", "_carVelocity"]; + + private _moveVectors = [ + [-(_carVelocity select 1), _carVelocity select 0, _carPos select 2], + [_carVelocity select 1, -(_carVelocity select 0), _carPos select 2] + ]; + // go left or right, depending on where to get further from the vehicle + private _moveVector = _moveVectors select 0; + if ((_moveVector distance _carPos) > ((_moveVectors select 1) distance _carPos)) then { + _moveVector = _moveVectors select 1; + }; + _civ call EFUNC(legacy,forcePanicSpeed); + _civ doMove ((position _civ) vectorAdd _moveVector); + }, + {}, + _waitTime, + [_carPos, _carVelocity], + "honked_at", + format["am avoiding honking car, will resume activity at %1", _waitTime call EFUNC(common,formatNowPlusSeconds)] + ] call EFUNC(legacy,doCustomActivity); + } +] call CBA_fnc_addEventHandler; + +[QGVAR(gestured_at_vehicle_go), { + params [ + ["_target", objNull], + ["_vectorDir", [0, 0, 0]] + ]; + if (_target == ACE_player) exitWith {}; + if (_vectorDir isEqualTo [0, 0, 0]) exitWith { + WARNING_1("inconclusive 'go' gesture, %1 will do nothing", _target); + }; + + private _reverseTargetPos = (getPos _target) vectorAdd (_vectorDir vectorMultiply 50); + + [_target, _reverseTargetPos] call EFUNC(legacy,doReverse); +}] call CBA_fnc_addEventHandler; + +[QGVAR(told_to_reverse), { + params [ + ["_target", objNull, [objNull]], + ["_reverseTargetPos", [0, 0, 0], [[]]] + ]; + [_target, _reverseTargetPos] call EFUNC(legacy,doReverse); +}] call CBA_fnc_addEventHandler; diff --git a/addons/legacy/functions/fnc_checkHonkingOnCivilian.sqf b/addons/interact/functions/fnc_checkHonkingOnCivilian.sqf similarity index 100% rename from addons/legacy/functions/fnc_checkHonkingOnCivilian.sqf rename to addons/interact/functions/fnc_checkHonkingOnCivilian.sqf diff --git a/addons/legacy/functions/fnc_checkWeaponOnCivilianPerception.sqf b/addons/interact/functions/fnc_checkWeaponOnCivilianPerception.sqf similarity index 100% rename from addons/legacy/functions/fnc_checkWeaponOnCivilianPerception.sqf rename to addons/interact/functions/fnc_checkWeaponOnCivilianPerception.sqf diff --git a/addons/legacy/functions/fnc_checkWeaponOnCivilianPointer.sqf b/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf similarity index 100% rename from addons/legacy/functions/fnc_checkWeaponOnCivilianPointer.sqf rename to addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf diff --git a/addons/legacy/functions/fnc_feelsAddressedByGesture.spec.sqf b/addons/interact/functions/fnc_feelsAddressedByGesture.spec.sqf similarity index 95% rename from addons/legacy/functions/fnc_feelsAddressedByGesture.spec.sqf rename to addons/interact/functions/fnc_feelsAddressedByGesture.spec.sqf index b59092a4..90a45578 100644 --- a/addons/legacy/functions/fnc_feelsAddressedByGesture.spec.sqf +++ b/addons/interact/functions/fnc_feelsAddressedByGesture.spec.sqf @@ -2,7 +2,7 @@ private _bAwareOfAGesturing = [ "then B will feel addressed by A", { params ["_a", "_b"]; - [[_a, vectorDirVisual _a, driver _b] call grad_civs_legacy_fnc_feelsAddressedByGesture] call grad_testing_fnc_assertTrue; + [[_a, vectorDirVisual _a, driver _b] call grad_civs_interact_fnc_feelsAddressedByGesture] call grad_testing_fnc_assertTrue; } ]; @@ -10,7 +10,7 @@ private _bUnawareOfAGesturing = [ "then B will not feel addressed by A", { params ["_a", "_b"]; - [[_a, vectorDirVisual _a, driver _b] call grad_civs_legacy_fnc_feelsAddressedByGesture] call grad_testing_fnc_assertFalse; + [[_a, vectorDirVisual _a, driver _b] call grad_civs_interact_fnc_feelsAddressedByGesture] call grad_testing_fnc_assertFalse; } ]; diff --git a/addons/legacy/functions/fnc_feelsAddressedByGesture.sqf b/addons/interact/functions/fnc_feelsAddressedByGesture.sqf similarity index 100% rename from addons/legacy/functions/fnc_feelsAddressedByGesture.sqf rename to addons/interact/functions/fnc_feelsAddressedByGesture.sqf diff --git a/addons/legacy/functions/fnc_handleAnimation.sqf b/addons/interact/functions/fnc_handleAnimation.sqf similarity index 100% rename from addons/legacy/functions/fnc_handleAnimation.sqf rename to addons/interact/functions/fnc_handleAnimation.sqf diff --git a/addons/legacy/functions/fnc_handleGestureGo.sqf b/addons/interact/functions/fnc_handleGestureGo.sqf similarity index 100% rename from addons/legacy/functions/fnc_handleGestureGo.sqf rename to addons/interact/functions/fnc_handleGestureGo.sqf diff --git a/addons/legacy/functions/fnc_handleGestureStop.sqf b/addons/interact/functions/fnc_handleGestureStop.sqf similarity index 100% rename from addons/legacy/functions/fnc_handleGestureStop.sqf rename to addons/interact/functions/fnc_handleGestureStop.sqf diff --git a/addons/legacy/functions/fnc_interact_backUpAction.sqf b/addons/interact/functions/fnc_interact_backUpAction.sqf similarity index 100% rename from addons/legacy/functions/fnc_interact_backUpAction.sqf rename to addons/interact/functions/fnc_interact_backUpAction.sqf diff --git a/addons/legacy/functions/fnc_interact_backUpCondition.sqf b/addons/interact/functions/fnc_interact_backUpCondition.sqf similarity index 100% rename from addons/legacy/functions/fnc_interact_backUpCondition.sqf rename to addons/interact/functions/fnc_interact_backUpCondition.sqf diff --git a/addons/interact/functions/fnc_interact_carryOnAction.sqf b/addons/interact/functions/fnc_interact_carryOnAction.sqf new file mode 100644 index 00000000..1e86e7a8 --- /dev/null +++ b/addons/interact/functions/fnc_interact_carryOnAction.sqf @@ -0,0 +1,3 @@ +#include "..\script_component.hpp" + +[_target] call EFUNC(legacy,doCarryOn); diff --git a/addons/legacy/functions/fnc_interact_carryOnCondition.sqf b/addons/interact/functions/fnc_interact_carryOnCondition.sqf similarity index 54% rename from addons/legacy/functions/fnc_interact_carryOnCondition.sqf rename to addons/interact/functions/fnc_interact_carryOnCondition.sqf index da5ccc7f..c8f89312 100644 --- a/addons/legacy/functions/fnc_interact_carryOnCondition.sqf +++ b/addons/interact/functions/fnc_interact_carryOnCondition.sqf @@ -2,4 +2,4 @@ alive _target && (_target getVariable ["grad_civs_primaryTask", ""] != "") && - (_target getVariable [QGVAR(customActivity_id), ""] != "") + (_target getVariable [QEGVAR(legacy,customActivity_id), ""] != "") // TODO isStopped maybe? hmm diff --git a/addons/legacy/functions/fnc_isPlayerHonking.sqf b/addons/interact/functions/fnc_isPlayerHonking.sqf similarity index 100% rename from addons/legacy/functions/fnc_isPlayerHonking.sqf rename to addons/interact/functions/fnc_isPlayerHonking.sqf diff --git a/addons/interact/script_component.hpp b/addons/interact/script_component.hpp new file mode 100644 index 00000000..8ce0fa68 --- /dev/null +++ b/addons/interact/script_component.hpp @@ -0,0 +1,14 @@ +#define COMPONENT interact +#include "\z\grad_civs\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE + +#ifdef DEBUG_ENABLED_MAIN + #define DEBUG_MODE_FULL +#endif +#ifdef DEBUG_SETTINGS_MAIN + #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN +#endif + +#include "\z\grad_civs\addons\main\script_macros.hpp" diff --git a/addons/legacy/XEH_PREP.hpp b/addons/legacy/XEH_PREP.hpp index ea25a321..1ca3ac16 100644 --- a/addons/legacy/XEH_PREP.hpp +++ b/addons/legacy/XEH_PREP.hpp @@ -1,10 +1,6 @@ -PREP(addCivInteractions); -PREP(checkHonkingOnCivilian); -PREP(checkWeaponOnCivilianPerception); -PREP(checkWeaponOnCivilianPointer); PREP(clearCurrentlyThinking); PREP(compare); -PREP(customActivity_reverse); +PREP(doReverse); PREP(deleteIfDamaged); PREP(doCustomActivity); @@ -13,8 +9,7 @@ PREP(isStopped); PREP(doCarryOn); PREP(endCustomActivity); -// PREP(feelsAddressedByGesture.spec); -PREP(feelsAddressedByGesture); + PREP(findBuildings); PREP(findPositionOfInterest); PREP(findRandomPosArea); @@ -24,25 +19,15 @@ PREP(findSpawnPosition); PREP(findUnclaimedHouse); PREP(forceEmotionSpeed); PREP(forcePanicSpeed); -PREP(formatNowPlusSeconds); PREP(getCurrentlyThinking); PREP(getGlobalCivs); -PREP(handleAnimation); -PREP(handleGestureGo); -PREP(handleGestureStop); + PREP(initCommonEventhandlers); PREP(initConfig); PREP(initHCs); -PREP(initPlayer); -PREP(interact_backUpAction); -PREP(interact_backUpCondition); -PREP(interact_carryOnAction); -PREP(interact_carryOnCondition); PREP(isInDistanceFromOtherPlayers); PREP(isInHouse); -PREP(isPlayerHonking); PREP(nowPlusSeconds); -PREP(playerLoop); PREP(reverse_abort); PREP(reverse_internal_end); PREP(reverse_internal_pfh); diff --git a/addons/legacy/XEH_postInit.sqf b/addons/legacy/XEH_postInit.sqf index bd420b3b..544d7a9f 100644 --- a/addons/legacy/XEH_postInit.sqf +++ b/addons/legacy/XEH_postInit.sqf @@ -6,4 +6,14 @@ if (!(EGVAR(main,enabled))) exitWith { [] call FUNC(initCommonEventhandlers); [] call FUNC(initHCs); -[] call FUNC(initPlayer); + +if (hasInterface) then { + [ + "server_fps", + { + if (GVAR(debugFps)) then { + systemChat format ["%1 fps on %2", _this select 1, _this select 0]; + }; + } + ] call CBA_fnc_addEventHandler; +}; diff --git a/addons/legacy/functions/fnc_customActivity_reverse.sqf b/addons/legacy/functions/doReverse.sqf similarity index 100% rename from addons/legacy/functions/fnc_customActivity_reverse.sqf rename to addons/legacy/functions/doReverse.sqf diff --git a/addons/legacy/functions/fnc_doStop.sqf b/addons/legacy/functions/fnc_doStop.sqf index a0610b75..b19b22fe 100644 --- a/addons/legacy/functions/fnc_doStop.sqf +++ b/addons/legacy/functions/fnc_doStop.sqf @@ -27,7 +27,7 @@ if (local _object) exitWith { _waitTime, [], "doStop", - format["am halting, will resume activity at %1", _waitTime call FUNC(formatNowPlusSeconds)] + format["am halting, will resume activity at %1", _waitTime call EFUNC(common,formatNowPlusSeconds)] ] call FUNC(doCustomActivity); }; diff --git a/addons/legacy/functions/fnc_initPlayer.sqf b/addons/legacy/functions/fnc_initPlayer.sqf deleted file mode 100644 index a645cb4a..00000000 --- a/addons/legacy/functions/fnc_initPlayer.sqf +++ /dev/null @@ -1,12 +0,0 @@ -#include "..\script_component.hpp" - -if (hasInterface) then { - - [] call FUNC(playerLoop); - [] call FUNC(addCivInteractions); - if (GVAR(debugCivState)) then { - [] call FUNC(showWhatTheyThink); - - [{!isNull (findDisplay 12)}, {[] call FUNC(mapMarkers)}, []] call CBA_fnc_waitUntilAndExecute; - }; -}; diff --git a/addons/legacy/functions/fnc_interact_carryOnAction.sqf b/addons/legacy/functions/fnc_interact_carryOnAction.sqf deleted file mode 100644 index ee7da4d2..00000000 --- a/addons/legacy/functions/fnc_interact_carryOnAction.sqf +++ /dev/null @@ -1,3 +0,0 @@ -#include "..\script_component.hpp" - -[_target] call FUNC(doCarryOn); diff --git a/addons/legacy/functions/fnc_playerLoop.sqf b/addons/legacy/functions/fnc_playerLoop.sqf deleted file mode 100644 index f4843429..00000000 --- a/addons/legacy/functions/fnc_playerLoop.sqf +++ /dev/null @@ -1,22 +0,0 @@ -#include "..\script_component.hpp" - -[{ - if (!isGameFocused || isGamePaused) exitWith {}; - [] call FUNC(checkWeaponOnCivilianPointer); -}, 0.5, []] call CBA_fnc_addPerFrameHandler; - -[{ - if (!isGameFocused || isGamePaused) exitWith {}; - if ([] call FUNC(isPlayerHonking)) then { - [] call FUNC(checkHonkingOnCivilian); - }; -}, 0.1, []] call CBA_fnc_addPerFrameHandler; - -[ - "server_fps", - { - if (GVAR(debugFps)) then { - systemChat format ["%1 fps on %2", _this select 1, _this select 0]; - }; - } -] call CBA_fnc_addEventHandler; diff --git a/addons/legacy/functions/fnc_sm_activities.sqf b/addons/legacy/functions/fnc_sm_activities.sqf index fac64679..1204d960 100644 --- a/addons/legacy/functions/fnc_sm_activities.sqf +++ b/addons/legacy/functions/fnc_sm_activities.sqf @@ -4,134 +4,6 @@ private _activities = [[], true] call CBA_statemachine_fnc_create; private _business = [] call FUNC(sm_business); private _panic = [] call FUNC(sm_panic); -[QEGVAR(common,pointed_at_inc), { - params ["_civ"]; - if (_civ == ACE_player) exitWith {}; - private _currentCount = _civ getVariable ["grad_civs_isPointedAtCount", 0]; - _civ setVariable ["grad_civs_isPointedAtCount", _currentCount + 1]; -}] call CBA_fnc_addEventHandler; - -[QEGVAR(common,pointed_at_dec), { - params ["_civ"]; - if (_civ == ACE_player) exitWith {}; - private _currentCount = _civ getVariable ["grad_civs_isPointedAtCount", 0]; - assert(_currentCount > 0); - if (_currentCount < 1) then {_currentCount = 1;}; - _civ setVariable ["grad_civs_isPointedAtCount", _currentCount - 1, true]; -}] call CBA_fnc_addEventHandler; - - -[ - "ace_interaction_getDown", - { - params [ - ["_target", objNull] - ]; - INFO_1("civ %1 is being sent down", _target); - - private _recklessness = _target getVariable ["grad_civs_recklessness", 5]; - private _waitTime = linearConversion [0, 10, _recklessness, 3600, 180, false]; - [ - _target, - {}, - { - params ["_target"]; - [_target, ""] call FUNC(setCurrentlyThinking); - }, - _waitTime, - [], - "ace_interaction_getDown", - format["I will keep my head down until %1", _waitTime call FUNC(formatNowPlusSeconds)] - ] call FUNC(doCustomActivity); - } -] call CBA_fnc_addEventHandler; - -[ - "ace_interaction_sendAway", - { - params [ - ["_target", objNull], - ["_pos", [0, 0, 0]] - ]; - INFO_2("civ %1 is being sent away to %2", _target, _pos); - private _recklessness = _target getVariable ["grad_civs_recklessness", 5]; - private _waitTime = linearConversion [0, 10, _recklessness, 60, 5, false]; - [ - _target, - { - }, - {}, - _waitTime, - [], - "ace_interaction_sendAway", - format["am being sent away to %1, will resume activity at %2", _pos, _waitTime call FUNC(formatNowPlusSeconds)] - ] call FUNC(doCustomActivity); - } -] call CBA_fnc_addEventHandler; - -[ - QEGVAR(common,honked_at), - { - params [ - ["_target", objNull], - ["_carPos", [0, 0, 0]], - ["_carVelocity", [0, 0, 0]] - ]; - if (_target == ACE_player) exitWith {}; - INFO_1("civ %1 is being honked at", _target); - - private _recklessness = _target getVariable ["grad_civs_recklessness", 5]; - private _waitTime = linearConversion [0, 10, _recklessness, 15, 1, false]; - - [ - _target, - { - params ["_target", "_carPos", "_carVelocity"]; - - private _moveVectors = [ - [-(_carVelocity select 1), _carVelocity select 0, _carPos select 2], - [_carVelocity select 1, -(_carVelocity select 0), _carPos select 2] - ]; - // go left or right, depending on where to get further from the vehicle - private _moveVector = _moveVectors select 0; - if ((_moveVector distance _carPos) > ((_moveVectors select 1) distance _carPos)) then { - _moveVector = _moveVectors select 1; - }; - _civ call FUNC(forcePanicSpeed); - _civ doMove ((position _civ) vectorAdd _moveVector); - }, - {}, - _waitTime, - [_carPos, _carVelocity], - "honked_at", - format["am avoiding honking car, will resume activity at %1", _waitTime call FUNC(formatNowPlusSeconds)] - ] call FUNC(doCustomActivity); - } -] call CBA_fnc_addEventHandler; - -[QGVAR(gestured_at_vehicle_go), { - params [ - ["_target", objNull], - ["_vectorDir", [0, 0, 0]] - ]; - if (_target == ACE_player) exitWith {}; - if (_vectorDir isEqualTo [0, 0, 0]) exitWith { - WARNING_1("inconclusive 'go' gesture, %1 will do nothing", _target); - }; - - private _reverseTargetPos = (getPos _target) vectorAdd (_vectorDir vectorMultiply 50); - - [_target, _reverseTargetPos] call FUNC(customActivity_reverse); -}] call CBA_fnc_addEventHandler; - -[QGVAR(told_to_reverse), { - params [ - ["_target", objNull, [objNull]], - ["_reverseTargetPos", [0, 0, 0], [[]]] - ]; - [_target, _reverseTargetPos] call FUNC(customActivity_reverse); -}] call CBA_fnc_addEventHandler; - // STATES assert(_activities isEqualType locationNull); assert(_business isEqualType locationNull); diff --git a/addons/legacy/functions/fnc_sm_emotions.sqf b/addons/legacy/functions/fnc_sm_emotions.sqf index 3b2c33b0..cc1372f4 100644 --- a/addons/legacy/functions/fnc_sm_emotions.sqf +++ b/addons/legacy/functions/fnc_sm_emotions.sqf @@ -58,7 +58,7 @@ assert ([ _this, format[ "I need until %1 to get a bit calmer", - _cooldownAt call FUNC(formatNowPlusSeconds) + _cooldownAt call EFUNC(common,formatNowPlusSeconds) ] ] call FUNC(setCurrentlyThinking); }, @@ -82,7 +82,7 @@ assert ([ _this, format[ "I need until %1 to calm down completely", - _cooldownAt call FUNC(formatNowPlusSeconds) + _cooldownAt call EFUNC(common,formatNowPlusSeconds) ] ] call FUNC(setCurrentlyThinking); }, From 768442558311d59fc06a2daae6986774222f46d6 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Fri, 24 Jul 2020 08:54:20 +0200 Subject: [PATCH 11/55] remove now-broken setDebugMode function --- README.md | 8 -------- addons/legacy/XEH_PREP.hpp | 1 - addons/legacy/functions/fnc_setDebugMode.sqf | 10 ---------- 3 files changed, 19 deletions(-) delete mode 100644 addons/legacy/functions/fnc_setDebugMode.sqf diff --git a/README.md b/README.md index 6421b2e6..ab66677e 100644 --- a/README.md +++ b/README.md @@ -184,14 +184,6 @@ Parameter | Explanation ----------|------------------------------------------------------------- vehicles | Array - All classnames of vehicles that civilians may drive. -#### Syntax -`[debugCivState] call grad_civs_legacy_fnc_setDebugMode` - -Parameter | Explanation ---------------|-------------------------- -debugCivState | Bool - Debug mode on/off. - - ### grad_civs_common_fnc_addExclusionZone and grad_civs_common_fnc_addPopulationZone Prevent civilians from entering areas. diff --git a/addons/legacy/XEH_PREP.hpp b/addons/legacy/XEH_PREP.hpp index 1ca3ac16..a11f9af7 100644 --- a/addons/legacy/XEH_PREP.hpp +++ b/addons/legacy/XEH_PREP.hpp @@ -36,7 +36,6 @@ PREP(reverse_internal_stopCondition); PREP(reverse); PREP(serverLoop); PREP(setCurrentlyThinking); -PREP(setDebugMode); PREP(sm_activities_helper_freeCondition); PREP(sm_activities_helper_surrenderCondition); PREP(sm_activities); diff --git a/addons/legacy/functions/fnc_setDebugMode.sqf b/addons/legacy/functions/fnc_setDebugMode.sqf deleted file mode 100644 index 7ec2cda1..00000000 --- a/addons/legacy/functions/fnc_setDebugMode.sqf +++ /dev/null @@ -1,10 +0,0 @@ -#include "..\script_component.hpp" - -params [["_value",false]]; - -if (GVAR(debugCivState) isEqualTo _value) exitWith {}; - -GVAR(debugCivState) = _value; - -[_value] remoteExec [QFUNC(showWhatTheyThink),0,false]; -[_value] remoteExec [QFUNC(mapMarkers),0,false]; From cf0c84713caa52ea63d91ccf48ba0fb9455dd33d Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Fri, 24 Jul 2020 10:23:11 +0200 Subject: [PATCH 12/55] crazy many refactorings * move infoLine loop to diagnostics * optimize server loop * explicit ace dep * oops, doReverse rename was broken * purge currentlyThinking ... completely * purge debugCivState var, move debugFps & pointing hints to diagnostics --- README.md | 2 - addons/common/XEH_PREP.hpp | 3 +- .../functions/fnc_nowPlusSeconds.sqf | 0 addons/diagnostics/XEH_PREP.hpp | 2 + addons/diagnostics/XEH_postInit.sqf | 33 +++++++++++++ .../diagnostics/functions/fnc_initConfig.sqf | 17 +++++-- .../functions/fnc_showHonkAtArea.sqf | 2 +- .../functions/fnc_showPointingHints.sqf | 21 +++++++++ .../functions/fnc_updateInfoLine.sqf | 2 +- addons/interact/config.cpp | 2 +- .../functions/fnc_aceInteractWrapper.sqf | 5 +- .../fnc_checkWeaponOnCivilianPointer.sqf | 8 +++- addons/legacy/XEH_PREP.hpp | 6 --- addons/legacy/XEH_postInit.sqf | 13 +---- .../functions/fnc_clearCurrentlyThinking.sqf | 5 -- .../legacy/functions/fnc_doCustomActivity.sqf | 3 -- .../{doReverse.sqf => fnc_doReverse.sqf} | 5 +- .../functions/fnc_getCurrentlyThinking.sqf | 7 --- addons/legacy/functions/fnc_initConfig.sqf | 22 --------- addons/legacy/functions/fnc_reverse.sqf | 5 +- addons/legacy/functions/fnc_serverLoop.sqf | 25 +--------- .../functions/fnc_setCurrentlyThinking.sqf | 10 ---- addons/legacy/functions/fnc_sm_emotions.sqf | 47 +++++-------------- addons/legacy/functions/fnc_sm_panic.sqf | 8 ++-- .../fnc_sm_panic_state_hide_enter.sqf | 1 - .../fnc_sm_panic_state_hide_exit.sqf | 3 -- addons/residents/XEH_PREP.hpp | 1 - .../residents/functions/fnc_sm_business.sqf | 2 +- .../fnc_sm_business_state_chat_enter.sqf | 2 - .../fnc_sm_business_state_chat_exit.sqf | 1 - ...c_sm_business_state_meetNeighbor_enter.sqf | 1 - ...nc_sm_business_state_meetNeighbor_exit.sqf | 3 -- ...trans_housework_meetNeighbor_condition.sqf | 2 - .../fnc_sm_business_state_transit_exit.sqf | 1 - .../fnc_sm_business_state_transit_loop.sqf | 4 -- .../fnc_sm_business_state_voyage_enter.sqf | 2 - .../fnc_sm_business_state_voyage_exit.sqf | 1 - .../fnc_sm_business_state_voyage_loop.sqf | 4 -- 38 files changed, 106 insertions(+), 175 deletions(-) rename addons/{legacy => common}/functions/fnc_nowPlusSeconds.sqf (100%) create mode 100644 addons/diagnostics/functions/fnc_showPointingHints.sqf rename addons/{legacy => diagnostics}/functions/fnc_updateInfoLine.sqf (87%) delete mode 100644 addons/legacy/functions/fnc_clearCurrentlyThinking.sqf rename addons/legacy/functions/{doReverse.sqf => fnc_doReverse.sqf} (83%) delete mode 100644 addons/legacy/functions/fnc_getCurrentlyThinking.sqf delete mode 100644 addons/legacy/functions/fnc_setCurrentlyThinking.sqf delete mode 100644 addons/legacy/functions/fnc_sm_panic_state_hide_exit.sqf delete mode 100644 addons/residents/functions/fnc_sm_business_state_meetNeighbor_exit.sqf diff --git a/README.md b/README.md index ab66677e..532fc694 100644 --- a/README.md +++ b/README.md @@ -54,10 +54,8 @@ backpackProbability | 0.5 | Probability that a civilian will wea backpacks | [] | All classnames of backpacks that civilians may wear. civClasses | ["C_Man_1"] | Unit classes to use for spawning civilians clothes | [] | All classnames of clothes that civilians may wear. -debugCivState | 0 | Toggles civ behavior debugging mode (0/1). debugFps | 0 | Toggles fps monitoring mode (0/1). enabled | false | if grad_civs is enabled (false,true) -exitOn | "" | Condition upon which grad-civs loops will stop. faces | [] | All classnames of faces that civilians may have. goggles | [] | All classnames of goggles that civilians may wear. headgear | [] | All classnames of headgear that civilians may wear. diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index c001fdff..b18e4e7a 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -4,9 +4,9 @@ PREP(augmentStateMachine); PREP(civGetState); PREP(clearExclusionZones); PREP(clearPopulationZones); +PREP(config_getCivClasses); PREP(dismissCiv); PREP(dismissGroup); -PREP(config_getCivClasses); PREP(formatNowPlusSeconds); PREP(getExclusionZones); PREP(getPopulationZones); @@ -14,5 +14,6 @@ PREP(initConfig); PREP(isInPopulatedZone); PREP(module_exclusionZone); PREP(module_populationZone); +PREP(nowPlusSeconds); PREP(parseCsv); PREP(registerCivTaskType); diff --git a/addons/legacy/functions/fnc_nowPlusSeconds.sqf b/addons/common/functions/fnc_nowPlusSeconds.sqf similarity index 100% rename from addons/legacy/functions/fnc_nowPlusSeconds.sqf rename to addons/common/functions/fnc_nowPlusSeconds.sqf diff --git a/addons/diagnostics/XEH_PREP.hpp b/addons/diagnostics/XEH_PREP.hpp index 61493c15..dac01f00 100644 --- a/addons/diagnostics/XEH_PREP.hpp +++ b/addons/diagnostics/XEH_PREP.hpp @@ -4,3 +4,5 @@ PREP(showInfoLine); PREP(showOnMap); PREP(showOnMap_drawCivs); PREP(showPinkArrows); +PREP(showPointingHints); +PREP(updateInfoLine); diff --git a/addons/diagnostics/XEH_postInit.sqf b/addons/diagnostics/XEH_postInit.sqf index 93beae88..9bcb8357 100644 --- a/addons/diagnostics/XEH_postInit.sqf +++ b/addons/diagnostics/XEH_postInit.sqf @@ -8,5 +8,38 @@ if (hasInterface) then { call FUNC(showHonkAtArea); call FUNC(showOnMap); call FUNC(showPinkArrows); + call FUNC(showPointingHints); call FUNC(showInfoLine); }; + +if (!hasInterface || isServer) then { + GVAR(debugLoopHandle) = [{ + params ["_args", "_handle"]; + if (!isGameFocused || isGamePaused) exitWith {}; + if (call EGVAR(legacy,EXITON)) exitWith {[_handle] call CBA_fnc_removePerFrameHandler}; + if (GVAR(showInfoLine)) then { + { _x call FUNC(updateInfoLine); } forEach EGVAR(legacy,localCivs); + }; + }, 0.1, []] call CBA_fnc_addPerFrameHandler; + + [ + { + if (GVAR(debugFps)) then { + ["server_fps", [clientOwner, diag_fps]] call CBA_fnc_globalEvent; + }; + }, + 2, + [] + ] call CBA_fnc_addPerFrameHandler; +}; + +if (hasInterface) then { + [ + "server_fps", + { + if (GVAR(debugFps)) then { + systemChat format ["%1 fps on %2", _this select 1, _this select 0]; + }; + } + ] call CBA_fnc_addEventHandler; +}; diff --git a/addons/diagnostics/functions/fnc_initConfig.sqf b/addons/diagnostics/functions/fnc_initConfig.sqf index a248185d..9a982eda 100644 --- a/addons/diagnostics/functions/fnc_initConfig.sqf +++ b/addons/diagnostics/functions/fnc_initConfig.sqf @@ -4,6 +4,17 @@ INFO("initConfig running..."); private _settingsGroup = ["GRAD Civs", "9) diagnostics"]; +[ + QGVAR(debugFps), + "CHECKBOX", + "Toggles server/HC fps debugging mode", + _settingsGroup, + false, + true, + {}, + false +] call CBA_fnc_addSetting; + [ QGVAR(showOnMap), "CHECKBOX", @@ -29,7 +40,7 @@ private _settingsGroup = ["GRAD Civs", "9) diagnostics"]; [ QGVAR(showPinkArrows), "CHECKBOX", - "Helpfully hover arrows", + "Create 3D arrows over civ heads", _settingsGroup, false, true, @@ -38,9 +49,9 @@ private _settingsGroup = ["GRAD Civs", "9) diagnostics"]; ] call CBA_fnc_addSetting; [ - QGVAR(showHonkAtArea), + QGVAR(showMisc), "CHECKBOX", - "Draw honked at area", + "Miscellaneous stuff", _settingsGroup, false, true, diff --git a/addons/diagnostics/functions/fnc_showHonkAtArea.sqf b/addons/diagnostics/functions/fnc_showHonkAtArea.sqf index 3c880af4..49447093 100644 --- a/addons/diagnostics/functions/fnc_showHonkAtArea.sqf +++ b/addons/diagnostics/functions/fnc_showHonkAtArea.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" ISNILS(GVAR(honkHandler), -1); -if (GVAR(showHonkAtArea)) then { +if (GVAR(showMisc)) then { if (GVAR(honkHandler) > -1) exitWith {}; GVAR(honkHandler) = [QEGVAR(interact,honking_at_poly), { diff --git a/addons/diagnostics/functions/fnc_showPointingHints.sqf b/addons/diagnostics/functions/fnc_showPointingHints.sqf new file mode 100644 index 00000000..71cca8fe --- /dev/null +++ b/addons/diagnostics/functions/fnc_showPointingHints.sqf @@ -0,0 +1,21 @@ +#include "..\script_component.hpp" + +ISNILS(GVAR(pointHandler), []); +if (GVAR(showMisc)) then { + if (GVAR(pointHandler) isEqualTo []) then { + GVAR(pointHandler) = [ + [ + QEGVAR(interact,pointing), + {systemChat format["now pointing also at: %1", _this]} + ] call CBA_fnc_addEventHandler, + [ + QEGVAR(interact,depointing), + {systemChat format["now depointing: %1", _this]} + ] call CBA_fnc_addEventHandler + ]; + }; +} else { + if (GVAR(pointHandler) isEqualTo []) exitWith {}; + [QEGVAR(interact,pointing), GVAR(pointHandler)#0] call CBA_fnc_removeEventHandler; + [QEGVAR(interact,depointing), GVAR(pointHandler)#1] call CBA_fnc_removeEventHandler; +}; diff --git a/addons/legacy/functions/fnc_updateInfoLine.sqf b/addons/diagnostics/functions/fnc_updateInfoLine.sqf similarity index 87% rename from addons/legacy/functions/fnc_updateInfoLine.sqf rename to addons/diagnostics/functions/fnc_updateInfoLine.sqf index dc7e9186..0b8bb6c0 100644 --- a/addons/legacy/functions/fnc_updateInfoLine.sqf +++ b/addons/diagnostics/functions/fnc_updateInfoLine.sqf @@ -14,7 +14,7 @@ private _states = (_statemachineNames apply { format ["%1: %2", _x, _state]; }) joinString ", "; -_text = format ["%1 | %2 | %3", _this, _states, _x call FUNC(getCurrentlyThinking)]; +_text = format ["%1 | %2", _this, _states]; _this setVariable ["grad_civs_infoLine", _text, true]; _this setVariable ["grad_civs_local_at", clientOwner, true]; diff --git a/addons/interact/config.cpp b/addons/interact/config.cpp index 05f02bfa..ca1a09ac 100644 --- a/addons/interact/config.cpp +++ b/addons/interact/config.cpp @@ -6,7 +6,7 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"grad_civs_main", "grad_civs_legacy"}; + requiredAddons[] = {"grad_civs_main", "grad_civs_legacy", "ace_interaction"}; author = "AUTHOR"; VERSION_CONFIG; }; diff --git a/addons/interact/functions/fnc_aceInteractWrapper.sqf b/addons/interact/functions/fnc_aceInteractWrapper.sqf index 652da9fc..513b3e08 100644 --- a/addons/interact/functions/fnc_aceInteractWrapper.sqf +++ b/addons/interact/functions/fnc_aceInteractWrapper.sqf @@ -13,10 +13,7 @@ [ _target, {}, - { - params ["_target"]; - [_target, ""] call EFUNC(legacy,setCurrentlyThinking); - }, + {}, _waitTime, [], "ace_interaction_getDown", diff --git a/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf b/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf index bada425d..07daa353 100644 --- a/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf +++ b/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf @@ -6,7 +6,9 @@ private _depoint = { _pointees deleteAt (_pointees find _x); [QEGVAR(common,pointed_at_dec), [_x], [_x]] call CBA_fnc_targetEvent; } forEach _this; - if (GVAR(debugCivState) && {count _this > 0}) then { systemChat format ["depointing %1", _this]; }; + if (count _this > 0) then { + [QGVAR(depointing), _this] call CBA_fnc_localEvent; + }; }; private _point = { @@ -19,7 +21,9 @@ private _point = { _pointees pushBackUnique _x; [QEGVAR(common,pointed_at_inc), [_x], [_x]] call CBA_fnc_targetEvent; } forEach _this; - if (GVAR(debugCivState) && {count _this > 0}) then { systemChat format ["pointing at %1", _this]; }; + if (count _this > 0) then { + [QGVAR(pointing), _this] call CBA_fnc_localEvent; + }; }; // NOTE: we need to use animationState, as !weaponLowered does *not* mean "weaponRaised" diff --git a/addons/legacy/XEH_PREP.hpp b/addons/legacy/XEH_PREP.hpp index a11f9af7..8c714c7b 100644 --- a/addons/legacy/XEH_PREP.hpp +++ b/addons/legacy/XEH_PREP.hpp @@ -1,4 +1,3 @@ -PREP(clearCurrentlyThinking); PREP(compare); PREP(doReverse); PREP(deleteIfDamaged); @@ -19,7 +18,6 @@ PREP(findSpawnPosition); PREP(findUnclaimedHouse); PREP(forceEmotionSpeed); PREP(forcePanicSpeed); -PREP(getCurrentlyThinking); PREP(getGlobalCivs); PREP(initCommonEventhandlers); @@ -27,7 +25,6 @@ PREP(initConfig); PREP(initHCs); PREP(isInDistanceFromOtherPlayers); PREP(isInHouse); -PREP(nowPlusSeconds); PREP(reverse_abort); PREP(reverse_internal_end); PREP(reverse_internal_pfh); @@ -35,7 +32,6 @@ PREP(reverse_internal_stopCondition); // PREP(reverse.spec); PREP(reverse); PREP(serverLoop); -PREP(setCurrentlyThinking); PREP(sm_activities_helper_freeCondition); PREP(sm_activities_helper_surrenderCondition); PREP(sm_activities); @@ -65,11 +61,9 @@ PREP(sm_panic_state_flight_enter); PREP(sm_panic_state_flight_loop); PREP(sm_panic_state_hidden_enter); PREP(sm_panic_state_hide_enter); -PREP(sm_panic_state_hide_exit); PREP(sm_panic_trans_hide_hidden_condition); PREP(sm_panic_trans_hide_hidden_handler); PREP(spawnCivilianGroup); PREP(spawnCivilian); PREP(spawnPass); PREP(uid); -PREP(updateInfoLine); diff --git a/addons/legacy/XEH_postInit.sqf b/addons/legacy/XEH_postInit.sqf index 544d7a9f..b1f6a80c 100644 --- a/addons/legacy/XEH_postInit.sqf +++ b/addons/legacy/XEH_postInit.sqf @@ -4,16 +4,7 @@ if (!(EGVAR(main,enabled))) exitWith { INFO("grad_civs is disabled. good bye."); }; +ISNILS(GVAR(EXITON), {false}); + [] call FUNC(initCommonEventhandlers); [] call FUNC(initHCs); - -if (hasInterface) then { - [ - "server_fps", - { - if (GVAR(debugFps)) then { - systemChat format ["%1 fps on %2", _this select 1, _this select 0]; - }; - } - ] call CBA_fnc_addEventHandler; -}; diff --git a/addons/legacy/functions/fnc_clearCurrentlyThinking.sqf b/addons/legacy/functions/fnc_clearCurrentlyThinking.sqf deleted file mode 100644 index 3d10ef9d..00000000 --- a/addons/legacy/functions/fnc_clearCurrentlyThinking.sqf +++ /dev/null @@ -1,5 +0,0 @@ -#include "..\script_component.hpp" - -if (GVAR(debugCivState)) then { - _this setVariable ["grad_civs_currentlyThinking", nil, true]; -}; diff --git a/addons/legacy/functions/fnc_doCustomActivity.sqf b/addons/legacy/functions/fnc_doCustomActivity.sqf index 82d65e01..72017ce4 100644 --- a/addons/legacy/functions/fnc_doCustomActivity.sqf +++ b/addons/legacy/functions/fnc_doCustomActivity.sqf @@ -50,8 +50,6 @@ INFO_2("civ %1: starts custom activity %2", _civ, _id); ([_civ] + _moreParameters) call _doStart; -[_target, _description] call FUNC(setCurrentlyThinking); - // NOTE: // civ might change owner in which case this will break, as I dont set vars as global. // I am however afraid of broadcasting code (where I have no idea how large it is) everytime a civ does something special. @@ -74,7 +72,6 @@ private _endCode = { _civ setVariable [QGVAR(customActivity_id), nil, true]; _civ setVariable [QGVAR(customActivity_doEnd), nil]; _civ setVariable [QGVAR(customActivity_parameters), nil]; - [_target, ""] call FUNC(setCurrentlyThinking); [QGVAR(customActivity_end), [_civ], _civ] call CBA_fnc_targetEvent; } else { diff --git a/addons/legacy/functions/doReverse.sqf b/addons/legacy/functions/fnc_doReverse.sqf similarity index 83% rename from addons/legacy/functions/doReverse.sqf rename to addons/legacy/functions/fnc_doReverse.sqf index 2c77f1ae..0170aa9c 100644 --- a/addons/legacy/functions/doReverse.sqf +++ b/addons/legacy/functions/fnc_doReverse.sqf @@ -18,10 +18,7 @@ params [ vehicle _civ, _reverseTargetPos, 60, - { // onDone - params ["_vehicle"]; - [leader group driver _vehicle, "I'm waiting for people to go away"] call FUNC(setCurrentlyThinking); - } + {} ] call FUNC(reverse); INFO_2("vehicle %1 reversing to %2 and then waiting", _civ, _reverseTargetPos); diff --git a/addons/legacy/functions/fnc_getCurrentlyThinking.sqf b/addons/legacy/functions/fnc_getCurrentlyThinking.sqf deleted file mode 100644 index a10d3bd3..00000000 --- a/addons/legacy/functions/fnc_getCurrentlyThinking.sqf +++ /dev/null @@ -1,7 +0,0 @@ -#include "..\script_component.hpp" - -if (GVAR(debugCivState)) then { - _this getVariable ["grad_civs_currentlyThinking", "dumdidum"]; -} else { - "" -}; diff --git a/addons/legacy/functions/fnc_initConfig.sqf b/addons/legacy/functions/fnc_initConfig.sqf index 3960ba43..a0cda0d8 100644 --- a/addons/legacy/functions/fnc_initConfig.sqf +++ b/addons/legacy/functions/fnc_initConfig.sqf @@ -4,28 +4,6 @@ INFO("initConfig running..."); private _settingsGroup = ["GRAD Civs", "2) basics"]; -[ - QGVAR(debugCivState), - "CHECKBOX", - "Toggle civ behavior debugging mode.", - _settingsGroup, - false, - true, - {}, - false -] call CBA_fnc_addSetting; - -[ - QGVAR(debugFps), - "CHECKBOX", - "Toggles fps debugging mode", - _settingsGroup, - false, - true, - {}, - false -] call CBA_fnc_addSetting; - [ QGVAR(minCivUpdateTime), "SLIDER", diff --git a/addons/legacy/functions/fnc_reverse.sqf b/addons/legacy/functions/fnc_reverse.sqf index e8a2dc86..7ad60e71 100644 --- a/addons/legacy/functions/fnc_reverse.sqf +++ b/addons/legacy/functions/fnc_reverse.sqf @@ -26,9 +26,8 @@ if (effectiveCommander _vehicle == _driver) then { breakOut "main"; }; _ec = (group _driver) createUnit ["C_Soldier_VR_F", [0, 0, 0], [], 0, "NONE"]; - if (!(GVAR(debugCivState))) then { - ["ace_common_hideObjectGlobal", [_ec, true]] call CBA_fnc_serverEvent; - }; + // _ec disableAI "MOVE"; // TODO I saw one jump off th vehicle ... + ["ace_common_hideObjectGlobal", [_ec, true]] call CBA_fnc_serverEvent; _ec assignAsCargo _vehicle; _ec moveInCargo _vehicle; _ec setVariable ["grad_civs_virtual_ec", true]; diff --git a/addons/legacy/functions/fnc_serverLoop.sqf b/addons/legacy/functions/fnc_serverLoop.sqf index f50d5f00..303ecb00 100644 --- a/addons/legacy/functions/fnc_serverLoop.sqf +++ b/addons/legacy/functions/fnc_serverLoop.sqf @@ -2,8 +2,6 @@ ASSERT_SERVER(""); -ISNILS(GVAR(EXITON), {}); - private _mainLoop = { params ["_args", "_handle"]; if (!isGameFocused || isGamePaused) exitWith {}; @@ -12,7 +10,7 @@ private _mainLoop = { INFO("exiting because GRAD_CIVS_EXITON returned true"); [_handle] call CBA_fnc_removePerFrameHandler }; - if (isDedicated && (count ((entities "HeadlessClient_F") arrayIntersect allPlayers) > 0)) exitWith { + if (isDedicated && {count ((entities "HeadlessClient_F") arrayIntersect allPlayers) > 0}) exitWith { INFO("HCs are available, will not spawn any more civs"); [_handle] call CBA_fnc_removePerFrameHandler }; @@ -30,27 +28,6 @@ private _mainLoop = { 10 ] call CBA_fnc_waitAndExecute; - -GVAR(debugLoopHandle) = [{ - params ["_args", "_handle"]; - if (!isGameFocused || isGamePaused) exitWith {}; - if (call GVAR(EXITON)) exitWith {[_handle] call CBA_fnc_removePerFrameHandler}; - if (GVAR(debugCivState)) then { - { _x call FUNC(updateInfoLine); } forEach GVAR(localCivs); - }; -}, 0.1, []] call CBA_fnc_addPerFrameHandler; - - -[ - { - if (GVAR(debugFps)) then { - ["server_fps", [clientOwner, diag_fps]] call CBA_fnc_globalEvent; - }; - }, - 2, - [] -] call CBA_fnc_addPerFrameHandler; - // clean up objNull references in civs array - that happens for example when a zeus person deletes them [ { diff --git a/addons/legacy/functions/fnc_setCurrentlyThinking.sqf b/addons/legacy/functions/fnc_setCurrentlyThinking.sqf deleted file mode 100644 index 8c5b2011..00000000 --- a/addons/legacy/functions/fnc_setCurrentlyThinking.sqf +++ /dev/null @@ -1,10 +0,0 @@ -#include "..\script_component.hpp" - -params [ - ["_unit", objNull], - ["_thoughts", ""] -]; - -if (GVAR(debugCivState)) then { - _unit setVariable ["grad_civs_currentlyThinking", _thoughts]; -}; diff --git a/addons/legacy/functions/fnc_sm_emotions.sqf b/addons/legacy/functions/fnc_sm_emotions.sqf index cc1372f4..bd515549 100644 --- a/addons/legacy/functions/fnc_sm_emotions.sqf +++ b/addons/legacy/functions/fnc_sm_emotions.sqf @@ -20,6 +20,10 @@ private _emo_wary = [ { }, { + _this call FUNC(forceEmotionSpeed); + + private _cooldownAt = (_this getVariable["GRAD_CIVS_PANICCOOLDOWN", 60]) + CBA_missionTime; + _this setVariable [QGVAR(cooldownAt), _cooldownAt]; }, { }, @@ -31,6 +35,11 @@ private _emo_panic = [ {}, { _this call FUNC(endCustomActivity); + _this call FUNC(forceEmotionSpeed); + + private _cooldownAt = (_this getVariable["GRAD_CIVS_PANICCOOLDOWN", 60]) + CBA_missionTime; + _this setVariable [QGVAR(cooldownAt), _cooldownAt]; + ["grad_civs_panicking", [_this], [_this]] call CBA_fnc_targetEvent; }, { @@ -46,22 +55,8 @@ private _emo_panic = [ assert ([ _emotions, _emo_panic, _emo_wary, - { - (_this getVariable [QGVAR(cooldownAt), 0]) < CBA_missionTime - }, - { - _this call FUNC(forceEmotionSpeed); - - private _cooldownAt = _this getVariable["GRAD_CIVS_PANICCOOLDOWN", 60] + CBA_missionTime; - _this setVariable [QGVAR(cooldownAt), _cooldownAt]; - [ - _this, - format[ - "I need until %1 to get a bit calmer", - _cooldownAt call EFUNC(common,formatNowPlusSeconds) - ] - ] call FUNC(setCurrentlyThinking); - }, + {(_this getVariable [QGVAR(cooldownAt), 0]) < CBA_missionTime}, + {}, _emo_panic + _emo_wary ] call EFUNC(cba_statemachine,addTransition)); @@ -69,23 +64,8 @@ assert ([ assert ([ _emotions, _emo_wary, _emo_relaxed, - { - (_this getVariable [QGVAR(cooldownAt), 0]) < CBA_missionTime - - }, - { - _this call FUNC(forceEmotionSpeed); - - private _cooldownAt = _this getVariable["GRAD_CIVS_PANICCOOLDOWN", 60] + CBA_missionTime; - _this setVariable [QGVAR(cooldownAt), _cooldownAt]; - [ - _this, - format[ - "I need until %1 to calm down completely", - _cooldownAt call EFUNC(common,formatNowPlusSeconds) - ] - ] call FUNC(setCurrentlyThinking); - }, + {(_this getVariable [QGVAR(cooldownAt), 0]) < CBA_missionTime}, + {}, _emo_wary + _emo_relaxed ] call EFUNC(cba_statemachine,addTransition)); @@ -119,5 +99,4 @@ assert ([ EGVAR(common,stateMachines) setVariable ["emotions", _emotions]; - _emotions diff --git a/addons/legacy/functions/fnc_sm_panic.sqf b/addons/legacy/functions/fnc_sm_panic.sqf index 5cf203f3..7443af11 100644 --- a/addons/legacy/functions/fnc_sm_panic.sqf +++ b/addons/legacy/functions/fnc_sm_panic.sqf @@ -14,15 +14,15 @@ private _pan_flight = [ { _this call FUNC(sm_panic_state_flight_enter) }, { _this call FUNC(sm_panic_state_flight_exit) }, "pan_flight" -] call EFUNC(cba_statemachine,addState);; +] call EFUNC(cba_statemachine,addState); private _pan_hide = [ _panic, {}, { _this call FUNC(sm_panic_state_hide_enter) }, - { _this call FUNC(sm_panic_state_hide_exit) }, + {}, "pan_hide" -] call EFUNC(cba_statemachine,addState);; +] call EFUNC(cba_statemachine,addState); // NOTE concerning act_hidden and act_surrendered @@ -34,7 +34,7 @@ private _pan_hidden = [ { _this call FUNC(sm_panic_state_hidden_enter) }, {}, "pan_hidden" -] call EFUNC(cba_statemachine,addState);; +] call EFUNC(cba_statemachine,addState); // TRANSITIONS diff --git a/addons/legacy/functions/fnc_sm_panic_state_hide_enter.sqf b/addons/legacy/functions/fnc_sm_panic_state_hide_enter.sqf index 2a39d329..d1308671 100644 --- a/addons/legacy/functions/fnc_sm_panic_state_hide_enter.sqf +++ b/addons/legacy/functions/fnc_sm_panic_state_hide_enter.sqf @@ -1,7 +1,6 @@ #include "..\script_component.hpp" private _pos = [_this, true] call FUNC(findPositionOfInterest); -[_this, format ["going to pos %1 (still %2m) to hide", _pos, _this distance _pos]] call FUNC(setCurrentlyThinking); _this setVariable ["grad_civs_hidepoint", _pos]; _this doMove _pos; _this setSpeedMode "FULL"; diff --git a/addons/legacy/functions/fnc_sm_panic_state_hide_exit.sqf b/addons/legacy/functions/fnc_sm_panic_state_hide_exit.sqf deleted file mode 100644 index 6b566552..00000000 --- a/addons/legacy/functions/fnc_sm_panic_state_hide_exit.sqf +++ /dev/null @@ -1,3 +0,0 @@ -#include "..\script_component.hpp" - -_this call FUNC(clearCurrentlyThinking) diff --git a/addons/residents/XEH_PREP.hpp b/addons/residents/XEH_PREP.hpp index 91febf06..17074145 100644 --- a/addons/residents/XEH_PREP.hpp +++ b/addons/residents/XEH_PREP.hpp @@ -8,7 +8,6 @@ PREP(sm_business_state_housework_enter); PREP(sm_business_state_housework_exit); PREP(sm_business_trans_chat_housework_condition); PREP(sm_business_state_meetNeighbor_enter); -PREP(sm_business_state_meetNeighbor_exit); PREP(sm_business_state_meetNeighbor_loop); PREP(sm_business_trans_housework_housework_condition); PREP(sm_business_trans_housework_meetNeighbor_condition); diff --git a/addons/residents/functions/fnc_sm_business.sqf b/addons/residents/functions/fnc_sm_business.sqf index 8cdd00f7..7d46e4ab 100644 --- a/addons/residents/functions/fnc_sm_business.sqf +++ b/addons/residents/functions/fnc_sm_business.sqf @@ -24,7 +24,7 @@ private _bus_meetNeighbor = [ _business, { _this call FUNC(sm_business_state_meetNeighbor_loop) }, { _this call FUNC(sm_business_state_meetNeighbor_enter) }, - { _this call FUNC(sm_business_state_meetNeighbor_exit) }, + {}, "bus_meetNeighbor" ] call EFUNC(cba_statemachine,addState); diff --git a/addons/residents/functions/fnc_sm_business_state_chat_enter.sqf b/addons/residents/functions/fnc_sm_business_state_chat_enter.sqf index 3e1aca18..b17fca8e 100644 --- a/addons/residents/functions/fnc_sm_business_state_chat_enter.sqf +++ b/addons/residents/functions/fnc_sm_business_state_chat_enter.sqf @@ -8,6 +8,4 @@ _this setVariable ["grad_civs_chat_time", _chatTime]; private _neighbor = _this getVariable ["grad_civs_neighborToMeet", objNull]; if (isNull _neighbor) exitWith {}; -[_this, format ["chatting with %1", _neighbor]] call EFUNC(legacy,setCurrentlyThinking); - _this lookAt _neighbor; diff --git a/addons/residents/functions/fnc_sm_business_state_chat_exit.sqf b/addons/residents/functions/fnc_sm_business_state_chat_exit.sqf index 7c6acbc8..b9896eb5 100644 --- a/addons/residents/functions/fnc_sm_business_state_chat_exit.sqf +++ b/addons/residents/functions/fnc_sm_business_state_chat_exit.sqf @@ -4,4 +4,3 @@ _this setVariable["grad_civs_lastSocialContact", CBA_missionTime]; _this setVariable ["grad_civs_chat_time", nil]; _this setVariable ["grad_civs_neighborToMeet", nil]; _this setRandomLip false; -_this call EFUNC(legacy,clearCurrentlyThinking); diff --git a/addons/residents/functions/fnc_sm_business_state_meetNeighbor_enter.sqf b/addons/residents/functions/fnc_sm_business_state_meetNeighbor_enter.sqf index 3981924c..03edeeab 100644 --- a/addons/residents/functions/fnc_sm_business_state_meetNeighbor_enter.sqf +++ b/addons/residents/functions/fnc_sm_business_state_meetNeighbor_enter.sqf @@ -4,4 +4,3 @@ doStop _this; _this setVariable ["grad_civs_stopDistance", random [3, 7, 20]]; private _neighborToMeet = _this getVariable ["grad_civs_neighborToMeet", objNull]; -[_this, format ["going to chat with %1", _neighborToMeet]] call EFUNC(legacy,setCurrentlyThinking); diff --git a/addons/residents/functions/fnc_sm_business_state_meetNeighbor_exit.sqf b/addons/residents/functions/fnc_sm_business_state_meetNeighbor_exit.sqf deleted file mode 100644 index 659e5654..00000000 --- a/addons/residents/functions/fnc_sm_business_state_meetNeighbor_exit.sqf +++ /dev/null @@ -1,3 +0,0 @@ -#include "..\script_component.hpp" - -_this call EFUNC(legacy,clearCurrentlyThinking); diff --git a/addons/residents/functions/fnc_sm_business_trans_housework_meetNeighbor_condition.sqf b/addons/residents/functions/fnc_sm_business_trans_housework_meetNeighbor_condition.sqf index b39314ff..144ec3b9 100644 --- a/addons/residents/functions/fnc_sm_business_trans_housework_meetNeighbor_condition.sqf +++ b/addons/residents/functions/fnc_sm_business_trans_housework_meetNeighbor_condition.sqf @@ -6,7 +6,6 @@ if ((_this getVariable ["grad_civs_lastSocialContact", 0]) + _neighborCooldown > private _neighborToMeet = _this getVariable ["grad_civs_neighborToMeet", objNull]; if (!(isNull _neighborToMeet)) exitWith { - [_this, format ["going to chat with %1", _neighborToMeet]] call EFUNC(legacy,setCurrentlyThinking); true }; @@ -33,5 +32,4 @@ if (isNil "_neighborToMeet") exitWith {false}; if (isNull _neighborToMeet) exitWith {false}; _this setVariable ["grad_civs_neighborToMeet", _neighborToMeet, true]; -[_this, format ["going to chat with %1", _neighborToMeet]] call EFUNC(legacy,setCurrentlyThinking); true diff --git a/addons/transit/functions/fnc_sm_business_state_transit_exit.sqf b/addons/transit/functions/fnc_sm_business_state_transit_exit.sqf index 5b7b6e26..84cb225f 100644 --- a/addons/transit/functions/fnc_sm_business_state_transit_exit.sqf +++ b/addons/transit/functions/fnc_sm_business_state_transit_exit.sqf @@ -1,4 +1,3 @@ #include "..\script_component.hpp" [group _this] call CBA_fnc_clearWaypoints; -_this call EFUNC(legacy,clearCurrentlyThinking); diff --git a/addons/transit/functions/fnc_sm_business_state_transit_loop.sqf b/addons/transit/functions/fnc_sm_business_state_transit_loop.sqf index dccfa39c..d6883f2e 100644 --- a/addons/transit/functions/fnc_sm_business_state_transit_loop.sqf +++ b/addons/transit/functions/fnc_sm_business_state_transit_loop.sqf @@ -13,7 +13,3 @@ if (isNull _group) exitWith { private _wpidx = currentWaypoint _group; private _wps = waypoints _group; private _wppos = waypointPosition (_wps select _wpidx); - -#ifdef DEBUG_MODE_FULL - [_this, format ["traveling to transit sink %1, %2 (%3m left)", _wpidx, _wppos, _this distance _wppos]] call EFUNC(legacy,setCurrentlyThinking); -#endif diff --git a/addons/voyage/functions/fnc_sm_business_state_voyage_enter.sqf b/addons/voyage/functions/fnc_sm_business_state_voyage_enter.sqf index 314fa115..bcf1df2b 100644 --- a/addons/voyage/functions/fnc_sm_business_state_voyage_enter.sqf +++ b/addons/voyage/functions/fnc_sm_business_state_voyage_enter.sqf @@ -11,5 +11,3 @@ _this setSpeedMode "LIMITED"; _this forceSpeed -1; _this enableDynamicSimulation true; _this doFollow _this; - -[_this, format ["I'm on a %1 km voyage to %2", floor((_this distance _wppos) / 100)/10, _wppos]] call EFUNC(legacy,setCurrentlyThinking); diff --git a/addons/voyage/functions/fnc_sm_business_state_voyage_exit.sqf b/addons/voyage/functions/fnc_sm_business_state_voyage_exit.sqf index 5b7b6e26..84cb225f 100644 --- a/addons/voyage/functions/fnc_sm_business_state_voyage_exit.sqf +++ b/addons/voyage/functions/fnc_sm_business_state_voyage_exit.sqf @@ -1,4 +1,3 @@ #include "..\script_component.hpp" [group _this] call CBA_fnc_clearWaypoints; -_this call EFUNC(legacy,clearCurrentlyThinking); diff --git a/addons/voyage/functions/fnc_sm_business_state_voyage_loop.sqf b/addons/voyage/functions/fnc_sm_business_state_voyage_loop.sqf index 8bbf16f2..ff2a677b 100644 --- a/addons/voyage/functions/fnc_sm_business_state_voyage_loop.sqf +++ b/addons/voyage/functions/fnc_sm_business_state_voyage_loop.sqf @@ -7,7 +7,3 @@ if (isNull _group) exitWith { }; private _wps = waypoints _group; private _wppos = waypointPosition (_wps select (currentWaypoint _group)); - -#ifdef DEBUG_MODE_FULL - [_this, format ["traveling to waypoint %1, %2 (%3m left)", currentWaypoint _group, _wppos, _this distance _wppos]] call EFUNC(legacy,setCurrentlyThinking); -#endif From 81b91fc8cc439265ff0632e18b4c01cc3d769a3f Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Fri, 24 Jul 2020 23:39:38 +0200 Subject: [PATCH 13/55] refactor weapon pointing logic * implement poor man's "aimedAtTarget" * require player to keep on civ half a second longer before they raise arms (two-stage process) --- addons/interact/XEH_PREP.hpp | 1 + .../functions/fnc_aimedAtTarget.spec.sqf | 67 +++++++++++++++++++ .../interact/functions/fnc_aimedAtTarget.sqf | 30 +++++++++ .../fnc_checkWeaponOnCivilianPerception.sqf | 7 +- .../fnc_checkWeaponOnCivilianPointer.sqf | 40 ++++++----- 5 files changed, 125 insertions(+), 20 deletions(-) create mode 100644 addons/interact/functions/fnc_aimedAtTarget.spec.sqf create mode 100644 addons/interact/functions/fnc_aimedAtTarget.sqf diff --git a/addons/interact/XEH_PREP.hpp b/addons/interact/XEH_PREP.hpp index 68be4185..fd085900 100644 --- a/addons/interact/XEH_PREP.hpp +++ b/addons/interact/XEH_PREP.hpp @@ -1,6 +1,7 @@ PREP(aceInteractWrapper); PREP(addCivInteractions); PREP(addInteractEventHandlers); +PREP(aimedAtTarget); PREP(checkHonkingOnCivilian); PREP(checkWeaponOnCivilianPerception); PREP(checkWeaponOnCivilianPointer); diff --git a/addons/interact/functions/fnc_aimedAtTarget.spec.sqf b/addons/interact/functions/fnc_aimedAtTarget.spec.sqf new file mode 100644 index 00000000..bfb8df10 --- /dev/null +++ b/addons/interact/functions/fnc_aimedAtTarget.spec.sqf @@ -0,0 +1,67 @@ +// made for VR + +["GIVEN two units A (on foot) and B", + [ + { + private _group = createGroup [civilian, true]; + _group setCombatMode "GREEN"; + private _pos = [0, 0, 0]; + private _a = _group createUnit ["C_Man_1", _pos, [], 0, "NONE"]; + private _b = _group createUnit ["C_Man_1", _pos, [], 0, "NONE"]; + [_a, _b] + } + ], + [ + ["WHEN A aims at B", + { + params ["_a", "_b"]; + _b setPos [0, 100, 0]; + [_a, _b, [0, 1, 0]] + }, + [ + ["THEN aimedAtTarget is 1", + { + params ["_a", "_b", "_vectorDir"]; + sleep 1; + [_this call grad_civs_interact_fnc_aimedAtTarget, 1] call grad_testing_fnc_assertEquals; + } + ] + ] + ], + ["WHEN A aims away from B", + { + params ["_a", "_b"]; + _b setPos [0, 100, 0]; + [_a, _b, [0, -1, 0]] + }, + [ + ["THEN aimedAtTarget is 0", + { + params ["_a", "_b", "_vectorDir"]; + [_this call grad_civs_interact_fnc_aimedAtTarget, 0] call grad_testing_fnc_assertEquals; + } + ] + ] + ], + ["WHEN A aims straight up", + { + params ["_a", "_b"]; + _b setPos [0, 100, 0]; + [_a, _b, [0, 0, 1]] + }, + [ + ["THEN aimedAtTarget is 0.5", + { + params ["_a", "_b", "_vectorDir"]; + [_this call grad_civs_interact_fnc_aimedAtTarget, 0.5] call grad_testing_fnc_assertEquals; + } + ] + ] + ] + ], + { + params ["_a", "_b"]; + deleteVehicle _a; + deleteVehicle _b; + } +] call grad_testing_fnc_executeTest; diff --git a/addons/interact/functions/fnc_aimedAtTarget.sqf b/addons/interact/functions/fnc_aimedAtTarget.sqf new file mode 100644 index 00000000..cd5158e8 --- /dev/null +++ b/addons/interact/functions/fnc_aimedAtTarget.sqf @@ -0,0 +1,30 @@ +// this function aims to be for infantry what I presume the `aimedAtTarget` command wants to be for vehicles. + +/** + * return value: value from 0..1 , with + * * 0 turned into opposite direction and + * * 1 aimed anywhere at object (FIRE geomatry) + * * 1 being aimed (point blank) on center of target + */ +params [ + ["_shooter", objNull, [objNull]], + ["_target", objNull, [objNull]], + ["_weaponOrWeaponVectorDir", "", ["", [0,0,0]]] +]; + +private _weaponVectorDir = _weaponOrWeaponVectorDir; +if (_weaponOrWeaponVectorDir isEqualType "") then { + _weaponVectorDir = _shooter weaponDirection _weaponOrWeaponVectorDir; +}; + +private _intersectionsWithTarget = [_target, "FIRE"] intersect [getPos _shooter, (getPos _shooter) vectorAdd (_weaponVectorDir vectorMultiply 300)]; +if (count _intersectionsWithTarget > 0) exitWith {1}; + +private _distanceVector = (getPosASL _target) vectorDiff (getPosASL _shooter); +private _aimingError = acos (_weaponVectorDir vectorCos _distanceVector); + +private _aimingPrecision = (180 - _aimingError); + +// this is all rather meh, but good enough atm + +_aimingPrecision / 180 diff --git a/addons/interact/functions/fnc_checkWeaponOnCivilianPerception.sqf b/addons/interact/functions/fnc_checkWeaponOnCivilianPerception.sqf index 1ba95020..366743b2 100644 --- a/addons/interact/functions/fnc_checkWeaponOnCivilianPerception.sqf +++ b/addons/interact/functions/fnc_checkWeaponOnCivilianPerception.sqf @@ -5,7 +5,7 @@ params [ ["_pointee", objNull] ]; -private _dist = _pointer distance _pointee; +if ([_pointer, vehicle _pointee, primaryWeapon _pointer] call FUNC(aimedAtTarget) < 0.95) exitWith {false}; /* @@ -31,11 +31,12 @@ private _speedDiff = (velocity _pointer) vectorDistance (velocity _pointee); // NOTE: speedDiff value is in m/s ! private _perceptionAngleDiff = linearConversion [0, 50, _speedDiff, 90, 15, true]; +if (_angleDiff > _perceptionAngleDiff) exitWith {false}; + // as with the angular perception, linear conversion is a bit too simple here, but better than nothing private _minPerceptionDistance = linearConversion [5, 50, _speedDiff, 0, 50, true]; /* = if speed diff is larger than 5m/s, the min perception distance increases from 0m to 50m at a speed of 50m/s*/ private _maxPerceptionDistance = linearConversion [5, 50, _speedDiff, 50, 300, true]; - -if (_angleDiff > _perceptionAngleDiff) exitWith {false}; +private _dist = _pointer distance _pointee; if (_dist > _maxPerceptionDistance) exitWith {false}; diff --git a/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf b/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf index 07daa353..3b5a4d54 100644 --- a/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf +++ b/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf @@ -1,29 +1,33 @@ #include "..\script_component.hpp" +ISNILS(GVAR(gunpointees), [ARR_2([], 0)] call cba_fnc_hashCreate); + private _depoint = { - private _pointees = player getVariable [QGVAR(gunpointees), []]; { - _pointees deleteAt (_pointees find _x); - [QEGVAR(common,pointed_at_dec), [_x], [_x]] call CBA_fnc_targetEvent; + private _counter = [GVAR(gunpointees), _x] call CBA_fnc_hashGet; + if (_counter > 0) then { + _counter = 0 max (_counter - 1); + [GVAR(gunpointees), _x, _counter] call CBA_fnc_hashSet; + if (_counter == 1) then { + [QEGVAR(common,pointed_at_dec), [_x], [_x]] call CBA_fnc_targetEvent; + [QGVAR(depointing), _x] call CBA_fnc_localEvent; + }; + }; } forEach _this; - if (count _this > 0) then { - [QGVAR(depointing), _this] call CBA_fnc_localEvent; - }; }; private _point = { - private _pointees = player getVariable [QGVAR(gunpointees), false]; - if (_pointees isEqualTo false) then { - _pointees = []; - player setVariable [QGVAR(gunpointees), _pointees]; - }; { - _pointees pushBackUnique _x; - [QEGVAR(common,pointed_at_inc), [_x], [_x]] call CBA_fnc_targetEvent; + private _counter = [GVAR(gunpointees), _x] call CBA_fnc_hashGet; + if (_counter < 2) then { + _counter = 2 min (_counter + 1); + [GVAR(gunpointees), _x, _counter] call CBA_fnc_hashSet; + if (_counter == 2) then { + [QEGVAR(common,pointed_at_inc), [_x], [_x]] call CBA_fnc_targetEvent; + [QGVAR(pointing), _this] call CBA_fnc_localEvent; + }; + }; } forEach _this; - if (count _this > 0) then { - [QGVAR(pointing), _this] call CBA_fnc_localEvent; - }; }; // NOTE: we need to use animationState, as !weaponLowered does *not* mean "weaponRaised" @@ -32,7 +36,8 @@ private _weaponRaisedOnFoot = (alive player) && {vehicle player == player} && {"sras" in (animationState player)}; -private _pointees = player getVariable [QGVAR(gunpointees), []]; +//([GVAR(gunpointees), {_value > 0}] call CBA_fnc_hashFilter; // not necessary due to https://github.com/CBATeam/CBA_A3/issues/1358 +private _pointees = ([GVAR(gunpointees)] call CBA_fnc_hashKeys); if (!_weaponRaisedOnFoot) exitWith { // I lowered my weapon. Everyone feels free to go. No one is added. @@ -44,6 +49,7 @@ private _scaredPointees = _pointees select { [player, _x] call FUNC(checkWeaponOnCivilianPerception); }; (_pointees - _scaredPointees) call _depoint; +_scaredPointees call _point; // maybe someone new here I can threaten? private _possibleCiv = driver cursorTarget; From a31b7c4a5f193ef9549e5e94d8bce2fdacc239db Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Fri, 24 Jul 2020 23:40:37 +0200 Subject: [PATCH 14/55] uppercase module title --- addons/common/CfgVehicles.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/common/CfgVehicles.hpp b/addons/common/CfgVehicles.hpp index 6980bed7..6006e1e8 100644 --- a/addons/common/CfgVehicles.hpp +++ b/addons/common/CfgVehicles.hpp @@ -12,7 +12,7 @@ class CfgVehicles class GVAR(PopulationZone): Module_F { scope = 2; // visible in editor - displayName = "population zone"; + displayName = "Population Zone"; icon = QPATHTOF(ui\icon_module_population_zone_ca.paa); category = QEGVAR(main,modules); function = QFUNC(module_populationZone); @@ -32,7 +32,7 @@ class CfgVehicles class GVAR(ExclusionZone): Module_F { scope = 2; // visible in editor - displayName = "exclusion zone"; + displayName = "Exclusion Zone"; icon = QPATHTOF(ui\icon_module_exclusion_zone_ca.paa); category = QEGVAR(main,modules); function = QFUNC(module_exclusionZone); From 6d1400c27f2611dfe440e3d6ffeb4b02452e9184 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 00:44:41 +0200 Subject: [PATCH 15/55] Update fnc_initConfig.sqf --- addons/diagnostics/functions/fnc_initConfig.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/diagnostics/functions/fnc_initConfig.sqf b/addons/diagnostics/functions/fnc_initConfig.sqf index 9a982eda..7040e85c 100644 --- a/addons/diagnostics/functions/fnc_initConfig.sqf +++ b/addons/diagnostics/functions/fnc_initConfig.sqf @@ -2,7 +2,7 @@ INFO("initConfig running..."); -private _settingsGroup = ["GRAD Civs", "9) diagnostics"]; +private _settingsGroup = ["GRAD Civs", "a) diagnostics"]; [ QGVAR(debugFps), From b3ee2c71ad710093df8cab8010c3ecc636aad78c Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 11:15:54 +0200 Subject: [PATCH 16/55] fix honking. also, move event from common to interact --- addons/diagnostics/functions/fnc_showHonkAtArea.sqf | 4 ++-- addons/interact/functions/fnc_addInteractEventHandlers.sqf | 2 +- addons/interact/functions/fnc_checkHonkingOnCivilian.sqf | 4 ++-- addons/mimikry/functions/fnc_addEventHandlers.sqf | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/diagnostics/functions/fnc_showHonkAtArea.sqf b/addons/diagnostics/functions/fnc_showHonkAtArea.sqf index 49447093..0c48582b 100644 --- a/addons/diagnostics/functions/fnc_showHonkAtArea.sqf +++ b/addons/diagnostics/functions/fnc_showHonkAtArea.sqf @@ -25,8 +25,8 @@ if (GVAR(showMisc)) then { drawLine3D [_from, _to, [1, 0.3, 0.5, 1]]; } forEach _poly; }, - [CBA_missionTime + 3, _this], - 0 + 0, + [CBA_missionTime + 3, _this] ] call CBA_fnc_addPerFrameHandler; }] call CBA_fnc_addEventHandler; } else { diff --git a/addons/interact/functions/fnc_addInteractEventHandlers.sqf b/addons/interact/functions/fnc_addInteractEventHandlers.sqf index 7fb902ca..b181c7c7 100644 --- a/addons/interact/functions/fnc_addInteractEventHandlers.sqf +++ b/addons/interact/functions/fnc_addInteractEventHandlers.sqf @@ -17,7 +17,7 @@ }] call CBA_fnc_addEventHandler; [ - QEGVAR(common,honked_at), + QGVAR(honked_at), { params [ ["_target", objNull], diff --git a/addons/interact/functions/fnc_checkHonkingOnCivilian.sqf b/addons/interact/functions/fnc_checkHonkingOnCivilian.sqf index 92dbed49..65a51b74 100644 --- a/addons/interact/functions/fnc_checkHonkingOnCivilian.sqf +++ b/addons/interact/functions/fnc_checkHonkingOnCivilian.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" private _playerPos = getPosATL player; -private _nearCivs = (_playerPos nearEntities [["Man"], 200]) arrayIntersect ([] call FUNC(getGlobalCivs)); +private _nearCivs = (_playerPos nearEntities [["Man"], 200]) arrayIntersect ([] call EFUNC(legacy,getGlobalCivs)); private _playerVelocity = velocity player; private _speed = vectorMagnitude _playerVelocity; @@ -45,7 +45,7 @@ private _dangerPolyInPlayerHeight = _dangerPoly apply { private _civPosInPlayerHeight = [_civPos select 0, _civPos select 1, _playerPos select 2]; if (isOnRoad _civPos || !_playerIsOnRoad) then { if (_civPosInPlayerHeight inPolygon _dangerPolyInPlayerHeight) then { - [QEGVAR(common,honked_at), [_x, _playerPos, _playerVelocity], [_x]] call CBA_fnc_targetEvent; + [QGVAR(honked_at), [_x, _playerPos, _playerVelocity], [_x]] call CBA_fnc_targetEvent; }; }; } forEach _nearCivs; diff --git a/addons/mimikry/functions/fnc_addEventHandlers.sqf b/addons/mimikry/functions/fnc_addEventHandlers.sqf index df97327c..5e50a74a 100644 --- a/addons/mimikry/functions/fnc_addEventHandlers.sqf +++ b/addons/mimikry/functions/fnc_addEventHandlers.sqf @@ -49,7 +49,7 @@ }] call CBA_fnc_addEventHandler; -[QEGVAR(common,honked_at), { +[QEGVAR(interact,honked_at), { params ["_civ"]; if (_civ != ACE_player) exitWith {}; From 66e014c5ea80460b0e14f219e6ab2fa3390e1cc8 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 11:15:59 +0200 Subject: [PATCH 17/55] Update fnc_showOnMap_drawCivs.sqf --- addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf b/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf index 0bb765a7..27307f0a 100644 --- a/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf +++ b/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf @@ -7,6 +7,10 @@ params [ ]; { - _map drawIcon [_icon, [0.4,0,0.5,0.5], getPos _x, 24, 24, getDir _x, ([_x, "business"] call EFUNC(common,civGetState)), 0, 0.03, 'TahomaB', 'right']; + private _bus = [_x, "business"] call EFUNC(common,civGetState); + if (_bus == "") then { + private _bus = [_x, "activities"] call EFUNC(common,civGetState); + }; + _map drawIcon [_icon, [0.4,0,0.5,0.5], getPos _x, 24, 24, getDir _x, _bus, 0, 0.03, 'TahomaB', 'right']; false } count _units; From 3878eb1f05852b8bf52276cf8ae90b2ac07754e9 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 11:55:41 +0200 Subject: [PATCH 18/55] move pointing event name to interact --- addons/interact/functions/fnc_addInteractEventHandlers.sqf | 4 ++-- .../interact/functions/fnc_checkWeaponOnCivilianPointer.sqf | 6 +++--- addons/mimikry/functions/fnc_addEventHandlers.sqf | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/interact/functions/fnc_addInteractEventHandlers.sqf b/addons/interact/functions/fnc_addInteractEventHandlers.sqf index b181c7c7..ebc8f46d 100644 --- a/addons/interact/functions/fnc_addInteractEventHandlers.sqf +++ b/addons/interact/functions/fnc_addInteractEventHandlers.sqf @@ -1,13 +1,13 @@ #include "..\script_component.hpp" -[QEGVAR(common,pointed_at_inc), { +[QGVAR(pointed_at_inc), { params ["_civ"]; if (_civ == ACE_player) exitWith {}; private _currentCount = _civ getVariable ["grad_civs_isPointedAtCount", 0]; _civ setVariable ["grad_civs_isPointedAtCount", _currentCount + 1]; }] call CBA_fnc_addEventHandler; -[QEGVAR(common,pointed_at_dec), { +[QGVAR(pointed_at_dec), { params ["_civ"]; if (_civ == ACE_player) exitWith {}; private _currentCount = _civ getVariable ["grad_civs_isPointedAtCount", 0]; diff --git a/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf b/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf index 3b5a4d54..07a09958 100644 --- a/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf +++ b/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf @@ -9,7 +9,7 @@ private _depoint = { _counter = 0 max (_counter - 1); [GVAR(gunpointees), _x, _counter] call CBA_fnc_hashSet; if (_counter == 1) then { - [QEGVAR(common,pointed_at_dec), [_x], [_x]] call CBA_fnc_targetEvent; + [QGVAR(pointed_at_dec), [_x], [_x]] call CBA_fnc_targetEvent; [QGVAR(depointing), _x] call CBA_fnc_localEvent; }; }; @@ -23,8 +23,8 @@ private _point = { _counter = 2 min (_counter + 1); [GVAR(gunpointees), _x, _counter] call CBA_fnc_hashSet; if (_counter == 2) then { - [QEGVAR(common,pointed_at_inc), [_x], [_x]] call CBA_fnc_targetEvent; - [QGVAR(pointing), _this] call CBA_fnc_localEvent; + [QGVAR(pointed_at_inc), [_x], [_x]] call CBA_fnc_targetEvent; + [QGVAR(pointing), _x] call CBA_fnc_localEvent; }; }; } forEach _this; diff --git a/addons/mimikry/functions/fnc_addEventHandlers.sqf b/addons/mimikry/functions/fnc_addEventHandlers.sqf index 5e50a74a..08eb7a46 100644 --- a/addons/mimikry/functions/fnc_addEventHandlers.sqf +++ b/addons/mimikry/functions/fnc_addEventHandlers.sqf @@ -21,7 +21,7 @@ }] call CBA_fnc_addEventHandler; -[QEGVAR(common,pointed_at_inc), { +[QEGVAR(interact,pointed_at_inc), { params ["_civ"]; if (_civ != ACE_player) exitWith {}; @@ -32,7 +32,7 @@ [_message] call FUNC(showCivHint); }] call CBA_fnc_addEventHandler; -[QEGVAR(common,pointed_at_dec), { +[QEGVAR(interact,pointed_at_dec), { params ["_civ"]; if (_civ != ACE_player) exitWith {}; From 92bb0c667a9854903202ef0a315e97466cac39e4 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 17:40:30 +0200 Subject: [PATCH 19/55] cleanup: "fired_near" > QGVAR(fireadNear) . also remove empty log messages, --- addons/cars/functions/fnc_spawnVehicle.sqf | 2 +- addons/legacy/functions/fnc_serverLoop.sqf | 6 ++++-- addons/legacy/functions/fnc_sm_emotions.sqf | 4 ++-- .../functions/fnc_sm_lifecycle_state_spawn_enter.sqf | 9 +++------ 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/addons/cars/functions/fnc_spawnVehicle.sqf b/addons/cars/functions/fnc_spawnVehicle.sqf index 48dd74f2..f8f7ce72 100644 --- a/addons/cars/functions/fnc_spawnVehicle.sqf +++ b/addons/cars/functions/fnc_spawnVehicle.sqf @@ -19,7 +19,7 @@ _veh addEventHandler ["FiredNear", private _units = crew _vec; - ["fired_near", _units, _units] call CBA_fnc_targetEvent; + [QEGVAR(legacy,firedNear), _units, _units] call CBA_fnc_targetEvent; }]; private _animalChance = GVAR(animalTransportChance); diff --git a/addons/legacy/functions/fnc_serverLoop.sqf b/addons/legacy/functions/fnc_serverLoop.sqf index 303ecb00..84d82ba9 100644 --- a/addons/legacy/functions/fnc_serverLoop.sqf +++ b/addons/legacy/functions/fnc_serverLoop.sqf @@ -60,8 +60,10 @@ if (!hasInterface && !isDedicated) then { private _allCivs = entities [_civClasses, [], true, true]; private _myCivs = _allCivs select { local _x && (_x getVariable ["grad_civs_primaryTask", ""] != "")}; private _orphanedCivs = _myCivs - GVAR(localCivs); - INFO_1("%1 orphaned civs - putting them into my own array", count _orphanedCivs); - GVAR(localCivs) = GVAR(localCivs) + _orphanedCivs; + if (count _orphanedCivs > 0) then { + INFO_1("%1 orphaned civs - putting them into my own array", count _orphanedCivs); + GVAR(localCivs) = GVAR(localCivs) + _orphanedCivs; + }; }, 30, [] diff --git a/addons/legacy/functions/fnc_sm_emotions.sqf b/addons/legacy/functions/fnc_sm_emotions.sqf index bd515549..ffe30c11 100644 --- a/addons/legacy/functions/fnc_sm_emotions.sqf +++ b/addons/legacy/functions/fnc_sm_emotions.sqf @@ -72,7 +72,7 @@ assert ([ assert ([ _emotions, _emo_relaxed, _emo_panic, - ["fired_near"], + [QGVAR(firedNear)], {true}, {}, _emo_relaxed + _emo_panic @@ -81,7 +81,7 @@ assert ([ assert ([ _emotions, _emo_wary, _emo_panic, - ["fired_near"], + [QGVAR(firedNear)], {true}, {}, _emo_wary + _emo_panic diff --git a/addons/legacy/functions/fnc_sm_lifecycle_state_spawn_enter.sqf b/addons/legacy/functions/fnc_sm_lifecycle_state_spawn_enter.sqf index f1512977..baf1d9ee 100644 --- a/addons/legacy/functions/fnc_sm_lifecycle_state_spawn_enter.sqf +++ b/addons/legacy/functions/fnc_sm_lifecycle_state_spawn_enter.sqf @@ -30,7 +30,7 @@ private _addKilledNews = { _unit removeAllEventHandlers "Killed"; _unit removeAllEventHandlers "FiredNear"; - [QGVAR(switchMove), [_unit, ""]] call CBA_fnc_globalEvent; + [QGVAR(switchMove), [_unit, ""]] call CBA_fnc_globalEvent; // TODO: is that really necessary? }]; }; @@ -38,11 +38,8 @@ private _addGunfightNewsAndFlee = { (_this select 0) addEventHandler ["FiredNear", { params ["_unit"]; - - CIV_GUNFIGHT_POS = getPos _unit; - INFO_1("civ gunfight at %1",CIV_GUNFIGHT_POS); - publicVariableServer "CIV_GUNFIGHT_POS"; - ["fired_near", [_unit], [_unit]] call CBA_fnc_targetEvent; + INFO_2("gunfight close to %1 at %2", _unit, getPos _unit); + [QGVAR(firedNear), [_unit], [_unit]] call CBA_fnc_targetEvent; }]; }; From 029ae032a1ab00fe3816b7a1286029e748ef5c8d Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 18:05:42 +0200 Subject: [PATCH 20/55] I think I fixed some more mimikry events --- .../functions/fnc_showOnMap_drawCivs.sqf | 3 ++- .../functions/fnc_addInteractEventHandlers.sqf | 15 --------------- .../interact/functions/fnc_handleGestureGo.sqf | 5 ++++- .../functions/fnc_handleGestureStop.sqf | 2 +- addons/legacy/functions/fnc_doCarryOn.sqf | 17 +++++++++-------- addons/legacy/functions/fnc_doReverse.sqf | 10 ++++++++++ .../functions/fnc_initCommonEventhandlers.sqf | 17 +++-------------- .../mimikry/functions/fnc_addEventHandlers.sqf | 18 +++++++++++++++++- 8 files changed, 46 insertions(+), 41 deletions(-) diff --git a/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf b/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf index 27307f0a..faa0ff62 100644 --- a/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf +++ b/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf @@ -7,7 +7,8 @@ params [ ]; { - private _bus = [_x, "business"] call EFUNC(common,civGetState); + + private _bus = [_x, "business"] call EFUNC(common,civGetState); // works local only :sad: if (_bus == "") then { private _bus = [_x, "activities"] call EFUNC(common,civGetState); }; diff --git a/addons/interact/functions/fnc_addInteractEventHandlers.sqf b/addons/interact/functions/fnc_addInteractEventHandlers.sqf index ebc8f46d..f6ae0677 100644 --- a/addons/interact/functions/fnc_addInteractEventHandlers.sqf +++ b/addons/interact/functions/fnc_addInteractEventHandlers.sqf @@ -56,21 +56,6 @@ } ] call CBA_fnc_addEventHandler; -[QGVAR(gestured_at_vehicle_go), { - params [ - ["_target", objNull], - ["_vectorDir", [0, 0, 0]] - ]; - if (_target == ACE_player) exitWith {}; - if (_vectorDir isEqualTo [0, 0, 0]) exitWith { - WARNING_1("inconclusive 'go' gesture, %1 will do nothing", _target); - }; - - private _reverseTargetPos = (getPos _target) vectorAdd (_vectorDir vectorMultiply 50); - - [_target, _reverseTargetPos] call EFUNC(legacy,doReverse); -}] call CBA_fnc_addEventHandler; - [QGVAR(told_to_reverse), { params [ ["_target", objNull, [objNull]], diff --git a/addons/interact/functions/fnc_handleGestureGo.sqf b/addons/interact/functions/fnc_handleGestureGo.sqf index 7662e0b0..2f0d167b 100644 --- a/addons/interact/functions/fnc_handleGestureGo.sqf +++ b/addons/interact/functions/fnc_handleGestureGo.sqf @@ -21,8 +21,11 @@ private _observers = _potentialObservers select { || (_gesturer distance _x < SEND_RADIUS) /* HACK: as this is also triggered by ACE interact "go away", we need to disregard direction when very close*/ }; +private _vectorDir = vectorDirVisual _gesturer; + { - [QGVAR(gestured_at_vehicle_go), [_x, vectorDirVisual _gesturer], _x] call CBA_fnc_targetEvent; + private _reverseTargetPos = (getPos _x) vectorAdd (_vectorDir vectorMultiply 50); + [_target, _reverseTargetPos] call EFUNC(legacy,doReverse); } forEach _observers; INFO_1("%1 civs were triggered for being gestured with 'go'", count _observers); diff --git a/addons/interact/functions/fnc_handleGestureStop.sqf b/addons/interact/functions/fnc_handleGestureStop.sqf index 5942f5f2..3801c707 100644 --- a/addons/interact/functions/fnc_handleGestureStop.sqf +++ b/addons/interact/functions/fnc_handleGestureStop.sqf @@ -25,4 +25,4 @@ private _observers = _potentialObservers select { [_x, _waitTime] call FUNC(doStop); } forEach _observers; -INFO_1("%1 civs were triggered for being gestured with 'stop'", count _observers); +INFO_1("%1 civ observers were triggered for being gestured with 'stop'", count _observers); diff --git a/addons/legacy/functions/fnc_doCarryOn.sqf b/addons/legacy/functions/fnc_doCarryOn.sqf index 4b342a5a..42a95f4c 100644 --- a/addons/legacy/functions/fnc_doCarryOn.sqf +++ b/addons/legacy/functions/fnc_doCarryOn.sqf @@ -4,13 +4,14 @@ params [ ["_object", objNull, [objNull]] ]; -if (local _object) exitWith { - if (_object == ACE_player) exitWith {}; - _object call FUNC(endCustomActivity); +if (!(local _object)) exitWith { + [ + QGVAR(doCarryOn), + [_object], + _object + ] call CBA_fnc_targetEvent; }; -[ - QGVAR(doCarryOn), - [_object], - _object -] call CBA_fnc_targetEvent; +if (_object == ACE_player) exitWith {}; + +_object call FUNC(endCustomActivity); diff --git a/addons/legacy/functions/fnc_doReverse.sqf b/addons/legacy/functions/fnc_doReverse.sqf index 0170aa9c..b102b9f1 100644 --- a/addons/legacy/functions/fnc_doReverse.sqf +++ b/addons/legacy/functions/fnc_doReverse.sqf @@ -5,6 +5,16 @@ params [ ["_reverseTargetPos", [0, 0, 0]] ]; +if (!(local _civ)) exitWith { + [ + QGVAR(doReverse), + [_object, _reverseTargetPos], + _object + ] call CBA_fnc_targetEvent; +}; + +if (_civ == ACE_player) exitWith {}; + [ _civ, { diff --git a/addons/legacy/functions/fnc_initCommonEventhandlers.sqf b/addons/legacy/functions/fnc_initCommonEventhandlers.sqf index bc2d9168..c205214d 100644 --- a/addons/legacy/functions/fnc_initCommonEventhandlers.sqf +++ b/addons/legacy/functions/fnc_initCommonEventhandlers.sqf @@ -15,17 +15,6 @@ }] call CBA_fnc_addEventHandler; -[QGVAR(doStop), { - params [ - ["_target", objNull, [objNull]], - ["_waitTime", 0, [0]] - ]; - [_target, _waitTime] call FUNC(doStop); -}] call CBA_fnc_addEventHandler; - -[QGVAR(doCarryOn), { - params [ - ["_target", objNull, [objNull]] - ]; - [_target] call FUNC(doCarryOn); -}] call CBA_fnc_addEventHandler; +[QGVAR(doStop), FUNC(doStop)] call CBA_fnc_addEventHandler; +[QGVAR(doCarryOn), FUNC(doCarryOn)] call CBA_fnc_addEventHandler; +[QGVAR(doReverse), FUNC(doReverse)] call CBA_fnc_addEventHandler; diff --git a/addons/mimikry/functions/fnc_addEventHandlers.sqf b/addons/mimikry/functions/fnc_addEventHandlers.sqf index 08eb7a46..94f6aa32 100644 --- a/addons/mimikry/functions/fnc_addEventHandlers.sqf +++ b/addons/mimikry/functions/fnc_addEventHandlers.sqf @@ -57,10 +57,26 @@ [_message] call FUNC(showCivHint); }] call CBA_fnc_addEventHandler; -[QEGVAR(common,gestured_at_stop), { +[QEGVAR(legacy,doStop), { params ["_civ"]; if (_civ != ACE_player) exitWith {}; private _message = "someone gestures at you to stop"; [_message] call FUNC(showCivHint); }] call CBA_fnc_addEventHandler; + +[QEGVAR(legacy,doReverse), { + params ["_civ"]; + if (_civ != ACE_player) exitWith {}; + + private _message = "someone tells you to reverse"; + [_message] call FUNC(showCivHint); +}] call CBA_fnc_addEventHandler; + +[QEGVAR(legacy,doCarryOn), { + params ["_civ"]; + if (_civ != ACE_player) exitWith {}; + + private _message = "someone tells you to carry on"; + [_message] call FUNC(showCivHint); +}] call CBA_fnc_addEventHandler; From 5359f1654dd1d21b4d1152ea0abb1dc0e86aea51 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 22:29:51 +0200 Subject: [PATCH 21/55] no, we do not threaten buildings. --- addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf | 1 + addons/mimikry/functions/fnc_addEventHandlers.sqf | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf b/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf index 07a09958..0f33a990 100644 --- a/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf +++ b/addons/interact/functions/fnc_checkWeaponOnCivilianPointer.sqf @@ -56,6 +56,7 @@ private _possibleCiv = driver cursorTarget; if (!(_possibleCiv in _pointees)) then { if ( ((side _possibleCiv) == civilian) && + {_possibleCiv isKindOf "Man"} && {alive _possibleCiv} && {[player, _possibleCiv] call FUNC(checkWeaponOnCivilianPerception)} ) then { diff --git a/addons/mimikry/functions/fnc_addEventHandlers.sqf b/addons/mimikry/functions/fnc_addEventHandlers.sqf index 94f6aa32..1f620362 100644 --- a/addons/mimikry/functions/fnc_addEventHandlers.sqf +++ b/addons/mimikry/functions/fnc_addEventHandlers.sqf @@ -48,7 +48,6 @@ [_message] call FUNC(showCivHint); }] call CBA_fnc_addEventHandler; - [QEGVAR(interact,honked_at), { params ["_civ"]; if (_civ != ACE_player) exitWith {}; From 803c16bd43c1623e59c81a463d5c799bfb2ecfd9 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 22:30:18 +0200 Subject: [PATCH 22/55] even local servers can have HCs, stop producing civs then. --- addons/legacy/functions/fnc_serverLoop.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/legacy/functions/fnc_serverLoop.sqf b/addons/legacy/functions/fnc_serverLoop.sqf index 84d82ba9..7fcd6c97 100644 --- a/addons/legacy/functions/fnc_serverLoop.sqf +++ b/addons/legacy/functions/fnc_serverLoop.sqf @@ -10,7 +10,7 @@ private _mainLoop = { INFO("exiting because GRAD_CIVS_EXITON returned true"); [_handle] call CBA_fnc_removePerFrameHandler }; - if (isDedicated && {count ((entities "HeadlessClient_F") arrayIntersect allPlayers) > 0}) exitWith { + if (isServer && {count ((entities "HeadlessClient_F") arrayIntersect allPlayers) > 0}) exitWith { INFO("HCs are available, will not spawn any more civs"); [_handle] call CBA_fnc_removePerFrameHandler }; @@ -62,7 +62,7 @@ if (!hasInterface && !isDedicated) then { private _orphanedCivs = _myCivs - GVAR(localCivs); if (count _orphanedCivs > 0) then { INFO_1("%1 orphaned civs - putting them into my own array", count _orphanedCivs); - GVAR(localCivs) = GVAR(localCivs) + _orphanedCivs; + GVAR(localCivs) = GVAR(localCivs) + _orphanedCivs; }; }, 30, From 2871b80787fa2d7cd8b626fde9b74e635b7afe8b Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 22:30:30 +0200 Subject: [PATCH 23/55] warn only once if gruppe_adler_mod is missing --- addons/cars/functions/fnc_loadAnimals.sqf | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/cars/functions/fnc_loadAnimals.sqf b/addons/cars/functions/fnc_loadAnimals.sqf index be1d85aa..f7047097 100644 --- a/addons/cars/functions/fnc_loadAnimals.sqf +++ b/addons/cars/functions/fnc_loadAnimals.sqf @@ -11,12 +11,16 @@ if (isNull _vehicle) exitWith { if ((random 1) >= _chance) exitWith {}; -if (isNil "grad_animalTransport_fnc_findSuitableSpaces") exitWith { - WARNING("grad_animalTransport_fnc_findSuitableSpaces does not exist, not spawning animals"); +if (isNil "grad_animalTransport_fnc_getSupportedAnimalConfigs") exitWith { + WARNING("grad_animalTransport does not exist, not spawning animals"); + grad_animalTransport_fnc_getSupportedAnimalConfigs = {[]}; // yes this is evil. }; -private _animalConfig = selectRandom ([] call grad_animalTransport_fnc_getSupportedAnimalConfigs); +private _supportedAnimalConfigs = [] call grad_animalTransport_fnc_getSupportedAnimalConfigs; +if (_supportedAnimalConfigs isEqualTo []) exitWith {}; + +private _animalConfig = selectRandom _supportedAnimalConfigs; private _animalClassName = configName _animalConfig; private _spaces = [_vehicle, _animalClassName] call grad_animalTransport_fnc_findSuitableSpaces; From f568ed6bfa1da1917d38dedbdc20089581f5fecd Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 22:32:28 +0200 Subject: [PATCH 24/55] dont error if civs local info does not exist for map view --- addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf b/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf index faa0ff62..af891008 100644 --- a/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf +++ b/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf @@ -8,9 +8,12 @@ params [ { - private _bus = [_x, "business"] call EFUNC(common,civGetState); // works local only :sad: - if (_bus == "") then { - private _bus = [_x, "activities"] call EFUNC(common,civGetState); + private _bus = ""; + if (local _x) then { + _bus = [_x, "business"] call EFUNC(common,civGetState); // works local only :sad: + if (_bus == "") then { + private _bus = [_x, "activities"] call EFUNC(common,civGetState); + }; }; _map drawIcon [_icon, [0.4,0,0.5,0.5], getPos _x, 24, 24, getDir _x, _bus, 0, 0.03, 'TahomaB', 'right']; false From 41e21f9ec275e3497d088027c5cbcb73a1df20df Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 22:44:41 +0200 Subject: [PATCH 25/55] do use CBA_isHeadlessClient for better readability --- addons/cars/XEH_postInit.sqf | 4 ++-- addons/diagnostics/XEH_postInit.sqf | 3 ++- addons/gta/XEH_postInit.sqf | 2 +- addons/legacy/functions/fnc_initHCs.sqf | 2 +- addons/legacy/functions/fnc_serverLoop.sqf | 2 +- addons/main/script_macros.hpp | 4 ++-- addons/patrol/XEH_postInit.sqf | 2 +- addons/residents/XEH_postInit.sqf | 2 +- addons/transit/XEH_postInit.sqf | 2 +- addons/voyage/XEH_postInit.sqf | 2 +- 10 files changed, 13 insertions(+), 12 deletions(-) diff --git a/addons/cars/XEH_postInit.sqf b/addons/cars/XEH_postInit.sqf index a8d8c353..23e3c959 100644 --- a/addons/cars/XEH_postInit.sqf +++ b/addons/cars/XEH_postInit.sqf @@ -4,6 +4,6 @@ if (!(EGVAR(main,enabled))) exitWith { INFO("GRAD civs is disabled. Good bye!"); }; -if (isServer || !hasInterface) 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); }; diff --git a/addons/diagnostics/XEH_postInit.sqf b/addons/diagnostics/XEH_postInit.sqf index 9bcb8357..f5f65990 100644 --- a/addons/diagnostics/XEH_postInit.sqf +++ b/addons/diagnostics/XEH_postInit.sqf @@ -12,7 +12,8 @@ if (hasInterface) then { call FUNC(showInfoLine); }; -if (!hasInterface || isServer) then { + +if (isServer || CBA_isHeadlessClient) then { GVAR(debugLoopHandle) = [{ params ["_args", "_handle"]; if (!isGameFocused || isGamePaused) exitWith {}; diff --git a/addons/gta/XEH_postInit.sqf b/addons/gta/XEH_postInit.sqf index 8f44fd26..9b5b4789 100644 --- a/addons/gta/XEH_postInit.sqf +++ b/addons/gta/XEH_postInit.sqf @@ -4,7 +4,7 @@ if (!(EGVAR(main,enabled))) exitWith { INFO("GRAD civs is disabled. Good bye!"); }; -if (isServer || !hasInterface) then { +if (isServer || CBA_isHeadlessClient) then { [] call FUNC(registerCivAddedHandler); }; diff --git a/addons/legacy/functions/fnc_initHCs.sqf b/addons/legacy/functions/fnc_initHCs.sqf index 7227b1e5..bfce92af 100644 --- a/addons/legacy/functions/fnc_initHCs.sqf +++ b/addons/legacy/functions/fnc_initHCs.sqf @@ -1,6 +1,6 @@ #include "..\script_component.hpp" -if (isServer || !hasInterface) then { +if (isServer || CBA_isHeadlessClient) then { INFO("Server/HC init running..."); if ( diff --git a/addons/legacy/functions/fnc_serverLoop.sqf b/addons/legacy/functions/fnc_serverLoop.sqf index 7fcd6c97..26f11d60 100644 --- a/addons/legacy/functions/fnc_serverLoop.sqf +++ b/addons/legacy/functions/fnc_serverLoop.sqf @@ -53,7 +53,7 @@ private _mainLoop = { /* * if a civ gets moved to the HC for some reason (for example by acex_headless) take care to grab them */ -if (!hasInterface && !isDedicated) then { +if (CBA_isHeadlessClient) then { [ { private _civClasses = call EFUNC(common,config_getCivClasses); diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp index a86ee27d..8c9b8e24 100644 --- a/addons/main/script_macros.hpp +++ b/addons/main/script_macros.hpp @@ -12,12 +12,12 @@ #ifdef DEBUG_MODE_FULL -#define ASSERT_SERVER(var1) if (!assert(!hasInterface || isServer)) exitWith { diag_log(var1); } +#define ASSERT_SERVER(var1) if (!assert(CBA_isHeadlessClient || isServer)) exitWith { diag_log(var1); } #define ASSERT_PLAYER(var1) if (!assert(hasInterface)) exitWith { diag_log(var1); } #else -#define ASSERT_SERVER(var1) if (!(!hasInterface || isServer)) exitWith { diag_log(var1); } +#define ASSERT_SERVER(var1) if (!(CBA_isHeadlessClient || isServer)) exitWith { diag_log(var1); } #define ASSERT_PLAYER(var1) if (!hasInterface) exitWith { diag_log(var1); } #endif diff --git a/addons/patrol/XEH_postInit.sqf b/addons/patrol/XEH_postInit.sqf index 6bb6c354..a922b8b0 100644 --- a/addons/patrol/XEH_postInit.sqf +++ b/addons/patrol/XEH_postInit.sqf @@ -4,7 +4,7 @@ if (!(EGVAR(main,enabled))) exitWith { INFO("GRAD civs is disabled. Good bye!"); }; -if (isServer || !hasInterface) then { +if (isServer || CBA_isHeadlessClient) then { [ QEGVAR(legacy,spawnAllowed), { diff --git a/addons/residents/XEH_postInit.sqf b/addons/residents/XEH_postInit.sqf index f860502e..9691278d 100644 --- a/addons/residents/XEH_postInit.sqf +++ b/addons/residents/XEH_postInit.sqf @@ -4,7 +4,7 @@ if (!(EGVAR(main,enabled))) exitWith { INFO("GRAD civs is disabled. Good bye!"); }; -if (isServer || !hasInterface) then { +if (isServer || CBA_isHeadlessClient) then { [ QEGVAR(legacy,spawnAllowed), { diff --git a/addons/transit/XEH_postInit.sqf b/addons/transit/XEH_postInit.sqf index c7c241bf..98b698d9 100644 --- a/addons/transit/XEH_postInit.sqf +++ b/addons/transit/XEH_postInit.sqf @@ -4,7 +4,7 @@ if (!(EGVAR(main,enabled))) exitWith { INFO("GRAD civs is disabled. Good bye!"); }; -if (isServer || !hasInterface) then { +if (isServer || CBA_isHeadlessClient) then { [ QEGVAR(legacy,spawnAllowed), { diff --git a/addons/voyage/XEH_postInit.sqf b/addons/voyage/XEH_postInit.sqf index e80eaf08..70022f16 100644 --- a/addons/voyage/XEH_postInit.sqf +++ b/addons/voyage/XEH_postInit.sqf @@ -4,7 +4,7 @@ if (!(EGVAR(main,enabled))) exitWith { INFO("GRAD civs is disabled. Good bye!"); }; -if (isServer || !hasInterface) then { +if (isServer || CBA_isHeadlessClient) then { [ QEGVAR(legacy,spawnAllowed), { From 513e70765e77ce77ed18ec1968b5754257a27088 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 22:48:46 +0200 Subject: [PATCH 26/55] less spammy startup. but: identify role (player,hc,server) in log --- addons/cars/XEH_postInit.sqf | 4 +--- addons/common/XEH_postInit.sqf | 4 +--- addons/diagnostics/XEH_postInit.sqf | 4 +--- addons/gta/XEH_postInit.sqf | 4 +--- addons/interact/XEH_postInit.sqf | 4 +--- addons/legacy/XEH_postInit.sqf | 4 +--- addons/loadout/XEH_postInit.sqf | 4 +--- addons/main/XEH_postInit.sqf | 7 +++++++ addons/mimikry/XEH_postInit.sqf | 4 +--- addons/patrol/XEH_postInit.sqf | 4 +--- addons/residents/XEH_postInit.sqf | 4 +--- addons/transit/XEH_postInit.sqf | 4 +--- addons/voyage/XEH_postInit.sqf | 4 +--- addons/zeus/XEH_postInit.sqf | 4 +--- 14 files changed, 20 insertions(+), 39 deletions(-) diff --git a/addons/cars/XEH_postInit.sqf b/addons/cars/XEH_postInit.sqf index 23e3c959..e8399878 100644 --- a/addons/cars/XEH_postInit.sqf +++ b/addons/cars/XEH_postInit.sqf @@ -1,8 +1,6 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith { - INFO("GRAD civs is disabled. Good bye!"); -}; +if (!(EGVAR(main,enabled))) exitWith {}; if (isServer || CBA_isHeadlessClient) then { ["business", ["bus_rally"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine); diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index c5d93a5a..81fa40b5 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -1,8 +1,6 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith { - INFO("GRAD civs is disabled. Good bye!"); -}; +if (!(EGVAR(main,enabled))) exitWith {}; [ QGVAR(do_dismiss_civ), diff --git a/addons/diagnostics/XEH_postInit.sqf b/addons/diagnostics/XEH_postInit.sqf index f5f65990..57f62fe1 100644 --- a/addons/diagnostics/XEH_postInit.sqf +++ b/addons/diagnostics/XEH_postInit.sqf @@ -1,8 +1,6 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith { - INFO("GRAD civs is disabled. Good bye!"); -}; +if (!(EGVAR(main,enabled))) exitWith {}; if (hasInterface) then { call FUNC(showHonkAtArea); diff --git a/addons/gta/XEH_postInit.sqf b/addons/gta/XEH_postInit.sqf index 9b5b4789..e3a71516 100644 --- a/addons/gta/XEH_postInit.sqf +++ b/addons/gta/XEH_postInit.sqf @@ -1,8 +1,6 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith { - INFO("GRAD civs is disabled. Good bye!"); -}; +if (!(EGVAR(main,enabled))) exitWith {}; if (isServer || CBA_isHeadlessClient) then { [] call FUNC(registerCivAddedHandler); diff --git a/addons/interact/XEH_postInit.sqf b/addons/interact/XEH_postInit.sqf index 09325737..849c2a9e 100644 --- a/addons/interact/XEH_postInit.sqf +++ b/addons/interact/XEH_postInit.sqf @@ -1,8 +1,6 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith { - INFO("GRAD civs is disabled. Good bye!"); -}; +if (!(EGVAR(main,enabled))) exitWith {}; if (hasInterface) then { call FUNC(aceInteractWrapper); diff --git a/addons/legacy/XEH_postInit.sqf b/addons/legacy/XEH_postInit.sqf index b1f6a80c..f6dc068c 100644 --- a/addons/legacy/XEH_postInit.sqf +++ b/addons/legacy/XEH_postInit.sqf @@ -1,8 +1,6 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith { - INFO("grad_civs is disabled. good bye."); -}; +if (!(EGVAR(main,enabled))) exitWith {}; ISNILS(GVAR(EXITON), {false}); diff --git a/addons/loadout/XEH_postInit.sqf b/addons/loadout/XEH_postInit.sqf index d187f9d2..0b7b5e06 100644 --- a/addons/loadout/XEH_postInit.sqf +++ b/addons/loadout/XEH_postInit.sqf @@ -1,8 +1,6 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith { - INFO("GRAD Civs is disabled. Good bye!"); -}; +if (!(EGVAR(main,enabled))) exitWith {}; [QEGVAR(common,civ_added), { params [["_civ", objNull, [objNull]]]; diff --git a/addons/main/XEH_postInit.sqf b/addons/main/XEH_postInit.sqf index 421c54b4..eabb1219 100644 --- a/addons/main/XEH_postInit.sqf +++ b/addons/main/XEH_postInit.sqf @@ -1 +1,8 @@ #include "script_component.hpp" + + +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); diff --git a/addons/mimikry/XEH_postInit.sqf b/addons/mimikry/XEH_postInit.sqf index 9b258f13..52a4b04b 100644 --- a/addons/mimikry/XEH_postInit.sqf +++ b/addons/mimikry/XEH_postInit.sqf @@ -1,8 +1,6 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith { - INFO("GRAD civs is disabled. Good bye!"); -}; +if (!(EGVAR(main,enabled))) exitWith {}; if (!(GVAR(enabled))) exitWith { INFO("module disabled. good bye."); diff --git a/addons/patrol/XEH_postInit.sqf b/addons/patrol/XEH_postInit.sqf index a922b8b0..ce824d36 100644 --- a/addons/patrol/XEH_postInit.sqf +++ b/addons/patrol/XEH_postInit.sqf @@ -1,8 +1,6 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith { - INFO("GRAD civs is disabled. Good bye!"); -}; +if (!(EGVAR(main,enabled))) exitWith {}; if (isServer || CBA_isHeadlessClient) then { [ diff --git a/addons/residents/XEH_postInit.sqf b/addons/residents/XEH_postInit.sqf index 9691278d..6f656419 100644 --- a/addons/residents/XEH_postInit.sqf +++ b/addons/residents/XEH_postInit.sqf @@ -1,8 +1,6 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith { - INFO("GRAD civs is disabled. Good bye!"); -}; +if (!(EGVAR(main,enabled))) exitWith {}; if (isServer || CBA_isHeadlessClient) then { [ diff --git a/addons/transit/XEH_postInit.sqf b/addons/transit/XEH_postInit.sqf index 98b698d9..76a1a7e2 100644 --- a/addons/transit/XEH_postInit.sqf +++ b/addons/transit/XEH_postInit.sqf @@ -1,8 +1,6 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith { - INFO("GRAD civs is disabled. Good bye!"); -}; +if (!(EGVAR(main,enabled))) exitWith {}; if (isServer || CBA_isHeadlessClient) then { [ diff --git a/addons/voyage/XEH_postInit.sqf b/addons/voyage/XEH_postInit.sqf index 70022f16..1c189fee 100644 --- a/addons/voyage/XEH_postInit.sqf +++ b/addons/voyage/XEH_postInit.sqf @@ -1,8 +1,6 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith { - INFO("GRAD civs is disabled. Good bye!"); -}; +if (!(EGVAR(main,enabled))) exitWith {}; if (isServer || CBA_isHeadlessClient) then { [ diff --git a/addons/zeus/XEH_postInit.sqf b/addons/zeus/XEH_postInit.sqf index 9659cd9d..b38df62a 100644 --- a/addons/zeus/XEH_postInit.sqf +++ b/addons/zeus/XEH_postInit.sqf @@ -1,8 +1,6 @@ #include "script_component.hpp" -if (!(EGVAR(main,enabled))) exitWith { - INFO("GRAD civs is disabled. Good bye!"); -}; +if (!(EGVAR(main,enabled))) exitWith {}; if (hasInterface) then { [] call FUNC(setupZeusModules); From beb0bab9713dbe57dfc70b9e5fa817d8902ba001 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 22:50:45 +0200 Subject: [PATCH 27/55] info line fixup waypoint mode --- addons/diagnostics/functions/fnc_showInfoLine.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/diagnostics/functions/fnc_showInfoLine.sqf b/addons/diagnostics/functions/fnc_showInfoLine.sqf index 08934f70..51bc5678 100644 --- a/addons/diagnostics/functions/fnc_showInfoLine.sqf +++ b/addons/diagnostics/functions/fnc_showInfoLine.sqf @@ -36,13 +36,13 @@ ISNILS(GVAR(actionIds), []); _text = ""; switch (GVAR(civStateFormat)) do { - case 0: { _text =_x getVariable ["grad_civs_infoLine",""]; }; + case 0: { _text =_x getVariable ["grad_civs_infoLine",""]; }; case 1: { _text = format["%1 | speedmode: %2 %3", _x, speedMode _x, if (leader _x == _x) then {"(is leader)"} else {""}]; }; case 2: { _text = format["%1 | %2 guns point at him", _x, _x getVariable ["grad_civs_isPointedAtCount", 0]]}; case 3: { _text = format["%1 | is local at %2", _x, _x getVariable ["grad_civs_local_at", 0]]}; case 4: { _text = format["%1 | %2 %3 %4 | stopped: %5, unitReady: %6", _x, behaviour _x, combatMode _x, speedMode _x, stopped _x, unitReady _x]}; case 5: { _text = format["%1 | state times: %2", _x, _x call _filterTimeVars]}; - case 5: { _text = format["%1 | waypoints: %2 , current wp is %3", _x, count waypoints group _x, currentWaypoint group _x ]}; + case 6: { _text = format["%1 | waypoints: %2 , current wp is %3", _x, count waypoints group _x, currentWaypoint group _x ]}; default { _text = ""}; }; }; From ad7e1a215c32b10f98122ee03661080e92da1cf2 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 23:08:06 +0200 Subject: [PATCH 28/55] showFps: refactor (all in one line now, renamed config var) --- addons/diagnostics/XEH_postInit.sqf | 16 ++------- .../diagnostics/functions/fnc_initConfig.sqf | 4 +-- addons/diagnostics/functions/fnc_showFps.sqf | 36 +++++++++++++++++++ 3 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 addons/diagnostics/functions/fnc_showFps.sqf diff --git a/addons/diagnostics/XEH_postInit.sqf b/addons/diagnostics/XEH_postInit.sqf index 57f62fe1..bda10741 100644 --- a/addons/diagnostics/XEH_postInit.sqf +++ b/addons/diagnostics/XEH_postInit.sqf @@ -8,6 +8,7 @@ if (hasInterface) then { call FUNC(showPinkArrows); call FUNC(showPointingHints); call FUNC(showInfoLine); + call FUNC(showFps); }; @@ -23,22 +24,11 @@ if (isServer || CBA_isHeadlessClient) then { [ { - if (GVAR(debugFps)) then { - ["server_fps", [clientOwner, diag_fps]] call CBA_fnc_globalEvent; + if (GVAR(showFps)) then { + [QGVAR(fps), [clientOwner, diag_fps]] call CBA_fnc_globalEvent; }; }, 2, [] ] call CBA_fnc_addPerFrameHandler; }; - -if (hasInterface) then { - [ - "server_fps", - { - if (GVAR(debugFps)) then { - systemChat format ["%1 fps on %2", _this select 1, _this select 0]; - }; - } - ] call CBA_fnc_addEventHandler; -}; diff --git a/addons/diagnostics/functions/fnc_initConfig.sqf b/addons/diagnostics/functions/fnc_initConfig.sqf index 7040e85c..512519f9 100644 --- a/addons/diagnostics/functions/fnc_initConfig.sqf +++ b/addons/diagnostics/functions/fnc_initConfig.sqf @@ -5,9 +5,9 @@ INFO("initConfig running..."); private _settingsGroup = ["GRAD Civs", "a) diagnostics"]; [ - QGVAR(debugFps), + QGVAR(showFps), "CHECKBOX", - "Toggles server/HC fps debugging mode", + "Show server & HC fps", _settingsGroup, false, true, diff --git a/addons/diagnostics/functions/fnc_showFps.sqf b/addons/diagnostics/functions/fnc_showFps.sqf new file mode 100644 index 00000000..4ca10bfc --- /dev/null +++ b/addons/diagnostics/functions/fnc_showFps.sqf @@ -0,0 +1,36 @@ +#include "..\script_component.hpp" + +ISNILS(GVAR(lastFps), call CBA_fnc_hashCreate); +ISNILS(GVAR(fpsHandler), -1); +ISNILS(GVAR(fpsPfh), -1); + +if (GVAR(showFps)) then { + if (GVAR(fpsHandler) > -1) exitWith {}; + GVAR(fpsHandler) = [ + QGVAR(fps), + { + params [ + ["_clientId", -1, [0]], + ["_fps", -1, [0]] + ]; + [GVAR(lastFps), _clientId, _fps] call CBA_fnc_hashSet; + } + ] call CBA_fnc_addEventHandler; + + GVAR(fpsPfh) = [ + { + private _text = "FPS "; + [GVAR(lastFps), { + _text = format ["%1 | %2: %3", _text, _key, _value] + }] call CBA_fnc_hashEachPair; + systemChat _text; + }, + [], + 2 + ] call CBA_fnc_addPerFrameHandler; + +} else { + [QGVAR(fps), GVAR(fpsHandler)] call CBA_fnc_removeEventHandler; + GVAR(fpsHandler) = -1; + [GVAR(fpsPfh)] call CBA_fnc_removePerFrameHandler; +}; From 74f052067141955df6abd9b233268d30547ba999 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 23:41:48 +0200 Subject: [PATCH 29/55] meh, simplify code where it doesnt hurt. --- addons/diagnostics/functions/fnc_showFps.sqf | 52 ++++++++--------- .../functions/fnc_showHonkAtArea.sqf | 57 ++++++++----------- .../diagnostics/functions/fnc_showOnMap.sqf | 36 +++++------- .../functions/fnc_showPinkArrows.sqf | 49 +++++++--------- 4 files changed, 84 insertions(+), 110 deletions(-) diff --git a/addons/diagnostics/functions/fnc_showFps.sqf b/addons/diagnostics/functions/fnc_showFps.sqf index 4ca10bfc..a111cf2d 100644 --- a/addons/diagnostics/functions/fnc_showFps.sqf +++ b/addons/diagnostics/functions/fnc_showFps.sqf @@ -4,33 +4,29 @@ ISNILS(GVAR(lastFps), call CBA_fnc_hashCreate); ISNILS(GVAR(fpsHandler), -1); ISNILS(GVAR(fpsPfh), -1); -if (GVAR(showFps)) then { - if (GVAR(fpsHandler) > -1) exitWith {}; - GVAR(fpsHandler) = [ - QGVAR(fps), - { - params [ - ["_clientId", -1, [0]], - ["_fps", -1, [0]] - ]; - [GVAR(lastFps), _clientId, _fps] call CBA_fnc_hashSet; - } - ] call CBA_fnc_addEventHandler; +GVAR(fpsHandler) = [ + QGVAR(fps), + { + if (!GVAR(showFps)) exitWith {}; + params [ + ["_clientId", -1, [0]], + ["_fps", -1, [0]] + ]; - GVAR(fpsPfh) = [ - { - private _text = "FPS "; - [GVAR(lastFps), { - _text = format ["%1 | %2: %3", _text, _key, _value] - }] call CBA_fnc_hashEachPair; - systemChat _text; - }, - [], - 2 - ] call CBA_fnc_addPerFrameHandler; + [GVAR(lastFps), _clientId, _fps] call CBA_fnc_hashSet; + } +] call CBA_fnc_addEventHandler; -} else { - [QGVAR(fps), GVAR(fpsHandler)] call CBA_fnc_removeEventHandler; - GVAR(fpsHandler) = -1; - [GVAR(fpsPfh)] call CBA_fnc_removePerFrameHandler; -}; +GVAR(fpsPfh) = [ + { + if (!GVAR(showFps)) exitWith {}; + + private _text = "FPS "; + [GVAR(lastFps), { + _text = format ["%1 | %2: %3", _text, _key, _value] + }] call CBA_fnc_hashEachPair; + systemChat _text; + }, + [], + 2 +] call CBA_fnc_addPerFrameHandler; diff --git a/addons/diagnostics/functions/fnc_showHonkAtArea.sqf b/addons/diagnostics/functions/fnc_showHonkAtArea.sqf index 0c48582b..bb350cf5 100644 --- a/addons/diagnostics/functions/fnc_showHonkAtArea.sqf +++ b/addons/diagnostics/functions/fnc_showHonkAtArea.sqf @@ -1,35 +1,28 @@ #include "..\script_component.hpp" -ISNILS(GVAR(honkHandler), -1); -if (GVAR(showMisc)) then { - if (GVAR(honkHandler) > -1) exitWith {}; +GVAR(honkHandler) = [QEGVAR(interact,honking_at_poly), { + if (!GVAR(showMisc)) exitWith {}; + [ + { + params [ + ["_args", [], [[]]], + ["_handle", 0, [0]] + ]; + _args params [ + ["_endTime", 0, [0]], + ["_poly", [], [[]]] + ]; + if (CBA_missionTime >= _endTime) exitWith { + [_handle] call CBA_fnc_removePerFrameHandler; + }; - GVAR(honkHandler) = [QEGVAR(interact,honking_at_poly), { - [ - { - params [ - ["_args", [], [[]]], - ["_handle", 0, [0]] - ]; - _args params [ - ["_endTime", 0, [0]], - ["_poly", [], [[]]] - ]; - if (CBA_missionTime >= _endTime) exitWith { - [_handle] call CBA_fnc_removePerFrameHandler; - }; - - { // show the honked_at "danger zone" in front of the vehicle - private _from = _poly select _forEachIndex; - private _to = _poly select ((_forEachIndex + 1) mod (count _poly)); - drawLine3D [_from, _to, [1, 0.3, 0.5, 1]]; - } forEach _poly; - }, - 0, - [CBA_missionTime + 3, _this] - ] call CBA_fnc_addPerFrameHandler; - }] call CBA_fnc_addEventHandler; -} else { - [QEGVAR(interact,honking_at_poly), GVAR(honkHandler)] call CBA_fnc_removeEventHandler; - GVAR(honkHandler) = -1; -}; + { // show the honked_at "danger zone" in front of the vehicle + private _from = _poly select _forEachIndex; + private _to = _poly select ((_forEachIndex + 1) mod (count _poly)); + drawLine3D [_from, _to, [1, 0.3, 0.5, 1]]; + } forEach _poly; + }, + 0, + [CBA_missionTime + 3, _this] + ] call CBA_fnc_addPerFrameHandler; +}] call CBA_fnc_addEventHandler; diff --git a/addons/diagnostics/functions/fnc_showOnMap.sqf b/addons/diagnostics/functions/fnc_showOnMap.sqf index 2423b8c2..53c65b8b 100644 --- a/addons/diagnostics/functions/fnc_showOnMap.sqf +++ b/addons/diagnostics/functions/fnc_showOnMap.sqf @@ -1,26 +1,18 @@ #include "..\script_component.hpp" -ISNILS(GVAR(DRAWUNITSEH), -1); -if (GVAR(showOnMap)) then { - if (GVAR(DRAWUNITSEH) != -1) exitWith {}; +GVAR(DRAWUNITSEH) = ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", { + if (!GVAR(showOnMap)) exitWith {}; - GVAR(DRAWUNITSEH) = ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", { + private _civs = [] call EFUNC(legacy,getGlobalCivs); + private _civsInCarDrivers = _civs select { + private _vec = vehicle _x; + _vec != _x && driver _vec == _x + }; + private _civsOnFoot = _civs select { + vehicle _x == _x + }; - private _civs = [] call EFUNC(legacy,getGlobalCivs); - private _civsInCarDrivers = _civs select { - private _vec = vehicle _x; - _vec != _x && driver _vec == _x - }; - private _civsOnFoot = _civs select { - vehicle _x == _x - }; - - [_this select 0, _civsOnFoot, "iconMan"] call FUNC(showOnMap_drawCivs); - [_this select 0, _civsInCarDrivers, "iconCar"] call FUNC(showOnMap_drawCivs); - //one day: iconHelicopter - }]; -} else { - if (GVAR(DRAWUNITSEH) == -1) exitWith {}; - ((findDisplay 12) displayCtrl 51) ctrlRemoveEventHandler ["Draw", GVAR(DRAWUNITSEH)]; - GVAR(DRAWUNITSEH) = -1; -}; + [_this select 0, _civsOnFoot, "iconMan"] call FUNC(showOnMap_drawCivs); + [_this select 0, _civsInCarDrivers, "iconCar"] call FUNC(showOnMap_drawCivs); + //one day: iconHelicopter +}]; diff --git a/addons/diagnostics/functions/fnc_showPinkArrows.sqf b/addons/diagnostics/functions/fnc_showPinkArrows.sqf index cbbc5626..6d6b1aca 100644 --- a/addons/diagnostics/functions/fnc_showPinkArrows.sqf +++ b/addons/diagnostics/functions/fnc_showPinkArrows.sqf @@ -1,34 +1,27 @@ #include "..\script_component.hpp" -ISNILS(GVAR(showWhatTheyThink_civ_added), 0); -ISNILS(GVAR(showWhatTheyThinkciv_removed), 0); +GVAR(showWhatTheyThink_civ_added) = [ + QEGVAR(common,civ_added), + { + if (!GVAR(showPinkArrows)) exitWith {}; -if (GVAR(showPinkArrows)) then { - if (GVAR(showWhatTheyThink_civ_added) != 0) exitWith {}; - - GVAR(showWhatTheyThink_civ_added) = [ - QEGVAR(common,civ_added), + SCRIPT("showWhatTheyThink_civ_added"); { - SCRIPT("showWhatTheyThink_civ_added"); - { - private _arrow = createSimpleObject ["Sign_Arrow_Large_Pink_F", [0, 0, 0]]; - _arrow attachTo [_x, [0, 0, 5]]; - } forEach _this; - } - ] call CBA_fnc_addEventHandler; - GVAR(showWhatTheyThinkciv_removed) = [ - QEGVAR(common,civ_removed), + private _arrow = createSimpleObject ["Sign_Arrow_Large_Pink_F", [0, 0, 0]]; + _arrow attachTo [_x, [0, 0, 5]]; + } forEach _this; + } +] call CBA_fnc_addEventHandler; + +GVAR(showWhatTheyThinkciv_removed) = [ + QEGVAR(common,civ_removed), + { + SCRIPT("showWhatTheyThink_civ_removed"); { - SCRIPT("showWhatTheyThink_civ_removed"); + private _civ = _x; { - private _civ = _x; - { - deleteVehicle _x; - } forEach (attachedObjects _civ); - } forEach _this; - } - ] call CBA_fnc_addEventHandler; -} else { - [QEGVAR(common,civ_added), GVAR(showWhatTheyThink_civ_added)] call CBA_fnc_removeEventHandler; - [QEGVAR(common,civ_removed), GVAR(showWhatTheyThinkciv_removed)] call CBA_fnc_removeEventHandler; -}; + deleteVehicle _x; + } forEach (attachedObjects _civ); + } forEach _this; + } +] call CBA_fnc_addEventHandler; From 21bae320151aa3d329f5566ebded549e4636e83c Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 23:52:02 +0200 Subject: [PATCH 30/55] optimization * set locality indicator from server only, and on spawn & event only * update info line much less often --- addons/diagnostics/XEH_postInit.sqf | 17 ++++++++++++++++- .../functions/fnc_updateInfoLine.sqf | 1 - addons/legacy/functions/fnc_serverLoop.sqf | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/addons/diagnostics/XEH_postInit.sqf b/addons/diagnostics/XEH_postInit.sqf index bda10741..f2fc1ccf 100644 --- a/addons/diagnostics/XEH_postInit.sqf +++ b/addons/diagnostics/XEH_postInit.sqf @@ -20,7 +20,7 @@ if (isServer || CBA_isHeadlessClient) then { if (GVAR(showInfoLine)) then { { _x call FUNC(updateInfoLine); } forEach EGVAR(legacy,localCivs); }; - }, 0.1, []] call CBA_fnc_addPerFrameHandler; + }, 1, []] call CBA_fnc_addPerFrameHandler; [ { @@ -32,3 +32,18 @@ if (isServer || CBA_isHeadlessClient) then { [] ] call CBA_fnc_addPerFrameHandler; }; + +if (isServer) then { + [ + QEGVAR(common,civ_added), + { + { + _x setVariable ["grad_civs_local_at", owner _x, true]; + _x addEventHandler ["Local", { + params ["_entity", ""]; + _x setVariable ["grad_civs_local_at", owner _x, true]; + }]; + } forEach _this; + } + ] call CBA_fnc_addEventHandler; +}; diff --git a/addons/diagnostics/functions/fnc_updateInfoLine.sqf b/addons/diagnostics/functions/fnc_updateInfoLine.sqf index 0b8bb6c0..e6bf5896 100644 --- a/addons/diagnostics/functions/fnc_updateInfoLine.sqf +++ b/addons/diagnostics/functions/fnc_updateInfoLine.sqf @@ -17,4 +17,3 @@ private _states = (_statemachineNames apply { _text = format ["%1 | %2", _this, _states]; _this setVariable ["grad_civs_infoLine", _text, true]; -_this setVariable ["grad_civs_local_at", clientOwner, true]; diff --git a/addons/legacy/functions/fnc_serverLoop.sqf b/addons/legacy/functions/fnc_serverLoop.sqf index 26f11d60..274700b8 100644 --- a/addons/legacy/functions/fnc_serverLoop.sqf +++ b/addons/legacy/functions/fnc_serverLoop.sqf @@ -51,7 +51,7 @@ private _mainLoop = { ] call CBA_fnc_addPerFrameHandler; /* - * if a civ gets moved to the HC for some reason (for example by acex_headless) take care to grab them + * if a civ gets moved to the HC for some reason (for example by acex_headless) take care to grab them */ if (CBA_isHeadlessClient) then { [ From 1a00276554dca1757b5d903c91dac72d2fa78fb0 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 25 Jul 2020 23:58:16 +0200 Subject: [PATCH 31/55] declare than civ_added event only ever carries one civ -> simplify code --- addons/diagnostics/XEH_postInit.sqf | 13 ++++++------- .../diagnostics/functions/fnc_showPinkArrows.sqf | 16 ++++++---------- addons/legacy/functions/fnc_getGlobalCivs.sqf | 6 ++++-- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/addons/diagnostics/XEH_postInit.sqf b/addons/diagnostics/XEH_postInit.sqf index f2fc1ccf..af218a73 100644 --- a/addons/diagnostics/XEH_postInit.sqf +++ b/addons/diagnostics/XEH_postInit.sqf @@ -37,13 +37,12 @@ if (isServer) then { [ QEGVAR(common,civ_added), { - { - _x setVariable ["grad_civs_local_at", owner _x, true]; - _x addEventHandler ["Local", { - params ["_entity", ""]; - _x setVariable ["grad_civs_local_at", owner _x, true]; - }]; - } forEach _this; + params [["_civ", objNull, [objNull]]]; + _civ setVariable ["grad_civs_local_at", owner _civ, true]; + _civ addEventHandler ["Local", { + params ["_civ", ""]; + _civ setVariable ["grad_civs_local_at", owner _civ, true]; + }]; } ] call CBA_fnc_addEventHandler; }; diff --git a/addons/diagnostics/functions/fnc_showPinkArrows.sqf b/addons/diagnostics/functions/fnc_showPinkArrows.sqf index 6d6b1aca..30d20556 100644 --- a/addons/diagnostics/functions/fnc_showPinkArrows.sqf +++ b/addons/diagnostics/functions/fnc_showPinkArrows.sqf @@ -4,24 +4,20 @@ GVAR(showWhatTheyThink_civ_added) = [ QEGVAR(common,civ_added), { if (!GVAR(showPinkArrows)) exitWith {}; - + params [["_civ", objNull, [objNull]]]; SCRIPT("showWhatTheyThink_civ_added"); - { - private _arrow = createSimpleObject ["Sign_Arrow_Large_Pink_F", [0, 0, 0]]; - _arrow attachTo [_x, [0, 0, 5]]; - } forEach _this; + private _arrow = createSimpleObject ["Sign_Arrow_Large_Pink_F", [0, 0, 0]]; + _arrow attachTo [_civ, [0, 0, 5]]; } ] call CBA_fnc_addEventHandler; GVAR(showWhatTheyThinkciv_removed) = [ QEGVAR(common,civ_removed), { + params [["_civ", objNull, [objNull]]]; SCRIPT("showWhatTheyThink_civ_removed"); { - private _civ = _x; - { - deleteVehicle _x; - } forEach (attachedObjects _civ); - } forEach _this; + deleteVehicle _x; + } forEach (attachedObjects _civ); } ] call CBA_fnc_addEventHandler; diff --git a/addons/legacy/functions/fnc_getGlobalCivs.sqf b/addons/legacy/functions/fnc_getGlobalCivs.sqf index b9cce90b..52637b95 100644 --- a/addons/legacy/functions/fnc_getGlobalCivs.sqf +++ b/addons/legacy/functions/fnc_getGlobalCivs.sqf @@ -15,15 +15,17 @@ if (isNil QFUNC(getGlobalCivs_arr)) then { [ QEGVAR(common,civ_added), { + params [["_civ", objNull, [objNull]]]; SCRIPT("getGlobalCivs_civ_added"); - FUNC(getGlobalCivs_arr) = FUNC(getGlobalCivs_arr) + _this; + FUNC(getGlobalCivs_arr) = FUNC(getGlobalCivs_arr) + [_civ]; } ] call CBA_fnc_addEventHandler; [ QEGVAR(common,civ_removed), { + params [["_civ", objNull, [objNull]]]; SCRIPT("getGlobalCivs_civ_removed"); - FUNC(getGlobalCivs_arr) = FUNC(getGlobalCivs_arr) - _this; + FUNC(getGlobalCivs_arr) = FUNC(getGlobalCivs_arr) - [_civ]; } ] call CBA_fnc_addEventHandler; }; From 788f8a61a5d6840d22dad30b4ad65edf77f763a5 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 00:01:11 +0200 Subject: [PATCH 32/55] lelwhat. fix wrong usage of FUNC to designate GVAR --- addons/legacy/functions/fnc_getGlobalCivs.sqf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/legacy/functions/fnc_getGlobalCivs.sqf b/addons/legacy/functions/fnc_getGlobalCivs.sqf index 52637b95..aec77f1a 100644 --- a/addons/legacy/functions/fnc_getGlobalCivs.sqf +++ b/addons/legacy/functions/fnc_getGlobalCivs.sqf @@ -5,11 +5,11 @@ params [ ["_primaryTask", "", [""]] /* filter civs by primary task */ ]; -if (isNil QFUNC(getGlobalCivs_arr)) then { +if (isNil QGVAR(getGlobalCivs_arr)) then { // on first run, init array with existing civs private _civClasses = call EFUNC(common,config_getCivClasses); private _potentialCivs = entities [_civClasses, [], true, true]; - FUNC(getGlobalCivs_arr) = _potentialCivs select { (_x getVariable ["grad_civs_primaryTask", ""]) != ""}; + GVAR(getGlobalCivs_arr) = _potentialCivs select { (_x getVariable ["grad_civs_primaryTask", ""]) != ""}; // then, register event handler to update the array appropriately to always include all living civs [ @@ -17,7 +17,7 @@ if (isNil QFUNC(getGlobalCivs_arr)) then { { params [["_civ", objNull, [objNull]]]; SCRIPT("getGlobalCivs_civ_added"); - FUNC(getGlobalCivs_arr) = FUNC(getGlobalCivs_arr) + [_civ]; + GVAR(getGlobalCivs_arr) = GVAR(getGlobalCivs_arr) + [_civ]; } ] call CBA_fnc_addEventHandler; [ @@ -25,13 +25,13 @@ if (isNil QFUNC(getGlobalCivs_arr)) then { { params [["_civ", objNull, [objNull]]]; SCRIPT("getGlobalCivs_civ_removed"); - FUNC(getGlobalCivs_arr) = FUNC(getGlobalCivs_arr) - [_civ]; + GVAR(getGlobalCivs_arr) = GVAR(getGlobalCivs_arr) - [_civ]; } ] call CBA_fnc_addEventHandler; }; if (_primaryTask == "") then { - FUNC(getGlobalCivs_arr) + GVAR(getGlobalCivs_arr) } else { - (FUNC(getGlobalCivs_arr) select { _x getVariable ["grad_civs_primaryTask", ""] == _primaryTask}) + (GVAR(getGlobalCivs_arr) select { _x getVariable ["grad_civs_primaryTask", ""] == _primaryTask}) }; From 1e8014df395095fdeac781c3076ba1589eb607f3 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 00:07:31 +0200 Subject: [PATCH 33/55] more QGVAR, fix missing PREP --- addons/diagnostics/XEH_PREP.hpp | 3 ++- addons/diagnostics/XEH_postInit.sqf | 5 ++--- addons/diagnostics/functions/fnc_showInfoLine.sqf | 4 ++-- addons/diagnostics/functions/fnc_updateInfoLine.sqf | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/diagnostics/XEH_PREP.hpp b/addons/diagnostics/XEH_PREP.hpp index dac01f00..7cdfc0ee 100644 --- a/addons/diagnostics/XEH_PREP.hpp +++ b/addons/diagnostics/XEH_PREP.hpp @@ -1,8 +1,9 @@ PREP(initConfig); +PREP(showFps); PREP(showHonkAtArea); PREP(showInfoLine); -PREP(showOnMap); PREP(showOnMap_drawCivs); +PREP(showOnMap); PREP(showPinkArrows); PREP(showPointingHints); PREP(updateInfoLine); diff --git a/addons/diagnostics/XEH_postInit.sqf b/addons/diagnostics/XEH_postInit.sqf index af218a73..0e9a7b38 100644 --- a/addons/diagnostics/XEH_postInit.sqf +++ b/addons/diagnostics/XEH_postInit.sqf @@ -11,7 +11,6 @@ if (hasInterface) then { call FUNC(showFps); }; - if (isServer || CBA_isHeadlessClient) then { GVAR(debugLoopHandle) = [{ params ["_args", "_handle"]; @@ -38,10 +37,10 @@ if (isServer) then { QEGVAR(common,civ_added), { params [["_civ", objNull, [objNull]]]; - _civ setVariable ["grad_civs_local_at", owner _civ, true]; + _civ setVariable [QGVAR(localAt), owner _civ, true]; _civ addEventHandler ["Local", { params ["_civ", ""]; - _civ setVariable ["grad_civs_local_at", owner _civ, true]; + _civ setVariable [QGVAR(localAt), owner _civ, true]; }]; } ] call CBA_fnc_addEventHandler; diff --git a/addons/diagnostics/functions/fnc_showInfoLine.sqf b/addons/diagnostics/functions/fnc_showInfoLine.sqf index 51bc5678..a5d5edb9 100644 --- a/addons/diagnostics/functions/fnc_showInfoLine.sqf +++ b/addons/diagnostics/functions/fnc_showInfoLine.sqf @@ -36,10 +36,10 @@ ISNILS(GVAR(actionIds), []); _text = ""; switch (GVAR(civStateFormat)) do { - case 0: { _text =_x getVariable ["grad_civs_infoLine",""]; }; + case 0: { _text =_x getVariable [QGVAR(infoLine),""]; }; case 1: { _text = format["%1 | speedmode: %2 %3", _x, speedMode _x, if (leader _x == _x) then {"(is leader)"} else {""}]; }; case 2: { _text = format["%1 | %2 guns point at him", _x, _x getVariable ["grad_civs_isPointedAtCount", 0]]}; - case 3: { _text = format["%1 | is local at %2", _x, _x getVariable ["grad_civs_local_at", 0]]}; + case 3: { _text = format["%1 | is local at %2", _x, _x getVariable [QGVAR(localAt), 0]]}; case 4: { _text = format["%1 | %2 %3 %4 | stopped: %5, unitReady: %6", _x, behaviour _x, combatMode _x, speedMode _x, stopped _x, unitReady _x]}; case 5: { _text = format["%1 | state times: %2", _x, _x call _filterTimeVars]}; case 6: { _text = format["%1 | waypoints: %2 , current wp is %3", _x, count waypoints group _x, currentWaypoint group _x ]}; diff --git a/addons/diagnostics/functions/fnc_updateInfoLine.sqf b/addons/diagnostics/functions/fnc_updateInfoLine.sqf index e6bf5896..e54f3e9a 100644 --- a/addons/diagnostics/functions/fnc_updateInfoLine.sqf +++ b/addons/diagnostics/functions/fnc_updateInfoLine.sqf @@ -16,4 +16,4 @@ private _states = (_statemachineNames apply { _text = format ["%1 | %2", _this, _states]; -_this setVariable ["grad_civs_infoLine", _text, true]; +_this setVariable [QGVAR(infoLine), _text, true]; From 73fbba413064e348df440850d82684b5cdcf2da9 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 00:10:42 +0200 Subject: [PATCH 34/55] Update fnc_showFps.sqf --- addons/diagnostics/functions/fnc_showFps.sqf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/diagnostics/functions/fnc_showFps.sqf b/addons/diagnostics/functions/fnc_showFps.sqf index a111cf2d..99a453c9 100644 --- a/addons/diagnostics/functions/fnc_showFps.sqf +++ b/addons/diagnostics/functions/fnc_showFps.sqf @@ -21,12 +21,12 @@ GVAR(fpsPfh) = [ { if (!GVAR(showFps)) exitWith {}; - private _text = "FPS "; + private _text = "FPS "; [GVAR(lastFps), { _text = format ["%1 | %2: %3", _text, _key, _value] }] call CBA_fnc_hashEachPair; systemChat _text; }, - [], - 2 + 2, + [] ] call CBA_fnc_addPerFrameHandler; From ad0449103129d38ee93365a8a24f9b35137d4c68 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 00:27:20 +0200 Subject: [PATCH 35/55] fix stop gesture --- addons/interact/functions/fnc_handleGestureStop.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/interact/functions/fnc_handleGestureStop.sqf b/addons/interact/functions/fnc_handleGestureStop.sqf index 3801c707..3970cd3a 100644 --- a/addons/interact/functions/fnc_handleGestureStop.sqf +++ b/addons/interact/functions/fnc_handleGestureStop.sqf @@ -22,7 +22,7 @@ private _observers = _potentialObservers select { { private _recklessness = _x getVariable ["grad_civs_recklessness", 5]; private _waitTime = linearConversion [0, 10, _recklessness, 60*15, 15, false]; - [_x, _waitTime] call FUNC(doStop); + [_x, _waitTime] call EFUNC(legacy,doStop); } forEach _observers; INFO_1("%1 civ observers were triggered for being gestured with 'stop'", count _observers); From d7311308d6f2cf0e84b9adbc127d8d6091c23dec Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 09:28:45 +0200 Subject: [PATCH 36/55] lol remove unnecessary file --- addons/legacy/XEH_PREP.hpp | 1 - ...fnc_sm_activities_trans_dismount_surrendered_condition.sqf | 4 ---- 2 files changed, 5 deletions(-) delete mode 100644 addons/legacy/functions/fnc_sm_activities_trans_dismount_surrendered_condition.sqf diff --git a/addons/legacy/XEH_PREP.hpp b/addons/legacy/XEH_PREP.hpp index 8c714c7b..532bce93 100644 --- a/addons/legacy/XEH_PREP.hpp +++ b/addons/legacy/XEH_PREP.hpp @@ -43,7 +43,6 @@ PREP(sm_activities_state_surrendered_enter); PREP(sm_activities_state_surrendered_exit); PREP(sm_activities_trans_business_panic_condition); PREP(sm_activities_trans_business_surrendered_condition); -PREP(sm_activities_trans_dismount_surrendered_condition); PREP(sm_activities_trans_surrendered_business_condition); PREP(sm_activities_trans_surrendered_panic_condition); PREP(sm_business); diff --git a/addons/legacy/functions/fnc_sm_activities_trans_dismount_surrendered_condition.sqf b/addons/legacy/functions/fnc_sm_activities_trans_dismount_surrendered_condition.sqf deleted file mode 100644 index 16d6dde9..00000000 --- a/addons/legacy/functions/fnc_sm_activities_trans_dismount_surrendered_condition.sqf +++ /dev/null @@ -1,4 +0,0 @@ -#include "..\script_component.hpp" - -// transition if surrendering and has dismounted -(_this call FUNC(sm_activities_helper_surrenderCondition)) && (vehicle _this == _this) From 549a9daf2db69c425117eeb6bea6b2ba3cd65f2e Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 10:31:56 +0200 Subject: [PATCH 37/55] move surrender logic to interact module --- ...iness_trans_mountUp_dismount_condition.sqf | 2 +- addons/interact/XEH_PREP.hpp | 9 +++- addons/interact/XEH_postInit.sqf | 4 ++ addons/interact/config.cpp | 2 +- .../interact/functions/fnc_sm_activities.sqf | 45 +++++++++++++++++++ ...fnc_sm_activities_helper_freeCondition.sqf | 0 ...m_activities_helper_surrenderCondition.sqf | 0 ..._sm_activities_state_surrendered_enter.sqf | 0 ...c_sm_activities_state_surrendered_exit.sqf | 0 ...s_trans_business_surrendered_condition.sqf | 0 ...s_trans_surrendered_business_condition.sqf | 0 ...ties_trans_surrendered_panic_condition.sqf | 0 addons/legacy/XEH_PREP.hpp | 7 --- addons/legacy/functions/fnc_sm_activities.sqf | 34 -------------- ...iness_trans_transit_dismount_condition.sqf | 2 +- ...siness_trans_voyage_dismount_condition.sqf | 2 +- 16 files changed, 61 insertions(+), 46 deletions(-) create mode 100644 addons/interact/functions/fnc_sm_activities.sqf rename addons/{legacy => interact}/functions/fnc_sm_activities_helper_freeCondition.sqf (100%) rename addons/{legacy => interact}/functions/fnc_sm_activities_helper_surrenderCondition.sqf (100%) rename addons/{legacy => interact}/functions/fnc_sm_activities_state_surrendered_enter.sqf (100%) rename addons/{legacy => interact}/functions/fnc_sm_activities_state_surrendered_exit.sqf (100%) rename addons/{legacy => interact}/functions/fnc_sm_activities_trans_business_surrendered_condition.sqf (100%) rename addons/{legacy => interact}/functions/fnc_sm_activities_trans_surrendered_business_condition.sqf (100%) rename addons/{legacy => interact}/functions/fnc_sm_activities_trans_surrendered_panic_condition.sqf (100%) diff --git a/addons/cars/functions/fnc_sm_business_trans_mountUp_dismount_condition.sqf b/addons/cars/functions/fnc_sm_business_trans_mountUp_dismount_condition.sqf index 106689bb..7de7c965 100644 --- a/addons/cars/functions/fnc_sm_business_trans_mountUp_dismount_condition.sqf +++ b/addons/cars/functions/fnc_sm_business_trans_mountUp_dismount_condition.sqf @@ -1,3 +1,3 @@ #include "..\script_component.hpp" -(([_this, "emotions"] call EFUNC(common,civGetState)) == "emo_panic") || (_this call EFUNC(legacy,sm_activities_helper_surrenderCondition)) +(([_this, "emotions"] call EFUNC(common,civGetState)) == "emo_panic") || (_this call EFUNC(interact,sm_activities_helper_surrenderCondition)) diff --git a/addons/interact/XEH_PREP.hpp b/addons/interact/XEH_PREP.hpp index fd085900..4c15cd31 100644 --- a/addons/interact/XEH_PREP.hpp +++ b/addons/interact/XEH_PREP.hpp @@ -5,7 +5,6 @@ PREP(aimedAtTarget); PREP(checkHonkingOnCivilian); PREP(checkWeaponOnCivilianPerception); PREP(checkWeaponOnCivilianPointer); -// PREP(feelsAddressedByGesture.spec); PREP(feelsAddressedByGesture); PREP(handleAnimation); PREP(handleGestureGo); @@ -15,3 +14,11 @@ PREP(interact_backUpCondition); PREP(interact_carryOnAction); PREP(interact_carryOnCondition); PREP(isPlayerHonking); +PREP(sm_activities_helper_freeCondition); +PREP(sm_activities_helper_surrenderCondition); +PREP(sm_activities_state_surrendered_enter); +PREP(sm_activities_state_surrendered_exit); +PREP(sm_activities_trans_business_surrendered_condition); +PREP(sm_activities_trans_surrendered_business_condition); +PREP(sm_activities_trans_surrendered_panic_condition); +PREP(sm_activities); diff --git a/addons/interact/XEH_postInit.sqf b/addons/interact/XEH_postInit.sqf index 849c2a9e..b00d5e19 100644 --- a/addons/interact/XEH_postInit.sqf +++ b/addons/interact/XEH_postInit.sqf @@ -22,3 +22,7 @@ if (hasInterface) then { }; + +if (isServer || CBA_isHeadlessClient) then { + ["activities", ["act_business"], FUNC(sm_activities)] call EFUNC(common,augmentStateMachine); +}; diff --git a/addons/interact/config.cpp b/addons/interact/config.cpp index ca1a09ac..036e4edd 100644 --- a/addons/interact/config.cpp +++ b/addons/interact/config.cpp @@ -6,7 +6,7 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"grad_civs_main", "grad_civs_legacy", "ace_interaction"}; + requiredAddons[] = {"grad_civs_main", "grad_civs_legacy", "ace_interaction", "ace_captives"}; author = "AUTHOR"; VERSION_CONFIG; }; diff --git a/addons/interact/functions/fnc_sm_activities.sqf b/addons/interact/functions/fnc_sm_activities.sqf new file mode 100644 index 00000000..78359def --- /dev/null +++ b/addons/interact/functions/fnc_sm_activities.sqf @@ -0,0 +1,45 @@ +#include "..\script_component.hpp" + + +params [ + ["_activities", locationNull, [locationNull]] +]; +assert(!(isNull _activities)); + +private _act_business = "act_business"; +private _act_panic = "act_panic"; + +private _act_surrendered = [ + _activities, + {}, + { _this call FUNC(sm_activities_state_surrendered_enter) }, + { _this call FUNC(sm_activities_state_surrendered_exit) }, + "act_surrendered" +] call EFUNC(cba_statemachine,addState); +assert(_act_surrendered != ""); + +// TRANSITIONS + +assert ([ + _activities, + _act_business, _act_surrendered, + { _this call FUNC(sm_activities_trans_business_surrendered_condition) }, + {}, + _act_business + _act_surrendered +] call EFUNC(cba_statemachine,addTransition)); + +assert ([ + _activities, + _act_surrendered, _act_business, + { _this call FUNC(sm_activities_trans_surrendered_business_condition) }, + {}, + _act_surrendered + _act_business +] call EFUNC(cba_statemachine,addTransition)); + +assert ([ + _activities, + _act_surrendered, _act_panic, + { _this call FUNC(sm_activities_trans_surrendered_panic_condition) }, + {}, + _act_surrendered + _act_panic +] call EFUNC(cba_statemachine,addTransition)); diff --git a/addons/legacy/functions/fnc_sm_activities_helper_freeCondition.sqf b/addons/interact/functions/fnc_sm_activities_helper_freeCondition.sqf similarity index 100% rename from addons/legacy/functions/fnc_sm_activities_helper_freeCondition.sqf rename to addons/interact/functions/fnc_sm_activities_helper_freeCondition.sqf diff --git a/addons/legacy/functions/fnc_sm_activities_helper_surrenderCondition.sqf b/addons/interact/functions/fnc_sm_activities_helper_surrenderCondition.sqf similarity index 100% rename from addons/legacy/functions/fnc_sm_activities_helper_surrenderCondition.sqf rename to addons/interact/functions/fnc_sm_activities_helper_surrenderCondition.sqf diff --git a/addons/legacy/functions/fnc_sm_activities_state_surrendered_enter.sqf b/addons/interact/functions/fnc_sm_activities_state_surrendered_enter.sqf similarity index 100% rename from addons/legacy/functions/fnc_sm_activities_state_surrendered_enter.sqf rename to addons/interact/functions/fnc_sm_activities_state_surrendered_enter.sqf diff --git a/addons/legacy/functions/fnc_sm_activities_state_surrendered_exit.sqf b/addons/interact/functions/fnc_sm_activities_state_surrendered_exit.sqf similarity index 100% rename from addons/legacy/functions/fnc_sm_activities_state_surrendered_exit.sqf rename to addons/interact/functions/fnc_sm_activities_state_surrendered_exit.sqf diff --git a/addons/legacy/functions/fnc_sm_activities_trans_business_surrendered_condition.sqf b/addons/interact/functions/fnc_sm_activities_trans_business_surrendered_condition.sqf similarity index 100% rename from addons/legacy/functions/fnc_sm_activities_trans_business_surrendered_condition.sqf rename to addons/interact/functions/fnc_sm_activities_trans_business_surrendered_condition.sqf diff --git a/addons/legacy/functions/fnc_sm_activities_trans_surrendered_business_condition.sqf b/addons/interact/functions/fnc_sm_activities_trans_surrendered_business_condition.sqf similarity index 100% rename from addons/legacy/functions/fnc_sm_activities_trans_surrendered_business_condition.sqf rename to addons/interact/functions/fnc_sm_activities_trans_surrendered_business_condition.sqf diff --git a/addons/legacy/functions/fnc_sm_activities_trans_surrendered_panic_condition.sqf b/addons/interact/functions/fnc_sm_activities_trans_surrendered_panic_condition.sqf similarity index 100% rename from addons/legacy/functions/fnc_sm_activities_trans_surrendered_panic_condition.sqf rename to addons/interact/functions/fnc_sm_activities_trans_surrendered_panic_condition.sqf diff --git a/addons/legacy/XEH_PREP.hpp b/addons/legacy/XEH_PREP.hpp index 532bce93..760c234c 100644 --- a/addons/legacy/XEH_PREP.hpp +++ b/addons/legacy/XEH_PREP.hpp @@ -32,19 +32,12 @@ PREP(reverse_internal_stopCondition); // PREP(reverse.spec); PREP(reverse); PREP(serverLoop); -PREP(sm_activities_helper_freeCondition); -PREP(sm_activities_helper_surrenderCondition); PREP(sm_activities); PREP(sm_activities_state_asOrdered_enter); PREP(sm_activities_state_asOrdered_exit); PREP(sm_activities_state_panic_enter); PREP(sm_activities_state_panic_exit); -PREP(sm_activities_state_surrendered_enter); -PREP(sm_activities_state_surrendered_exit); PREP(sm_activities_trans_business_panic_condition); -PREP(sm_activities_trans_business_surrendered_condition); -PREP(sm_activities_trans_surrendered_business_condition); -PREP(sm_activities_trans_surrendered_panic_condition); PREP(sm_business); PREP(sm_business_state_rally_enter); PREP(sm_emotions); diff --git a/addons/legacy/functions/fnc_sm_activities.sqf b/addons/legacy/functions/fnc_sm_activities.sqf index 1204d960..130e8323 100644 --- a/addons/legacy/functions/fnc_sm_activities.sqf +++ b/addons/legacy/functions/fnc_sm_activities.sqf @@ -28,15 +28,6 @@ private _act_asOrdered = [ ] call EFUNC(cba_statemachine,addState); assert(_act_asOrdered != ""); -private _act_surrendered = [ - _activities, - {}, - { _this call FUNC(sm_activities_state_surrendered_enter) }, - { _this call FUNC(sm_activities_state_surrendered_exit) }, - "act_surrendered" -] call EFUNC(cba_statemachine,addState); -assert(_act_surrendered != ""); - private _act_panic = [ _activities, [_panic], @@ -49,14 +40,6 @@ assert(_act_panic != ""); // TRANSITIONS -assert ([ - _activities, - _act_business, _act_surrendered, - { _this call FUNC(sm_activities_trans_business_surrendered_condition) }, - {}, - _act_business + _act_surrendered -] call EFUNC(cba_statemachine,addTransition)); - assert ([ _activities, _act_business, _act_panic, @@ -65,22 +48,6 @@ assert ([ _act_business + _act_panic ] call EFUNC(cba_statemachine,addTransition)); -assert ([ - _activities, - _act_surrendered, _act_business, - { _this call FUNC(sm_activities_trans_surrendered_business_condition) }, - {}, - _act_surrendered + _act_business -] call EFUNC(cba_statemachine,addTransition)); - -assert ([ - _activities, - _act_surrendered, _act_panic, - { _this call FUNC(sm_activities_trans_surrendered_panic_condition) }, - {}, - _act_surrendered + _act_panic -] call EFUNC(cba_statemachine,addTransition)); - assert ([ _activities, _act_panic, _act_business, @@ -111,5 +78,4 @@ assert ([ EGVAR(common,stateMachines) setVariable ["activities", _activities]; - _activities diff --git a/addons/transit/functions/fnc_sm_business_trans_transit_dismount_condition.sqf b/addons/transit/functions/fnc_sm_business_trans_transit_dismount_condition.sqf index 013a07fd..2debf65c 100644 --- a/addons/transit/functions/fnc_sm_business_trans_transit_dismount_condition.sqf +++ b/addons/transit/functions/fnc_sm_business_trans_transit_dismount_condition.sqf @@ -1,3 +1,3 @@ #include "..\script_component.hpp" -(_this call EFUNC(legacy,sm_activities_helper_surrenderCondition)) || !(canMove vehicle _this) +(_this call EFUNC(interact,sm_activities_helper_surrenderCondition)) || !(canMove vehicle _this) diff --git a/addons/voyage/functions/fnc_sm_business_trans_voyage_dismount_condition.sqf b/addons/voyage/functions/fnc_sm_business_trans_voyage_dismount_condition.sqf index 013a07fd..2debf65c 100644 --- a/addons/voyage/functions/fnc_sm_business_trans_voyage_dismount_condition.sqf +++ b/addons/voyage/functions/fnc_sm_business_trans_voyage_dismount_condition.sqf @@ -1,3 +1,3 @@ #include "..\script_component.hpp" -(_this call EFUNC(legacy,sm_activities_helper_surrenderCondition)) || !(canMove vehicle _this) +(_this call EFUNC(interact,sm_activities_helper_surrenderCondition)) || !(canMove vehicle _this) From ce32750f55e693f4d828e2ba3294577ebec3a48f Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 11:17:45 +0200 Subject: [PATCH 38/55] haha! fix player gestures, finally --- addons/interact/functions/fnc_aceInteractWrapper.sqf | 8 ++++++++ addons/interact/functions/fnc_handleAnimation.sqf | 2 +- addons/legacy/functions/fnc_doCustomActivity.sqf | 8 ++++---- addons/legacy/functions/fnc_initCommonEventhandlers.sqf | 9 --------- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/addons/interact/functions/fnc_aceInteractWrapper.sqf b/addons/interact/functions/fnc_aceInteractWrapper.sqf index 513b3e08..dff383e2 100644 --- a/addons/interact/functions/fnc_aceInteractWrapper.sqf +++ b/addons/interact/functions/fnc_aceInteractWrapper.sqf @@ -44,3 +44,11 @@ ] call EFUNC(legacy,doCustomActivity); } ] call CBA_fnc_addEventHandler; + +["ace_common_playActionNow", { + params ["_unit", "_animation"]; + if (!local _unit) exitWith { + WARNING_2("got playActionNow event %1 non-local unit %2!", _animation _unit); + }; + [_unit, _animation] call FUNC(handleAnimation); +}] call CBA_fnc_addEventHandler; diff --git a/addons/interact/functions/fnc_handleAnimation.sqf b/addons/interact/functions/fnc_handleAnimation.sqf index 4ca4d57b..b69d9aee 100644 --- a/addons/interact/functions/fnc_handleAnimation.sqf +++ b/addons/interact/functions/fnc_handleAnimation.sqf @@ -2,7 +2,7 @@ params ["_unit", "_animation"]; -// systemChat format["_animation: %1", _animation]; +LOG_2("handling unit %1 animation %2", _unit, _animation); if ((toLower _animation) in ["gesturefreeze", "ace_gestures_hold", "ace_gestures_holdstandlowered"]) exitWith { [_unit] call FUNC(handleGestureStop); diff --git a/addons/legacy/functions/fnc_doCustomActivity.sqf b/addons/legacy/functions/fnc_doCustomActivity.sqf index 72017ce4..6f468319 100644 --- a/addons/legacy/functions/fnc_doCustomActivity.sqf +++ b/addons/legacy/functions/fnc_doCustomActivity.sqf @@ -21,16 +21,16 @@ params [ assert(local _civ); private _id = ([_name, call FUNC(uid)] select { _x != ""}) joinString "_"; -INFO_2("civ %1: generated uid %2 for custom activity", _civ, _id); +LOG_2("civ %1: generated uid %2 for custom activity", _civ, _id); private _timeout = 86400*366; // if you run a scenario for over one year, take this bug with love <3. private _endCondition = _endConditionOrTimeout; if (typeName _endConditionOrTimeout == typeName 0) then { - INFO_2("civ %1: custom activity %2 seems to have timeout, will use that", _civ, _id); + LOG_2("civ %1: custom activity %2 has timeout", _civ, _id); _timeout = _endConditionOrTimeout; _endCondition = {false}; } else { - INFO_2("civ %1: custom activity %2 seems to have code, will use that", _civ, _id); + LOG_2("civ %1: custom activity %2 has endCondition", _civ, _id); }; // force the previous custom activity to end @@ -63,7 +63,7 @@ private _endCode = { params ["_civ", "_id"]; if (_civ getVariable [QGVAR(customActivity_id), ""] == _id) then { - INFO_2("civ %1: ending custom activity %2", _civ, _id); + LOG_2("civ %1: ending custom activity %2", _civ, _id); private _doEnd = _civ getVariable [QGVAR(customActivity_doEnd), {}]; private _moreParameters = _civ getVariable [QGVAR(customActivity_parameters), []]; ([_civ] + _moreParameters) call _doEnd; diff --git a/addons/legacy/functions/fnc_initCommonEventhandlers.sqf b/addons/legacy/functions/fnc_initCommonEventhandlers.sqf index c205214d..0566634c 100644 --- a/addons/legacy/functions/fnc_initCommonEventhandlers.sqf +++ b/addons/legacy/functions/fnc_initCommonEventhandlers.sqf @@ -6,15 +6,6 @@ } ] call CBA_fnc_addEventHandler; -["ace_common_playActionNow", { - params ["_unit", "_animation"]; - if (!local _unit) exitWith { - WARNING_2("got playActionNow event %1 non-local unit %2!", _animation _unit); - }; - [_unit, _animation] call FUNC(handleAnimation); -}] call CBA_fnc_addEventHandler; - - [QGVAR(doStop), FUNC(doStop)] call CBA_fnc_addEventHandler; [QGVAR(doCarryOn), FUNC(doCarryOn)] call CBA_fnc_addEventHandler; [QGVAR(doReverse), FUNC(doReverse)] call CBA_fnc_addEventHandler; From 8652f3464b3d3ac3fbea4f69e8f6656ce3ae98cd Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 11:57:40 +0200 Subject: [PATCH 39/55] add backup action to vehicle AND driver --- addons/interact/functions/fnc_addCivInteractions.sqf | 4 ++-- .../interact/functions/fnc_interact_backUpAction.sqf | 10 ++++++++-- .../functions/fnc_interact_backUpCondition.sqf | 7 ++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/addons/interact/functions/fnc_addCivInteractions.sqf b/addons/interact/functions/fnc_addCivInteractions.sqf index c25c2c8d..ce270e7b 100644 --- a/addons/interact/functions/fnc_addCivInteractions.sqf +++ b/addons/interact/functions/fnc_addCivInteractions.sqf @@ -21,7 +21,7 @@ private _carryOnAction = [ } forEach _civClasses; private _backUpAction = [ - QGVAR(carryOnAction), + QGVAR(backUpAction), "back up your vehicle!", "", // icon FUNC(interact_backUpAction), @@ -36,4 +36,4 @@ private _backUpAction = [ _backUpAction, true ] call ace_interact_menu_fnc_addActionToClass; -} forEach _civClasses; +} forEach (_civClasses + ["Car"]); diff --git a/addons/interact/functions/fnc_interact_backUpAction.sqf b/addons/interact/functions/fnc_interact_backUpAction.sqf index b9fc6e0d..d2134d30 100644 --- a/addons/interact/functions/fnc_interact_backUpAction.sqf +++ b/addons/interact/functions/fnc_interact_backUpAction.sqf @@ -1,10 +1,16 @@ #include "..\script_component.hpp" private _veh = vehicle _target; +private _driver = driver _veh; + +if (isNull _driver) exitWith { + ERROR_1("cannot back up vehicle %1 without driver!", _veh); +}; + private _reverseTargetPos = (getPos _veh) vectorAdd ((vectorDir _veh) vectorMultiply -50); [ QGVAR(told_to_reverse), - [_target, _reverseTargetPos], - _target + [_driver, _reverseTargetPos], + _driver ] call CBA_fnc_targetEvent; diff --git a/addons/interact/functions/fnc_interact_backUpCondition.sqf b/addons/interact/functions/fnc_interact_backUpCondition.sqf index 25a41190..8f6154d0 100644 --- a/addons/interact/functions/fnc_interact_backUpCondition.sqf +++ b/addons/interact/functions/fnc_interact_backUpCondition.sqf @@ -1,7 +1,8 @@ #include "..\script_component.hpp" -private _veh = vehicle _target; +private _veh = vehicle _target; // target may be a vehicle itself +private _driver = driver _veh; alive _target && - (_veh != _target) && - (driver _veh == _target) + (_driver isKindOf "Man") && + (_driver getVariable ["grad_civs_primaryTask", ""] != "") From b8bfb65a11efc3dd83f0bcde76cd3c3995d66941 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 11:57:51 +0200 Subject: [PATCH 40/55] fix reverse halt condition --- addons/legacy/functions/fnc_reverse.sqf | 6 ++---- .../legacy/functions/fnc_reverse_internal_stopCondition.sqf | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/legacy/functions/fnc_reverse.sqf b/addons/legacy/functions/fnc_reverse.sqf index 7ad60e71..4461be10 100644 --- a/addons/legacy/functions/fnc_reverse.sqf +++ b/addons/legacy/functions/fnc_reverse.sqf @@ -8,8 +8,6 @@ params [ ["_abortCondition", {false}] ]; -#define TARGET_PRECISION 5 /*precision in meters*/ - scopeName "main"; private _driver = driver _vehicle; @@ -26,7 +24,7 @@ if (effectiveCommander _vehicle == _driver) then { breakOut "main"; }; _ec = (group _driver) createUnit ["C_Soldier_VR_F", [0, 0, 0], [], 0, "NONE"]; - // _ec disableAI "MOVE"; // TODO I saw one jump off th vehicle ... + // _ec disableAI "MOVE"; // TODO I saw one jump off th vehicle ... ["ace_common_hideObjectGlobal", [_ec, true]] call CBA_fnc_serverEvent; _ec assignAsCargo _vehicle; _ec moveInCargo _vehicle; @@ -35,7 +33,7 @@ if (effectiveCommander _vehicle == _driver) then { _ec = (crew _vehicle) select 1; }; - INFO_1("setting EC to %1", typeOf _ec); + LOG_1("setting EC to %1", typeOf _ec); _vehicle setEffectiveCommander _ec; }; diff --git a/addons/legacy/functions/fnc_reverse_internal_stopCondition.sqf b/addons/legacy/functions/fnc_reverse_internal_stopCondition.sqf index 64d94a84..f997394f 100644 --- a/addons/legacy/functions/fnc_reverse_internal_stopCondition.sqf +++ b/addons/legacy/functions/fnc_reverse_internal_stopCondition.sqf @@ -1,4 +1,5 @@ #include "..\script_component.hpp" +#define TARGET_PRECISION 5 /*precision in meters*/ params ["_handle", "_vehicle", "_targetPos", "_tryAtLeastUntil", "", "_abortCondition"]; private _nowDst = (_targetPos distance _vehicle); From 5ca61ea948f3e5ec63f60d70a4320cf8e912edae Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 13:00:53 +0200 Subject: [PATCH 41/55] stop/carryon everywhere * also for footsies and directly on vehicles * add FUNC(legacy,doingCustomActivity) --- addons/interact/XEH_PREP.hpp | 2 + .../functions/fnc_addCivInteractions.sqf | 40 ++++++++++--------- .../fnc_interact_backUpCondition.sqf | 7 ++-- .../functions/fnc_interact_carryOnAction.sqf | 5 ++- .../fnc_interact_carryOnCondition.sqf | 9 +++-- .../functions/fnc_interact_stopAction.sqf | 6 +++ .../functions/fnc_interact_stopCondition.sqf | 8 ++++ addons/legacy/XEH_PREP.hpp | 1 + .../functions/fnc_doingCustomActivity.sqf | 6 +++ 9 files changed, 58 insertions(+), 26 deletions(-) create mode 100644 addons/interact/functions/fnc_interact_stopAction.sqf create mode 100644 addons/interact/functions/fnc_interact_stopCondition.sqf create mode 100644 addons/legacy/functions/fnc_doingCustomActivity.sqf diff --git a/addons/interact/XEH_PREP.hpp b/addons/interact/XEH_PREP.hpp index 4c15cd31..744faa7a 100644 --- a/addons/interact/XEH_PREP.hpp +++ b/addons/interact/XEH_PREP.hpp @@ -13,6 +13,8 @@ PREP(interact_backUpAction); PREP(interact_backUpCondition); PREP(interact_carryOnAction); PREP(interact_carryOnCondition); +PREP(interact_stopAction); +PREP(interact_stopCondition); PREP(isPlayerHonking); PREP(sm_activities_helper_freeCondition); PREP(sm_activities_helper_surrenderCondition); diff --git a/addons/interact/functions/fnc_addCivInteractions.sqf b/addons/interact/functions/fnc_addCivInteractions.sqf index ce270e7b..15bb8c71 100644 --- a/addons/interact/functions/fnc_addCivInteractions.sqf +++ b/addons/interact/functions/fnc_addCivInteractions.sqf @@ -10,30 +10,32 @@ private _carryOnAction = [ FUNC(interact_carryOnCondition) ] call ace_interact_menu_fnc_createAction; -{ - [ - _x, - 0, - ["ACE_MainActions"], - _carryOnAction, - true - ] call ace_interact_menu_fnc_addActionToClass; -} forEach _civClasses; - private _backUpAction = [ QGVAR(backUpAction), - "back up your vehicle!", + "back up your vehicle", "", // icon FUNC(interact_backUpAction), FUNC(interact_backUpCondition) ] call ace_interact_menu_fnc_createAction; + +private _stopAction = [ + QGVAR(stopAction), + "stop", + "", // icon + FUNC(interact_stopAction), + FUNC(interact_stopCondition) +] call ace_interact_menu_fnc_createAction; + { - [ - _x, - 0, - ["ACE_MainActions"], - _backUpAction, - true - ] call ace_interact_menu_fnc_addActionToClass; -} forEach (_civClasses + ["Car"]); + private _action = _x; + { + [ + _x, + 0, + ["ACE_MainActions"], + _action, + true + ] call ace_interact_menu_fnc_addActionToClass; + } forEach (_civClasses + ["Car"]); +} forEach [_stopAction, _backUpAction, _carryOnAction]; diff --git a/addons/interact/functions/fnc_interact_backUpCondition.sqf b/addons/interact/functions/fnc_interact_backUpCondition.sqf index 8f6154d0..0b937467 100644 --- a/addons/interact/functions/fnc_interact_backUpCondition.sqf +++ b/addons/interact/functions/fnc_interact_backUpCondition.sqf @@ -1,8 +1,9 @@ #include "..\script_component.hpp" private _veh = vehicle _target; // target may be a vehicle itself -private _driver = driver _veh; +private _civ = driver _veh; alive _target && - (_driver isKindOf "Man") && - (_driver getVariable ["grad_civs_primaryTask", ""] != "") + (_veh isKindOf "Car") && + (_civ isKindOf "Man") && + (_civ getVariable ["grad_civs_primaryTask", ""] != "") diff --git a/addons/interact/functions/fnc_interact_carryOnAction.sqf b/addons/interact/functions/fnc_interact_carryOnAction.sqf index 1e86e7a8..52ef4edb 100644 --- a/addons/interact/functions/fnc_interact_carryOnAction.sqf +++ b/addons/interact/functions/fnc_interact_carryOnAction.sqf @@ -1,3 +1,6 @@ #include "..\script_component.hpp" -[_target] call EFUNC(legacy,doCarryOn); +private _veh = vehicle _target; // target may be a vehicle itself +private _civ = driver _veh; + +[_civ] call EFUNC(legacy,doCarryOn); diff --git a/addons/interact/functions/fnc_interact_carryOnCondition.sqf b/addons/interact/functions/fnc_interact_carryOnCondition.sqf index c8f89312..37871850 100644 --- a/addons/interact/functions/fnc_interact_carryOnCondition.sqf +++ b/addons/interact/functions/fnc_interact_carryOnCondition.sqf @@ -1,5 +1,8 @@ #include "..\script_component.hpp" -alive _target && - (_target getVariable ["grad_civs_primaryTask", ""] != "") && - (_target getVariable [QEGVAR(legacy,customActivity_id), ""] != "") // TODO isStopped maybe? hmm +private _veh = vehicle _target; // target may be a vehicle itself +private _civ = driver _veh; + +alive _civ && + (_civ isKindOf "Man") && + ([_civ] call EFUNC(legacy,doingCustomActivity)) diff --git a/addons/interact/functions/fnc_interact_stopAction.sqf b/addons/interact/functions/fnc_interact_stopAction.sqf new file mode 100644 index 00000000..a323b4f0 --- /dev/null +++ b/addons/interact/functions/fnc_interact_stopAction.sqf @@ -0,0 +1,6 @@ +#include "..\script_component.hpp" + +private _veh = vehicle _target; // target may be a vehicle itself +private _civ = driver _veh; + +[_civ] call EFUNC(legacy,doStop); diff --git a/addons/interact/functions/fnc_interact_stopCondition.sqf b/addons/interact/functions/fnc_interact_stopCondition.sqf new file mode 100644 index 00000000..0045428f --- /dev/null +++ b/addons/interact/functions/fnc_interact_stopCondition.sqf @@ -0,0 +1,8 @@ +#include "..\script_component.hpp" + +private _veh = vehicle _target; // target may be a vehicle itself +private _civ = driver _veh; + +alive _civ && + (_civ isKindOf "Man") && + (_civ getVariable ["grad_civs_primaryTask", ""] != "") diff --git a/addons/legacy/XEH_PREP.hpp b/addons/legacy/XEH_PREP.hpp index 760c234c..c171fd70 100644 --- a/addons/legacy/XEH_PREP.hpp +++ b/addons/legacy/XEH_PREP.hpp @@ -2,6 +2,7 @@ PREP(compare); PREP(doReverse); PREP(deleteIfDamaged); PREP(doCustomActivity); +PREP(doingCustomActivity); PREP(doStop); PREP(isStopped); diff --git a/addons/legacy/functions/fnc_doingCustomActivity.sqf b/addons/legacy/functions/fnc_doingCustomActivity.sqf new file mode 100644 index 00000000..b6e60518 --- /dev/null +++ b/addons/legacy/functions/fnc_doingCustomActivity.sqf @@ -0,0 +1,6 @@ +#include "..\script_component.hpp" + +params [ + ["_civ", objNull, [objNull]] +]; +(_civ getVariable [QGVAR(customActivity_id), ""]) != ""; From c70590192a99b9d16be4f2ae6d256516374b1938 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 14:59:45 +0200 Subject: [PATCH 42/55] next to fps, show civ count --- addons/diagnostics/XEH_postInit.sqf | 2 +- addons/diagnostics/functions/fnc_showFps.sqf | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/diagnostics/XEH_postInit.sqf b/addons/diagnostics/XEH_postInit.sqf index 0e9a7b38..33853f07 100644 --- a/addons/diagnostics/XEH_postInit.sqf +++ b/addons/diagnostics/XEH_postInit.sqf @@ -24,7 +24,7 @@ if (isServer || CBA_isHeadlessClient) then { [ { if (GVAR(showFps)) then { - [QGVAR(fps), [clientOwner, diag_fps]] call CBA_fnc_globalEvent; + [QGVAR(fps), [clientOwner, diag_fps, count EGVAR(legacy,localCivs)]] call CBA_fnc_globalEvent; }; }, 2, diff --git a/addons/diagnostics/functions/fnc_showFps.sqf b/addons/diagnostics/functions/fnc_showFps.sqf index 99a453c9..a49f409c 100644 --- a/addons/diagnostics/functions/fnc_showFps.sqf +++ b/addons/diagnostics/functions/fnc_showFps.sqf @@ -10,10 +10,11 @@ GVAR(fpsHandler) = [ if (!GVAR(showFps)) exitWith {}; params [ ["_clientId", -1, [0]], - ["_fps", -1, [0]] + ["_fps", -1, [0]], + ["_civCount", 0, [0]] ]; - [GVAR(lastFps), _clientId, _fps] call CBA_fnc_hashSet; + [GVAR(lastFps), _clientId, [_fps, _civCount]] call CBA_fnc_hashSet; } ] call CBA_fnc_addEventHandler; @@ -23,10 +24,10 @@ GVAR(fpsPfh) = [ private _text = "FPS "; [GVAR(lastFps), { - _text = format ["%1 | %2: %3", _text, _key, _value] + _text = format ["%1 | %2: %3 (%4)", _text, _key, _value#0, _value#1] }] call CBA_fnc_hashEachPair; systemChat _text; }, 2, - [] + [] ] call CBA_fnc_addPerFrameHandler; From e6b60e4db21c4f467d2918a03de3046be5ad9ade Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 15:54:00 +0200 Subject: [PATCH 43/55] optional state machine multiplicator --- addons/legacy/functions/fnc_initConfig.sqf | 11 +++++++++++ addons/legacy/functions/fnc_serverLoop.sqf | 13 ++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/addons/legacy/functions/fnc_initConfig.sqf b/addons/legacy/functions/fnc_initConfig.sqf index a0cda0d8..67108b81 100644 --- a/addons/legacy/functions/fnc_initConfig.sqf +++ b/addons/legacy/functions/fnc_initConfig.sqf @@ -15,6 +15,17 @@ private _settingsGroup = ["GRAD Civs", "2) basics"]; false ] call CBA_fnc_addSetting; +[ + QGVAR(smMultiplicator), + "SLIDER", + "CBA state machine speed multiplicator", + _settingsGroup, + [1, 10, 1, 0], + true, + {}, + false +] call CBA_fnc_addSetting; + [ QGVAR(minFps), "SLIDER", diff --git a/addons/legacy/functions/fnc_serverLoop.sqf b/addons/legacy/functions/fnc_serverLoop.sqf index 274700b8..cea1969a 100644 --- a/addons/legacy/functions/fnc_serverLoop.sqf +++ b/addons/legacy/functions/fnc_serverLoop.sqf @@ -2,6 +2,12 @@ ASSERT_SERVER(""); +ISNILS(GVAR(efIDs), []); +for "_i" from 2 to GVAR(smMultiplicator) do { + GVAR(efIDs) pushBack (addMissionEventHandler ["EachFrame", {call cba_statemachine_fnc_clockwork}]); +}; +INFO_1("CBA statemachines are running %1 more ticks per frame now", count GVAR(efIDs)); + private _mainLoop = { params ["_args", "_handle"]; if (!isGameFocused || isGamePaused) exitWith {}; @@ -12,7 +18,12 @@ private _mainLoop = { }; if (isServer && {count ((entities "HeadlessClient_F") arrayIntersect allPlayers) > 0}) exitWith { INFO("HCs are available, will not spawn any more civs"); - [_handle] call CBA_fnc_removePerFrameHandler + [_handle] call CBA_fnc_removePerFrameHandler; + { + removeMissionEventHandler ["EachFrame", _x]; + } forEach GVAR(efIDs); + GVAR(efIDs) = []; + INFO("CBA statemachines are running at default tick rate again"); }; [] call FUNC(spawnPass); From 527afb2cf4e9c62758cf325a46423c245cd13ad0 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 16:15:34 +0200 Subject: [PATCH 44/55] fix showOnMap for MP --- .../diagnostics/functions/fnc_showOnMap.sqf | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/addons/diagnostics/functions/fnc_showOnMap.sqf b/addons/diagnostics/functions/fnc_showOnMap.sqf index 53c65b8b..14c1162f 100644 --- a/addons/diagnostics/functions/fnc_showOnMap.sqf +++ b/addons/diagnostics/functions/fnc_showOnMap.sqf @@ -1,18 +1,24 @@ #include "..\script_component.hpp" -GVAR(DRAWUNITSEH) = ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", { - if (!GVAR(showOnMap)) exitWith {}; +[ + {!isNull (findDisplay 12)}, + { + GVAR(DRAWUNITSEH) = ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", { + if (!GVAR(showOnMap)) exitWith {}; - private _civs = [] call EFUNC(legacy,getGlobalCivs); - private _civsInCarDrivers = _civs select { - private _vec = vehicle _x; - _vec != _x && driver _vec == _x - }; - private _civsOnFoot = _civs select { - vehicle _x == _x - }; + private _civs = [] call EFUNC(legacy,getGlobalCivs); + private _civsInCarDrivers = _civs select { + private _vec = vehicle _x; + _vec != _x && driver _vec == _x + }; + private _civsOnFoot = _civs select { + vehicle _x == _x + }; - [_this select 0, _civsOnFoot, "iconMan"] call FUNC(showOnMap_drawCivs); - [_this select 0, _civsInCarDrivers, "iconCar"] call FUNC(showOnMap_drawCivs); - //one day: iconHelicopter -}]; + [_this select 0, _civsOnFoot, "iconMan"] call FUNC(showOnMap_drawCivs); + [_this select 0, _civsInCarDrivers, "iconCar"] call FUNC(showOnMap_drawCivs); + //one day: iconHelicopter + }]; + }, + [] +] call CBA_fnc_waitUntilAndExecute; From 15fba5560e022232d510fec5a97e3e7e629ad982 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 20:01:29 +0200 Subject: [PATCH 45/55] spawn control refactor * add config for minServerFps * HC spawn passes are triggered by the server now * majjjor cleanup of the spawn logic --- .../functions/fnc_showOnMap_drawCivs.sqf | 4 +- addons/legacy/XEH_PREP.hpp | 7 +- addons/legacy/XEH_postInit.sqf | 5 +- .../functions/fnc_adoptAbandonedCivs.sqf | 15 ++++ .../legacy/functions/fnc_cleanupLocalCivs.sqf | 18 ++++ .../legacy/functions/fnc_globalSpawnPass.sqf | 19 +++++ addons/legacy/functions/fnc_initConfig.sqf | 17 +++- addons/legacy/functions/fnc_initHCs.sqf | 34 +++++--- ...c_spawnPass.sqf => fnc_localSpawnPass.sqf} | 4 +- .../functions/fnc_overclockStateMachines.sqf | 7 ++ addons/legacy/functions/fnc_serverLoop.sqf | 82 ------------------- addons/main/script_component.hpp | 1 + addons/patrol/XEH_postInit.sqf | 2 +- addons/residents/XEH_postInit.sqf | 2 +- addons/transit/XEH_postInit.sqf | 2 +- addons/voyage/XEH_postInit.sqf | 2 +- 16 files changed, 112 insertions(+), 109 deletions(-) create mode 100644 addons/legacy/functions/fnc_adoptAbandonedCivs.sqf create mode 100644 addons/legacy/functions/fnc_cleanupLocalCivs.sqf create mode 100644 addons/legacy/functions/fnc_globalSpawnPass.sqf rename addons/legacy/functions/{fnc_spawnPass.sqf => fnc_localSpawnPass.sqf} (87%) create mode 100644 addons/legacy/functions/fnc_overclockStateMachines.sqf delete mode 100644 addons/legacy/functions/fnc_serverLoop.sqf diff --git a/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf b/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf index af891008..d99679a8 100644 --- a/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf +++ b/addons/diagnostics/functions/fnc_showOnMap_drawCivs.sqf @@ -7,7 +7,6 @@ params [ ]; { - private _bus = ""; if (local _x) then { _bus = [_x, "business"] call EFUNC(common,civGetState); // works local only :sad: @@ -16,5 +15,4 @@ params [ }; }; _map drawIcon [_icon, [0.4,0,0.5,0.5], getPos _x, 24, 24, getDir _x, _bus, 0, 0.03, 'TahomaB', 'right']; - false -} count _units; +} forEach _units; diff --git a/addons/legacy/XEH_PREP.hpp b/addons/legacy/XEH_PREP.hpp index c171fd70..22b98363 100644 --- a/addons/legacy/XEH_PREP.hpp +++ b/addons/legacy/XEH_PREP.hpp @@ -1,3 +1,4 @@ +PREP(adoptAbandonedCivs); PREP(compare); PREP(doReverse); PREP(deleteIfDamaged); @@ -26,13 +27,13 @@ PREP(initConfig); PREP(initHCs); PREP(isInDistanceFromOtherPlayers); PREP(isInHouse); +PREP(overclockStateMachines); PREP(reverse_abort); PREP(reverse_internal_end); PREP(reverse_internal_pfh); PREP(reverse_internal_stopCondition); // PREP(reverse.spec); PREP(reverse); -PREP(serverLoop); PREP(sm_activities); PREP(sm_activities_state_asOrdered_enter); PREP(sm_activities_state_asOrdered_exit); @@ -58,5 +59,7 @@ PREP(sm_panic_trans_hide_hidden_condition); PREP(sm_panic_trans_hide_hidden_handler); PREP(spawnCivilianGroup); PREP(spawnCivilian); -PREP(spawnPass); +PREP(localSpawnPass); +PREP(globalSpawnPass); PREP(uid); +PREP(cleanupLocalCivs); diff --git a/addons/legacy/XEH_postInit.sqf b/addons/legacy/XEH_postInit.sqf index f6dc068c..3af3ae68 100644 --- a/addons/legacy/XEH_postInit.sqf +++ b/addons/legacy/XEH_postInit.sqf @@ -5,4 +5,7 @@ if (!(EGVAR(main,enabled))) exitWith {}; ISNILS(GVAR(EXITON), {false}); [] call FUNC(initCommonEventhandlers); -[] call FUNC(initHCs); + +if (isServer || CBA_isHeadlessClient) then { + [] call FUNC(initHCs); +}; diff --git a/addons/legacy/functions/fnc_adoptAbandonedCivs.sqf b/addons/legacy/functions/fnc_adoptAbandonedCivs.sqf new file mode 100644 index 00000000..513b8348 --- /dev/null +++ b/addons/legacy/functions/fnc_adoptAbandonedCivs.sqf @@ -0,0 +1,15 @@ +#include "..\script_component.hpp" + +/* + * if a civ gets moved to the HC for some reason (for example by acex_headless) take care to grab them + * this *should not happen, as we're setting the acex exlusion var, but you never know... + */ + +private _civClasses = call EFUNC(common,config_getCivClasses); +private _allCivs = entities [_civClasses, [], true, true]; +private _myCivs = _allCivs select { local _x && (_x getVariable ["grad_civs_primaryTask", ""] != "")}; +private _orphanedCivs = _myCivs - GVAR(localCivs); +if (count _orphanedCivs > 0) then { + WARNING_1("%1 orphaned civs - putting them into my own array. this should not happen.", count _orphanedCivs); + GVAR(localCivs) = GVAR(localCivs) + _orphanedCivs; +}; diff --git a/addons/legacy/functions/fnc_cleanupLocalCivs.sqf b/addons/legacy/functions/fnc_cleanupLocalCivs.sqf new file mode 100644 index 00000000..6b67d87a --- /dev/null +++ b/addons/legacy/functions/fnc_cleanupLocalCivs.sqf @@ -0,0 +1,18 @@ +#include "..\script_component.hpp" +// clean up objNull references in civs array - that happens for example when a zeus person deletes them +{ + GVAR(localCivs) = GVAR(localCivs) select { + // NOTE: do not handle `alive` here, we've got a transition & state for proper disposal of dead civilians + if (isNull _x) then { + INFO_1("abandoning civilian %1 they have become NULL (deleted?)", _x); + false + } else { + if (local _x) then { + true + } else { + WARNING_1("abandoning civilian %1 as they are not local any more", _x); + false + }; + }; + }; +} diff --git a/addons/legacy/functions/fnc_globalSpawnPass.sqf b/addons/legacy/functions/fnc_globalSpawnPass.sqf new file mode 100644 index 00000000..6794c519 --- /dev/null +++ b/addons/legacy/functions/fnc_globalSpawnPass.sqf @@ -0,0 +1,19 @@ +#include "..\script_component.hpp" + +params ["", "_handle"]; + +if (!isGameFocused || isGamePaused) exitWith {}; +if (call GVAR(EXITON)) exitWith { + INFO_1("shutting down because %1 returned true", QGVAR(EXITON)); + [_handle] call CBA_fnc_removePerFrameHandler +}; +if (diag_fps < GVAR(minServerFps)) exitWith { + LOG_2("Server fps %1 is below minimum of %2 - skipping spawn", diag_fps, GVAR(minServerFps)); +}; + +private _hcs = (entities "HeadlessClient_F") arrayIntersect allPlayers; +if (count _hcs > 0) then { + [QGVAR(globalSpawn), [], _hcs] call CBA_fnc_targetEvent; +} else { + [QGVAR(globalSpawn), []] call CBA_fnc_serverEvent; +}; diff --git a/addons/legacy/functions/fnc_initConfig.sqf b/addons/legacy/functions/fnc_initConfig.sqf index 67108b81..700dfe17 100644 --- a/addons/legacy/functions/fnc_initConfig.sqf +++ b/addons/legacy/functions/fnc_initConfig.sqf @@ -18,7 +18,7 @@ private _settingsGroup = ["GRAD Civs", "2) basics"]; [ QGVAR(smMultiplicator), "SLIDER", - "CBA state machine speed multiplicator", + "CBA state machine speed multiplicator on HCs", _settingsGroup, [1, 10, 1, 0], true, @@ -27,11 +27,22 @@ private _settingsGroup = ["GRAD Civs", "2) basics"]; ] call CBA_fnc_addSetting; [ - QGVAR(minFps), + QGVAR(minCivOwnerFps), "SLIDER", "Keep civ owner fps over [1/s]", _settingsGroup, - [10, 50, 35, 0], + [10, 50, 30, 0], + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(minServerFps), + "SLIDER", + "Keep server fps over [1/s]", + _settingsGroup, + [10, 50, 40, 0], true, {}, false diff --git a/addons/legacy/functions/fnc_initHCs.sqf b/addons/legacy/functions/fnc_initHCs.sqf index bfce92af..96a73434 100644 --- a/addons/legacy/functions/fnc_initHCs.sqf +++ b/addons/legacy/functions/fnc_initHCs.sqf @@ -1,18 +1,28 @@ #include "..\script_component.hpp" -if (isServer || CBA_isHeadlessClient) then { - INFO("Server/HC init running..."); +INFO("Server/HC init running..."); - if ( - (GVAR(cleanupCorpses)) && - !(([missionConfigFile, "corpseManagerMode", -1] call BIS_fnc_returnConfigEntry) in [1, 3]) - ) then { - WARNING("'cleanupCorpses' flag is set, but 'corpseManagerMode' in description.ext is switched off!"); - }; +if ( + (GVAR(cleanupCorpses)) && + !(([missionConfigFile, "corpseManagerMode", -1] call BIS_fnc_returnConfigEntry) in [1, 3]) +) then { + WARNING("'cleanupCorpses' flag is set, but 'corpseManagerMode' in description.ext is switched off!"); +}; + +GVAR(localCivs) = []; +EGVAR(common,stateMachines) = false call CBA_fnc_createNamespace; + +[] call FUNC(sm_lifecycle); - GVAR(localCivs) = []; - EGVAR(common,stateMachines) = false call CBA_fnc_createNamespace; +GVAR(globalSpawnHandler) = [QGVAR(globalSpawn), FUNC(localSpawnPass)] call CBA_fnc_addEventHandler; + +[FUNC(cleanupLocalCivs), 10, []] call CBA_fnc_addPerFrameHandler; + +if (isServer) then { + [FUNC(globalSpawnPass), 2, []] call CBA_fnc_addPerFrameHandler; +}; - [] call FUNC(sm_lifecycle); - [] call FUNC(serverLoop); +if (CBA_isHeadlessClient) then { + call FUNC(overclockStateMachines); + [FUNC(adoptAbandonedCivs), 30, []] call CBA_fnc_addPerFrameHandler; }; diff --git a/addons/legacy/functions/fnc_spawnPass.sqf b/addons/legacy/functions/fnc_localSpawnPass.sqf similarity index 87% rename from addons/legacy/functions/fnc_spawnPass.sqf rename to addons/legacy/functions/fnc_localSpawnPass.sqf index 11256632..b9b0f2e2 100644 --- a/addons/legacy/functions/fnc_spawnPass.sqf +++ b/addons/legacy/functions/fnc_localSpawnPass.sqf @@ -5,10 +5,10 @@ if ((ALL_HUMAN_PLAYERS isEqualTo []) && (GVAR(spawnOnlyWithPlayers))) exitWith { }; private _minCivUpdateTime = GVAR(minCivUpdateTime); -private _minFps = GVAR(minFps); +private _minFps = GVAR(minCivOwnerFps); private _fps = diag_fps; if (_fps < _minFps) exitWith {LOG_2("not spawning additional civs: less FPS than required (%1/%2)", _fps, _minFps)}; if ((_fps * _minCivUpdateTime) < (count GVAR(localCivs))) exitWith {LOG_3("not spawning additional civs: cannot guarantee update times less than %1 for %2 civs with %3 fps", _minCivUpdateTime, count GVAR(localCivs), _fps)}; -[QGVAR(spawnAllowed), []] call CBA_fnc_localEvent; +[QGVAR(localSpawn), []] call CBA_fnc_localEvent; diff --git a/addons/legacy/functions/fnc_overclockStateMachines.sqf b/addons/legacy/functions/fnc_overclockStateMachines.sqf new file mode 100644 index 00000000..ddbaf0aa --- /dev/null +++ b/addons/legacy/functions/fnc_overclockStateMachines.sqf @@ -0,0 +1,7 @@ +#include "..\script_component.hpp" + +ISNILS(GVAR(efIDs), []); +for "_i" from 2 to GVAR(smMultiplicator) do { + GVAR(efIDs) pushBack (addMissionEventHandler ["EachFrame", {call cba_statemachine_fnc_clockwork}]); +}; +INFO_1("CBA statemachines are running %1 more ticks per frame now", count GVAR(efIDs)); diff --git a/addons/legacy/functions/fnc_serverLoop.sqf b/addons/legacy/functions/fnc_serverLoop.sqf deleted file mode 100644 index cea1969a..00000000 --- a/addons/legacy/functions/fnc_serverLoop.sqf +++ /dev/null @@ -1,82 +0,0 @@ -#include "..\script_component.hpp" - -ASSERT_SERVER(""); - -ISNILS(GVAR(efIDs), []); -for "_i" from 2 to GVAR(smMultiplicator) do { - GVAR(efIDs) pushBack (addMissionEventHandler ["EachFrame", {call cba_statemachine_fnc_clockwork}]); -}; -INFO_1("CBA statemachines are running %1 more ticks per frame now", count GVAR(efIDs)); - -private _mainLoop = { - params ["_args", "_handle"]; - if (!isGameFocused || isGamePaused) exitWith {}; - - if (call GVAR(EXITON)) exitWith { - INFO("exiting because GRAD_CIVS_EXITON returned true"); - [_handle] call CBA_fnc_removePerFrameHandler - }; - if (isServer && {count ((entities "HeadlessClient_F") arrayIntersect allPlayers) > 0}) exitWith { - INFO("HCs are available, will not spawn any more civs"); - [_handle] call CBA_fnc_removePerFrameHandler; - { - removeMissionEventHandler ["EachFrame", _x]; - } forEach GVAR(efIDs); - GVAR(efIDs) = []; - INFO("CBA statemachines are running at default tick rate again"); - }; - - [] call FUNC(spawnPass); -}; - -// wait a bit until the main loop starts. that way, exclusion zone trigger inits have a chance to run -[ - { - private _mainLoop = _this#0; - GVAR(mainLoopHandle) = [_mainLoop, 2, []] call CBA_fnc_addPerFrameHandler; - }, - [_mainLoop], - 10 -] call CBA_fnc_waitAndExecute; - -// clean up objNull references in civs array - that happens for example when a zeus person deletes them -[ - { - GVAR(localCivs) = GVAR(localCivs) select { - // NOTE: do not handle `alive` here, we've got a transition & state for proper disposal of dead civilians - if (isNull _x) then { - INFO_1("abandoning civilian they have become NULL (deleted?)", _x); - false - } else { - if (local _x) then { - true - } else { - WARNING_1("abandoning civilian %1 as they are not local any more", _x); - false - }; - }; - }; - }, - 5, - [] -] call CBA_fnc_addPerFrameHandler; - -/* - * if a civ gets moved to the HC for some reason (for example by acex_headless) take care to grab them - */ -if (CBA_isHeadlessClient) then { - [ - { - private _civClasses = call EFUNC(common,config_getCivClasses); - private _allCivs = entities [_civClasses, [], true, true]; - private _myCivs = _allCivs select { local _x && (_x getVariable ["grad_civs_primaryTask", ""] != "")}; - private _orphanedCivs = _myCivs - GVAR(localCivs); - if (count _orphanedCivs > 0) then { - INFO_1("%1 orphaned civs - putting them into my own array", count _orphanedCivs); - GVAR(localCivs) = GVAR(localCivs) + _orphanedCivs; - }; - }, - 30, - [] - ] call CBA_fnc_addPerFrameHandler; -}; diff --git a/addons/main/script_component.hpp b/addons/main/script_component.hpp index ed5295d7..cccede0e 100644 --- a/addons/main/script_component.hpp +++ b/addons/main/script_component.hpp @@ -1,6 +1,7 @@ #define COMPONENT main #include "\z\grad_civs\addons\main\script_mod.hpp" +#define DEBUG_ENABLED_MAIN // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE diff --git a/addons/patrol/XEH_postInit.sqf b/addons/patrol/XEH_postInit.sqf index ce824d36..ee27bb25 100644 --- a/addons/patrol/XEH_postInit.sqf +++ b/addons/patrol/XEH_postInit.sqf @@ -4,7 +4,7 @@ if (!(EGVAR(main,enabled))) exitWith {}; if (isServer || CBA_isHeadlessClient) then { [ - QEGVAR(legacy,spawnAllowed), + QEGVAR(legacy,localSpawn), { ISNILS(GVAR(maxCivsOnFoot), GVAR(maxCivsOnFoot)); if ((count (["patrol"] call EFUNC(legacy,getGlobalCivs))) < GVAR(maxCivsOnFoot)) then { diff --git a/addons/residents/XEH_postInit.sqf b/addons/residents/XEH_postInit.sqf index 6f656419..b5c72c82 100644 --- a/addons/residents/XEH_postInit.sqf +++ b/addons/residents/XEH_postInit.sqf @@ -4,7 +4,7 @@ if (!(EGVAR(main,enabled))) exitWith {}; if (isServer || CBA_isHeadlessClient) then { [ - QEGVAR(legacy,spawnAllowed), + QEGVAR(legacy,localSpawn), { ISNILS(GVAR(maxCivsResidents), GVAR(maxCivsResidents)); if ((count (["reside"] call EFUNC(legacy,getGlobalCivs))) < GVAR(maxCivsResidents)) then { diff --git a/addons/transit/XEH_postInit.sqf b/addons/transit/XEH_postInit.sqf index 76a1a7e2..9992de01 100644 --- a/addons/transit/XEH_postInit.sqf +++ b/addons/transit/XEH_postInit.sqf @@ -4,7 +4,7 @@ if (!(EGVAR(main,enabled))) exitWith {}; if (isServer || CBA_isHeadlessClient) then { [ - QEGVAR(legacy,spawnAllowed), + QEGVAR(legacy,localSpawn), { _maxVehiclesInTransit = GVAR(maxVehiclesInTransit); if ((count (["transit"] call EFUNC(cars,getGlobalVehicles))) < _maxVehiclesInTransit) then { diff --git a/addons/voyage/XEH_postInit.sqf b/addons/voyage/XEH_postInit.sqf index 1c189fee..2acaaaf8 100644 --- a/addons/voyage/XEH_postInit.sqf +++ b/addons/voyage/XEH_postInit.sqf @@ -4,7 +4,7 @@ if (!(EGVAR(main,enabled))) exitWith {}; if (isServer || CBA_isHeadlessClient) then { [ - QEGVAR(legacy,spawnAllowed), + QEGVAR(legacy,localSpawn), { private _maxCivsInVehicles = GVAR(maxCivsInVehicles); if ((count (["voyage"] call EFUNC(legacy,getGlobalCivs))) < _maxCivsInVehicles) then { From 7522b24e5e74fdee9fd581d06f6271faa7ed9e33 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 21:32:28 +0200 Subject: [PATCH 46/55] facepalmierung: on server/HCs, dont check for !isgamefocused --- addons/diagnostics/XEH_postInit.sqf | 2 +- addons/diagnostics/functions/fnc_showInfoLine.sqf | 2 +- addons/legacy/functions/fnc_globalSpawnPass.sqf | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/diagnostics/XEH_postInit.sqf b/addons/diagnostics/XEH_postInit.sqf index 33853f07..393ebdab 100644 --- a/addons/diagnostics/XEH_postInit.sqf +++ b/addons/diagnostics/XEH_postInit.sqf @@ -14,7 +14,7 @@ if (hasInterface) then { if (isServer || CBA_isHeadlessClient) then { GVAR(debugLoopHandle) = [{ params ["_args", "_handle"]; - if (!isGameFocused || isGamePaused) exitWith {}; + if (hasInterface && (!isGameFocused || isGamePaused)) exitWith {}; if (call EGVAR(legacy,EXITON)) exitWith {[_handle] call CBA_fnc_removePerFrameHandler}; if (GVAR(showInfoLine)) then { { _x call FUNC(updateInfoLine); } forEach EGVAR(legacy,localCivs); diff --git a/addons/diagnostics/functions/fnc_showInfoLine.sqf b/addons/diagnostics/functions/fnc_showInfoLine.sqf index a5d5edb9..319a52df 100644 --- a/addons/diagnostics/functions/fnc_showInfoLine.sqf +++ b/addons/diagnostics/functions/fnc_showInfoLine.sqf @@ -36,7 +36,7 @@ ISNILS(GVAR(actionIds), []); _text = ""; switch (GVAR(civStateFormat)) do { - case 0: { _text =_x getVariable [QGVAR(infoLine),""]; }; + case 0: { _text = _x getVariable [QGVAR(infoLine),""]; }; case 1: { _text = format["%1 | speedmode: %2 %3", _x, speedMode _x, if (leader _x == _x) then {"(is leader)"} else {""}]; }; case 2: { _text = format["%1 | %2 guns point at him", _x, _x getVariable ["grad_civs_isPointedAtCount", 0]]}; case 3: { _text = format["%1 | is local at %2", _x, _x getVariable [QGVAR(localAt), 0]]}; diff --git a/addons/legacy/functions/fnc_globalSpawnPass.sqf b/addons/legacy/functions/fnc_globalSpawnPass.sqf index 6794c519..8e06dfbc 100644 --- a/addons/legacy/functions/fnc_globalSpawnPass.sqf +++ b/addons/legacy/functions/fnc_globalSpawnPass.sqf @@ -2,7 +2,7 @@ params ["", "_handle"]; -if (!isGameFocused || isGamePaused) exitWith {}; +if (hasInterface && (!isGameFocused || isGamePaused)) exitWith {}; if (call GVAR(EXITON)) exitWith { INFO_1("shutting down because %1 returned true", QGVAR(EXITON)); [_handle] call CBA_fnc_removePerFrameHandler @@ -11,6 +11,8 @@ if (diag_fps < GVAR(minServerFps)) exitWith { LOG_2("Server fps %1 is below minimum of %2 - skipping spawn", diag_fps, GVAR(minServerFps)); }; +if ((count (entities "HeadlessClient_F") > 0) && CBA_missionTime < 10) exitWith {}; // wait a few seconds for HCs to connect + private _hcs = (entities "HeadlessClient_F") arrayIntersect allPlayers; if (count _hcs > 0) then { [QGVAR(globalSpawn), [], _hcs] call CBA_fnc_targetEvent; From d7049f6fa5fad0efa56b0c234d18ed3745513a91 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 21:41:35 +0200 Subject: [PATCH 47/55] "grad_civs_isPointedAtCount" => QEGVAR(pointedAtCount) --- addons/diagnostics/functions/fnc_showInfoLine.sqf | 2 +- .../functions/fnc_addInteractEventHandlers.sqf | 8 ++++---- .../fnc_sm_activities_helper_freeCondition.sqf | 2 +- ...fnc_sm_activities_helper_surrenderCondition.sqf | 2 +- addons/mimikry/functions/fnc_addEventHandlers.sqf | 14 ++++++++------ 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/addons/diagnostics/functions/fnc_showInfoLine.sqf b/addons/diagnostics/functions/fnc_showInfoLine.sqf index 319a52df..9c132d60 100644 --- a/addons/diagnostics/functions/fnc_showInfoLine.sqf +++ b/addons/diagnostics/functions/fnc_showInfoLine.sqf @@ -38,7 +38,7 @@ ISNILS(GVAR(actionIds), []); switch (GVAR(civStateFormat)) do { case 0: { _text = _x getVariable [QGVAR(infoLine),""]; }; case 1: { _text = format["%1 | speedmode: %2 %3", _x, speedMode _x, if (leader _x == _x) then {"(is leader)"} else {""}]; }; - case 2: { _text = format["%1 | %2 guns point at him", _x, _x getVariable ["grad_civs_isPointedAtCount", 0]]}; + case 2: { _text = format["%1 | %2 guns point at him", _x, _x getVariable [QEGVAR(interact,pointedAtCount), 0]]}; case 3: { _text = format["%1 | is local at %2", _x, _x getVariable [QGVAR(localAt), 0]]}; case 4: { _text = format["%1 | %2 %3 %4 | stopped: %5, unitReady: %6", _x, behaviour _x, combatMode _x, speedMode _x, stopped _x, unitReady _x]}; case 5: { _text = format["%1 | state times: %2", _x, _x call _filterTimeVars]}; diff --git a/addons/interact/functions/fnc_addInteractEventHandlers.sqf b/addons/interact/functions/fnc_addInteractEventHandlers.sqf index f6ae0677..fcb4aed0 100644 --- a/addons/interact/functions/fnc_addInteractEventHandlers.sqf +++ b/addons/interact/functions/fnc_addInteractEventHandlers.sqf @@ -3,17 +3,17 @@ [QGVAR(pointed_at_inc), { params ["_civ"]; if (_civ == ACE_player) exitWith {}; - private _currentCount = _civ getVariable ["grad_civs_isPointedAtCount", 0]; - _civ setVariable ["grad_civs_isPointedAtCount", _currentCount + 1]; + private _currentCount = _civ getVariable [QGVAR(pointedAtCount), 0]; + _civ setVariable [QGVAR(pointedAtCount), _currentCount + 1]; }] call CBA_fnc_addEventHandler; [QGVAR(pointed_at_dec), { params ["_civ"]; if (_civ == ACE_player) exitWith {}; - private _currentCount = _civ getVariable ["grad_civs_isPointedAtCount", 0]; + private _currentCount = _civ getVariable [QGVAR(pointedAtCount), 0]; assert(_currentCount > 0); if (_currentCount < 1) then {_currentCount = 1;}; - _civ setVariable ["grad_civs_isPointedAtCount", _currentCount - 1, true]; + _civ setVariable [QGVAR(pointedAtCount), _currentCount - 1, true]; }] call CBA_fnc_addEventHandler; [ diff --git a/addons/interact/functions/fnc_sm_activities_helper_freeCondition.sqf b/addons/interact/functions/fnc_sm_activities_helper_freeCondition.sqf index 04ef9231..9f3439f4 100644 --- a/addons/interact/functions/fnc_sm_activities_helper_freeCondition.sqf +++ b/addons/interact/functions/fnc_sm_activities_helper_freeCondition.sqf @@ -1,4 +1,4 @@ #include "..\script_component.hpp" -(_this getVariable ["grad_civs_isPointedAtCount", 0] <= 0) && +(_this getVariable [QGVAR(pointedAtCount), 0] <= 0) && ((CBA_missionTime - (_this getVariable ["grad_civs_surrenderTime", 0])) > 3) diff --git a/addons/interact/functions/fnc_sm_activities_helper_surrenderCondition.sqf b/addons/interact/functions/fnc_sm_activities_helper_surrenderCondition.sqf index a85e8968..e527c577 100644 --- a/addons/interact/functions/fnc_sm_activities_helper_surrenderCondition.sqf +++ b/addons/interact/functions/fnc_sm_activities_helper_surrenderCondition.sqf @@ -1,6 +1,6 @@ #include "..\script_component.hpp" -private _pointingCount = _this getVariable ["grad_civs_isPointedAtCount", 0]; +private _pointingCount = _this getVariable [QGVAR(pointedAtCount), 0]; private _recklessness = _this getVariable ["grad_civs_recklessness", 5]; // goes from 0…10 as gaussian distribution // recklessness gets reduced somewhat by the number of people pointing their weapons diff --git a/addons/mimikry/functions/fnc_addEventHandlers.sqf b/addons/mimikry/functions/fnc_addEventHandlers.sqf index 1f620362..44e951d9 100644 --- a/addons/mimikry/functions/fnc_addEventHandlers.sqf +++ b/addons/mimikry/functions/fnc_addEventHandlers.sqf @@ -25,8 +25,8 @@ params ["_civ"]; if (_civ != ACE_player) exitWith {}; - private _newCount = (_civ getVariable ["grad_civs_isPointedAtCount", 0]) + 1; - _civ setVariable ["grad_civs_isPointedAtCount", _newCount]; + private _newCount = (_civ getVariable [QGVAR(pointedAtCount), 0]) + 1; + _civ setVariable [QGVAR(pointedAtCount), _newCount]; private _message = format["you're being pointed at with %1 guns", _newCount]; [_message] call FUNC(showCivHint); @@ -36,10 +36,12 @@ params ["_civ"]; if (_civ != ACE_player) exitWith {}; - private _newCount = (_civ getVariable ["grad_civs_isPointedAtCount", 0]) - 1; - assert(_newCount >= 0); - if (_newCount < 0) then {_newCount = 0;}; - _civ setVariable ["grad_civs_isPointedAtCount", _newCount]; + private _newCount = (_civ getVariable [QGVAR(pointedAtCount), 0]) - 1; + if (_newCount < 0) then { + _newCount = 0; + WARNING("pointed at underrun!"); + }; + _civ setVariable [QGVAR(pointedAtCount), _newCount]; private _message = format["you're being pointed at with %1 guns", _newCount]; if (_newCount == 0) then { From 31033e0377a99ba9511e482319c394b45c68751e Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 21:53:45 +0200 Subject: [PATCH 48/55] make weapon pointing global for now. --- addons/interact/functions/fnc_addInteractEventHandlers.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/interact/functions/fnc_addInteractEventHandlers.sqf b/addons/interact/functions/fnc_addInteractEventHandlers.sqf index fcb4aed0..cd0175ea 100644 --- a/addons/interact/functions/fnc_addInteractEventHandlers.sqf +++ b/addons/interact/functions/fnc_addInteractEventHandlers.sqf @@ -4,7 +4,7 @@ params ["_civ"]; if (_civ == ACE_player) exitWith {}; private _currentCount = _civ getVariable [QGVAR(pointedAtCount), 0]; - _civ setVariable [QGVAR(pointedAtCount), _currentCount + 1]; + _civ setVariable [QGVAR(pointedAtCount), _currentCount + 1, true]; }] call CBA_fnc_addEventHandler; [QGVAR(pointed_at_dec), { From 7cff9a4ffb3ce7467cedbc8e097327ca27eb7292 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 26 Jul 2020 22:02:49 +0200 Subject: [PATCH 49/55] mehr facepalm. fix interactions on non-local --- addons/interact/XEH_postInit.sqf | 4 ++-- addons/interact/functions/fnc_addInteractEventHandlers.sqf | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/interact/XEH_postInit.sqf b/addons/interact/XEH_postInit.sqf index b00d5e19..a9e1534b 100644 --- a/addons/interact/XEH_postInit.sqf +++ b/addons/interact/XEH_postInit.sqf @@ -4,10 +4,8 @@ if (!(EGVAR(main,enabled))) exitWith {}; if (hasInterface) then { call FUNC(aceInteractWrapper); - call FUNC(addInteractEventHandlers); call FUNC(addCivInteractions); - [{ if (!isGameFocused || isGamePaused) exitWith {}; [] call FUNC(checkWeaponOnCivilianPointer); @@ -23,6 +21,8 @@ if (hasInterface) then { }; +[] call FUNC(addInteractEventHandlers); + if (isServer || CBA_isHeadlessClient) then { ["activities", ["act_business"], FUNC(sm_activities)] call EFUNC(common,augmentStateMachine); }; diff --git a/addons/interact/functions/fnc_addInteractEventHandlers.sqf b/addons/interact/functions/fnc_addInteractEventHandlers.sqf index cd0175ea..637936e2 100644 --- a/addons/interact/functions/fnc_addInteractEventHandlers.sqf +++ b/addons/interact/functions/fnc_addInteractEventHandlers.sqf @@ -61,5 +61,6 @@ ["_target", objNull, [objNull]], ["_reverseTargetPos", [0, 0, 0], [[]]] ]; + if (_target == ACE_player) exitWith {}; [_target, _reverseTargetPos] call EFUNC(legacy,doReverse); }] call CBA_fnc_addEventHandler; From 78584269b355f0b588bb8525893af36d78078f80 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Mon, 27 Jul 2020 08:46:02 +0200 Subject: [PATCH 50/55] define DEBUG_ENABLED_MAIN in the correct place, ugh --- addons/main/script_component.hpp | 1 - addons/main/script_mod.hpp | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/main/script_component.hpp b/addons/main/script_component.hpp index cccede0e..ed5295d7 100644 --- a/addons/main/script_component.hpp +++ b/addons/main/script_component.hpp @@ -1,7 +1,6 @@ #define COMPONENT main #include "\z\grad_civs\addons\main\script_mod.hpp" -#define DEBUG_ENABLED_MAIN // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE diff --git a/addons/main/script_mod.hpp b/addons/main/script_mod.hpp index 534e9b6c..a367ab7c 100644 --- a/addons/main/script_mod.hpp +++ b/addons/main/script_mod.hpp @@ -8,3 +8,5 @@ #define REQUIRED_VERSION 1.96 #define AUTHOR Gruppe##Adler + +#define DEBUG_ENABLED_MAIN From 4a19674677fddb16abbd6d7759ce4888cabeea7f Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Mon, 27 Jul 2020 09:08:16 +0200 Subject: [PATCH 51/55] build RC --- addons/legacy/functions/fnc_initHCs.sqf | 2 +- addons/main/script_version.hpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/legacy/functions/fnc_initHCs.sqf b/addons/legacy/functions/fnc_initHCs.sqf index 96a73434..ff0d2302 100644 --- a/addons/legacy/functions/fnc_initHCs.sqf +++ b/addons/legacy/functions/fnc_initHCs.sqf @@ -23,6 +23,6 @@ if (isServer) then { }; if (CBA_isHeadlessClient) then { - call FUNC(overclockStateMachines); + [] call FUNC(overclockStateMachines); [FUNC(adoptAbandonedCivs), 30, []] call CBA_fnc_addPerFrameHandler; }; diff --git a/addons/main/script_version.hpp b/addons/main/script_version.hpp index 459a818b..90995a91 100644 --- a/addons/main/script_version.hpp +++ b/addons/main/script_version.hpp @@ -1,4 +1,4 @@ -#define MAJOR 4 -#define MINOR 1 -#define PATCH 0 +#define MAJOR 5 +#define MINOR 0 +#define PATCH -1 #define BUILD 0 From 7e57a1a93ecb890d4b26a8ad3e7040170bf355d1 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Mon, 27 Jul 2020 09:11:52 +0200 Subject: [PATCH 52/55] RC 5.0.0 --- addons/main/script_mod.hpp | 4 ++-- addons/main/script_version.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/main/script_mod.hpp b/addons/main/script_mod.hpp index a367ab7c..c9646635 100644 --- a/addons/main/script_mod.hpp +++ b/addons/main/script_mod.hpp @@ -1,6 +1,8 @@ #define MAINPREFIX z #define PREFIX grad_civs +//#define DEBUG_ENABLED_MAIN + #include "script_version.hpp" #define VERSION MAJOR.MINOR.PATCH.BUILD @@ -8,5 +10,3 @@ #define REQUIRED_VERSION 1.96 #define AUTHOR Gruppe##Adler - -#define DEBUG_ENABLED_MAIN diff --git a/addons/main/script_version.hpp b/addons/main/script_version.hpp index 90995a91..a9cff2ec 100644 --- a/addons/main/script_version.hpp +++ b/addons/main/script_version.hpp @@ -1,4 +1,4 @@ #define MAJOR 5 #define MINOR 0 -#define PATCH -1 +#define PATCH 0 #define BUILD 0 From 1a374beb396606e446ec03ca5c35e889ac3e2c33 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Mon, 27 Jul 2020 12:39:48 +0200 Subject: [PATCH 53/55] fix FiredNear for vehicles (does it even work in principle? hmm) --- addons/cars/functions/fnc_spawnVehicle.sqf | 17 +++++++++-------- .../fnc_sm_lifecycle_state_spawn_enter.sqf | 4 ++-- addons/main/script_version.hpp | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/addons/cars/functions/fnc_spawnVehicle.sqf b/addons/cars/functions/fnc_spawnVehicle.sqf index f8f7ce72..9d1acc5c 100644 --- a/addons/cars/functions/fnc_spawnVehicle.sqf +++ b/addons/cars/functions/fnc_spawnVehicle.sqf @@ -13,14 +13,15 @@ clearWeaponCargoGlobal _veh; clearItemCargoGlobal _veh; clearMagazineCargoGlobal _veh; -_veh addEventHandler ["FiredNear", - { - params ["_vec", "_firer", "_distance", "_weapon", "_muzzle", "_mode", "_ammo", "_gunner"]; - - private _units = crew _vec; - - [QEGVAR(legacy,firedNear), _units, _units] call CBA_fnc_targetEvent; - }]; +_veh addEventHandler [ + "FiredNear", + { + params ["_vec", "_firer", "_distance", "_weapon", "_muzzle", "_mode", "_ammo", "_gunner"]; + { + [QEGVAR(legacy,firedNear), [_x], _x] call CBA_fnc_targetEvent; + } forEach (crew _vec); + } + ]; private _animalChance = GVAR(animalTransportChance); [_veh, _animalChance] call FUNC(loadAnimals); diff --git a/addons/legacy/functions/fnc_sm_lifecycle_state_spawn_enter.sqf b/addons/legacy/functions/fnc_sm_lifecycle_state_spawn_enter.sqf index baf1d9ee..e1621056 100644 --- a/addons/legacy/functions/fnc_sm_lifecycle_state_spawn_enter.sqf +++ b/addons/legacy/functions/fnc_sm_lifecycle_state_spawn_enter.sqf @@ -35,11 +35,11 @@ private _addKilledNews = { }; private _addGunfightNewsAndFlee = { - (_this select 0) addEventHandler ["FiredNear", + (_this select 0) addEventHandler ["FiredNear", { params ["_unit"]; INFO_2("gunfight close to %1 at %2", _unit, getPos _unit); - [QGVAR(firedNear), [_unit], [_unit]] call CBA_fnc_targetEvent; + [QGVAR(firedNear), [_unit], _unit] call CBA_fnc_targetEvent; }]; }; diff --git a/addons/main/script_version.hpp b/addons/main/script_version.hpp index a9cff2ec..b1e6987a 100644 --- a/addons/main/script_version.hpp +++ b/addons/main/script_version.hpp @@ -1,4 +1,4 @@ #define MAJOR 5 #define MINOR 0 #define PATCH 0 -#define BUILD 0 +#define BUILD 1 From 7e8f33149f5ec9d1541f669c9d832a34c3e69c07 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Tue, 28 Jul 2020 15:34:17 +0200 Subject: [PATCH 54/55] mimikry: make sure messages reach player only when civilian --- addons/main/script_version.hpp | 2 +- addons/mimikry/functions/fnc_addEventHandlers.sqf | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/main/script_version.hpp b/addons/main/script_version.hpp index b1e6987a..d61c07ce 100644 --- a/addons/main/script_version.hpp +++ b/addons/main/script_version.hpp @@ -1,4 +1,4 @@ #define MAJOR 5 #define MINOR 0 #define PATCH 0 -#define BUILD 1 +#define BUILD 2 diff --git a/addons/mimikry/functions/fnc_addEventHandlers.sqf b/addons/mimikry/functions/fnc_addEventHandlers.sqf index 44e951d9..70272eaf 100644 --- a/addons/mimikry/functions/fnc_addEventHandlers.sqf +++ b/addons/mimikry/functions/fnc_addEventHandlers.sqf @@ -3,6 +3,7 @@ ["ace_interaction_sendAway", { params ["_civ"]; if (_civ != ACE_player) exitWith {}; + if (side player != civilian) exitWith {}; addCamShake [4, 0.5, 5]; @@ -13,6 +14,7 @@ ["ace_interaction_getDown", { params ["_civ"]; if (_civ != ACE_player) exitWith {}; + if (side player != civilian) exitWith {}; addCamShake [4, 0.5, 5]; @@ -24,6 +26,7 @@ [QEGVAR(interact,pointed_at_inc), { params ["_civ"]; if (_civ != ACE_player) exitWith {}; + if (side player != civilian) exitWith {}; private _newCount = (_civ getVariable [QGVAR(pointedAtCount), 0]) + 1; _civ setVariable [QGVAR(pointedAtCount), _newCount]; @@ -35,6 +38,7 @@ [QEGVAR(interact,pointed_at_dec), { params ["_civ"]; if (_civ != ACE_player) exitWith {}; + if (side player != civilian) exitWith {}; private _newCount = (_civ getVariable [QGVAR(pointedAtCount), 0]) - 1; if (_newCount < 0) then { @@ -53,6 +57,7 @@ [QEGVAR(interact,honked_at), { params ["_civ"]; if (_civ != ACE_player) exitWith {}; + if (side player != civilian) exitWith {}; private _message = "a car honks at you"; [_message] call FUNC(showCivHint); @@ -61,6 +66,7 @@ [QEGVAR(legacy,doStop), { params ["_civ"]; if (_civ != ACE_player) exitWith {}; + if (side player != civilian) exitWith {}; private _message = "someone gestures at you to stop"; [_message] call FUNC(showCivHint); @@ -69,6 +75,7 @@ [QEGVAR(legacy,doReverse), { params ["_civ"]; if (_civ != ACE_player) exitWith {}; + if (side player != civilian) exitWith {}; private _message = "someone tells you to reverse"; [_message] call FUNC(showCivHint); @@ -77,6 +84,7 @@ [QEGVAR(legacy,doCarryOn), { params ["_civ"]; if (_civ != ACE_player) exitWith {}; + if (side player != civilian) exitWith {}; private _message = "someone tells you to carry on"; [_message] call FUNC(showCivHint); From 8fda9538cb5b2a1bfa909800e9e106c0083479a3 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Tue, 28 Jul 2020 15:58:58 +0200 Subject: [PATCH 55/55] prevent transit spawn collisions --- addons/legacy/functions/fnc_globalSpawnPass.sqf | 2 +- addons/main/script_version.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/legacy/functions/fnc_globalSpawnPass.sqf b/addons/legacy/functions/fnc_globalSpawnPass.sqf index 8e06dfbc..91e06a3a 100644 --- a/addons/legacy/functions/fnc_globalSpawnPass.sqf +++ b/addons/legacy/functions/fnc_globalSpawnPass.sqf @@ -15,7 +15,7 @@ if ((count (entities "HeadlessClient_F") > 0) && CBA_missionTime < 10) exitWith private _hcs = (entities "HeadlessClient_F") arrayIntersect allPlayers; if (count _hcs > 0) then { - [QGVAR(globalSpawn), [], _hcs] call CBA_fnc_targetEvent; + [QGVAR(globalSpawn), [], selectRandom _hcs] call CBA_fnc_targetEvent; } else { [QGVAR(globalSpawn), []] call CBA_fnc_serverEvent; }; diff --git a/addons/main/script_version.hpp b/addons/main/script_version.hpp index d61c07ce..176da1ab 100644 --- a/addons/main/script_version.hpp +++ b/addons/main/script_version.hpp @@ -1,4 +1,4 @@ #define MAJOR 5 #define MINOR 0 #define PATCH 0 -#define BUILD 2 +#define BUILD 3