• 🏆 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!

Does this trigger leak?

Status
Not open for further replies.
Level 8
Joined
Dec 12, 2010
Messages
280
This is a working revive trigger for the AI heroes I'm currently using on my map. My question is simple. Does this trigger leak. If so how would you fix it? Keep in mind also that this trigger is used by 4 different AI heroes.

  • Revive Ai
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in Ai_Units) Equal to True
      • ((Triggering unit) is Summoned) Equal to False
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of items carried by (Triggering unit)) Greater than 5
        • Then - Actions
          • Hero - Drop (Item carried by (Triggering unit) in slot (Random integer number between 1 and 6)) from (Triggering unit)
        • Else - Actions
      • Wait 20.00 seconds
      • Hero - Instantly revive (Dying unit) at ((Owner of (Dying unit)) start location), Show revival graphics
 
Yeah, it leaks. This should work:
  • Revive Ai
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in Ai_Units) Equal to True
      • ((Triggering unit) is Summoned) Equal to False
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of items carried by (Triggering unit)) Greater than 5
        • Then - Actions
          • Hero - Drop (Item carried by (Triggering unit) in slot (Random integer number between 1 and 6)) from (Triggering unit)
        • Else - Actions
      • Wait 20.00 seconds
      • Set AITempLoc = ((Owner of (Triggering unit)) start location
      • Hero - Instantly revive (Triggering unit) at AITempLoc, Show revival graphics
      • Custom script: call RemoveLocation(udg_AITempLoc)
Make a point variable named AITempLoc. In this situation, I also switched (Dying Unit) to (Triggering unit) so that it is MUI. (Triggering unit is local to the function, while dying unit acts as a global pointing to the last unit that died) :)
 
Level 8
Joined
Dec 12, 2010
Messages
280
I can't help but wondering about this action
  • Hero - Drop (Item carried by (Triggering unit) in slot (Random integer number between 1 and 6)) from (Triggering unit)
Does the game create a leaky point variable when the item is dropped? It seems it would have to. And its ok to use wait before the set var action as you specified?
 
I can't help but wondering about this action
  • Hero - Drop (Item carried by (Triggering unit) in slot (Random integer number between 1 and 6)) from (Triggering unit)

Don't worry, it doesn't create a point. :)

Does the game create a leaky point variable when the item is dropped? It seems it would have to. And its ok to use wait before the set var action as you specified?

Yep, otherwise it would lose its MUI.
 
Status
Not open for further replies.
Top