From e8eedfa5388f64e751da71430988c03400e2fbec Mon Sep 17 00:00:00 2001 From: eraser1 Date: Thu, 10 Sep 2015 17:48:56 -0500 Subject: [PATCH] More features, fixes, tweaks * 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```. --- @ExileServer/addons/a3_dms/config.cpp | 2 ++ @ExileServer/addons/a3_dms/config.sqf | 3 ++ .../addons/a3_dms/missions/mission_init.sqf | 2 +- .../a3_dms/scripts/fn_AddMissionToMonitor.sqf | 2 +- .../addons/a3_dms/scripts/fn_CreateMarker.sqf | 28 ++++++++++++--- .../addons/a3_dms/scripts/fn_IsNearWater.sqf | 20 +++++++---- .../a3_dms/scripts/fn_RemoveMarkers.sqf | 6 ++-- .../a3_dms/scripts/fn_SelectMission.sqf | 2 +- .../a3_dms/scripts/fn_SelectOffsetPos.sqf | 33 ++++++++++++++++++ .../a3_dms/scripts/fn_SelectRandomVal.sqf | 30 ++++++++++++++++ Pre-Packed PBO/a3_dms.pbo | Bin 167316 -> 169369 bytes README.md | 9 +++++ 12 files changed, 121 insertions(+), 16 deletions(-) create mode 100644 @ExileServer/addons/a3_dms/scripts/fn_SelectOffsetPos.sqf create mode 100644 @ExileServer/addons/a3_dms/scripts/fn_SelectRandomVal.sqf 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 16230d2f1f84fdc5be4a491b2268e0be06313949..035fbde74bdc37f5a7d385f567a2885aac75dcfc 100644 GIT binary patch delta 2599 zcmaJ?Z){Ul6!*RTYa6;hVX(OkysMeE@YuQyFm%kYF-b7TrPN1zyT0)H-uB+> z%0N<0_+Vm;%m;ZTh>04{z4xuGb8N|a z?>qP0bAIRi&N=t=+paf1be)>oGG6rv{kwRz5F-1SswAYTPJJdp#n%t9ssOi8*fsfym2&{OpE(oUu{bDJ#@Zj)|WC zrVzSiZmK@uK4;$}F3*{-S05q<7pk9h->@UR|7{_3!+gAEfA+rZ`^(FP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