Jump to content
Sign in to follow this  
skatardude10

setMarkerPos to _unit offset by random value?

Recommended Posts

Hey guys! This is my first post. Ill start with going off topic for a moment. I figured i'd buy Arma II: OA to play DayZ after seeing a good video review of DayZ and thought I might be wasting time on the ARMA part of it. Long story short I jumped into the armory and was confounded by how many options there were to play Arma - It's become like Crack for me literally I can't stop. The editor alone is endless enjoyment. Now to my question per the title.

I've got this respawn script from Tajin in another post

_temp = _this select 0;
_varname = vehicleVarName _temp;
_unit = objnull;


createMarkerLocal [_varname, [0,0]];
_varname setMarkerShape "ICON";
_varname setMarkerColor "ColorBlack";
_varname setMarkerSize [1,1];
_varname setMarkerType "Arrow";

while {true} do {
   waitUntil {
       call compile format ["_unit = %1",_varname];
       alive _unit;
   };

   while {alive _unit} do {
       if (side _unit == west) then {
           _varname setMarkerColor "ColorBlue";
       };
       if (side _unit == east) then {
           _varname setMarkerColor "ColorRed";
       };
       _varname setMarkerDir getDir _unit;
       _varname setMarkerPos getPos _unit;

       sleep 0.5;
   };
   _varname setMarkerColor "ColorBlack";
   sleep 5;
};

This keeps moving the marker to where the player is, And along with the SP_Respawn.sqf I found elsewhere it works GREAT to respawn troops exactly where they died. The above script updates every half second or so.

What I want to do is say offset this markers position by a random value in the range of negative 10m to positive 10m, X and Y... I want it to be like when I look at the map the marker every half second jumps somewhere within 10 meters of my vicinity rather than right ontop of me so that when I die or someone else dies, they spawn just around the corner, or wherever the marker has randomly jumped to just nearby so you don't spawn exactly where you died basically.

I was trying things like

createMarkerLocal [_varname, [ {(random 20) - 10} , {(random 20) - 10} ]];

but they just end up somewhere on the edge of the map... or I would try

        _varname setMarkerDir getDir _unit + [(random 20) - 10} , {(random 20) - 10];
       _varname setMarkerPos getPos _unit + [(random 20) - 10} , {(random 20) - 10];

and the same thing would happen. The problem is I don't know any scripting. Can you guys help me out?

Edit: I just found this: http://www.armaholic.com/page.php?id=13783 SHK_pos... That's a lot to learn lol :-) better start reading

Edited by skatardude10

Share this post


Link to post
Share on other sites

_pos = [(getpos player select 0) + 10, (getpos player select 1) - 10, 0];
_mkr = createMarker ["Name",_pos];

This basically selects the X-axis of the player and adds 10 m to it, select 1 selects the y-axis and subtracts 10m from it, height is 0.

I suggest you go read Mr Murrays editing guide, and, depending if you have any other programming language experience, this basic SQF tutorial.

Share this post


Link to post
Share on other sites

Thanks for the help, im going to try it like this.

	_pos = [(getpos _unit select 0) + (random 20) - (random 20), (getpos player select 1) - (random 20) - (random 20), 0];
       _varname setMarkerDir getDir _unit;
       _varname setMarkerPos _pos;

Awesome! Thank you, it works. I will look that up later tonight when I have time to dive in. Got to get back to work.

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  

×