Skip to content

Commit

Permalink
Add distinction for villages and cities in terms of spawn radius
Browse files Browse the repository at this point in the history
  • Loading branch information
3Mydlo3 committed Feb 15, 2024
1 parent c218ed8 commit d639ef9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions addons/civilian/functions/fnc_initCivilians.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define NEAR_ROAD true
#define ALLOW_ON_ROAD true
#define NEAR_BUILDINGS true
#define MAX_DISTANCE_TO_VILLAGE 500
#define MAX_DISTANCE_TO_NEAREST_CITY 1000

private _i = GVAR(initialCiviliansCount);
Expand All @@ -27,6 +28,12 @@ while {_i > 0} do {
if (!(_pos isEqualTo [])) then {
private _nearestCity = [_pos, MAX_DISTANCE_TO_NEAREST_CITY] call FUNC(getNearestCity);
if (_nearestCity isEqualTo objNull) exitWith {};

private _nearestCityType = _nearestCity getVariable [QGVAR(cityType), "NameVillage"];
private _cityPosition = _nearestCity getVariable [QGVAR(position), [0, 0, 0]];
private _maxAllowedDistance = if (_nearestCityType isEqualTo "NameVillage") then { MAX_DISTANCE_TO_VILLAGE } else { MAX_DISTANCE_TO_NEAREST_CITY };
if (_pos distance _cityPosition > _maxAllowedDistance) exitWith {};

private _nearbyCivilians = _pos nearEntities ["Man", 100];
private _nearbyCiviliansCount = count _nearbyCivilians;
if (_nearbyCiviliansCount >= 2 && {(random 1) - _nearbyCiviliansCount * 0.05 > 0.1}) exitWith {};
Expand Down

0 comments on commit d639ef9

Please sign in to comment.