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!
WonderRect is a happy, little library to create ALICE objects out of pre-placed rects. It emulates regions without using the native type. WonderRegions expand native regions by allowing triangular shapes, giving you the ability to compute the distance of an object to the nearest edge of the region, as well as providing a way to enumerate objects inside of it with ALICE_EnumObjectsInRegion.
In addition, WonderRect offers convenient, automatic grouping of rects and merges them into regions based on their names. If you're not using ALICE, you might still find this automatic rect grouping useful. You can remove all mentions of ALICE from the code and modify the library to fit your own needs.
How to Use
WonderRect creates a list of all preplaced rects (as their name) in the RectList global. You can use this table to access your rects manually.
For WonderRect to create regions out of our preplaced rects successfully, they must be grouped by name. The rects' names should be formatted as:
Lua:
<prefix><Name><X><modifiers>
Prefix
Only necessary when using the WonderRect.CreateAll function.
Name
The name of our rect batch.
X
An integer. All rects with the same prefix and name, but different integers are joined together into one region.
modifiers
These are optional and modify the shape or the active edges of the final region.
Example:
Lua:
--Our list of preplaced rects
gg_rct_fogModifierTemple1
gg_rct_fogModifierTemple2bottomleft
gg_rct_fogModifierForest1TTTF
gg_rct_fogModifierForest2
gg_rct_killZoneNorth
gg_rct_killZoneSouth
--Create a data table for our fog modifiers:
local DATA = {
temple = {
density = 2
},
forest = {
color = blue
}
}
--Create a region for each fog modifier:
WonderRect.CreateAll("fogModifier", {camera = AdjustFog}, DATA, true)
--Create the kill zones north and south.
DATA = {
--Callback for WonderRect.Event.
onEnter = function(wonderRegion, unit)
KillUnit(unit)
end
}
WonderRect.CreateAll("killZone", {unit = WonderRect.Event}, DATA)
Modifiers
Modifiers are put after the rect number and are ignored in search patterns. You can turn a rect into a triangle by adding the vertex that is missing:
Lua:
"topleft"
"topright"
"bottomleft"
"bottomright"
Edge flags modify which edges are considered when calculating the edge distance. The edge flag is a string of four T or F. Each denotes if an edge is active (true or false), starting with the right edge and going counter-clockwise.
Lua:
gg_rct_fogModifierForest1FFFT --only the bottom edge is active
When joining multiple rects for one region, all rect edges that are touching another rect are automatically removed and do not need to be disabled manually.
Installation
Follow the ALICE installation guide. WonderRect itself can be installed simply by copy&pasting the script file into your map.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.