• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Trigger question

Status
Not open for further replies.
Level 3
Joined
May 8, 2008
Messages
28
Here is my trigger. What I'm unsure of is what will happen if this trigger fires multiple times back to back. For example, Hero 1 triggers this and then 0.5 seconds later Hero 2 triggers it. The first run of the trigger, the timer is started expiring in two seconds to destroy the special effect. Will the second run of the trigger restart the timer before it is able to finish, causing a leak?

  • CompulsionLaborers
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Killing unit) has an item of type Compulsion: Laborers) Equal to True
      • ((Killing unit) is A Hero) Equal to True
      • ((Unit-type of (Dying unit)) Equal to Farmer) or ((Unit-type of (Dying unit)) Equal to Merchant)
    • Actions
      • Set CompulsionRandom = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CompulsionRandom Greater than or equal to 50
        • Then - Actions
          • Player - Add 1 to (Owner of (Killing unit)) Current gold
          • Special Effect - Create a special effect attached to the overhead of (Killing unit) using Abilities\Spells\Other\Transmute\PileofGold.mdl
          • Set CompulsionSpecialEffect[0] = (Last created special effect)
          • Countdown Timer - Start CompulsionTimer[0] as a One-shot timer that will expire in 2.00 seconds
        • Else - Actions
  • CompulsionTimerExpireZero
    • Events
      • Time - CompulsionTimer[0] expires
    • Conditions
    • Actions
      • Special Effect - Destroy CompulsionSpecialEffect[0]
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Yes, the timer is restarted and the first created special effect is not destroyed. To solve this, you need to make your trigger MUI: MUI Triggers with Waits
The solution suggested in this tutorial is not good as stated at the top of the page, but it should give you an idea what MUI is.
 
Level 6
Joined
Jun 4, 2017
Messages
172
Here is my trigger. What I'm unsure of is what will happen if this trigger fires multiple times back to back. For example, Hero 1 triggers this and then 0.5 seconds later Hero 2 triggers it. The first run of the trigger, the timer is started expiring in two seconds to destroy the special effect. Will the second run of the trigger restart the timer before it is able to finish, causing a leak?

  • CompulsionLaborers
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Killing unit) has an item of type Compulsion: Laborers) Equal to True
      • ((Killing unit) is A Hero) Equal to True
      • ((Unit-type of (Dying unit)) Equal to Farmer) or ((Unit-type of (Dying unit)) Equal to Merchant)
    • Actions
      • Set CompulsionRandom = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CompulsionRandom Greater than or equal to 50
        • Then - Actions
          • Player - Add 1 to (Owner of (Killing unit)) Current gold
          • Special Effect - Create a special effect attached to the overhead of (Killing unit) using Abilities\Spells\Other\Transmute\PileofGold.mdl
          • Set CompulsionSpecialEffect[0] = (Last created special effect)
          • Countdown Timer - Start CompulsionTimer[0] as a One-shot timer that will expire in 2.00 seconds
        • Else - Actions
  • CompulsionTimerExpireZero
    • Events
      • Time - CompulsionTimer[0] expires
    • Conditions
    • Actions
      • Special Effect - Destroy CompulsionSpecialEffect[0]
I don't think this trigger is MUI so, if another hero activate the trigger in those 2 seconds the first special effect will probably become permanent. You can also put the "Destroy special effect" action right after you create it without using waits or timers. If you do that, the special effect will appear until the end of its animation and then it will be deleted.
 
Status
Not open for further replies.
Top