-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix spawn positions in relation to players
* lots of refactor - refactored house finding / spawn position / patrol waypoint logic * there were bugfixes to be had in relation to player distancing & exclusion zones * make cars appear it least 100m away from other "Man" (dont look into civilians array) * add some tests (have to be executed manually on a terrain with flat SW corner like Zargabad… there is some TODO to be had here) NOTE FOR USERS: I recommend defining exclusion zones for little islands, steep mountains and other non-trivial terrain to avoid bad server fps. For the same reason, using a headless client is recommended.
- Loading branch information
1 parent
d3da1b6
commit 6779b00
Showing
25 changed files
with
547 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "..\..\component.hpp" | ||
|
||
GRAD_CIVS_EXCLUSION_ZONES = []; | ||
|
||
INFO("all exclusion zones removed"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
GRAD_CIVS_EXCLUSION_ZONES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// 1: position position or object - if object, position of object is used | ||
// 2: radius number or array - if array, random radius between first and second element is used | ||
// 3: count number > 1, or array - amount of waypoints to generate, if array, random amount between first and second element is used | ||
|
||
#include "..\..\component.hpp" | ||
|
||
params [ | ||
["_position", [0, 0, 0]], | ||
["_radius", 0], | ||
["_maxTries", 10], | ||
["_findPosOfInterest",false], | ||
["_findRoadPos",false], | ||
["_findWaterPos",false] | ||
]; | ||
|
||
private _waypointPosition = []; | ||
|
||
//create waypoints | ||
|
||
for "_i" from 1 to _maxTries do { | ||
LOG_1("trying to create wp, pass #%1 ", _i); | ||
|
||
private _searchPosition = [ | ||
_position, | ||
[_radius / 2 ,_radius], | ||
[0,360], | ||
nil, | ||
_findWaterPos, | ||
_findRoadPos | ||
] call FUNC(findRandomPos); | ||
|
||
_searchPosition = if (_findPosOfInterest && {80 > random 100}) then { | ||
[_searchPosition, false] call FUNC(findPositionOfInterest); | ||
} else { | ||
_searchPosition | ||
}; | ||
|
||
private _inAnyExclusionZone = [GRAD_CIVS_EXCLUSION_ZONES, {_searchPosition inArea (_this#0)}] call FUNC(arrayContains); | ||
if (!_inAnyExclusionZone) exitWith { | ||
LOG_1("position %1 is not in exclusionzone, return it", _searchPosition); | ||
_waypointPosition = _searchPosition; | ||
}; | ||
LOG_1("not creating WP at %1", _searchPosition); | ||
}; | ||
|
||
_waypointPosition |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
["given a point surrounded by exclusion zones on three sides", | ||
{ | ||
private _trgW = createTrigger ["EmptyDetector", [-250, 150, 0]]; | ||
_trgW setTriggerArea [150, 250, 0, true]; | ||
[_trgW] call grad_civs_fnc_addExclusionZone; | ||
|
||
private _trgS = createTrigger ["EmptyDetector", [0, -250, 0]]; | ||
_trgS setTriggerArea [200, 150, 0, true]; | ||
[_trgS] call grad_civs_fnc_addExclusionZone; | ||
|
||
private _trgE = createTrigger ["EmptyDetector", [250, 150, 0]]; | ||
_trgE setTriggerArea [150, 250, 0, true]; | ||
[_trgE] call grad_civs_fnc_addExclusionZone; | ||
}, | ||
[ | ||
["when a patrol path is created", | ||
{ | ||
[([[0, 0, 0], 250, 3] call grad_civs_fnc_taskPatrolFindWaypoints)] | ||
}, | ||
[ | ||
["three positions are returned as requested", | ||
{ | ||
params [["_positions", []]]; | ||
[3, count _positions] call grad_testing_fnc_assertEquals; | ||
} | ||
], | ||
["will avoid exclusion zones as waypoints", | ||
{ | ||
params [["_positions", []]]; | ||
|
||
{ | ||
private _exclusionZone = _x; | ||
private _exclusionZoneIdx = _forEachIndex; | ||
{ | ||
[ | ||
_x inArea _exclusionZone, | ||
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_fnc_getExclusionZones); | ||
} | ||
], | ||
["will avoid crossing exclusion zones", | ||
{ | ||
["TODO"] call grad_testing_fnc_skipTest; | ||
} | ||
] | ||
] | ||
] | ||
], | ||
grad_civs_fnc_clearExclusionZones | ||
] call grad_testing_fnc_executeTest; |
Oops, something went wrong.