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!
There are more ways to do this.
The simplest but the worst (efficiency-wise) would be to use this whenever you need to find out how many ancients are ingame:
-------- the custom script below takes care of memory leaks --------
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) is An Ancient) Equal to True) and (((Matching unit) is alive) Equal to True))) and do (Actions)
Loop - Actions
Set count = (count + 1)
The problem with the above is if you have too many units in your map, then the game will pick every unit in your map, check if its ancient and put it inside the unit group, then it will iterate through each unit inside the unit group and increase value in "count" variable by 1.
Unit groups are also heavy process, so creating them in very quick succession one after another may cause lags.
More efficient way is imo by having 1 variable specifically used to keep track of ancients. This will require more (but simple) triggers.
Map Ini
Events
Map initialization
Conditions
Actions
-------- the custom script below takes care of memory leaks --------
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) is An Ancient) Equal to True)) and do (Actions)
Loop - Actions
Set NumberOfAncients = (NumberOfAncients + 1)
You need to do this once at map initialization.
Increase
Events
Unit - A unit enters (Playable map area)
Conditions
((Triggering unit) is An Ancient) Equal to True
Actions
Set NumberOfAncients = (NumberOfAncients + 1)
Decrease
Events
Unit - A unit Dies
Conditions
((Triggering unit) is An Ancient) Equal to True
Actions
Set NumberOfAncients = (NumberOfAncients - 1)
To find out if unit is an ancient, use the Boolean comparison
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.