mirror of
https://github.com/Defent/DMS_Exile.git
synced 2024-08-30 16:52:12 +00:00
30136c8f37
#### October 17, 2015 (2:30 PM CST-America): * **NEW CONFIG VALUES**: |DMS_TimeToFirstMission| |DMS_ShowDifficultyColorLegend| |DMS_TerritoryNearBlacklist| |DMS_MinSurfaceNormal| (Used to be DMS_MaxSurfaceNormal, simply renamed) |DMS_ai_launchers_per_group| * **UPDATING ALL OF YOUR MISSION FILES IS HIGHLY RECOMMENDED UNLESS YOU KNOW WHAT YOU'RE DOING** * RENAMED "DMS_MaxSurfaceNormal" to "DMS_MinSurfaceNormal". I must have been very tired when I named it... * DMS_MinSurfaceNormal is now 0.9 by default, but will be 0.95 for Altis and Bornholm (since they're relatively large/flat maps). Esseker is still 0.85. If you want to convert DMS_MinSurfaceNormal to degrees, you would take the arc-cosine of the surfaceNormal, and that will give you the degrees from horizontal. For example, arccos(0.9) is about 25 degrees. Google: "arccos(0.9) in degrees" * Tweaked and rebalanced "DMS_BanditMissionTypes". Most of the spawn chances are the same, they're just reduced in order to prevent the creation of arrays that are far larger than they need to be. * You can now manually define how long it takes for the first mission to spawn after a restart. * DMS will now by default create markers on the bottom left of the map to show which colors correspond to which difficulty. It isn't very pretty, but it gets the point across. * DMS will now manually calculate the center of the map and its radius, if it isn't preconfigured by DMS. * You can now specify the vehicles to spawn for missions: "bandits", "cardealer", "construction", "donthasslethehoff", and "thieves". * You can now specify the spawning location of any mission (and whether or not to use an alternative location if the provided location is invalid). This will allow for easy integration of DMS into admin tools. * Added support for scripts to be executed on mission completion or mission failure (this will allow you to have "multi-part" missions, where you would simply spawn the next part of the mission if the previous is completed). * Restructured DMS_DEBUG from the previous patch in favor of a more "optimized" method. * DMS_fnc_findSafePos is completely overhauled; DMS no longer uses "BIS_fnc_findSafePos". It also now throttles minSurfaceNormal on repeated failure. You can now determine whether or not the mission should spawn on water (however, I don't suggest you use this function for water spawns yet). * You can also now define a minimum distance from other territories for missions. * DMS_fnc_IsValidPosition will now check for water depth if the provided position is meant to be checked as a "water spawn". It will now also check for nearby missions from A3XAI or VEMF (untested). * DMS_fnc_IsValidPosition now checks whether or not the position is outside of the map borders. * DMS_fnc_SelectOffsetPos will now return the 3rd element of the provided position as-is. * You can now have multiple AI within a group with a launcher. * AI now have a 5-second godmode after spawning. * You can now spawn a crate using ASL pos. DMS_fnc_SpawnCrate will also make sure that the provided classname is valid. * Just like SpawnCrate, "DMS_fnc_SpawnNonPersistentVehicle" and "DMS_fnc_SpawnPersistentVehicle" will now make sure that the provided classname is valid. * "DMS_fnc_SpawnPersistentVehicle" now supports ASL spawning. * Added support for [Rod Serling's](https://github.com/Rod-Serling) AVS. * General optimization.
184 lines
5.3 KiB
Plaintext
184 lines
5.3 KiB
Plaintext
/*
|
|
DMS_fnc_IsValidPosition
|
|
Created by eraser1
|
|
|
|
Usage:
|
|
[
|
|
_pos, // ARRAY (position): The position to check.
|
|
_waterNearLimit, // NUMBER (distance): Minimum distance from water.
|
|
_minSurfaceNormal, // NUMBER (between 0-1): Maximum "surfaceNormal"; Basically determines how steep a position is. Check the comment for config value "DMS_MinSurfaceNormal" 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.
|
|
_waterSpawn // BOOLEAN: Whether or not the mission is supposed to spawn on water.
|
|
] call DMS_fnc_IsValidPosition;
|
|
|
|
All parameters except "_pos" are optional.
|
|
|
|
Returns whether or not the provided position matches the parameters.
|
|
*/
|
|
|
|
private ["_pos", "_nearestObjectMinDistance", "_waterNearLimit", "_minSurfaceNormal", "_spawnZoneNearLimit", "_traderZoneNearLimit", "_missionNearLimit", "_playerNearLimit", "_territoryNearLimit", "_waterSpawn", "_isValidPos", "_xpos", "_ypos"];
|
|
|
|
_OK = params
|
|
[
|
|
["_pos", [], [[]], [0,2,3]],
|
|
["_waterNearLimit", DMS_WaterNearBlacklist, [0] ],
|
|
["_minSurfaceNormal", DMS_MinSurfaceNormal, [0] ],
|
|
["_spawnZoneNearLimit", DMS_SpawnZoneNearBlacklist, [0] ],
|
|
["_traderZoneNearLimit", DMS_TraderZoneNearBlacklist,[0] ],
|
|
["_missionNearLimit", DMS_MissionNearBlacklist, [0] ],
|
|
["_playerNearLimit", DMS_PlayerNearBlacklist, [0] ],
|
|
["_territoryNearLimit", DMS_TerritoryNearBlacklist, [0] ],
|
|
["_waterSpawn", false, [false] ]
|
|
];
|
|
|
|
|
|
_isValidPos = false;
|
|
|
|
if (!_OK) then
|
|
{
|
|
diag_log format ["DMS ERROR :: Calling DMS_fnc_isValidPosition with invalid parameters: %1",_this];
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
if ((count _pos)<2) then
|
|
{
|
|
throw ("(ERROR UNDEFINED POSITION)");
|
|
};
|
|
|
|
if ((count _pos) isEqualTo 2) then
|
|
{
|
|
_pos set [2, 0];
|
|
};
|
|
|
|
_xpos = _pos select 0;
|
|
_ypos = _pos select 1;
|
|
|
|
if ((_xpos<0) || {_ypos<0} || {_xpos>worldSize} || {_ypos>worldSize}) then
|
|
{
|
|
throw ("or is outside of the map edge");
|
|
};
|
|
|
|
|
|
|
|
if (!(DMS_findSafePosBlacklist isEqualTo []) && {([_pos, DMS_findSafePosBlacklist] call BIS_fnc_isPosBlacklisted)}) then
|
|
{
|
|
throw ("a blacklisted position");
|
|
};
|
|
|
|
|
|
// Only do these checks if the mission is supposed to be on land.
|
|
if (!_waterSpawn) then
|
|
{
|
|
// Check for nearby water
|
|
if ((_waterNearLimit>0) && {[_pos,_waterNearLimit] call DMS_fnc_isNearWater}) then
|
|
{
|
|
throw ("water");
|
|
};
|
|
|
|
// Terrain steepness check
|
|
// 0 surfacenormal means completely vertical, 1 surfaceNormal means completely flat and horizontal.
|
|
// Take the arccos of the surfaceNormal to determine how many degrees it is from the horizontal. In SQF: {acos ((surfaceNormal _pos) select 2)}. Don't forget to define _pos.
|
|
if ((_minSurfaceNormal>0) && {_minSurfaceNormal<=1}) then
|
|
{
|
|
if (((surfaceNormal _pos) select 2)<_minSurfaceNormal) then
|
|
{
|
|
throw ("a steep location");
|
|
};
|
|
|
|
// Check the surrounding area (within 5 meters)
|
|
private "_dir";
|
|
for "_dir" from 0 to 359 step 45 do
|
|
{
|
|
if (((surfaceNormal ([_pos,5,_dir] call DMS_fnc_SelectOffsetPos)) select 2)<_minSurfaceNormal) then
|
|
{
|
|
throw ("a nearby steep location");
|
|
};
|
|
};
|
|
};
|
|
}
|
|
else
|
|
{
|
|
// Check to see if the position is actually water.
|
|
if !(surfaceIsWater _pos) then
|
|
{
|
|
throw ("land");
|
|
};
|
|
|
|
// Check the depth of the water.
|
|
if ((getTerrainHeightASL _pos)<-DMS_MinWaterDepth) then
|
|
{
|
|
throw ("shallow water");
|
|
};
|
|
};
|
|
|
|
|
|
{
|
|
if (((getMarkerPos _x) distance2D _pos)<=_missionNearLimit) then
|
|
{
|
|
throw ("an A3XAI mission");
|
|
};
|
|
} forEach (missionNamespace getVariable ["A3XAI_mapMarkerArray",[]]);
|
|
|
|
{
|
|
// Check for nearby spawn points
|
|
if ((_spawnZoneNearLimit>0) && {((markertype _x) == "ExileSpawnZone") && {((getMarkerPos _x) distance2D _pos)<=_spawnZoneNearLimit}}) then
|
|
{
|
|
throw ("a spawn zone");
|
|
};
|
|
|
|
// Check for nearby trader zones
|
|
if ((_traderZoneNearLimit>0) && {((markertype _x) == "ExileTraderZone") && {((getMarkerPos _x) distance2D _pos)<=_traderZoneNearLimit}}) then
|
|
{
|
|
throw ("a trader zone");
|
|
};
|
|
|
|
// Check for nearby missions
|
|
if (_missionNearLimit>0) then
|
|
{
|
|
_missionPos = missionNamespace getVariable [format ["%1_pos",_x], []];
|
|
if (!(_missionPos isEqualTo []) && {(_missionPos distance2D _pos)<=_missionNearLimit}) then
|
|
{
|
|
throw ("a mission");
|
|
};
|
|
|
|
if (((_x find "VEMFr_DynaLocInva_ID")>0) && {((getMarkerPos _x) distance2D _pos)<=_missionNearLimit}) then
|
|
{
|
|
throw ("a VEMF mission");
|
|
};
|
|
};
|
|
} forEach allMapMarkers;
|
|
|
|
|
|
// Check for nearby players
|
|
// This is done last because it is likely to be the most resource intensive.
|
|
if ((_playerNearLimit>0) && {[_pos,_playerNearLimit] call DMS_fnc_IsPlayerNearby}) then
|
|
{
|
|
throw ("a player");
|
|
};
|
|
|
|
if ((_territoryNearLimit>0) && {[_pos,_territoryNearLimit] call ExileClient_util_world_isTerritoryInRange}) then
|
|
{
|
|
throw ("a territory");
|
|
};
|
|
|
|
|
|
|
|
// No exceptions found
|
|
_isValidPos = true;
|
|
}
|
|
catch
|
|
{
|
|
if (DMS_DEBUG) then
|
|
{
|
|
(format ["IsValidPosition :: Position %1 is too close to %2!",_pos,_exception]) call DMS_fnc_DebugLog;
|
|
};
|
|
};
|
|
};
|
|
|
|
|
|
_isValidPos; |