• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

How to pick random points within radius

Status
Not open for further replies.
  • Var_Real_Random_Angle = Math(random(0, 360))
  • Var_Real_Random_Distance = MAth(random(0, 1000))
  • Var_Random_Point = Offset by angle and distance(Var_Real_Random_Angle, Var_Real_Random_Distance) from Var_Centre_Point
This is close to how it should look in GUI. No WE underhand so syntax may vary but you get the idea.
 
  • Var_Real_Random_Angle = Math(random(0, 360))
  • Var_Real_Random_Distance = MAth(random(0, 1000))
  • Var_Random_Point = Offset by angle and distance(Var_Real_Random_Angle, Var_Real_Random_Distance) from Var_Centre_Point
This is close to how it should look in GUI. No WE underhand so syntax may vary but you get the idea.
Thanks. Although I'm pretty sure that isn't the most accurate way since the angle is an integer and some points will probably never be picked especially at bigger radii. Are there any other ways?
 
Last edited:
You could do the math yourself lol. Is it worth the trouble though for some accuracy ? Perhaps.

Pseudo code:
Get a randomized angle
Get a randomized distance
Get X of start point
Get Y of start point
X of end point = X of start point + (dist * cos(angle))
Y of end point = Y of start point + (dist * sin(angle))
Set end point X
Set end point Y


Some of those would be custom scripts like Set X for point ;)
Also, sin & cos in war3 may or may not ;) work in rads instead of deg so you may or may not ;) have to do a conversion of the angle or use it as rad from the beginning;)
 
You could do the math yourself lol. Is it worth the trouble though for some accuracy ? Perhaps.

Pseudo code:
Get a randomized angle
Get a randomized distance
Get X of start point
Get Y of start point
X of end point = X of start point + (dist * cos(angle))
Y of end point = Y of start point + (dist * sin(angle))
Set end point X
Set end point Y


Some of those would be custom scripts like Set X for point ;)
Also, sin & cos in war3 may or may not ;) work in rads instead of deg so you may or may not ;) have to do a conversion of the angle or use it as rad from the beginning;)
I see thanks. Looks like jass will be handy here. Is this way any slower than just picking a random point in region with a native function?
 
Status
Not open for further replies.
Back
Top