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

Blink ability issue.

Status
Not open for further replies.
Level 12
Joined
Dec 2, 2016
Messages
733
  • Sphere Blink
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set SphereBlinkTarget = (Target point of ability being cast)
      • Set SphereBlinkMagnitude = (Distance between (Position of (Triggering unit)) and SphereBlinkTarget)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Terrain pathing at (Target point of ability being cast) of type Buildability is off) Equal to True
          • SphereBlinkMagnitude Greater than or equal to 150.00
          • (Ability being cast) Equal to Sphere of Doom Blink Custom
        • Then - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SphereBlinkMagnitude Greater than or equal to 150.00
              • (Ability being cast) Equal to Sphere of Doom Blink Custom
            • Then - Actions
              • Item - Create Tome of Experience at ((Target point of ability being cast) offset by ((Distance between (Target point of ability being cast) and (Position of (Triggering unit))) - 175.00) towards (Angle from (Target point of ability being cast) to (Position of (Triggering unit))) degrees)
              • Unit - Move (Triggering unit) instantly to ((Target point of ability being cast) offset by ((Distance between (Target point of ability being cast) and (Position of (Triggering unit))) - 175.00) towards (Angle from (Target point of ability being cast) to (Position of (Triggering unit))) degrees)
              • Unit - Move (Triggering unit) instantly to (Position of (Last created item))
              • Item - Remove (Last created item)
              • Custom script: call RemoveLocation(udg_SphereBlinkTarget)
            • Else - Actions
              • Unit - Move (Triggering unit) instantly to (Target point of ability being cast)
Does this leak^ ? All the tutorials I've looked at it seems leaks are just units, effects and locations? Or am I mistaken. Does any variable that stores information leak? Like my real variable that stores the distance between two points?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
How do I remove a real variable?
You do not. Real is a primitive type so creates no object to leak. Variables themselves cannot leak as they have well defined life times. Global variables are only created at map initialization and last until map end. Local variables (local keyword declared and function parameters) are created at the start of a function and last until the function call returns.

So if I did this ^ I'd have assign target point to a variable and then use the RemoveLocation of that variable to properly remove the leak?
Yes. Obviously you can reuse the location object as much as you want as long as you remember to pass it to RemoveLocation before losing reference to it.

Complex types such as unit, location, group, etc are actually references to the object. The reference is in the form of a unique object identifier number which variables store as a primitive type. These references are called handles or agents. You pass these around to functions you call as arguments. When you assign a variable to a new reference, the object it previously referred to does not automatically get destroyed, hence you need to pass it as an argument to the destructor functions before losing reference to it.

It is very important to learn how to prevent triggers from leaking early on if you plan to map in Warcraft III seriously. It is much harder/more effort to discover the leaks are causing playability problems with your map and have to clean them up retrospectively then.
 
Status
Not open for further replies.
Top