2015-08-28 21:52:56 +00:00
/*
2015-10-04 03:32:42 +00:00
DMS_fnc_FindSafePos
2015-08-28 21:52:56 +00:00
Created by eraser1
2015-10-04 03:32:42 +00:00
ALL PARAMETERS ARE OPTIONAL (as long as configs are properly defined).
Excluding parameters will create some RPT spam, but it's not too much of an issue.
2015-08-28 21:52:56 +00:00
Usage:
[
2015-10-04 03:32:42 +00:00
_nearestObjectMinDistance, // NUMBER (distance): Minimum distance from the nearest object.
_waterNearLimit, // NUMBER (distance): Minimum distance from water.
_maxSurfaceNormal, // NUMBER (between 0-1): Maximum "surfaceNormal"; Basically determines how steep a position is. Check the comment for config value "DMS_MaxSurfaceNormal" in config.sqf for more info
_spawnZoneNearLimit, // NUMBER (distance): Minimum distance from a spawn point.
_traderZoneNearLimit, // NUMBER (distance): Minimum distance from a trader zone.
_missionNearLimit, // NUMBER (distance): Minimum distance from another mission.
_playerNearLimit, // NUMBER (distance): Minimum distance from a player.
_throttleParams // BOOLEAN: Whether or not some of the distance values should be throttled on repeated attempts.
2015-09-05 03:40:00 +00:00
] call DMS_fnc_findSafePos;
2015-08-28 21:52:56 +00:00
*/
2015-10-04 03:32:42 +00:00
private ["_nearestObjectMinDistance", "_waterNearLimit", "_maxSurfaceNormal", "_spawnZoneNearLimit", "_traderZoneNearLimit", "_missionNearLimit", "_playerNearLimit", "_throttleParams", "_safePosParams", "_validspot", "_attempts", "_pos"];
2015-08-28 19:14:59 +00:00
2015-08-31 02:42:02 +00:00
params
[
2015-10-04 03:32:42 +00:00
["_nearestObjectMinDistance", 25, [0] ],
["_waterNearLimit", DMS_WaterNearBlacklist, [0] ],
["_maxSurfaceNormal", DMS_MaxSurfaceNormal, [0] ],
["_spawnZoneNearLimit", DMS_SpawnZoneNearBlacklist, [0] ],
["_traderZoneNearLimit", DMS_TraderZoneNearBlacklist,[0] ],
["_missionNearLimit", DMS_MissionNearBlacklist, [0] ],
["_playerNearLimit", DMS_PlayerNearBlacklist, [0] ],
["_throttleParams", DMS_ThrottleBlacklists, [true]]
2015-08-31 02:42:02 +00:00
];
2015-08-28 06:04:50 +00:00
2015-09-12 01:21:53 +00:00
// Some custom maps don't have the proper safePos config entries.
// If you are using one and you have an issue with mission spawns, please create an issue on GitHub or post a comment in the DMS thread.
switch (toLower worldName) do
{
2015-10-04 03:32:42 +00:00
case "altis": { _safePosParams = [[16000,16000],0,16000]; }; // [16000,16000] w/ radius of 16000 works well for Altis
case "bornholm": { _safePosParams = [[11265,11265],0,12000]; }; // Thanks to thirdhero for testing this info
case "esseker": { _safePosParams = [[6275,6350,0],0,5000]; }; // Thanks to Flowrider for this info
case "tavi": { _safePosParams = [[12800,12800],0,12800]; }; // Thanks to JamieKG for this info
default { _safePosParams = [[],0,-1]; }; // Use default BIS_fnc_findSafePos methods for finding map center (worldSize)
2015-09-12 01:21:53 +00:00
};
2015-10-04 03:32:42 +00:00
_safePosParams append [_nearestObjectMinDistance,0,9999,0,DMS_findSafePosBlacklist];
2015-08-28 06:04:50 +00:00
_validspot = false;
2015-10-04 03:32:42 +00:00
_attempts = 0;
2015-09-12 01:21:53 +00:00
while{!_validspot} do
{
2015-10-04 03:32:42 +00:00
_pos = _safePosParams call BIS_fnc_findSafePos;
_attempts = _attempts+1;
2015-09-20 20:26:08 +00:00
2015-10-04 03:32:42 +00:00
// It will only throttle the missionNear blacklist and playerNear limits because those are the most likely to throw an exception.
// The throttling works by decreasing the parameters by 10% every 15 attempts, until it reaches 100 meters (by default).
if (_throttleParams && {(_attempts>=DMS_AttemptsUntilThrottle) && {(_attempts%DMS_AttemptsUntilThrottle)==0}}) then
2015-08-28 19:14:59 +00:00
{
2015-10-04 03:32:42 +00:00
_missionNearLimit = (DMS_ThrottleCoefficient * _missionNearLimit) max DMS_MinThrottledDistance;
_playerNearLimit = (DMS_ThrottleCoefficient * _playerNearLimit) max DMS_MinThrottledDistance;
Readme changes, new debug fnc, fixes, tweaks
Created disclaimer for DMS. Now mentioning that HC for DMS isn't that
good.
Some structure stuff in readme (let's see if it works lol)
* **NEW CONFIG VALUE: DMS_Use_Map_Config**
* You can now overwrite "main config values" with map-specific config
values located in the new "map_configs" folder. This should allow you to
use one DMS PBO if you have multiple servers with different maps.
Included examples for Altis, Bornholm, Esseker, and Tavi (Taviana).
* Because of the above implementation, DMS by default will not include
the salt flats blacklist for findSafePos. In addition, it is
preconfigured to the hilly terrains in Esseker and Taviana, as well as
reducing all of the blacklist distances due to the smaller map size in
Esseker.
* Created new function "DMS_fnc_DebugLog". All DMS files (that produced
debug logs) have been changed, including mission files. However,
updating them is not important (and completely pointless if you don't
even use DMS_DEBUG).
* Fixed a few locations where it said "sized" instead of "seized".
Thanks to [icomrade](https://github.com/icomrade) for pointing them out.
* DMS now utilizes the "ARMA_LOG" DLL (if it exists) by infiSTAR to
produce debug logs (if enabled). All debug logs now also include server
uptime (in seconds) and server FPS.
* The FSM no longer produces debug logs.
* AI Locality manager will now run every minute.
* Debug logs for "DMS_fnc_MissionsMonitor" will only output the mission
name and the position, instead of all of the parameters.
* "DMS_fnc_IsNearWater" will now check the provided position itself for
water.
* "DMS_fnc_IsValidPosition" will now do a surfaceNormal check within a 5
meter radius of the provided position as well.
* "_customGearSet" should now actually work for
"DMS_fnc_SpawnAISoldier", and the function title comment has been
updated for the slightly tweaked syntax.
2015-10-10 01:35:07 +00:00
(format ["FindSafePos :: Throttling _missionNearLimit to %1 and _playerNearLimit to %2 after %3 failed attempts to find a safe position! FPS: %4",_missionNearLimit,_playerNearLimit,_attempts,diag_fps]) call DMS_fnc_DebugLog;
2015-08-28 06:04:50 +00:00
};
2015-10-04 03:32:42 +00:00
_validspot = [_pos, _waterNearLimit, _maxSurfaceNormal, _spawnZoneNearLimit, _traderZoneNearLimit, _missionNearLimit, _playerNearLimit] call DMS_fnc_IsValidPosition;
2015-08-28 06:04:50 +00:00
};
2015-10-04 03:32:42 +00:00
Readme changes, new debug fnc, fixes, tweaks
Created disclaimer for DMS. Now mentioning that HC for DMS isn't that
good.
Some structure stuff in readme (let's see if it works lol)
* **NEW CONFIG VALUE: DMS_Use_Map_Config**
* You can now overwrite "main config values" with map-specific config
values located in the new "map_configs" folder. This should allow you to
use one DMS PBO if you have multiple servers with different maps.
Included examples for Altis, Bornholm, Esseker, and Tavi (Taviana).
* Because of the above implementation, DMS by default will not include
the salt flats blacklist for findSafePos. In addition, it is
preconfigured to the hilly terrains in Esseker and Taviana, as well as
reducing all of the blacklist distances due to the smaller map size in
Esseker.
* Created new function "DMS_fnc_DebugLog". All DMS files (that produced
debug logs) have been changed, including mission files. However,
updating them is not important (and completely pointless if you don't
even use DMS_DEBUG).
* Fixed a few locations where it said "sized" instead of "seized".
Thanks to [icomrade](https://github.com/icomrade) for pointing them out.
* DMS now utilizes the "ARMA_LOG" DLL (if it exists) by infiSTAR to
produce debug logs (if enabled). All debug logs now also include server
uptime (in seconds) and server FPS.
* The FSM no longer produces debug logs.
* AI Locality manager will now run every minute.
* Debug logs for "DMS_fnc_MissionsMonitor" will only output the mission
name and the position, instead of all of the parameters.
* "DMS_fnc_IsNearWater" will now check the provided position itself for
water.
* "DMS_fnc_IsValidPosition" will now do a surfaceNormal check within a 5
meter radius of the provided position as well.
* "_customGearSet" should now actually work for
"DMS_fnc_SpawnAISoldier", and the function title comment has been
updated for the slightly tweaked syntax.
2015-10-10 01:35:07 +00:00
(format["FindSafePos :: Found mission position %1 with %2 params in %3 attempts. _this: %4",_pos,_safePosParams,_attempts,_this]) call DMS_fnc_DebugLog;
2015-10-04 03:32:42 +00:00
2015-08-28 19:14:59 +00:00
_pos set [2, 0];
_pos;