[Trigger] Leak? Simple Trigger

Status
Not open for further replies.
Level 5
Joined
Aug 6, 2009
Messages
136
I've recently come back in triggering. But I've kind of forgot, how to remove leaks.

So this is how it looks like currently.

(Variable - Point (Name: Point))

  • Events:
    • Unit - A unit Dies
  • Condition:
  • Actions:
    • Set Point = (Position of (Dying Unit))
    • If ((Random integer number between 1 and 3) Equal to 1) then do (Item - Create "Item" at Point) else do (Do nothing)
    • Custom script: call RemoveLocation(udg_Point)
Does this still cause any leaks?
Or have I done it right?
I'm very unsure.

Also, if I use the same variable for other triggers. Will that cause any conflicts if used in the same way as shown above?

Thanks in Advance
 
Last edited:
Does this still cause any leaks?
Or have I done it right?
I'm very unsure.

It's very okay, there is a very simple leak you can do this after the custom script:
  • Custom script: set udg_Point = null
OR
  • Set Point = No point/Null

This will remove the point entirely

Also, if I use the same variable for other triggers. Will that cause any conflicts if used in the same way as shown above?
If you use the same variable for other triggers it would be okay since it's afterwards straightly removed and erased, doesn't matter.

P.S: Replace ( Dying Unit ) with (Triggering Unit) as it's much less efficient (Inefficient)
 
Last edited:
Also just a tip for a better structure:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • RanomIntegerBetween 1 and 3 Equals 1
    • Then - Actions
      • Set Point = Position of Triggering Unit
      • Item - Create Item at Point
      • Custom script: RemoveLocation(udg_Point)
    • Else - Actions
Because you only need to create/remove the point, when the condition is true. :)
 
Status
Not open for further replies.
Back
Top