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

[Trigger] Help fixing leaking trigger

Status
Not open for further replies.
Level 5
Joined
Feb 3, 2012
Messages
107
alright so i have a trigger like this:

Event
Every 1 second of game time
Conditions
skelenumber greater than skelemax
Actions
Unit Group - Pick every unit in (Random units from skelegroup) and do (Unit -Kill (Picked Unit))

skelenumber is the number of skeletons spawned: every time a skeleton is summoned, it adds +1 to skelenumber and if the skelenumber is over the skelemax, then a random unit in skelegroup will be killed.

when a skeletons is killed, he will be removed from the skelegroup and the skelenumber will decrease.

it looks solid in theory but when i tried it out: sometimes it worked, but sometimes i could have six skeletons at once! can any1 help me to fix the leak?

the ability spawns 3 skeletons but thats not the problem.

the ability is practically like this:
-use ability-
-1 skeleton spawned-
-added +1 to skelenumber
-wait 1 second-
-1 skeleton spawned-
-added +1 to skelenumber-
-wait 1 second-
-1 skeleton spawned-
-added +1 to skelenumber-

this shouldn't be a problem because the skeletons are spawning one at a time, not all at once.

the event is also every 1 second so even when there are 6 skeletons, the other 3 should have been killed every 1 second but that did not happen. so if any1 can help that would be great!
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Showing all the triggers might help.

Unit Group - Pick every unit in (Random units from skelegroup) and do (Unit -Kill (Picked Unit))
This looks like it leaks a unit group as you create a unit group but never remove it. Not the leak you are after but a leak still the same.

Is this an off-by-one error? Or does it fail to work at times?

Try debugging the skelenumber variable by printing the value every time you change it.
 
Status
Not open for further replies.
Top