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

Will "event - a unit takes damage" cause leaks?

Level 5
Joined
Oct 5, 2012
Messages
73
I have this simple trigger in a map. I wonder if having a trigger that checks on every single damage instance on the map will slow down the game or cause leaks? Especially on a large map with many triggers and units. Do you have any thoughts on that? Are there better alternatives? :)

  • AmuletofFortune
    • Events
      • Unit - A unit Takes damage
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Damage source) has an item of type Amulet of Fortune) Equal to True
          • (Damage From Normal Attack) Equal to False
    • Actions
      • Event Response - Set Damage of Unit Damaged Event to ((Damage taken) x 1.05)
To be clear, the trigger works as intended, I just wonder if it is done in a bad fashion.
 
Nope, you're fine! It won't cause leaks and it won't slow down the game over time. Registering the event occupies one object in memory, but it can fire off as many times as you'd like and it won't leak.

If you look up similar topics, you'll probably see a lot of people mention using damage detection systems and such. But that was back when there wasn't a generic "any unit takes damage" event. You had to register it for each unit manually, which was pretty complicated to manage effectively since you would need an event for every unit on the map simultaneously.

But now it is a lot simpler thanks to that new event (added in reforged patches), and so the way you're doing it is as efficient as it gets. :)
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
I have this simple trigger in a map. I wonder if having a trigger that checks on every single damage instance on the map will slow down the game or cause leaks? Especially on a large map with many triggers and units. Do you have any thoughts on that? Are there better alternatives? :)

It will hurt performance but not in some exponential way. This is because of the Event itself which introduces overhead. That being said, it's an extremely useful Event since it opens up the door to many new possibilities so I recommend taking full advantage of it.

Also, you don't need to use "And - All (Conditions) are true" here. In fact, you should almost never need to use "And", this is the default behavior of Conditions.

These two triggers are identical:
  • AmuletofFortune
    • Events
      • Unit - A unit Takes damage
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Damage source) has an item of type Amulet of Fortune) Equal to True
          • (Damage From Normal Attack) Equal to False
    • Actions
      • Event Response - Set Damage of Unit Damaged Event to ((Damage taken) x 1.05)
  • AmuletofFortune
    • Events
      • Unit - A unit Takes damage
    • Conditions
      • ((Damage source) has an item of type Amulet of Fortune) Equal to True
      • (Damage From Normal Attack) Equal to False
    • Actions
      • Event Response - Set Damage of Unit Damaged Event to ((Damage taken) x 1.05)
Triggers execute from top to bottom and if one Condition fails then the entire trigger stops running.
 
Last edited:
Top