diff --git a/README.md b/README.md index fae51a55..ed2c7aa6 100644 --- a/README.md +++ b/README.md @@ -79,11 +79,11 @@ vehicles | ["C_Van_01_fuel_F", "C_Hatchback_01_F", "C_Offroad_02 ## 3DEN modules -### add exclusion zone +### exclusion zone Blacklist an area for civs by syncing it to a trigger. -### add population zone +### population zone Whitelist an area for civs by syncing it to a trigger. @@ -176,7 +176,7 @@ Parameter | Explanation backpacks | Array - All classnames of clothes that civilians may wear. probability | Number - Probability that civilian will wear a backpack. Default: 0.5. -### grad_civs_voyage_fnc_setVehicles +### grad_civs_cars_fnc_setVehicles Sets all vehicles that civilians may drive. Overwrites value from CBA settings. Execute globally #### Syntax @@ -197,17 +197,17 @@ Parameter | Explanation debugCivState | Bool - Debug mode on/off. -### grad_civs_legacy_fnc_addExclusionZone and grad_civs_legacy_fnc_addPopulationZone +### grad_civs_common_fnc_addExclusionZone and grad_civs_common_fnc_addPopulationZone Prevent civilians from entering areas. -Optionally whitelist areas using `[_area] call grad_civs_legacy_fnc_addPopulationZone` , then forbid parts of them using `[_area] call grad_civs_legacy_fnc_addExclusionZone` . +Optionally whitelist areas using `[_area] call grad_civs_common_fnc_addPopulationZone` , then forbid parts of them using `[_area] call grad_civs_common_fnc_addExclusionZone` . *known issues: pathing through area is not checked. To minimize that problem, define exclusionZones with large diameter.* #### Syntax -`[_trigger] call grad_civs_legacy_fnc_addExclusionZone;` +`[_trigger] call grad_civs_common_fnc_addExclusionZone;` ## Development diff --git a/addons/legacy/CfgVehicles.hpp b/addons/common/CfgVehicles.hpp similarity index 77% rename from addons/legacy/CfgVehicles.hpp rename to addons/common/CfgVehicles.hpp index 66e3ef51..6980bed7 100644 --- a/addons/legacy/CfgVehicles.hpp +++ b/addons/common/CfgVehicles.hpp @@ -9,13 +9,13 @@ class CfgVehicles }; class ModuleDescription {}; }; - class GVAR(addPopulationZone): Module_F + class GVAR(PopulationZone): Module_F { scope = 2; // visible in editor - displayName = "add population zone"; - icon = ""; // Map icon. Delete this entry to use the default icon + displayName = "population zone"; + icon = QPATHTOF(ui\icon_module_population_zone_ca.paa); category = QEGVAR(main,modules); - function = QFUNC(module_addPopulationZone); + function = QFUNC(module_populationZone); functionPriority = 0; // first to execute isGlobal = 1; isTriggerActivated = 0; @@ -29,13 +29,13 @@ class CfgVehicles sync[] = {}; // Array of synced entities (can contain base classes) }; }; - class GVAR(addExclusionZone): Module_F + class GVAR(ExclusionZone): Module_F { scope = 2; // visible in editor - displayName = "add exclusion zone"; - icon = ""; // Map icon. Delete this entry to use the default icon + displayName = "exclusion zone"; + icon = QPATHTOF(ui\icon_module_exclusion_zone_ca.paa); category = QEGVAR(main,modules); - function = QFUNC(module_addExclusionZone); + function = QFUNC(module_exclusionZone); functionPriority = 0; // first to execute isGlobal = 1; isTriggerActivated = 0; diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 627183c2..8c1233a7 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -1,4 +1,13 @@ +PREP(addExclusionZone); +PREP(addPopulationZone); PREP(augmentStateMachine); -PREP(registerCivTaskType); PREP(civGetState); +PREP(clearExclusionZones); +PREP(clearPopulationZones); +PREP(getExclusionZones); +PREP(getPopulationZones); +PREP(isInPopulatedZone); +PREP(module_exclusionZone); +PREP(module_populationZone); PREP(parseCsv); +PREP(registerCivTaskType); diff --git a/addons/common/config.cpp b/addons/common/config.cpp index 6a47f0e8..d851c36a 100644 --- a/addons/common/config.cpp +++ b/addons/common/config.cpp @@ -13,3 +13,4 @@ class CfgPatches { }; #include "CfgEventHandlers.hpp" +#include "CfgVehicles.hpp" diff --git a/addons/legacy/functions/fnc_addExclusionZone.sqf b/addons/common/functions/fnc_addExclusionZone.sqf similarity index 100% rename from addons/legacy/functions/fnc_addExclusionZone.sqf rename to addons/common/functions/fnc_addExclusionZone.sqf diff --git a/addons/legacy/functions/fnc_addPopulationZone.sqf b/addons/common/functions/fnc_addPopulationZone.sqf similarity index 100% rename from addons/legacy/functions/fnc_addPopulationZone.sqf rename to addons/common/functions/fnc_addPopulationZone.sqf diff --git a/addons/legacy/functions/fnc_clearExclusionZones.sqf b/addons/common/functions/fnc_clearExclusionZones.sqf similarity index 100% rename from addons/legacy/functions/fnc_clearExclusionZones.sqf rename to addons/common/functions/fnc_clearExclusionZones.sqf diff --git a/addons/legacy/functions/fnc_clearPopulationZones.sqf b/addons/common/functions/fnc_clearPopulationZones.sqf similarity index 100% rename from addons/legacy/functions/fnc_clearPopulationZones.sqf rename to addons/common/functions/fnc_clearPopulationZones.sqf diff --git a/addons/legacy/functions/fnc_getExclusionZones.sqf b/addons/common/functions/fnc_getExclusionZones.sqf similarity index 100% rename from addons/legacy/functions/fnc_getExclusionZones.sqf rename to addons/common/functions/fnc_getExclusionZones.sqf diff --git a/addons/legacy/functions/fnc_getPopulationZones.sqf b/addons/common/functions/fnc_getPopulationZones.sqf similarity index 100% rename from addons/legacy/functions/fnc_getPopulationZones.sqf rename to addons/common/functions/fnc_getPopulationZones.sqf diff --git a/addons/legacy/functions/fnc_isInPopulatedZone.sqf b/addons/common/functions/fnc_isInPopulatedZone.sqf similarity index 61% rename from addons/legacy/functions/fnc_isInPopulatedZone.sqf rename to addons/common/functions/fnc_isInPopulatedZone.sqf index 92a147ae..283639a9 100644 --- a/addons/legacy/functions/fnc_isInPopulatedZone.sqf +++ b/addons/common/functions/fnc_isInPopulatedZone.sqf @@ -10,13 +10,12 @@ private _populationZones = [] call FUNC(getPopulationZones); private _exclusionZones = [] call FUNC(getExclusionZones); private _inAnyPopulationZone = if (count _populationZones == 0) then { - true + true; // "there is no population zone" defaults to "*everywhere* is population zone" } else { - // TODO uhm… how about [] findIf {} != -1 ? - [_populationZones, {_position inArea (_this#0)}] call FUNC(arrayContains) + _populationZones findIf {_position inArea _x} != -1; }; if (!_inAnyPopulationZone) exitWith {false}; -private _inAnyExclusionZone = [_exclusionZones, {_position inArea (_this#0)}] call FUNC(arrayContains); +private _inAnyExclusionZone = _exclusionZones findIf {_position inArea (_x)} != -1; !_inAnyExclusionZone diff --git a/addons/legacy/functions/fnc_module_addExclusionZone.sqf b/addons/common/functions/fnc_module_exclusionZone.sqf similarity index 100% rename from addons/legacy/functions/fnc_module_addExclusionZone.sqf rename to addons/common/functions/fnc_module_exclusionZone.sqf diff --git a/addons/legacy/functions/fnc_module_addPopulationZone.sqf b/addons/common/functions/fnc_module_populationZone.sqf similarity index 100% rename from addons/legacy/functions/fnc_module_addPopulationZone.sqf rename to addons/common/functions/fnc_module_populationZone.sqf diff --git a/addons/common/functions/fnc_parseCsv.sqf b/addons/common/functions/fnc_parseCsv.sqf index c58d91f6..ee829d62 100644 --- a/addons/common/functions/fnc_parseCsv.sqf +++ b/addons/common/functions/fnc_parseCsv.sqf @@ -1,12 +1,14 @@ #include "..\script_component.hpp" /* - parse list of strings + parse list of strings into an array. tolerates arrays, will return input value in that case */ params [ - ["_rawValue", "", [""]] + ["_rawValue", "", ["", []]] ]; +if (_rawValue isEqualType []) exitWith { _rawValue }; + private _delimiter = ","; private _firstChar = _rawValue select [0, 1]; diff --git a/addons/common/ui/icon_module_exclusion_zone_ca.paa b/addons/common/ui/icon_module_exclusion_zone_ca.paa new file mode 100644 index 00000000..84a1d950 Binary files /dev/null and b/addons/common/ui/icon_module_exclusion_zone_ca.paa differ diff --git a/addons/common/ui/icon_module_population_zone_ca.paa b/addons/common/ui/icon_module_population_zone_ca.paa new file mode 100644 index 00000000..98708808 Binary files /dev/null and b/addons/common/ui/icon_module_population_zone_ca.paa differ diff --git a/addons/gta/functions/fnc_registerPlayerTheftHandler.sqf b/addons/gta/functions/fnc_registerPlayerTheftHandler.sqf index 6449ca70..e7397d5c 100644 --- a/addons/gta/functions/fnc_registerPlayerTheftHandler.sqf +++ b/addons/gta/functions/fnc_registerPlayerTheftHandler.sqf @@ -81,9 +81,3 @@ player addEventHandler [ [GVAR(stolenVehiclePfh)] call CBA_fnc_removePerFrameHandler; } ]; - - -// TEST -//["grad_civs_vehicleTheft", { -// systemChat format ["%1 has been stolen by %2", _this#0, _this#1]; -//}] call CBA_fnc_addEventHandler; diff --git a/addons/legacy/XEH_PREP.hpp b/addons/legacy/XEH_PREP.hpp index 14a38436..67fe62b1 100644 --- a/addons/legacy/XEH_PREP.hpp +++ b/addons/legacy/XEH_PREP.hpp @@ -1,13 +1,8 @@ PREP(addCivInteractions); -PREP(addExclusionZone); -PREP(addPopulationZone); -PREP(arrayContains); PREP(checkHonkingOnCivilian); PREP(checkWeaponOnCivilianPerception); PREP(checkWeaponOnCivilianPointer); PREP(clearCurrentlyThinking); -PREP(clearExclusionZones); -PREP(clearPopulationZones); PREP(compare); PREP(customActivity_reverse); PREP(deleteIfDamaged); @@ -27,9 +22,7 @@ PREP(forceEmotionSpeed); PREP(forcePanicSpeed); PREP(formatNowPlusSeconds); PREP(getCurrentlyThinking); -PREP(getExclusionZones); PREP(getGlobalCivs); -PREP(getPopulationZones); PREP(handleAnimation); PREP(handleGestureGo); PREP(handleGestureStop); @@ -43,11 +36,8 @@ PREP(interact_carryOnAction); PREP(interact_carryOnCondition); PREP(isInDistanceFromOtherPlayers); PREP(isInHouse); -PREP(isInPopulatedZone); PREP(isPlayerHonking); PREP(mapMarkers); -PREP(module_addExclusionZone); -PREP(module_addPopulationZone); PREP(nowPlusSeconds); PREP(playerLoop); PREP(reverse_abort); diff --git a/addons/legacy/config.cpp b/addons/legacy/config.cpp index c52feb44..9a4079d2 100644 --- a/addons/legacy/config.cpp +++ b/addons/legacy/config.cpp @@ -13,4 +13,3 @@ class CfgPatches { }; #include "CfgEventHandlers.hpp" -#include "CfgVehicles.hpp" diff --git a/addons/legacy/functions/fnc_arrayContains.sqf b/addons/legacy/functions/fnc_arrayContains.sqf deleted file mode 100644 index 820f1a2d..00000000 --- a/addons/legacy/functions/fnc_arrayContains.sqf +++ /dev/null @@ -1,13 +0,0 @@ -#include "..\script_component.hpp" - -params [ - ["_arr", []], - ["_discriminator", {}] -]; - -if ((count _arr) == 0) exitWith {false}; - -{ - private _result = [_x, _forEachIndex] call _discriminator; - if (_result) exitWith {true}; false -} forEach _arr diff --git a/addons/legacy/functions/fnc_findSpawnPosition.sqf b/addons/legacy/functions/fnc_findSpawnPosition.sqf index d023b6c6..3d319304 100644 --- a/addons/legacy/functions/fnc_findSpawnPosition.sqf +++ b/addons/legacy/functions/fnc_findSpawnPosition.sqf @@ -57,7 +57,7 @@ private _result = { [_allPlayers, _candidate, _minDistance] call FUNC(isInDistanceFromOtherPlayers) } && { - [getPos _candidate] call FUNC(isInPopulatedZone) + [getPos _candidate] call EFUNC(common,isInPopulatedZone) } ) exitWith { LOG_1("found spawn position %1", _candidate); diff --git a/addons/legacy/functions/fnc_handleAnimation.sqf b/addons/legacy/functions/fnc_handleAnimation.sqf index 99ec43d1..4ca4d57b 100644 --- a/addons/legacy/functions/fnc_handleAnimation.sqf +++ b/addons/legacy/functions/fnc_handleAnimation.sqf @@ -2,7 +2,7 @@ params ["_unit", "_animation"]; -systemChat format["_animation: %1", _animation]; +// systemChat format["_animation: %1", _animation]; if ((toLower _animation) in ["gesturefreeze", "ace_gestures_hold", "ace_gestures_holdstandlowered"]) exitWith { [_unit] call FUNC(handleGestureStop); diff --git a/addons/legacy/functions/fnc_setupZeusModules.sqf b/addons/legacy/functions/fnc_setupZeusModules.sqf index fafd4209..fa534581 100644 --- a/addons/legacy/functions/fnc_setupZeusModules.sqf +++ b/addons/legacy/functions/fnc_setupZeusModules.sqf @@ -19,7 +19,7 @@ }; private _marker = _areaMarkersAtPos select (_minDistanceAndIndex#1); - [_marker] call FUNC(addExclusionZone); + [_marker] call EFUNC(common,addExclusionZone); _marker setMarkerBrushLocal "BORDER"; _marker setMarkerColorLocal "ColorUNKNOWN"; } @@ -44,7 +44,7 @@ }; private _marker = _areaMarkersAtPos select (_minDistanceAndIndex#1); - [_marker] call FUNC(addPopulationZone); + [_marker] call EFUNC(common,addPopulationZone); _marker setMarkerBrushLocal "BORDER"; _marker setMarkerColorLocal "ColorCIV"; } diff --git a/addons/patrol/functions/fnc_taskPatrol.spec.sqf b/addons/patrol/functions/fnc_taskPatrol.spec.sqf index 6f4614ac..3e03584b 100644 --- a/addons/patrol/functions/fnc_taskPatrol.spec.sqf +++ b/addons/patrol/functions/fnc_taskPatrol.spec.sqf @@ -1,6 +1,6 @@ ["a civilian", { - call grad_civs_legacy_fnc_clearExclusionZones; + call grad_civs_common_fnc_clearExclusionZones; private _group = createGroup [civilian, true]; _group setCombatMode "GREEN"; private _pos = [0, 0, 0]; @@ -98,15 +98,15 @@ private _trgW = createTrigger ["EmptyDetector", (getPos _civ) vectorAdd [-250, 150, 0]]; _trgW setTriggerArea [150, 250, 0, true]; - [_trgW] call grad_civs_legacy_fnc_addExclusionZone; + [_trgW] call grad_civs_common_fnc_addExclusionZone; private _trgS = createTrigger ["EmptyDetector", (getPos _civ) vectorAdd [0, -250, 0]]; _trgS setTriggerArea [200, 150, 0, true]; - [_trgS] call grad_civs_legacy_fnc_addExclusionZone; + [_trgS] call grad_civs_common_fnc_addExclusionZone; private _trgE = createTrigger ["EmptyDetector", (getPos _civ) vectorAdd [250, 150, 0]]; _trgE setTriggerArea [150, 250, 0, true]; - [_trgE] call grad_civs_legacy_fnc_addExclusionZone; + [_trgE] call grad_civs_common_fnc_addExclusionZone; [_civ] }, @@ -134,7 +134,7 @@ format ["waypoint %1 at %2 is not in exclusion zone at %3 (%4)", _forEachIndex, _x, getPos _exclusionZone, triggerArea _exclusionZone] ] call grad_testing_fnc_assertFalse; } forEach _waypointPositions; - } forEach (call grad_civs_legacy_fnc_getExclusionZones); + } forEach (call grad_civs_common_fnc_getExclusionZones); } ], ["will avoid crossing exclusion zones", @@ -145,7 +145,7 @@ ] ] ], - grad_civs_legacy_fnc_clearExclusionZones + grad_civs_common_fnc_clearExclusionZones ] ], { diff --git a/addons/patrol/functions/fnc_taskPatrolFindWaypoint.sqf b/addons/patrol/functions/fnc_taskPatrolFindWaypoint.sqf index 0f8ecc90..6d9174e2 100644 --- a/addons/patrol/functions/fnc_taskPatrolFindWaypoint.sqf +++ b/addons/patrol/functions/fnc_taskPatrolFindWaypoint.sqf @@ -38,7 +38,7 @@ for "_i" from 1 to _maxTries do { _searchPosition }; - private _inPopulatedZone = [_searchPosition] call EFUNC(legacy,isInPopulatedZone); + private _inPopulatedZone = [_searchPosition] call EFUNC(common,isInPopulatedZone); if (_inPopulatedZone) exitWith { LOG_1("position %1 is not in exclusionzone, return it", _searchPosition); _waypointPosition = _searchPosition; diff --git a/addons/patrol/functions/fnc_taskPatrolFindWaypoints.spec.sqf b/addons/patrol/functions/fnc_taskPatrolFindWaypoints.spec.sqf index b0524a00..bf21b28f 100644 --- a/addons/patrol/functions/fnc_taskPatrolFindWaypoints.spec.sqf +++ b/addons/patrol/functions/fnc_taskPatrolFindWaypoints.spec.sqf @@ -2,15 +2,15 @@ { private _trgW = createTrigger ["EmptyDetector", [-250, 150, 0]]; _trgW setTriggerArea [150, 250, 0, true]; - [_trgW] call grad_civs_legacy_fnc_addExclusionZone; + [_trgW] call grad_civs_common_fnc_addExclusionZone; private _trgS = createTrigger ["EmptyDetector", [0, -250, 0]]; _trgS setTriggerArea [200, 150, 0, true]; - [_trgS] call grad_civs_legacy_fnc_addExclusionZone; + [_trgS] call grad_civs_common_fnc_addExclusionZone; private _trgE = createTrigger ["EmptyDetector", [250, 150, 0]]; _trgE setTriggerArea [150, 250, 0, true]; - [_trgE] call grad_civs_legacy_fnc_addExclusionZone; + [_trgE] call grad_civs_common_fnc_addExclusionZone; }, [ ["when a patrol path is created", @@ -37,7 +37,7 @@ format ["waypoint %1 at %2 is not in exclusion zone at %3 (%4)", _forEachIndex, _x, getPos _exclusionZone, triggerArea _exclusionZone] ] call grad_testing_fnc_assertFalse; } forEach _positions; - } forEach (call grad_civs_legacy_fnc_getExclusionZones); + } forEach (call grad_civs_common_fnc_getExclusionZones); } ], ["will avoid crossing exclusion zones", @@ -48,7 +48,7 @@ ] ] ], - grad_civs_legacy_fnc_clearExclusionZones + grad_civs_common_fnc_clearExclusionZones ] call grad_testing_fnc_executeTest; ["GIVEN a point and no exclusion zones WHEN a patrol path is created", diff --git a/addons/transit/CfgVehicles.hpp b/addons/transit/CfgVehicles.hpp index 1d99c080..fa09c5c3 100644 --- a/addons/transit/CfgVehicles.hpp +++ b/addons/transit/CfgVehicles.hpp @@ -15,7 +15,7 @@ class CfgVehicles { scope = 2; // visible in editor displayName = "Transit Traffic Source"; - icon = ""; // Map icon. Delete this entry to use the default icon + icon = QPATHTOF(ui\icon_module_transit_source_ca.paa); category = QEGVAR(main,modules); function = QFUNC(module_transitSource); functionPriority = 0; // first to execute @@ -64,7 +64,7 @@ class CfgVehicles { scope = 2; // visible in editor displayName = "Transit Traffic Sink"; - icon = ""; // Map icon. Delete this entry to use the default icon + icon = QPATHTOF(ui\icon_module_transit_sink_ca.paa); category = QEGVAR(main,modules); function = QFUNC(module_transitSink); functionPriority = 0; // first to execute diff --git a/addons/transit/ui/icon_module_transit_sink_ca.paa b/addons/transit/ui/icon_module_transit_sink_ca.paa new file mode 100644 index 00000000..ae7ab5f2 Binary files /dev/null and b/addons/transit/ui/icon_module_transit_sink_ca.paa differ diff --git a/addons/transit/ui/icon_module_transit_source_ca.paa b/addons/transit/ui/icon_module_transit_source_ca.paa new file mode 100644 index 00000000..47a97609 Binary files /dev/null and b/addons/transit/ui/icon_module_transit_source_ca.paa differ