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

Linking and subtracting regions

Status
Not open for further replies.
Level 3
Joined
Sep 20, 2010
Messages
29
Hey guys! I need a region of unusual form (not standart square-like). Is it possible to link some regions or subtract one of them from another?
 
Level 5
Joined
Nov 30, 2012
Messages
200
No, but you can make a huge number of regions. What are you exactly trying to do? Maybe there is some other solution.
 
Level 3
Joined
Sep 20, 2010
Messages
29
Sadly=( I need this for few triggers, one of them (simplier one) - mobs respawn. There are the forest around the town and there are a few type of animals here. Trigger is simple (sorry, I don't know how to use trigger-posting here):
-----------
A unit dies
-----------
If unit-type of dying unit = wolf (one of them exactly)
-----------
wait n seconds
create 1 wolf at random point of REGION

But this way they will spawn only at one side of the forest (or if ill extend region - in town to). Ony one solution i found is to make different unit types with same characteristics and different editor suffixes, and spawn each one in different regions or check for a random percentage, but it's too boring to realize=(
Same for item/unit random spawns

gorillabull, standart square of big size with hole in it's center and linked chain of regions
 
Last edited by a moderator:
Level 5
Joined
Nov 30, 2012
Messages
200
Oh, cool. I didn't know you could combine regions together, but of course there is no way to create a region that is shaped as a non-square in the region palette. But you can make shapes that are made of rectangles.
 
Level 17
Joined
Jul 17, 2011
Messages
1,863
in your case since you need a circle or a hole you can do it like this:

first define a point which will be the center of your circle, then define a radius after that
whenever you need to check if a unit is in our out of the circle use this formula

if (x of your unit - x of circle)^2 + (y of your unit - y of circle)^2 < circle radius ^ 2 then your unit is inside the circular rect..

regions are nothing more than distance from point numbers even if you do them in gui
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Regions are made of cells representing the smallest managed area of the map playfield. Be aware that regions in WC3 have basic functionality (events and a few other things only) so do not expect to do much with them.

It is entirly possible to detect when a unit enters a circil-ish area of the playfield using regions. It is not possible to test if a location is inside a region.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
There is not a native function for getting a random location within a region though. So you may have some fun finding a suitable algorithm. You will probably store the added rects/cells in an own structure in order to keep track of them.
This is a problem that even plagued StarCraft II and its developers many years after WarCraft III. How does one get a fair random point from a collection of odd shapes efficiently?

The StarCraft II approach is to get a random point in the smallest square that contains the entire region and then checking if it is in the region. This process repeats until such a point is found or a number of tries is exceeded and null is returned instead.
 
Status
Not open for further replies.
Top