DMS_Exile/@ExileServer/addons/a3_dms/scripts/fn_MissionParams.sqf

146 lines
5.5 KiB
Plaintext
Raw Normal View History

I know... it's been over a week... gimme a break #### 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.
2015-10-17 19:39:07 +00:00
/*
DMS_fnc_MissionParams
Created by eraser1
Takes input of any argument and converts it into a standard format for DMS missions.
It will use provided mission position requirements (if they exist) and simply return a position that matches the requirements.
If arguments provided do not have the mission position information, index 0 of the returned array will be an empty array.
Any other passed values (other than empty array "[]") will be added to the end of the returned array.
Usage:
[
_findSafePosParams, // ARRAY: If a new mission position has to be generated, these values are passed to "DMS_fnc_FindSafePos" if the provided _missionPosition is improperly defined, or if it doesn't have to spawn at the provided position and that position is invalid.
[
_missionPosition, // ARRAY (position ATL): Defines where the mission will spawn
_forceSpawn // (OPTIONAL) BOOL: Whether or not to force the mission to spawn at that location. Setting "_forceSpawn" to true means that the "DMS_fnc_IsValidPosition" check will be skipped, and the provided _missionPosition will be used regardless.
],
[
_extraParam_1, // (OPTIONAL) ANY: Extra parameter(s) that may be used by the mission.
_extraParam_2, // (OPTIONAL) ANY: Extra parameter(s) that may be used by the mission.
...
_extraParam_N // (OPTIONAL) ANY: Extra parameter(s) that may be used by the mission.
]
] call DMS_fnc_MissionParams;
or
_extraParams call DMS_fnc_MissionParams; // This will simply cause the function to use the default values for "DMS_fnc_FindSafePos" to generate a mission position. The "_extraParam" will be added to the back.
NOTE: If you pass an array with more than 1 element as an argument, the array must be in the form of the first example or the example below, or else you may get unexpected results.
If you want to pass some _extraParams as an array but spawn the mission at a random (valid) position, then call it as:
[
_findSafePosParams,
[
[],
],
_extraParams_ARRAY
] call DMS_fnc_MissionParams;
Returns an array in the form
[
_missionPos,
_extraParams
]
*/
private ["_parsedParams", "_extraParams", "_missionPosition", "_OK", "_posInfo", "_forceSpawn", "_findSafePosParams"];
_extraParams = [];
if (isNil "_this") then
{
if (DMS_DEBUG) then
{
(format ["MissionParams :: Calling with nil parameter; Setting _missionPosition to generated position with default values."]) call DMS_fnc_DebugLog;
};
// Simply use generated position with default values.
_missionPosition =
[
25,DMS_WaterNearBlacklist,DMS_MaxSurfaceNormal,DMS_SpawnZoneNearBlacklist,DMS_TraderZoneNearBlacklist,DMS_MissionNearBlacklist,DMS_PlayerNearBlacklist,DMS_TerritoryNearBlacklist,DMS_ThrottleBlacklists
] call DMS_fnc_FindSafePos;
}
else
{
if (((typeName _this)=="ARRAY") && {(count _this)>1}) then
{
_OK = params
[
["_findSafePosParams",[25,DMS_WaterNearBlacklist,DMS_MaxSurfaceNormal,DMS_SpawnZoneNearBlacklist,DMS_TraderZoneNearBlacklist,DMS_MissionNearBlacklist,DMS_PlayerNearBlacklist,DMS_TerritoryNearBlacklist,DMS_ThrottleBlacklists],[[]]],
["_posInfo",[],[[]],[1,2]]
];
if (_OK) then
{
_missionPosition = _posInfo select 0;
_forceSpawn = if ((count _posInfo)>1) then {_posInfo select 1} else {false};
if (((typeName _missionPosition)!="ARRAY") || {(count _missionPosition)<2}) then
{
// Empty array means that you want to generate a mission position.
if !(_missionPosition isEqualTo []) then
{
diag_log format ["DMS ERROR :: Calling MissionParams with invalid _missionPosition: %1 | Generating new one with _findSafePosParams: %2",_missionPosition,_findSafePosParams];
};
// Passed _missionPosition parameter is invalid, so we just find a position the regular way.
_missionPosition = _findSafePosParams call DMS_fnc_FindSafePos;
}
else
{
// Make sure z-pos is defined.
if ((count _missionPosition) isEqualTo 2) then
{
_missionPosition set [2,0];
};
if (!_forceSpawn && {!([_missionPosition,DMS_WaterNearBlacklist,DMS_MaxSurfaceNormal,DMS_SpawnZoneNearBlacklist,DMS_TraderZoneNearBlacklist,DMS_MissionNearBlacklist,DMS_PlayerNearBlacklist,DMS_TerritoryNearBlacklist] call DMS_fnc_IsValidPosition)}) then
{
if (DMS_DEBUG) then
{
(format ["MissionParams :: Finding new position as provided non-mandatory _missionPosition (%1) is invalid. Finding new position.",_missionPosition]) call DMS_fnc_DebugLog;
};
// Passed _missionPosition parameter is not mandatory and doesn't meet requirements, so we just find a new position.
_missionPosition = _findSafePosParams call DMS_fnc_FindSafePos;
};
};
// Assign "_extraParams" if they exist.
_extraParams = if ((count _this)>2) then {_this select 2} else {[]};
}
else
{
diag_log format ["DMS ERROR :: Calling MissionParams with invalid _findSafePosParams or _posInfo: %1 | Generating _missionPosition with _findSafePosParams params: %2. Setting _this as _extraParams: %3",_posInfo,_findSafePosParams,_this];
_missionPosition = _findSafePosParams call DMS_fnc_FindSafePos;
_extraParams = _this;
};
}
else
{
_missionPosition =
[
25,DMS_WaterNearBlacklist,DMS_MaxSurfaceNormal,DMS_SpawnZoneNearBlacklist,DMS_TraderZoneNearBlacklist,DMS_MissionNearBlacklist,DMS_PlayerNearBlacklist,DMS_TerritoryNearBlacklist,DMS_ThrottleBlacklists
] call DMS_fnc_FindSafePos;
_extraParams = _this;
};
};
_parsedParams =
[
_missionPosition,
_extraParams
];
if (DMS_DEBUG) then
{
(format ["MissionParams :: Returning _parsedParams: %1 | Calling params: %2",_parsedParams,_this]) call DMS_fnc_DebugLog;
};
_parsedParams