diff --git a/@ExileServer/addons/a3_dms/config.cpp b/@ExileServer/addons/a3_dms/config.cpp index 638b63a..280ee1d 100644 --- a/@ExileServer/addons/a3_dms/config.cpp +++ b/@ExileServer/addons/a3_dms/config.cpp @@ -43,8 +43,10 @@ class CfgFunctions class MissionSuccessState {}; class OnKilled {}; class RemoveMarkers {}; + class SelectRandomVal {}; class SelectMagazine {}; class SelectMission {}; + class SelectOffsetPos {}; class SetAILocality {}; class SetGroupBehavior {}; class SpawnAIGroup {}; diff --git a/@ExileServer/addons/a3_dms/config.sqf b/@ExileServer/addons/a3_dms/config.sqf index 1391dc1..c036836 100644 --- a/@ExileServer/addons/a3_dms/config.sqf +++ b/@ExileServer/addons/a3_dms/config.sqf @@ -21,6 +21,9 @@ DMS_DEBUG = false; DMS_AI_KillPercent = 100; // The percent amount of AI that need to be killed for "killPercent" mission requirement (NOT IMPLEMENTED) + 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 DMS_MissionMarkerWinDot = true; // Keep the mission marker dot with a "win" message after mission is over DMS_MissionMarkerLoseDot = true; // Keep the mission marker dot with a "lose" message after mission is over DMS_MissionMarkerWinDotTime = 30; // How many seconds the "win" mission dot will remain on the map diff --git a/@ExileServer/addons/a3_dms/missions/mission_init.sqf b/@ExileServer/addons/a3_dms/missions/mission_init.sqf index accc59a..054da75 100644 --- a/@ExileServer/addons/a3_dms/missions/mission_init.sqf +++ b/@ExileServer/addons/a3_dms/missions/mission_init.sqf @@ -13,8 +13,8 @@ DMS_CleanUpList = []; DMS_MissionCount = 0; DMS_RunningBMissionCount = 0; DMS_BMissionLastStart = diag_tickTime; +DMS_BMissionDelay = DMS_TimeBetweenMissions call DMS_fnc_SelectRandomVal; -DMS_BMissionDelay = (DMS_TimeBetweenMissions select 0) + random((DMS_TimeBetweenMissions select 1) - (DMS_TimeBetweenMissions select 0)); if (DMS_DEBUG) then { diff --git a/@ExileServer/addons/a3_dms/scripts/fn_AddMissionToMonitor.sqf b/@ExileServer/addons/a3_dms/scripts/fn_AddMissionToMonitor.sqf index 5c26c6b..c1a8dab 100644 --- a/@ExileServer/addons/a3_dms/scripts/fn_AddMissionToMonitor.sqf +++ b/@ExileServer/addons/a3_dms/scripts/fn_AddMissionToMonitor.sqf @@ -84,7 +84,7 @@ try _timeOutInfo params [ ["_timeStarted",diag_tickTime,[0]], - ["_timeUntilFail",(DMS_MissionTimeOut select 0) + random((DMS_MissionTimeOut select 1) - (DMS_MissionTimeOut select 0)),[0]] + ["_timeUntilFail",DMS_MissionTimeOut call DMS_fnc_SelectRandomVal,[0]] ]; _units = []; diff --git a/@ExileServer/addons/a3_dms/scripts/fn_CreateMarker.sqf b/@ExileServer/addons/a3_dms/scripts/fn_CreateMarker.sqf index a599af8..e104867 100644 --- a/@ExileServer/addons/a3_dms/scripts/fn_CreateMarker.sqf +++ b/@ExileServer/addons/a3_dms/scripts/fn_CreateMarker.sqf @@ -6,7 +6,8 @@ [ _pos, // Array: Position of the markers _text, // String: The text on the map marker that will appear on the map - _difficulty, // !!!OPTIONAL!!! String: "hardcore","difficult","moderate", "easy", OR custom color + _difficulty, // (OPTIONAL) String: "hardcore","difficult","moderate", "easy", OR custom color + _randomMarker // (OPTIONAL) Boolean: Whether or not to place the map marker on a random offset from mission, defined by DMS_MarkerPosRandomRadius ] call DMS_fnc_CreateMarker; Returns markers in format: @@ -18,14 +19,15 @@ */ -private["_pos", "_text", "_difficulty", "_num", "_color", "_dot", "_circle"]; +private["_pos", "_text", "_difficulty", "_randomMarker", "_num", "_color", "_dot", "_circle", "_dir", "_dis", "_npos"]; params [ ["_pos","ERROR",[[]],[2,3]], ["_text","ERROR",[""]], - ["_difficulty","moderate",[""]] + ["_difficulty","moderate",[""]], + ["_randomMarker",DMS_MarkerPosRandomization,[false]] ]; if ((_pos isEqualTo "ERROR") || ("_text" isEqualTo "ERROR")) exitWith @@ -49,7 +51,7 @@ switch (_difficulty) do _circle = createMarker [format ["DMS_MissionMarkerCircle%1",_num], _pos]; _circle setMarkerColor _color; _circle setMarkerShape "ELLIPSE"; -_circle setMarkerBrush "Grid"; +_circle setMarkerBrush "Solid"; _circle setMarkerSize [150,150]; _dot = createMarker [format ["DMS_MissionMarkerDot%1",_num], _pos]; @@ -57,9 +59,25 @@ _dot setMarkerColor "ColorBlack"; _dot setMarkerType "mil_dot"; _dot setMarkerText _text; +if (_randomMarker) then +{ + _dir = random 360; + _dis = DMS_MarkerPosRandomRadius call DMS_fnc_SelectRandomVal; + _npos = [_pos,_dis,_dir] call DMS_fnc_SelectOffsetPos; + + _circle setMarkerPos _npos; + _dot setMarkerPos _npos; + _circle setMarkerBrush DMS_RandomMarkerBrush; + + if (DMS_DEBUG) then + { + diag_log format ["Moving markers %1 from %2 to %3 (%4m away)",[_dot,_circle],_pos,_npos,_dis]; + }; +}; + if (DMS_DEBUG) then { - diag_log format ["Created markers |%1| at %2 with text |%3| colored %4",[_dot,_circle],_pos,_text,_color]; + diag_log format ["DMS_DEBUG CreateMarker :: Created markers |%1| at %2 with text |%3| colored %4",[_dot,_circle],_pos,_text,_color]; }; diff --git a/@ExileServer/addons/a3_dms/scripts/fn_IsNearWater.sqf b/@ExileServer/addons/a3_dms/scripts/fn_IsNearWater.sqf index 8973d38..10196cb 100644 --- a/@ExileServer/addons/a3_dms/scripts/fn_IsNearWater.sqf +++ b/@ExileServer/addons/a3_dms/scripts/fn_IsNearWater.sqf @@ -1,6 +1,7 @@ /* DMS_fnc_IsNearWater - All credit goes to WAI + Original function by WAI + Improved by eraser1 Usage: [ @@ -16,12 +17,19 @@ _result = false; _position = _this select 0; _radius = _this select 1; -for "_i" from 0 to 359 step 45 do { - _position = [(_position select 0) + (sin(_i)*_radius), (_position select 1) + (cos(_i)*_radius)]; - if (surfaceIsWater _position) exitWith { - _result = true; +try +{ + for "_i" from 0 to 359 step 45 do + { + if (surfaceIsWater ([_position,_radius,_i] call DMS_fnc_SelectOffsetPos)) then + { + throw true; + }; }; +} +catch +{ + _result = true; }; - _result \ No newline at end of file diff --git a/@ExileServer/addons/a3_dms/scripts/fn_RemoveMarkers.sqf b/@ExileServer/addons/a3_dms/scripts/fn_RemoveMarkers.sqf index 73ae653..b787c74 100644 --- a/@ExileServer/addons/a3_dms/scripts/fn_RemoveMarkers.sqf +++ b/@ExileServer/addons/a3_dms/scripts/fn_RemoveMarkers.sqf @@ -29,7 +29,8 @@ deleteMarker _markerCircle; if (_status == "win") then { - if (!DMS_MissionMarkerWinDot) exitWith { + if (!DMS_MissionMarkerWinDot) exitWith + { deleteMarker _markerDot; }; _markerDot setMarkerText ("COMPLETED: "+markerText _markerDot); @@ -42,7 +43,8 @@ if (_status == "win") then } else { - if (!DMS_MissionMarkerLoseDot) exitWith { + if (!DMS_MissionMarkerLoseDot) exitWith + { deleteMarker _markerDot; }; _markerDot setMarkerText ("FAILED: "+markerText _markerDot); diff --git a/@ExileServer/addons/a3_dms/scripts/fn_SelectMission.sqf b/@ExileServer/addons/a3_dms/scripts/fn_SelectMission.sqf index 7b4a574..bec9035 100644 --- a/@ExileServer/addons/a3_dms/scripts/fn_SelectMission.sqf +++ b/@ExileServer/addons/a3_dms/scripts/fn_SelectMission.sqf @@ -24,7 +24,7 @@ if ((_time - DMS_BMissionLastStart > DMS_BMissionDelay) && {diag_fps >= DMS_MinS DMS_BMissionLastStart = _time; _mission = DMS_MissionTypesArray call BIS_fnc_selectRandom; - DMS_BMissionDelay = (DMS_TimeBetweenMissions select 0) + random((DMS_TimeBetweenMissions select 1) - (DMS_TimeBetweenMissions select 0)); + DMS_BMissionDelay = DMS_TimeBetweenMissions call DMS_fnc_SelectRandomVal; if (DMS_DEBUG) then { diff --git a/@ExileServer/addons/a3_dms/scripts/fn_SelectOffsetPos.sqf b/@ExileServer/addons/a3_dms/scripts/fn_SelectOffsetPos.sqf new file mode 100644 index 0000000..f13e784 --- /dev/null +++ b/@ExileServer/addons/a3_dms/scripts/fn_SelectOffsetPos.sqf @@ -0,0 +1,33 @@ +/* + DMS_fnc_SelectOffsetPos + Created by eraser1 + + Usage: + [ + _pos, + _distance, + _direction + ] call DMS_fnc_SelectOffsetPos; + + Returns a new position offset from the provided position with the provided distance and direction. Position provided is at ground level in ATL + +*/ + +private ["_pos","_dis","_dir","_npos"]; + +_OK = params +[ + ["_pos","",[[]],[2,3]], + ["_dis",0,[0]], + ["_dir",0,[0]] +]; + +if (!_OK) exitWith +{ + diag_log format ["DMS ERROR :: Calling DMS_fnc_SelectOffsetPos with invalid parameters: %1",_this]; +}; + +_npos = [(_pos select 0)+(sin(_dir)*_dis),(_pos select 1)+(cos(_dir)*_dis),0]; + + +_npos \ No newline at end of file diff --git a/@ExileServer/addons/a3_dms/scripts/fn_SelectRandomVal.sqf b/@ExileServer/addons/a3_dms/scripts/fn_SelectRandomVal.sqf new file mode 100644 index 0000000..2be6325 --- /dev/null +++ b/@ExileServer/addons/a3_dms/scripts/fn_SelectRandomVal.sqf @@ -0,0 +1,30 @@ +/* + DMS_fnc_SelectRandomVal + Created by eraser1 + + Usage: + [ + _min, + _max + ] call DMS_fnc_SelectRandomVal; + + Returns a random value between _min and _max. + +*/ + +private ["_OK", "_min", "_max", "_return"]; + +_OK = params +[ + ["_min",0,[0]], + ["_max",0,[0]] +]; + +if (!_OK) exitWith +{ + diag_log format ["DMS ERROR :: Calling DMS_fnc_SelectRandomVal with invalid parameters: %1",_this]; +}; + +_return = _min + random(_max - _min); + +_return \ No newline at end of file diff --git a/Pre-Packed PBO/a3_dms.pbo b/Pre-Packed PBO/a3_dms.pbo index 16230d2..035fbde 100644 Binary files a/Pre-Packed PBO/a3_dms.pbo and b/Pre-Packed PBO/a3_dms.pbo differ diff --git a/README.md b/README.md index ca9c72a..4fc3478 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,15 @@ if (!hasInterface && !isServer) then ## Changelog: +#### September 10, 2015 (6:00 PM CST-America): +* NEW CONFIG VALUES: ```DMS_MarkerPosRandomization```, ```DMS_MarkerPosRandomRadius```, and ```DMS_RandomMarkerBrush``` +* With the above configs, you can randomize the marker positions in a random position around the actual mission center. +* You can also "force" DMS_fnc_CreateMarker to randomize (or not randomize) the marker position with optional boolean parameter of index 3. +* Changed the default (non-randomized) circle marker "brush". It should be a solid circle. +* Created new functions ```DMS_fnc_SelectOffsetPos``` and ```DMS_fnc_SelectRandomVal``` +* Adjusted a couple functions to use them. +* Fixed ```DMS_fnc_IsNearWater```. + #### September 9, 2015 (10:00 PM CST-America): * Added static AI! The "donthasslethehoff" mission has them included by default. :D * New config values: ```DMS_Bandit_Static_MoneyGain``` and ```DMS_Bandit_Static_RepGain```.