Jump to content
mcnools

Creating a marker NEAR and object (and not on it)

Recommended Posts

I'm trying to get back into editing a bit, and I'm trying to make a simple intel-collection system where after collecting an intel item, a marker should appear in an area near a target. The point is to have to gather several intel items to figure out the position. (I want the marker to spawn somewhere in a circle around 500 metres around the target, the targets position itself will be randomized at startup).

 

I know how to spawn a marker at a specfic position with this line:

 

_marker = createMarker ["intelmarker1", position target];

 

Is there some code I can add to the position to make it randomize around the target? I've tried googling but couldn't find anything that answered my question.

 

 

Thanks!

Share this post


Link to post
Share on other sites
[position target select 0 + (random 500 - random 500),position target select 1 + (random 500 - random 500),position target select 2]

Use that instead of

position target

500 is the max distance between marker and target

Share this post


Link to post
Share on other sites

Thanks very much for the quick reply!

 

Edit: hm, I can't seem to get it to work, this is how my "on activation" field looks for the trigger that should trigger the marker:

 

_marker = createMarker ["target1", [position target select 0 + (random 500 - random 500), position target select 1 + (random 500 - random 500),position target    select 2]];  "target1" setMarkerType "hd_unknown";  "target1" setMarkerSize [1, 1];  "target1" setMarkerDir 0.93884;  "target1" setMarkerColor "ColorRed";     "target1" setMarkerPos getMarkerPos "target1"; deletevehicle intel1;

Share this post


Link to post
Share on other sites

I would suggest using BIS_fnc_relPos.

Something like:

_targetPos = [_targetPos, (400 + random 200), random 360] call BIS_fnc_relPos.

Gives you a position based on the input that is 500m +/- 100 way from the input. It is based on a vector with n random angle.

With this method you can define the minimum/maximum distance very easy. In the example it is 400/600

  • Like 2

Share this post


Link to post
Share on other sites

how would that look when added to createmarker-thing I quoted in the post above? I have no idea where to put it, haha. (even though I've been making missions since OFP I still can't get my brain around these things, it's way too logical for me, haha). With this method I assume I can have a distance farther than 500? 500 seems a bit too close if I want to have to gather several intel-items to know what town the target is in.

Share this post


Link to post
Share on other sites


_targetPos = 

[

    position target,       //position to start from

    (

        400                    //minimum distance from starting position           

        + 

        random 200 //maximum distance from starting position to add to the minimum distance from starting position

    ),                          

    random 360           // direction, where to set the new position

] call BIS_fnc_relPos.

_marker = createMarker ["target1",_targetPos];

"target1" setMarkerType "hd_unknown";

"target1" setMarkerSize [1, 1];  

"target1" setMarkerDir 0.93884;  

"target1" setMarkerColor "ColorRed";     

"target1" setMarkerPos getMarkerPos "target1"; 

deletevehicle intel1;

Share this post


Link to post
Share on other sites


_marker = createMarker ["intelmarker1", position target vectorAdd [500 - random 1000, 500 - random 1000, 0]];

  • Like 2

Share this post


Link to post
Share on other sites
_marker = createMarker ["intelmarker1", position target vectorAdd [500 - random 1000, 500 - random 1000, 0]];

 

It can sometimes be so easy :D

Share this post


Link to post
Share on other sites

It can sometimes be so easy :D

Actually even simpler way has been already suggested with BIS_fnc_relPos only I would use command instead (in next stable hopefully):

_marker = createMarker ["intelmarker1", target getPos [random 500, random 360]];

Because you can easily tweak it, if for example you want marker not closer than 100m and not further than 500m:

_marker = createMarker ["intelmarker1", target getPos [100 + random 400, random 360]];

Share this post


Link to post
Share on other sites

Hm, I tried this:

 

 

_marker = createMarker ["intelmarker1", position target vectorAdd [500 - random 1000, 500 - random 1000, 0]];

"intelmarker1" setMarkerType "hd_unknown";
"intelmarker1" setMarkerSize [1, 1];  
"intelmarker1" setMarkerDir 0.93884;  
"intelmarker1" setMarkerColor "ColorRed";     
"intelmarker1" setMarkerPos getMarkerPos "target1";
 

 

But the marker just shows up at the bottom left of the map (right at the edge) every time (far, way more than a 1000 metres) from the unit called "target".

 

Edit: oh, nevermind,  the last thing should also say "intelmarker1" instead of "target1", made a small mistake there!

Share this post


Link to post
Share on other sites

Hm, I tried this:

 

 

But the marker just shows up at the bottom left of the map (right at the edge) every time (far, way more than a 1000 metres) from the unit called "target".

 

Edit: oh, nevermind,  the last thing should also say "intelmarker1" instead of "target1", made a small mistake there!

 

because you put it there with this command

 

"intelmarker1" setMarkerPos getMarkerPos "target1";

Share this post


Link to post
Share on other sites
_marker = createMarker ["intelmarker1", position target vectorAdd [500 - random 1000, 500 - random 1000, 0]];

"intelmarker1" setMarkerType "hd_unknown";

"intelmarker1" setMarkerSize [1, 1];  

"intelmarker1" setMarkerDir 0.93884;  

"intelmarker1" setMarkerColor "ColorRed";     

"intelmarker1" setMarkerPos getMarkerPos "intelmarker1";

This code seems to work fine! for anyone who searches and finds this topic in the future. :)

Share this post


Link to post
Share on other sites

This code seems to work fine! for anyone who searches and finds this topic in the future. :)

I cant see it working fine as first you create marker at random position then you move it to position of target1 marker. But if this is what you were looking for, then cool.

Share this post


Link to post
Share on other sites

I cant see it working fine as first you create marker at random position then you move it to position of target1 marker. But if this is what you were looking for, then cool.

 

Sorry, I made a mistake in the code and forgot to change target1 to intelmarker1 there at the end. I corrected it now.

Share this post


Link to post
Share on other sites

Sorry, I made a mistake in the code and forgot to change target1 to intelmarker1 there at the end. I corrected it now.

Yeah that looks more like it, but really you dont need that last line at all.

Share this post


Link to post
Share on other sites

I'm having problems with this on a dedicated server, for some reason the marker isn't created. Do I need to modify it somehow to work on dedicated servers?

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

×