Jump to content
Undeadenemy

Generate Random Markers with Trigger Areas

Recommended Posts

Hello. I am working on a mission where I want to have some random danger areas on the map that change with each play through. I want to:

 

Generate a number markers on the map (ellipses).

Use the markers as the placement POS for a triggerArea, which will be defined in 3D (ATL).

The marker text will then be the altitude bounds of the danger area. Deriving the zMax/zMin of the area will take some math. Probably something like:

zMin = zPOSATL - (zArea/2); zMax = zPOSATL + (zArea/2);

I know generally the steps I need to take to accomplish this, however, there are a lot of tricky ARMA things making this difficult (ex: I'm going to have to concatenate a string (prefix + index) in order to get around the fact that ARMA won't create a marker if the name is already in use.

 

The steps I think I need to take are:

Generate an array of N size.

Iterate through the array. For each item:

-createMarker, setMarkerShape, setMarkerSize, setMarkerColor, setMarkerBrush

 

Here is the code I have so far. It isn't much, but I'm out of time for a few hours and I was hoping someone could point me in the right direction:

params ["_prefixName","_numSites", "_mapX", "_mapY", "_minZ", "sizeZ"]

for _i from 0 to _numSites do {
    _x = createMarker [""_prefixName" "+" "_i"", [ random[0,(_mapX/2),_mapX], random[0,(mapY/2),_mapY]] ];
    _x = setMarkerShape "ELLIPSE";
    _x = setMarkerColor "RED";
    _x = setMarkerAlpha 0.5;
    _x = setMarkerBrush "Cross";
    _x = setMarkerSize [500,500];
    };

 

Share this post


Link to post
Share on other sites

format [“%1_%2”,_prefixName,_i]

 

And after you assign the marker into your _x variable, which I would recommend changing to something more specific, you shouldn’t do ‘_x = setMarkerXXX Y;’ just do ‘_x setMarkerXXX Y;’

 

And you may find some use in this newer function: https://community.bistudio.com/wiki/BIS_fnc_stringToMarker

  • Like 2

Share this post


Link to post
Share on other sites

So I fixed a few problems with my code and managed to get this to work in the INIT line of an invisible helipad:

 

_this = createMarker [format["%1_%2","test",_i], [random[0,6000,12000], random[0,6000,12000]]]; 
_this setMarkerType "Empty"; 
_this setMarkerShape "ELLIPSE"; 
_this setMarkerColor "ColorRed"; 
_this setMarkerAlpha 0.5; 
_this setMarkerBrush "Cross"; 
_this setMarkerSize [500,500];

 

This creates a single, randomly place, marker to my specs. However, I can't seem to get the iterable version to work:

 

for _i from 0 to 20 do {
_this = createMarker [format["%1_%2","test",_i], [random[0,6000,12000], random[0,6000,12000]]]; 
_this setMarkerType "Empty"; 
_this setMarkerShape "ELLIPSE"; 
_this setMarkerColor "ColorRed"; 
_this setMarkerAlpha 0.5; 
_this setMarkerBrush "Cross"; 
_this setMarkerSize [500,500];
};

Nor this version, using the magic variable _x (which was why I was using that earlier):

 

for _i from 0 to 20 do {
_x = createMarker [format["%1_%2","test",_i], [random[0,6000,12000], random[0,6000,12000]]]; 
_x setMarkerType "Empty"; 
_x setMarkerShape "ELLIPSE"; 
_x setMarkerColor "ColorRed"; 
_x setMarkerAlpha 0.5; 
_x setMarkerBrush "Cross"; 
_x setMarkerSize [500,500];
};

There could be numerous reasons for this (maybe the format command isn't working, resulting in multiple markers with the same name? Not sure, but using _this (but not _x) works in the single use version, but either way, as soon as I stick a for loop on it, it stops working.

Share this post


Link to post
Share on other sites

You don't need any magic variable (you should read how they work).

 

for "_i" from 0 to 20 do {
  _mk = createMarker [format["test_%1",_i], [random[0,6000,12000], random[0,6000,12000]]];  
  _mk setMarkerShape "ELLIPSE";  
  _mk setMarkerColor "ColorRed";  
  _mk setMarkerAlpha 0.5;  
  _mk setMarkerBrush "Cross";  
  _mk setMarkerSize [500,500];
};

  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×