• 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.

Have a few in-depth trigger questions

Status
Not open for further replies.
Level 8
Joined
Jul 17, 2004
Messages
283
1. Should I destroy triggers that aren't going to be used again? Does this clear up ram, or anything? If I destroy a trigger that is currently being executed, will the rest of the functions inside the trigger not execute after being destroyed? How do I destroy a trigger?

2. Deathismyfriend told me to create a Player Group variable and use it in place of any instance that uses '(All Players)'. The only reason I can think for doing this is because any time '(All Players)' is used, it creates a new player group per use, but creating and using a variable stops this from happening.

3. How do I use 'Pan Camera' and Unit Groups without them leaking?
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
1- Don't know , AFAIK , it ain't leaking . Because as long as Warcraft doesn't use it , this never hurts .
2- All players never leak AFAIK , np
3- Like this
  • Set TempGroup = (Your Group)
  • Camera - Pan Camera to (Random Unit from TempGroup) in 0.00 seconds .
  • Custom script: call DestroyGroup(udg_TempGroup)
 
Level 8
Joined
Jul 17, 2004
Messages
283
Well why did Ralle blacklist 'Pan Camera' in his Things That Leak thread location here? As well as Unit Group.
http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/

Also, does destroying a trigger clear ram? If I destroy a trigger that is currently being executed, will the rest of the functions inside the trigger not run after the trigger is destroyed?

Well I heard that (All Players) isn't what leaks. It creates a player group per use, and that is what leaks. Am I right or wrong?
 
1) Yes destroying a trigger clears ram. The rest of the trigger does not get executed if trigger is destroyed. Destroy trigger should only be placed at the end of the trigger.

2) That is not true. jonhysone.
The reason that you put all Players into a player group is for speed and efficiency. All players never leaks. All players does not create a new player group. It calls a function that returns all players that is why it is slow and inefficient.

3) Ralle blacklisted pan camera as necessary. Not the other pan camera actions.
Also if you are looking for a camera lock system i have one in my sig that may come in handy.
 
Level 5
Joined
May 6, 2013
Messages
125
IIRC, a trigger is executed just fine after destroying it. It actually gives problems too, as the trigger handle and its associated environment might be freed after a wait action as the game thinks that the trigger "finished" execution, when in fact its just waiting. Continuing the execution might then cause some trouble.
Don't really see why he banned SmartCameraPanBJ though. i see nothing wrong with it.
 
As death said, Ralle just blacklisted "Pan Camera as Necessary". The other pan functions are fine. Pan Camera as Necessary, aka SmartCameraPanBJ, has two problems:
  • Leaks--it generates a location here:
    JASS:
    function SmartCameraPanBJ takes player whichPlayer, location loc, real duration returns nothing
        local real dist
        if (GetLocalPlayer() == whichPlayer) then
            // Use only local code (no net traffic) within this block to avoid desyncs.
    
            // ** here **
            set dist = DistanceBetweenPoints(loc, GetCameraTargetPositionLoc())
            // ** GetCameraTargetPositionLoc() generates a location handle **
    
            if (dist >= bj_SMARTPAN_TRESHOLD_SNAP) then
                // If the user is too far away, snap the camera.
                call PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), 0)
            elseif (dist >= bj_SMARTPAN_TRESHOLD_PAN) then
                // If the user is moderately close, pan the camera.
                call PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), duration)
            else
                // User is close enough, so don't touch the camera.
            endif
        endif
    endfunction
  • Causes desyncs (as a consequence of the locally-generated location).
 
Status
Not open for further replies.
Top