Advertisement
BobTheHunted

fn_GenResZones_RTS

Sep 20th, 2017
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.46 KB | None | 0 0
  1. // nul = [zone list, zone radius, zone density, zone value, zone randomized value, zone randomized value range, resource object type, mark objects, use marker size] call BTH_fnc_GenResZones_RTS;
  2. // zone list:------------------- Array - Array containing all marker names for resource area markers.
  3. // zone radius:---------------- Number - Radius from the center marker to use as zone area.
  4. // zone density:--------------- Number - The amount of resource objects that will be created in each zone.
  5. // zone value:----------------- Number - The value (in resources) each resource object is worth.  Doubles as the minimum value if random value is enabled.
  6. // zone randomized value:-------- Bool - Determines whether or not to randomize the value of the resource objects.
  7. // zone randomized value range: Number - The range of randomization allowed, value is max possible value.
  8. // resource object type:------- String - Classname of object to use as resource object.
  9. // mark objects:----------------- Bool - Determines whether or not to create markers where the resource objects can be found on the map.
  10. // use marker size:-------------- Bool - Determines whether or not to get the radius from the size of the marker.  For use with elliptical area markers.  Only uses x-axis value.
  11. // Debug Example: nul = [["TestMarker0"], 50, 5, 50, true, 50, "Land_PaperBox_closed_F", false, true] call BTH_fnc_GenResZones_RTS;
  12.  
  13. params [
  14.     ['_zoneList', [], [[]]],
  15.     ['_zoneRadius', 0, [0]],
  16.     ['_zoneDensity', 0, [0]],
  17.     ['_zoneValue', 0, [0]],
  18.     ['_zoneRndVal', true, [true]],
  19.     ['_zoneRndRng', 0, [0]],
  20.     ['_resType', "Land_PaperBox_closed_F", [""]],
  21.     ['_resMark', false, [true]],
  22.     ['_markRadius', false, [true]]
  23. ];
  24.  
  25. _zoneDensity = _zoneDensity - 1;
  26.  
  27. {
  28.     private _mrk = _x;
  29.     private _pos = getMarkerPos _mrk;
  30.  
  31.     for "_i" from 0 to _zoneDensity do
  32.     {
  33.         if (_markRadius) then {
  34.             private _markSize = getMarkerSize _mrk;
  35.             _zoneRadius = (_markSize select 0);
  36.         };
  37.  
  38.         private _newPos = _pos getPos [_zoneRadius * sqrt random 1, random 360];
  39.  
  40.         if (_resMark) then {
  41.             private _markPos = createMarker [str _i, _newPos];
  42.             private _markPos setMarkerShape "ICON";
  43.             private _markPos setMarkerType "mil_dot";
  44.         };
  45.  
  46.         if (_zoneRndVal) then {
  47.             private _newValue = _zoneValue + round(random _zoneRndRng);
  48.             [_newValue, _resType, _newPos, true] call BTH_fnc_ResourceObject_RTS;
  49.         } else {
  50.             [_zoneValue, _resType, _newPos, true] call BTH_fnc_ResourceObject_RTS;
  51.         };
  52.     };
  53. } forEach _zoneList;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement