Jump to content
Sign in to follow this  
celery

Random placement script?

Recommended Posts

I need two teams to be randomly placed inside a big area (trigger or marker) so that they will be at least 1 km away from each other. I have no idea how to make a random setpos command, but I have a hunch that team 2 needs to check the range to team 1 and if it's below 1000 meters, the setpos launches again until the conditions are met. I'm not talking about initial radius now, but a script powered event.

Another thing to take into account is that when a player joins late in the game, they should spawn where the rest of the team is. Maybe it's possible by randomly placing a spawn marker which will then follow the player that spawns first.

To sum it up, main request is a snippet that will place an object (or preferably invisible marker) to a random location inside a defined area! smile_o.gif

Share this post


Link to post
Share on other sites

First place two Gamelogics. One named NWL in the NW corner of the AO. The other named SEL in the SE corner of the AO.

This code will come up with random coordinates inside the AO.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_HorizontalMin = getpos NWL select 0

_HorizontalMax = getpos SEL select 0

_HorizontalRange = _HorizontalMax - _HorizontalMin

_VerticalMin = getpos SEL select 1

_VerticalMax = getpos NWL select 1

_VerticalRange = _VerticalMax - _VerticalMin

_Hori = (random _HorizontalRange) + _HorizontalMin

_Vert = (random _VerticalRange) + _VerticalMin

_Location = [_Hori,_Vert,0]

Use the _Location array to place any object you like.

Share this post


Link to post
Share on other sites

That was all I needed, thank you very much! xmas_o.gif

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  

×