From ec03a600358c84a25fe58952fef82397271f2cc3 Mon Sep 17 00:00:00 2001 From: ColinM9991 <57466042+ColinM9991@users.noreply.github.com> Date: Mon, 25 Jul 2022 17:50:41 +0100 Subject: [PATCH 1/4] Add function to override civilian classes --- addons/lifecycle/README.md | 17 ++++++++++++++++- addons/lifecycle/XEH_PREP.hpp | 1 + addons/lifecycle/functions/fnc_setCivilians.sqf | 9 +++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 addons/lifecycle/functions/fnc_setCivilians.sqf diff --git a/addons/lifecycle/README.md b/addons/lifecycle/README.md index 0599a896..02ec865d 100644 --- a/addons/lifecycle/README.md +++ b/addons/lifecycle/README.md @@ -16,7 +16,22 @@ Controls all spawning & despawning of civilians, as well as incapacitation & dea ## API -### Events +## grad_civs_lifecycle_fnc_setCivilians + +Sets the classnames that civilians will spawn as. Overwrites value from CBA settings. Execute globally + +#### Example + +```sqf +private _civClasses = ["C_Man_01"]; +[_civClasses] call grad_civs_lifecycle_fnc_setCivilians +``` + +Parameter | Explanation +------------|------------------------------------------------------------- +civClasses | Array - All classnames that civilians will spawn as. + +## Events **NOTE:** event names are prefixed with `grad_civs_lifecycle_` diff --git a/addons/lifecycle/XEH_PREP.hpp b/addons/lifecycle/XEH_PREP.hpp index f30df858..b022bb3a 100644 --- a/addons/lifecycle/XEH_PREP.hpp +++ b/addons/lifecycle/XEH_PREP.hpp @@ -14,6 +14,7 @@ PREP(globalSpawnPass); PREP(initHCs); PREP(isInDistanceFromOtherPlayers); PREP(overclockStateMachines); +PREP(setCivilians); PREP(sm_lifecycle); PREP(sm_lifecycle_state_death_enter); PREP(sm_lifecycle_state_despawn_enter); diff --git a/addons/lifecycle/functions/fnc_setCivilians.sqf b/addons/lifecycle/functions/fnc_setCivilians.sqf new file mode 100644 index 00000000..9474b0c6 --- /dev/null +++ b/addons/lifecycle/functions/fnc_setCivilians.sqf @@ -0,0 +1,9 @@ +#include "..\script_component.hpp" + +params [ + ["_value",[], [[]]] // array of vehicle class names +]; + +assert(_value isEqualTypeAll ""); + +[QGVAR(civClasses), str _value, 1, "mission"] call CBA_settings_fnc_set; From 9b69d756d38d694e28f0dd89e2048c549ee038f3 Mon Sep 17 00:00:00 2001 From: ColinM9991 <57466042+ColinM9991@users.noreply.github.com> Date: Mon, 25 Jul 2022 17:52:11 +0100 Subject: [PATCH 2/4] Update population zone documentation to add alternative syntax --- addons/common/README.md | 42 +++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/addons/common/README.md b/addons/common/README.md index fda42244..3862ebb4 100644 --- a/addons/common/README.md +++ b/addons/common/README.md @@ -29,13 +29,35 @@ From existing Population Zones, subtract areas where civilian may *not* spawn. ## API -### `grad_civs_common_fnc_addExclusionZone` and `grad_civs_common_fnc_addPopulationZone` - -Whitelist areas or prevent civilians from spawning in areas (area = trigger area). - -*known issues: pathing through area is not checked. To minimize that problem, define exclusionZones with large diameter.* - -#### Syntax - -* `[_trigger, _civClasses, _vehicleClasses] call grad_civs_common_fnc_addPopulationZone` , then forbid parts of them using `[_area] call grad_civs_common_fnc_addExclusionZone` -* `[_trigger] call grad_civs_common_fnc_addExclusionZone;` \ No newline at end of file +## grad_civs_common_fnc_addPopulationZone + +Whitelist areas to allow civilians to spawn in those areas (area = trigger area). + +**Syntax** +```sqf +[_trigger, _civClasses, _vehicleClasses] call grad_civs_common_fnc_addPopulationZone +``` + +## grad_civs_common_fnc_addExclusionZone + +Prevent civilians from being spawned in specific areas. + +**Syntax** +```sqf +[_trigger] call grad_civs_common_fnc_addExclusionZone; +``` + +**Alternative syntax** +```sqf +[ + [ + [x, y, z], // Coordinates + 150, // X Radius + 150, // Y Radius + 0, // Angle + false // True if area is Rectangle. False for Ellipse + ] +] call grad_civs_common_fnc_addExclusionZone; +``` + +*known issues: pathing through area is not checked. To minimize that problem, define exclusionZones with large diameter.* \ No newline at end of file From 76072c1dd402c17fc97679d582bbc1611102cb26 Mon Sep 17 00:00:00 2001 From: ColinM9991 <57466042+ColinM9991@users.noreply.github.com> Date: Mon, 25 Jul 2022 20:18:30 +0100 Subject: [PATCH 3/4] Add function to remove an exclusion zone --- addons/common/README.md | 18 +++++++++++++++++- addons/common/XEH_PREP.hpp | 1 + .../functions/fnc_removeExclusionZone.sqf | 15 +++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 addons/common/functions/fnc_removeExclusionZone.sqf diff --git a/addons/common/README.md b/addons/common/README.md index 3862ebb4..92d33ead 100644 --- a/addons/common/README.md +++ b/addons/common/README.md @@ -60,4 +60,20 @@ Prevent civilians from being spawned in specific areas. ] call grad_civs_common_fnc_addExclusionZone; ``` -*known issues: pathing through area is not checked. To minimize that problem, define exclusionZones with large diameter.* \ No newline at end of file +*known issues: pathing through area is not checked. To minimize that problem, define exclusionZones with large diameter.* + +## grad_civs_common_fnc_removeExclusionZone + +Remove a zone from the exclusion list to allow civilians to spawn there again. + +**Syntax** +```sqf +[_trigger] call grad_civs_common_fnc_removeExclusionZone +``` + +**Alternative syntax** +```sqf +[ + [x, y, z] // Coordinates for an existing exclusion zone. X, Y and Z must be an exact match. +] call grad_civs_common_fnc_removeExclusionZone; +``` \ No newline at end of file diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index a063c103..fd15f50a 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -13,3 +13,4 @@ PREP(module_populationZone); PREP(nowPlusSeconds); PREP(parseCsv); PREP(registerCivTaskType); +PREP(removeExclusionZone); diff --git a/addons/common/functions/fnc_removeExclusionZone.sqf b/addons/common/functions/fnc_removeExclusionZone.sqf new file mode 100644 index 00000000..b4a2fe77 --- /dev/null +++ b/addons/common/functions/fnc_removeExclusionZone.sqf @@ -0,0 +1,15 @@ +#include "..\script_component.hpp" + +params ["_area"]; + +ISNILS(GVAR(EXCLUSION_ZONES), []); + +private _zoneIdx = GVAR(EXCLUSION_ZONES) findIf { + _area isEqualTo (if(_x isEqualType []) then [{_x#0}, {_x}]); +}; + +if(_zoneIdx isEqualTo -1) exitWith{}; + +GVAR(EXCLUSION_ZONES) deleteAt _zoneIdx; + +INFO_1("removed exclusion zone %1", _area); From cc993adcfd35fa53882101155293339f134a8a2a Mon Sep 17 00:00:00 2001 From: ColinM9991 <57466042+ColinM9991@users.noreply.github.com> Date: Thu, 28 Jul 2022 23:01:46 +0100 Subject: [PATCH 4/4] Update setCivilians param comment --- addons/lifecycle/functions/fnc_setCivilians.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/lifecycle/functions/fnc_setCivilians.sqf b/addons/lifecycle/functions/fnc_setCivilians.sqf index 9474b0c6..ae5b5e0b 100644 --- a/addons/lifecycle/functions/fnc_setCivilians.sqf +++ b/addons/lifecycle/functions/fnc_setCivilians.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" params [ - ["_value",[], [[]]] // array of vehicle class names + ["_value",[], [[]]] // array of civilian unit class names ]; assert(_value isEqualTypeAll "");