Fixes + Idiot-proofing + New Function

* NEW CONFIG VALUE: "DMS_MaxSurfaceNormal"
* The above config value now determines the maximum incline that a
mission can spawn on. Default value is 0.95, which should be
sufficiently flat.
* Added some grouping explanations in mission config settings.
* Added check for A3XAI for the lovely
["Face"/"dayzai"](https://github.com/dayzai)
* Added ability for people to use a static export from M3Editor. DMS
will then calculate the relative position, and spawn it at the mission.
Example provided in testmission.sqf.
* Fixed an issue with DMS_fnc_TargetsKilled always returning false.
This commit is contained in:
eraser1 2015-09-20 15:26:08 -05:00
parent fa75b5783f
commit d4733a5559
13 changed files with 257 additions and 22 deletions

View File

@ -38,7 +38,10 @@ class CfgFunctions
class FillCrate {};
class FindSafePos {};
class FindSuppressor {};
//class HeliParatroopers {};
//class HeliPatrol {};
class ImportFromM3E {};
class ImportFromM3E_Convert {};
class IsPlayerNearby {};
class IsNearWater {};
class MissionsMonitor {};

View File

@ -12,16 +12,19 @@ DMS_DEBUG = false;
/* Mission System Settings */
/*General settings for dynamic missions*/
DMS_DynamicMission = true; // Enable/disable dynamic mission system
DMS_MaxBanditMissions = 3; // Maximum number of Bandit Missions running at the same time
DMS_StaticMission = false; // Enable/disable static missions
DMS_TimeBetweenMissions = [600,900]; // [Minimum,Maximum] time between missions (if mission limit is not reached) | DEFAULT: 10-15 mins
DMS_MissionTimeOut = [900,1800]; // [Minimum,Maximum] time it will take for a mission to timeout | Default: 15-30 mins
/*General settings for dynamic missions*/
DMS_playerNearRadius = 100; // How close a player has to be to a mission in order to satisfy the "playerNear" mission requirement (can be customized per mission).
DMS_AI_KillPercent = 100; // The percent amount of AI that need to be killed for "killPercent" mission requirement (NOT IMPLEMENTED)
/*Mission Marker settings*/
DMS_MarkerPosRandomization = false; // Randomize the position of the circle marker of a mission
DMS_MarkerPosRandomRadius = [25,100]; // Minimum/Maximum distance that the circle marker position will be randomized | Default: 0 meters to 200 meters
DMS_RandomMarkerBrush = "Cross"; // See: https://community.bistudio.com/wiki/setMarkerBrush
@ -31,30 +34,38 @@ DMS_DEBUG = false;
DMS_MissionMarkerLoseDotTime = 30; // How many seconds the "lose" mission dot will remain on the map
DMS_MissionMarkerWinDotColor = "ColorBlue"; // The color of the "win" marker dot
DMS_MissionMarkerLoseDotColor = "ColorRed"; // The color of the "lose" marker dot
/*Mission Marker settings*/
/*Mission Cleanup/Timeout settings*/
DMS_CompletedMissionCleanup = true; // Cleanup mission-spawned buildings and AI bodies after some time
DMS_CompletedMissionCleanupTime = 3600; // Minimum time until mission-spawned buildings and AI are cleaned up
DMS_CleanUp_PlayerNearLimit = 20; // Cleanup of an object is aborted if a player is this many meters close to the object
DMS_AIVehCleanUpTime = 900; // Time until a destroyed AI vehicle is cleaned up.
DMS_MissionTimeoutReset = true; // Enable mission timeout timer reset if a player is close
DMS_MissionTimeoutResetRange = 1000; // If a player is this close to a mission then it won't time-out
/*Mission Cleanup/Timeout settings*/
/*Mission spawn location settings*/
DMS_PlayerNearBlacklist = 2000; // Missions won't spawn in a position this many meters close to a player
DMS_SpawnZoneNearBlacklist = 2500; // Missions won't spawn in a position this many meters close to a spawn zone
DMS_TraderZoneNearBlacklist = 3000; // Missions won't spawn in a position this many meters close to a trader zone
DMS_MissionNearBlacklist = 4000; // Missions won't spawn in a position this many meters close to another mission
DMS_WaterNearBlacklist = 750; // Missions won't spawn in a position this many meters close to water
DMS_MaxSurfaceNormal = 0.95; // Missions won't spawn if the surface normal of the location is less than this amount. The lower the value, the steeper the location. Greater values means flatter locations
/*Mission spawn location settings*/
DMS_MinWaterDepth = 20; // Minimum depth of water that an underwater mission can spawn at.
/*Crate/Box settings*/
DMS_HideBox = false; // "Hide" the box from being visible by players until the mission is completed.
DMS_SpawnBoxSmoke = true; // Spawn a smoke grenade on mission box upon misson completion during daytime
DMS_SpawnBoxIRGrenade = true; // Spawn an IR grenade on mission box upon misson completion during nighttime
/*Crate/Box settings*/
DMS_MinPlayerCount = 0; // Minimum number of players until mission start
DMS_MinServerFPS = 5; // Minimum server FPS for missions to start
//Mission notification settings
/*Mission notification settings*/
DMS_PlayerNotificationTypes = [ // Notification types. Supported values are: ["dynamicTextRequest", "standardHintRequest", "systemChatRequest"]
//"dynamicTextRequest", <--- Text formatting makes this weird...
"standardHintRequest"
@ -62,6 +73,7 @@ DMS_DEBUG = false;
];
DMS_dynamicText_Size = 0.65; // Dynamic Text size for "dynamicTextRequest" notification type.
DMS_dynamicText_Color = "#FFCC00"; // Dynamic Text color for "dynamicTextRequest" notification type.
/*Mission notification settings*/
DMS_MissionTypes = [ // List of missions with spawn chances. If they add up to 100%, they represent the percentage chance each one will spawn
["bandits",25],

View File

@ -12,6 +12,11 @@ EAST setFriend[RESISTANCE,0];
EAST setFriend[WEST,0];
WEST setFriend[EAST,0];
if ((!isNil "A3XAI_isActive") && {!DMS_ai_offload_Only_DMS_AI}) then
{
diag_log 'DMS DETECTED A3XAI. Enabling "DMS_ai_offload_Only_DMS_AI"!';
};
if(DMS_StaticMission) then
{

View File

@ -1,16 +1,89 @@
/*
DMS Pre-init
Written by eraser1 (trainwreckdayz.com)
This will be completely deprecated soon...
*/
/* Future stuff
DMS_HeliPara = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\HeliPara.sqf";
DMS_HeliPatrol = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\HeliPatrol.sqf";
*/
DMS_HC_Object = objNull;
//Load config
call compileFinal preprocessFileLineNumbers "\x\addons\dms\config.sqf";
call compileFinal preprocessFileLineNumbers "\x\addons\dms\config.sqf";
/*
Original Functions from
http://maca134.co.uk/portfolio/m3editor-arma-3-map-editor/
Slightly modified by eraser1
*/
M3E_fnc_getCenter =
{
private ['_objects', '_ax', '_ay', '_az', '_xs', '_xc', '_xz', '_ys', '_yc', '_yz', '_zs', '_zc', '_zz'];
_objects = [_this, 0, [], [[]]] call BIS_fnc_param;
_ax = [];
_ay = [];
_az = [];
{
private ['_position'];
_position = getPosATL _x;
_ax pushBack (_position select 0);
_ay pushBack (_position select 1);
_az pushBack (_position select 2);
} foreach _objects;
_xs = 0;
_xc = {_xs = _xs + _x; true} count _ax;
_xz = _xs / _xc;
_ys = 0;
_yc = {_ys = _ys + _x; true} count _ay;
_yz = _ys / _yc;
_zs = 0;
_zc = {_zs = _zs + _x; true} count _az;
_zz = _zs / _zc;
[_xz, _yz, _zz]
};
M3E_fnc_subArr =
{
private ['_a1', '_a2', '_a3'];
_a1 = [_this, 0, [], [[]]] call BIS_fnc_param;
_a2 = [_this, 1, [], [[]]] call BIS_fnc_param;
if (count _a1 == 0 || {count _a2 == 0}) exitWith {[]};
if (count _a1 != count _a2) exitWith {[]};
_a3 = [];
{
_a3 pushBack ((_a1 select _foreachindex) - (_a2 select _foreachindex));
} foreach _a1;
_a3
};
DMS_fnc_setRelPositions =
{
private ['_OK','_objects','_newCPos','_center'];
_OK = params
[
["_objects", [], [[]]],
["_newCPos", [], [[]],[3]]
];
if (!_OK) exitWith
{
diag_log format ["DMS ERROR :: Calling DMS_fnc_setRelPositions with invalid parameters: %1",_this];
};
_center = [_objects] call M3E_fnc_getCenter;
{
private ['_relpos','_objPos'];
_relpos = [getPosATL _x, _center] call M3E_fnc_subArr;
_objPos = [_newCPos,_relpos] call DMS_fnc_CalcPos;
_x setPosATL _objPos;
//diag_log format ["Setting %1 at %2; %3 is the relpos from original center %4, reapplied to new center %5",typeOf _x,_objPos,_relpos,_center,_newCPos];
} foreach _objects;
};

View File

@ -77,6 +77,15 @@ _veh =
] call DMS_fnc_SpawnAIVehicle;
_baseObjs =
[
"base1STATIC",
_pos
] call DMS_fnc_ImportFromM3E_Convert;
// Define mission-spawned AI Units
_missionAIUnits =
[
@ -86,7 +95,7 @@ _missionAIUnits =
// Define mission-spawned objects and loot values
_missionObjs =
[
_staticGuns+[_veh],
_staticGuns+[_veh]+_baseObjs,
[_vehicle],
[[_crate,"Sniper"]]
];

View File

@ -0,0 +1,27 @@
// This file is effectively the exact same as "base1.sqf" in the folder above it.
//Using relative position is preferable; this file is just an example on how to format a file with static objects.
private ["_objs"];
_objs = [
["Land_HBarrierTower_F",[1688.42,5601.6,0],180.049,[[-0.000857441,-1,0],[-0,0,1]],false],
["Land_HBarrierTower_F",[1702.61,5582.49,0],270.462,[[-0.999968,0.00806372,0],[0,0,1]],false],
["Land_HBarrierTower_F",[1688.42,5563.38,0],0,[[0,1,0],[0,0,1]],false],
["Land_HBarrierTower_F",[1674.23,5582.49,0],90.6414,[[0.999937,-0.0111948,0],[0,-0,1]],false],
["Land_HBarrierWall_corridor_F",[1673.47,5576.89,0],0,[[0,1,0],[0,0,1]],false],
["Land_CncWall4_F",[1682.45,5565.37,0],0,[[0,1,0],[0,0,1]],false],
["Land_CncWall4_F",[1678.62,5567.57,0],53.1818,[[0.800541,0.599277,0],[0,0,1]],false],
["Land_CncWall4_F",[1676.66,5572.1,0],82.6364,[[0.991753,0.128166,0],[0,0,1]],false],
["Land_CncWall4_F",[1694.47,5565.37,0],0,[[0,1,0],[0,0,1]],false],
["Land_CncWall4_F",[1698.32,5567.56,0],302.318,[[-0.845092,0.534621,0],[0,0,1]],false],
["Land_CncWall4_F",[1700.14,5572.25,0],280.636,[[-0.982818,0.184575,0],[0,0,1]],false],
["Land_HBarrierWall_corridor_F",[1703.4,5577.06,0],0,[[0,1,0],[0,0,1]],false],
["Land_CncWall4_F",[1700.73,5588.52,0],262.221,[[-0.990797,-0.135353,0],[-0,0,1]],false],
["Land_CncWall4_F",[1699.35,5593.46,0],249.539,[[-0.936912,-0.349566,0],[-0,0,1]],false],
["Land_CncWall4_F",[1696.28,5597.31,0],215.994,[[-0.587697,-0.809081,0],[-0,0,1]],false],
["Land_CncWall1_F",[1693.6,5599.05,0],201.682,[[-0.369452,-0.92925,0],[-0,0,1]],false],
["Land_HBarrier_1_F",[1692.58,5600.12,0],290.455,[[-0.93695,0.349464,0],[0,0,1]],false],
["Land_HBarrier_Big_F",[1681.72,5597.13,0],309.682,[[-0.769601,0.638525,0],[0,0,1]],false],
["Land_HBarrier_Big_F",[1677,5589.9,0],298.636,[[-0.877679,0.479249,0],[0,0,1]],false]
];
_objs;

View File

@ -50,6 +50,12 @@ while{!_validspot} do
{
throw ("players");
};
if (((surfaceNormal _pos) select 2)<DMS_MaxSurfaceNormal) then
{
diag_log format ["%1 is too steep.",_pos];
throw ("a steep location");
};
{
// Check for nearby spawn points

View File

@ -10,6 +10,8 @@
_pos // Object or Array: Center position
] call DMS_fnc_ImportFromM3E;
It takes RELATIVE POSITION as argument. In order to get relative positions, check this link: http://maca134.co.uk/portfolio/m3editor-arma-3-map-editor/
Returns all created objects.
*/
@ -31,7 +33,7 @@ if (!_OK) exitWith
// Get the position if an object was supplied instead of position
if ((typeName _pos)=="OBJECT") then
{
_pos = getPos _pos;
_pos = getPosATL _pos;
};
// Set the center pos to 0 if it isn't defined

View File

@ -0,0 +1,74 @@
/*
DMS_fnc_ImportFromM3E_Convert
Created by eraser1
Check out M3 Editor: http://maca134.co.uk/portfolio/m3editor-arma-3-map-editor/
Usage:
[
_file, // String: The filename (or filepath under the objects folder) that contains the exported M3E objects
_missionPos // Object or Array: Center position
] call DMS_fnc_ImportFromM3E;
This function will take a file exported from M3Editor, convert it into relative position, then place the objects from the converted relative positions.
Use this function if you don't know how to get the relative position, and you only have the exported static positions.
This function will return all created objects.
*/
private ["_file", "_missionPos", "_objs", "_export", "_obj", "_objPos"];
_OK = params
[
["_file","",[""]],
["_missionPos","",[[],objNull],[2,3]]
];
if (!_OK) exitWith
{
diag_log format ["DMS ERROR :: Calling DMS_fnc_ImportFromM3E with invalid parameters: %1",_this];
[]
};
// Get the position if an object was supplied instead of position
if ((typeName _missionPos)=="OBJECT") then
{
_missionPos = getPosATL _missionPos;
};
// Set the center pos to 0 if it isn't defined
if ((count _missionPos)<3) then
{
_missionPos set [2,0];
};
_objs = [];
_export = call compile preprocessFileLineNumbers (format ["\x\addons\DMS\objects\static\%1.sqf",_file]);
{
private ["_obj","_pos"];
_obj = createVehicle [_x select 0, [0,0,0], [], 0, "CAN_COLLIDE"];
_pos = _x select 1;
_pos set [2,(_pos select 2)+5000];
if (_x select 4) then
{
_obj setDir (_x select 2);
_obj setPos _pos;
}
else
{
_obj setPosATL _pos;
_obj setVectorDirAndUp (_x select 3);
};
_objs pushBack _obj;
} foreach _export;
[_objs,_missionPos] call DMS_fnc_setRelPositions;
_objs

View File

@ -90,7 +90,7 @@ _exit = false;
}
catch
{
if (true) then
if (DMS_DEBUG) then
{
diag_log format ["DMS_DEBUG MissionSuccessState :: %1",_exception];
};

View File

@ -31,8 +31,13 @@ try
{
if (((typeName _x) == "OBJECT") && {!isNull _x && {alive _x}}) then
{
// It only seems long... but it's only evaluating 3 conditions.
if ((DMS_MaxAIDistance>0) && {((time - (_x getVariable ["DMS_LastAIDistanceCheck",time]))>DMS_AIDistanceCheckFrequency) && {((getPosWorld _x) distance2D (_x getVariable ["DMS_AISpawnPos",getPosWorld _x]))>DMS_MaxAIDistance}}) then
private ["_lastDistanceCheckTime", "_spawnPos"];
_lastDistanceCheckTime = _x getVariable ["DMS_LastAIDistanceCheck",time];
_pos = getPosWorld _x;
_spawnPos = _x getVariable ["DMS_AISpawnPos",_pos];
if ((DMS_MaxAIDistance>0) && {((time - _lastDistanceCheckTime)>DMS_AIDistanceCheckFrequency) && {(_pos distance2D _spawnPos)>DMS_MaxAIDistance}}) then
{
_x setDamage 1;
diag_log format ["Killed a runaway unit! |%1| was more than %2m away from its spawn position %3!",_x,DMS_MaxAIDistance,_x getVariable "DMS_AISpawnPos"];
@ -49,14 +54,23 @@ try
diag_log format ["DMS ERROR :: %1 is neither OBJECT nor GROUP!",_x];
};
{
if ((DMS_MaxAIDistance>0) && {((time - (_x getVariable ["DMS_LastAIDistanceCheck",time]))>DMS_AIDistanceCheckFrequency) && {((getPosWorld _x) distance2D (_x getVariable ["DMS_AISpawnPos",getPosWorld _x]))>DMS_MaxAIDistance}}) then
if (alive _x) then
{
_x setDamage 1;
diag_log format ["Killed a runaway unit! |%1| was more than %2m away from its spawn position %3!",_x,DMS_MaxAIDistance,_x getVariable "DMS_AISpawnPos"];
}
else
{
throw _x;
private ["_lastDistanceCheckTime", "_spawnPos"];
_lastDistanceCheckTime = _x getVariable ["DMS_LastAIDistanceCheck",time];
_pos = getPosWorld _x;
_spawnPos = _x getVariable ["DMS_AISpawnPos",_pos];
if ((DMS_MaxAIDistance>0) && {((time - _lastDistanceCheckTime)>DMS_AIDistanceCheckFrequency) && {(_pos distance2D _spawnPos)>DMS_MaxAIDistance}}) then
{
_x setDamage 1;
diag_log format ["Killed a runaway unit! |%1| was more than %2m away from its spawn position %3!",_x,DMS_MaxAIDistance,_x getVariable "DMS_AISpawnPos"];
}
else
{
throw _x;
};
};
} forEach (units _x);
};
@ -66,7 +80,8 @@ try
}
catch
{
if (DMS_DEBUG) then {
if (DMS_DEBUG) then
{
diag_log format ["DMS_DEBUG TargetsKilled :: %1 is still alive! All of %2 are not yet killed!",_exception,_this];
};
};

Binary file not shown.

View File

@ -78,6 +78,15 @@ if (!hasInterface && !isServer) then
## Changelog:
#### September 20, 2015 (3:30 PM CST-America):
* NEW CONFIG VALUE: "DMS_MaxSurfaceNormal"
* The above config value now determines the maximum incline that a mission can spawn on. Default value is 0.95, which should be sufficiently flat.
* Added some grouping explanations in mission config settings.
* Added check for A3XAI for the lovely ["Face"/"dayzai"](https://github.com/dayzai)
* Added ability for people to use a static export from M3Editor. DMS will then calculate the relative position, and spawn it at the mission. Example provided in testmission.sqf.
* Fixed an issue with DMS_fnc_TargetsKilled always returning false.
#### September 20, 2015 (12:30 AM CST-America):
* NEW CONFIG VALUE: "DMS_ai_offload_Only_DMS_AI"
* You can use "DMS_ai_offload_Only_DMS_AI" to offload only AI spawned by DMS. This should resolve any issues with other mission systems from DMS.