Random X,Y(location) in region?

Romek

Super Moderator
Reaction score
963
There doesn't seem to be a way of doing this for regions other than getting random points on the map, checking if they're in the region, and repeat if they're not.
As you can probably guess, this isn't the most practical approach to the problem, and you may end up hitting the op. limit before you get your point.

As for [ljass]rect[/ljass]s:
JASS:
local rect r = //Your Rect

// If you want coordinates:
local real x = GetRandomReal(GetRectMinX(r), GetRectMaxX(r))
local real y = GetRandomReal(GetRectMinY(r), GetRectMaxY(r))

//If you want a location:
local location l = Location(GetRandomReal(GetRectMinX(r), GetRectMaxX(r)), GetRandomReal(GetRectMinY(r), GetRectMaxY(r)))
 

cryowraith

New Member
Reaction score
7
Well I am currently using the rects, but there are 2 rects that I need to consider. Which is why I tought using regions would be a cleaner way. But anyway thanks for the help.
 

Romek

Super Moderator
Reaction score
963
Get a random point in a random one of the two rects.
If one of the rects is larger, you'll need to ensure that there is a higher chance a random point is picked within that rect.

For example, if rect 'a' is twice as large as rect 'b', there should be a 2/3 chance of picking 'a', and a 1/3 chance of getting 'b'.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top