HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Destroy a point moving a unit?

11-13-2005, 02:46 AM#1
The_AwaKening
First off let me say thanks for all the help I've been getting in this forum and I'm sorry for all the new threads lately, but I am just doing final cleanup on my map to make sure it is smooth as I can make it.

I have a trigger to basically teleport units from one region to another. I just want to make sure I am correct in assuming that I don't need to set up a temppoint and destroy it since I am not creating units, but only moving them.

Here is the trigger as I have it.
Code:
Port1
    Events
        Unit - A unit enters Portal 1 <gen>
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Owner of (Entering unit)) Equal to Player 1 (Red)
                (Owner of (Entering unit)) Equal to Player 2 (Blue)
                (Owner of (Entering unit)) Equal to Player 3 (Teal)
    Actions
        Unit - Move (Entering unit) instantly to (Center of Recipe <gen>)
        Cinematic - Ping minimap for (All players matching ((Owner of (Entering unit)) Equal to (Matching player))) at (Center of Recipe <gen>) for 5.00 seconds
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Castle 0010 <gen> is dead) Equal to True
            Then - Actions
                Custom script:   call DestroyTrigger( GetTriggeringTrigger() )
            Else - Actions
11-13-2005, 04:47 AM#2
LegolasArcher
Code:
(Center of Recipe <gen>)
Leaks. If you are using purely GUI:
Code:
set TempPoint = Center of Recipe <gen>
// Action's here.
Custom Script: call RemoveLocation(udg_TempPoint)
More elegantly in JASS:
Collapse JASS:
local location pt = GetRectCenter([Whatever Rect])
// Actions here.
call RemoveLocation(pt)
set pt = null
11-13-2005, 05:14 PM#3
The_AwaKening
So I do need to destroy point even if moving units. That could explain some of the lag I get in longer games. Thanks and here is my new trigger. Looks good now?
Code:
Port1
    Events
        Unit - A unit enters Portal 1 <gen>
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Owner of (Entering unit)) Equal to Player 1 (Red)
                (Owner of (Entering unit)) Equal to Player 2 (Blue)
                (Owner of (Entering unit)) Equal to Player 3 (Teal)
    Actions
        Set tempPoint = (Center of Recipe <gen>)
        Unit - Move (Entering unit) instantly to tempPoint
        Custom script:   call RemoveLocation(udg_tempPoint)
        Cinematic - Ping minimap for (All players matching ((Owner of (Entering unit)) Equal to (Matching player))) at (Center of Recipe <gen>) for 5.00 seconds
11-13-2005, 05:53 PM#4
Anitarf
You leak a location whenever you use it, because it needs to be created for that purpose (unless you use a variable that points to an already existing location). So, even now, you still leak a location in your minimap ping action, because you don't use your variable there. Also, the ping action leaks a player group (force) object (The function "All players matching condition" creates a force the same way "center of region" creates a location; you need to clean it up)
11-13-2005, 06:39 PM#5
The_AwaKening
Wow, needs some fixin up. While I am on that subject also, do I need to destroy a special effect after it is used. For example I am using a special effect of ressurection on the unit I am moving. Would I also use
call DestroyEffect( bj_lastCreatedEffect )
?
11-13-2005, 07:17 PM#6
Vexorian
Just so there is no more confusion here.

what GUI calls points are not the actual points of the game, if you remove a point , which would be removing a location object, the function where you passed that point should not fail (unless they aren't native functions but some user-made functions that for some reason keep a location in memory for their use , something I never seen)
11-14-2005, 05:03 AM#7
The_AwaKening
Ok, I think I'm getting this now; however, I do have some questions about null.
When and what type of locals should you set to null?
11-14-2005, 05:54 PM#8
Anitarf
Quote:
Originally Posted by The_AwaKening
Ok, I think I'm getting this now; however, I do have some questions about null.
When and what type of locals should you set to null?
All handle locals (units, groups, forces, locations, effects...) should be set to null sometime before the end of function.