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```.
This commit is contained in:
eraser1 2015-09-10 17:48:56 -05:00
parent 6cc2f1451b
commit e8eedfa538
12 changed files with 121 additions and 16 deletions

View File

@ -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 {};

View File

@ -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

View File

@ -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
{

View File

@ -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 = [];

View File

@ -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];
};

View File

@ -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

View File

@ -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);

View File

@ -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
{

View File

@ -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

View File

@ -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

Binary file not shown.

View File

@ -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```.