Jump to content
Sign in to follow this  
1para{god-father}

Getpos + some distance

Recommended Posts

I am setting a marker position but i need to add some distance onto this so it will be way from the _vehicle and in a randon directon as it is a appreox location marker.

Not sure how to addthis bit on

getPos _vehicle

Share this post


Link to post
Share on other sites
//square
_marker setMarkerPos [(getPos _vehicle select 0) - 0.5 * _dist + (random _dist), (getPos _vehicle select 1) - 0.5 * _dist + (random _dist)];
//polar
_dist = random 40;
_angle = random 360;
_marker setMarkerPos [(getPos _vehicle select 0) + (_dist * cos _angle), (getPos _vehicle select 0) + (_dist * sin _angle)];

Share this post


Link to post
Share on other sites

Many thanks,

But this seems to put the marker a very long way infact the other end of the map most of the time? does not matter what i set the _Dist to ?

tower.sqf

if isserver then {
// get starting spot and range
_marker = _this select 0;
_radius = _this select 1;
_pos = getmarkerpos _marker;
// Find a good spot for the spawn (open area, not in trees)
_exp = "(1 + meadow) * (1 - forest) * (1 - trees)";
_prec = 100;
_bestplace = selectBestPlaces [_pos,_radius,_exp,_prec,1];
_spot = _bestplace select 0;
_spot2 = _spot select 0;
// Create the radar tower
_name = "Land_radar_EP1" createVehicle _spot2;
// Name it randomly 
_unitname = format["radar_%1", floor(random 100)];
_name setVehicleInit format ["%1 = this; this setVehicleVarName ""%1""",_unitname];
processInitCommands;


// Create a marker at the tower.
_dist = random 5;
_angle = random 359;
_marker = createMarker[format["marker%1",_name],getPos _name ];
_marker setMarkerShape "ICON";
_marker setMarkerType "FLAG";
_marker setMarkerText " Radar Tower";
_marker setMarkerSize [.50, .50];
_marker setMarkerPos [(getPos _name select 0) - 0.5 * _dist + (random _dist), (getPos _name select 1) - 0.5 * _dist + (random _dist)];

// Create a trigger at the tower.
_trigger = createTrigger["EmptyDetector", getPos _name]; 
_trigger setTriggerArea[0,0,0,false];
_trigger setTriggerActivation["None","PRESENT",true];
_trigger setTriggerStatements[format["!alive %1",_name], "HINT 'Radar Down'", ""]; 

};

Edited by psvialli

Share this post


Link to post
Share on other sites

In case you are perhaps copying the above without realising how it works, I'll reformat CarlGustaffa's answer:

//square
_dist = random 40;
_marker setMarkerPos [(getPos _vehicle select 0) - 0.5 * _dist + (random _dist), (getPos _vehicle select 1) - 0.5 * _dist + (random _dist)];

OR

//polar
_dist = random 40;
_angle = random 360;
_marker setMarkerPos [(getPos _vehicle select 0) + (_dist * cos _angle), (getPos _vehicle select 0) + (_dist * sin _angle)];

Share this post


Link to post
Share on other sites

//polar
_dist = random 40;
_angle = random 360;
_marker setMarkerPos [(getPos _vehicle select 0) + _dist*sin(_angle), (getPos _vehicle select 0) + _dist*sin(_angle)];

Try that for circle. I think in Carl's the math was multiplying distance with angle.

Share this post


Link to post
Share on other sites

Well, my bad if I didn't get the paranthesis right. Stuff like that happens when you don't test it :p But I think Grimes is wrong on using sin for both x and y. And yeah, DMarkwick is right, I forgot to assign _dist to a value, but you don't have to do random there as well. Also you assign a value to _angle while going for the square method which doesn't use it, but I'm not sure why it would move to other side of map...

Share this post


Link to post
Share on other sites

Ah. You're right. The second one should be cos :D That's what I get for rushing and just c/p ing.

Share this post


Link to post
Share on other sites

Or, for those of us who don't need to remember that stuff all the time, there is the Functions Module!

_marker setMarkerPos ([_vehicle, random 40, random 360] call BIS_fnc_relPos)

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  

×