• 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!

Circular Region for Unit Spawning

Level 2
Joined
Nov 27, 2017
Messages
12
I plan to create a circular field on the middle of the map as an intersections for players to hunt onto. I normally use rectangular areas to match the square shape of the region to spawn creeps, but I think its not equal to all the spawnings points, which can be unfair. Is there a way to create a circle-shaped region to spawn creeps onto, or a technique that imitates one, such as unit/doodad that you put in certain points in the circle part of the map. Please teach me how. Thank you.

If possible, I would also like it to be stackable inside the field, since i want to create smaller circle regions inside to create layers for difficulty.
 
Under the hood, regions are collections of rects which are always rectangular as the name implies. No circular region is possible natively. You COULD build an approximately-circular region out of a bunch of rects using JASS (GUI won't let you do that easily), but I think that's a lot of work. The simplest solution is to use random polar coordinates around a center point (random distance at a random angle):
  • Set Mid = (Center of REGION)
  • Set MinRange = 10.00
  • Set MaxRange = 1000.00
  • -------- --------
  • Set RandomPointInCircle = (Mid offset by (Random number between MinRange and MaxRange) towards (Random number between 0.00 and 360.00) Degrees)
This function is called Point With Polar Offset in the trigger editor. Because of how the random distance is used in generation this method will have a slight bias towards points near the center from which everything is offset. This non-uniform distribution is noticeable when using enough of these random points at once, but most of the time that shouldn't matter; there are ways to avoid this with a bit more math.

If you want to have different circles of different sizes just change the min and max range when generating points to make the ring/disc the size you want. Also don't forget to clean up any point leaks.
 
Back
Top