• 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] Is this leak free?

Status
Not open for further replies.
Level 4
Joined
Jun 8, 2008
Messages
87
recently ive been wondering about memory leaks, and i would like to ask, does item's leak? if it doesnt, this code should be clean right?
  • unit uses an item
    • Events
      • Unit - A unit Uses an item
    • Conditions
    • Actions
      • Set Temp_Item = (Item being manipulated)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of Temp_Item) Equal to Woodcutting Axe
        • Then - Actions
          • Set Temp_Item = No item
          • Set Temp_Unit = (Hero manipulating item)
          • Animation - Change Temp_Unit's animation speed to 50.00% of its original speed
          • Animation - Play Temp_Unit's attack animation
          • Set Temp_Unit = No unit
          • Wait 2.00 seconds
          • Set Temp_Unit = (Hero manipulating item)
          • Hero - Create Piece of Wood. and give it to Temp_Unit
          • Animation - Reset Temp_Unit's animation
          • Set Temp_Unit = No unit
        • Else - Actions
 
Level 4
Joined
Jun 8, 2008
Messages
87
hmmm lets see if i got it. this leaks
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Unit - Order (Attacked unit) to give (Item carried by (Attacked unit) in slot 1) to (Attacking unit)
and this one doesnt
  • Untitled Trigger 001 Copy
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set Temp_Attacked = (Attacked unit)
      • Set Temp_Attacking = (Attacking unit)
      • Unit - Order Temp_Attacked to give (Item carried by Temp_Attacked in slot 1) to Temp_Attacking
 
Level 4
Joined
Jun 8, 2008
Messages
87
well atleast this one leaks right?
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Unit - Order (Attacked unit) to give (Item carried by (Attacked unit) in slot 1) to (Attacking unit)
 
Level 4
Joined
Jun 8, 2008
Messages
87
so it should be clean now right`?
  • unit uses an item
    • Events
      • Unit - A unit Uses an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Woodcutting Axe
        • Then - Actions
          • Animation - Change (Hero manipulating item)'s animation speed to 50.00% of its original speed
          • Animation - Play (Hero manipulating item)'s attack animation
          • Wait 2.00 seconds
          • Hero - Create Piece of Wood. and give it to (Hero manipulating item)
          • Animation - Reset (Hero manipulating item)'s animation
        • Else - Actions
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
None of the triggers in this thread leak.
Globals, other then unit groups and locations, simply do not leak as you are just overwriting them every usage (in contrast to locals which every time of usage you create a new variable).
Therefore, you do not need to null them (Set Var = No Unit, for example).

You can also stop using most of the variables you did, as you can use Triggering Unit and other event responses.

Also as I suggest in about every possible thread, DO NOT USE ANY VARIATION OF A UNIT RESPONSE OTHER THEN Triggering Unit WHEN USING WAITS !
All the other variations are GLOBALS and therefore if the trigger runs while the wait didn't finish, the value of the event responses WILL change.
Triggering Unit is a trigger member (local to the trigger) and thus it will never be rewritten.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
  • unit uses an item
  • Events
    • Unit - A unit Uses an item
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of (Item being manipulated)) Equal to Woodcutting Axe
      • Then - Actions
        • Animation - Change (Triggering Unit) animation speed to 50.00% of its original speed
        • Animation - Play (Triggering Unit) attack animation
        • Wait 2.00 seconds (game-time)
        • Hero - Create Piece of Wood. and give it to (Triggering Unit)
        • Animation - Reset (Triggering Unit)'s animation
      • Else - Actions
 
Last edited:
Level 17
Joined
Apr 27, 2008
Messages
2,455
may i ask why i can only use "triggering unit" after waits?
no only few get are not MUI :

Ability
Ability being cast

Item
sold item ( because the item is detroyed )
Target item of Ability being cast (return nul when the spell is already started)


Order
Issued Order

Location
Target point of issued order
Target point of ability being cast

Units
Casting Unit
Target unit of issued order
Cancelled structure ( because the unit is destroyed )
Target unit of ability being cast (return null if the spell is already started)
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
That was there by mistake, so I removed it.
@ Troll-Brain You got it wrong: Most of the event responses do not work properly after waits. Only a few respond normally. Triggering Unit is one of them.
P.s. By "no only few get are not MUI :" understand that you mean that only a few event responses are global, and not local.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
That was there by mistake, so I removed it.
@ Troll-Brain You got it wrong: Most of the event responses do not work properly after waits. Only a few respond normally. Triggering Unit is one of them.
P.s. By "no only few get are not MUI :" understand that you mean that only a few event responses are global, and not local.

False, i tried all the get in gui, feel free to test them yourself but i'm sure about what i said. (just before the new patch).
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
With one unit, with one ability?
Well, that is not what MUI stands for.

Aha ...
Ofc i tried them with an enough long wait and with some units/abilities, etc., to test if it's MUI or not.

You can believe that i lie or that i'm too stupid to make a correct test, but hf to try to found a no MUI get which i didn't listed. (available in gui)

PS : I did it before the new patch, so i hope there are less or at least the same number of global get but no more ...
 
Status
Not open for further replies.
Top