• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] When to Remove Locations?

Status
Not open for further replies.
Level 4
Joined
Apr 20, 2009
Messages
106
This is a pretty quick and simple question. Do I have to "call RemoveLocation(udg_Point)" after every time I use the Point Variable "Point", or do I only do it once, at the end of the trigger, and it will clear the whole triggers leaks of that variable?
 
Level 17
Joined
Jun 17, 2007
Messages
1,433
If you're using the same variable that has been holding the same point the entire trigger, then you can remove it at the end of the trigger.

  • Set point[1] = (Position of (Triggering unit))
  • Unit - Create 1 Footman for Player 1 (Red) at point[1] facing Default building facing degrees
  • Custom script: call RemoveLocation(udg_point[1])
  • Unit - Create 1 Knight for Player 1 (Red) at point[1] facing Default building facing degrees
  • Custom script: call RemoveLocation(udg_point[1])
The above will not work. You should instead do something like this:


  • Set point[1] = (Position of (Triggering unit))
  • Unit - Create 1 Footman for Player 1 (Red) at point[1] facing Default building facing degrees
  • Unit - Create 1 Knight for Player 1 (Red) at point[1] facing Default building facing degrees
  • Custom script: call RemoveLocation(udg_point[1])
 
Level 4
Joined
Apr 20, 2009
Messages
106
Indeed, Codemonkey, that is what I am interested to know. I guess I could go through it, Removing the Location and setting it again after every use, but I really don't want to waste that time if it's not necessary.
 
Well, if you have this,
  • X
  • Actions
    • Set Point[1] = (Position of (Last created unit))
    • Set Point[2] = (Position of (Triggering unit))
    • Custom script: call RemoveLocation (udg_Point[1])
    • Custom script: call RemoveLocation (udg_Point[2])
As you can see, every new Point should be removed, no matter what -if you want a leakless event-. So no, If you do in the example above, "Custom script: call RemoveLocation (udg_Point)", you will realize that the World Editor, will show you an error message, telling you that your Point Variable containts "Index" and that it is not a normal variable. Index allows you to use that specific variable many times, so that you end up having many sub-variables of the main one. If you don't know everything about indexing, you should go for a tutorial. Other than that, the question has just been answered.
 
Level 4
Joined
Apr 20, 2009
Messages
106
I don't believe that it actually has been answered, but the fault lies in my inability to phrase the question. I'll just break out an example.
  • Events
    • Unit - A unit Is attacked
  • Conditions
    • Blargh.
  • Events
    • Set Point = (Position of (Attacked unit))
    • Unit - Create 1 Dummy for (Owner of (Attacking unit)) at Point facing Default building facing degrees
    • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
    • Set Point2 = (Point offset by 175.00 towards 90.00 degrees)
    • Unit - Order (Last created unit) to Undead Dreadlord - Inferno Point2
    • Wait 0.10 seconds
    • Unit - Create 1 Dummy for (Owner of (Attacking unit)) at Point facing Default building facing degrees
    • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
    • Set Point2 = (Point offset by 175.00 towards 270.00 degrees)
    • Unit - Order (Last created unit) to Undead Dreadlord - Inferno Point2
    • Custom script: call RemoveLocation(udg_Point)
    • Custom script: call RemoveLocation(udg_Point2)
This is showing what I need to know. I destroyed my Point2 at the end of the Trigger, but I set and used it twice. Will that leave one leak from the first use, or will it destroy all the leaks?
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
It is safest to remove every point location before you reuse it AND at the end of the trigger
Like:
  • Set Point = (Target Point of Ability being cast)
  • Unit - Move Triggering Unit instantly to Point
  • Custom script: call RemoveLocation(udg_Point)
  • Set Point = <Some other point>
  • Set --- More Trigger Actions
  • Set --- Even more trigger actions
  • Set --- This is the end of the trigger, so do:
  • Custom script: call RemoveLocation(udg_Point)
Everytime you REuse it, you remove it, and at the end of the trigger.
Make sure, though, that you remove it at the end of EVERY trigger that uses it. If you run a trigger that does not remove it, and you run this one, it will leak, because you havent removed it before you assign a new point to it,,
 
Status
Not open for further replies.
Top