DMS_Exile/@ExileServer/addons/a3_dms/scripts/fn_FindSafePos.sqf
eraser1 8562289765 Some more required changes... sorry
* **You must update all of your mission files; the mission message
system as well as the calling parameters for DMS_fnc_FindSafePos have
been overhauled and will be incompatible with previous versions.**
* NEW CONFIG VALUES:

|DMS_ThrottleBlacklists|
|DMS_AttemptsUntilThrottle|
|DMS_ThrottleCoefficient|
|DMS_MinThrottledDistance|
* Decreased
"DMS_TraderZoneNearBlacklist","DMS_MissionNearBlacklist","DMS_WaterNearBlacklist"
* Changed "DMS_dynamicText_Color" to "#FFFFFF" (white)
* Replaced weapon classes in "DMS_CrateCase_Sniper" to the base classes;
all attachments should now spawn in the box separately.
* New function DMS_fnc_IsValidPosition (uses logic that was previously
from "DMS_fnc_FindSafePos").
* You can now manually define every individual parameter for
DMS_fnc_findSafePos per-mission, instead of using global parameters.
* AI will now be offloaded to an HC even with "DMS_ai_offload_to_client"
set to false.
* All of the previously "supported" values for
"DMS_PlayerNotificationTypes" are now PROPERLY supported.
DMS_PlayerNotificationTypes is now set to default "dynamicTextRequest"
and "systemChatRequest".
* Tweaked "cardealer" mission, the cars should no longer spawn inside of
each other.
2015-10-03 22:32:42 -05:00

84 lines
3.9 KiB
Plaintext

/*
DMS_fnc_FindSafePos
Created by eraser1
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.
Usage:
[
_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.
] call DMS_fnc_findSafePos;
*/
private ["_nearestObjectMinDistance", "_waterNearLimit", "_maxSurfaceNormal", "_spawnZoneNearLimit", "_traderZoneNearLimit", "_missionNearLimit", "_playerNearLimit", "_throttleParams", "_safePosParams", "_validspot", "_attempts", "_pos"];
params
[
["_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]]
];
// 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
{
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)
};
_safePosParams append [_nearestObjectMinDistance,0,9999,0,DMS_findSafePosBlacklist];
_validspot = false;
_attempts = 0;
while{!_validspot} do
{
_pos = _safePosParams call BIS_fnc_findSafePos;
_attempts = _attempts+1;
// 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
{
_missionNearLimit = (DMS_ThrottleCoefficient * _missionNearLimit) max DMS_MinThrottledDistance;
_playerNearLimit = (DMS_ThrottleCoefficient * _playerNearLimit) max DMS_MinThrottledDistance;
if (DMS_DEBUG) then
{
diag_log format ["DMS_DEBUG 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];
};
};
_validspot = [_pos, _waterNearLimit, _maxSurfaceNormal, _spawnZoneNearLimit, _traderZoneNearLimit, _missionNearLimit, _playerNearLimit] call DMS_fnc_IsValidPosition;
};
if(DMS_DEBUG) then
{
diag_log format["DMS_DEBUG FindSafePos :: Found mission position %1 with %2 params in %3 attempts. _this: %4",_pos,_safePosParams,_attempts,_this];
};
_pos set [2, 0];
_pos;