Jump to content
Sign in to follow this  
phoenixegmh

Random creation of markers

Recommended Posts

Hello!

Hope someone can help. Have been racking my brains for a couple of days about trying to randomly generate a handful of markers around one "Base" marker.

Found SHK's SHK_pos script and have used it to create a unit along those lines but have been unable to mod the script for creating a marker or even naming the unit so I can use that unit's location to place a marker.

Any help is greatly appreciated!

BRgds

Share this post


Link to post
Share on other sites

_pos = [bla,bla] call SHK_pos;
_unit = grpBla createunit [_pos,blabla];

call compile format ["
 _m%1 = createMarker[""mUnit%1%2"",%3];
 _m%1 setMarkerShape ""Icon"";
 _m%1 setMarkerType ""Dot"";
 _m%1 setmarkerColor ""ColorRed"";
",(floor (_pos select 0)),(floor (_pos select 0)),_pos];

That should create marker using the position of the unit as part of the marker name. For example, names of them can be: "mUnit42141032", "mUnit18832633", etc.

Edit: If you need to refer to the marker later, when the unit might have moved. You could save the name to the unit.

_pos = [bla,bla] call SHK_pos;
_unit = grpBla createunit [_pos,blabla];

_marker = call compile format ["
 _m%1 = createMarker[""mUnit%1%2"",%3];
 _m%1 setMarkerShape ""Icon"";
 _m%1 setMarkerType ""Dot"";
 _m%1 setmarkerColor ""ColorRed"";
 _m%1
",(floor (_pos select 0)),(floor (_pos select 0)),_pos];
_unit setvariable ["MarkerName",_marker,true];

Didn't test if it actually worked, but that's the idea anyway.

Then, when you need to do something to the marker, you can get the name of it from the unit with:

_marker = whatEverUnit getvariable "MarkerName";
_marker setmarkercolor "ColorGreen";

Edited by Shuko

Share this post


Link to post
Share on other sites

SHK,

Cheers for the response. Had seen that bit of code but wasn't sure exactly what it did.

Still slightly confused if I'm honest (I am a simple sole!!).

I will give you the full story of what I want, it may help!

I have a selection of hidden markers from which one is selected and a HQ Marker is generated at that location. From there I want to create one Blue Start Marker and one Yellow Start marker somewhere within a 4000m-6000m range from the Base.

Players will then be distributed to the appropriate start marker dependant upon their team.

Sorry if I can't see the wood for the trees on this one!

Thanks In Advance

Edit: Just seen your edit, will give it a spin and report back!

Share this post


Link to post
Share on other sites

You could just make the empty (hidden) markers the right color etc. Then, when you randomly select the HQ position, just change the type of the marker to "Start" so it shows up.

Yellow marker:

_pos = [blabla] call SHK_pos; // find a position for the yellow
_m = createMarker ["mYellowStart",_pos];
_m setMarkerShape "Icon";
_m setMarkerType "Start";
_m setmarkerColor "ColorYellow";

Share this post


Link to post
Share on other sites

I'm not looking to create the start marker from one of the hidden markers. That is a base.

The (very) basic theory behind the mission is that players are dropped off randomly at a start location relative to their team (Blue/Yellow), must navigate to a specific (randomly generated) target location appropriate to their team and then on to the Base (The marker chosen from a hidden marker).

Share this post


Link to post
Share on other sites

Well, you already know how to select the positions with shk_pos. The function returns a position, so you don't need to name unit or otherwise figure out it's position. :P

There are examples here on how to create a marker the usual way and how to create one dynamically. ;)

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
Sign in to follow this  

×