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

[Trigger] Does this leak?

Status
Not open for further replies.
verwGezrL.jpg


I just CnP, dunno how to write in triggers :con:
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Yeah it does. The fix would be to use a temppoint and then destroy it after it is used. Since you are using waits, the variable could interfere if it is used somewhere else, so I suggest using the local variable trick.

  • Spawn
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
      • ((roarRawrer) is alive) Equal to True
    • Actions
      • Custom script: local location udg_temppoint1
      • Custom script: local location udg_temppoint2
      • Set temppoint1 = (Center of ("Death eaters spawn middle"))
      • Set temppoint2 = (Center of ("Death eaters end1"))
      • Unit - Create 1 Footman for Player 12 (Brown) at temppoint1 facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack-Move To temppoint2
      • Wait 0.05 game-time seconds
      • Unit - Create 1 Knight for Player 12 (Brown) at temppoint1 facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack-Move To temppoint2
      • Wait 0.05 game-time seconds
      • Unit - Create 1 Rifleman for Player 12 (Brown) at temppoint1 facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack-Move To temppoint2
      • -------- And so on.... --------
      • -------- //\\ --------
      • -------- At the end, do the following --------
      • Custom script: call RemoveLocation( udg_temppoint1 )
      • Custom script: call RemoveLocation( udg_temppoint2 )
      • Custom script: set udg_temppoint1 = null
      • Custom script: set udg_temppoin2 = null
Also, 0.05 seconds has a threshold. It will wait around ~0.27 seconds.
Don't forget to create the point variables in the variable editor window.
 
Level 5
Joined
Feb 5, 2008
Messages
109
This "trick" can only be used for one global variable in a trigger.
If you don't want to do this trigger in JASS, do it this way:

  • Spawn
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
      • (Death Eater Camp 0012 <gen> is alive) Equal to True
    • Actions
      • Custom script: local integer udg_Integer
      • For each (Integer Integer) from 1 to 4, do (Actions)
        • Schleifen - Aktionen
          • Set Point = (Center of Death Eater Spawn Middle <gen>)
          • Set Point_2 = (Center of Death Eeaters End1 <gen>)
          • Unit - Create 1 Death Eater (Female) for Player 12 (Brown) at Point facing Default building facing degrees
          • Unit - Order (Last created unit) to Attack-Move To Point_2
          • Custom script: call RemoveLocation(udg_Point)
          • Custom script: call RemoveLocation(udg_Point_2)
          • Wait 0.05 game-time seconds
      • For each (Integer Integer) from 1 to 4, do (Actions)
        • Schleifen - Aktionen
          • Set Point = (Center of Death Eater Spawn Middle <gen>)
          • Set Point_2 = (Center of Death Eeaters End1 <gen>)
          • Unit - Create 1 Death Eater (Male) for Player 12 (Brown) at Point facing Default building facing degrees
          • Unit - Order (Last created unit) to Attack-Move To Point_2
          • Custom script: call RemoveLocation(udg_Point)
          • Custom script: call RemoveLocation(udg_Point_2)
          • Wait 0.05 game-time seconds
      • Set Point = (Center of Death Eater Spawn Middle <gen>)
      • Set Point_2 = (Center of Death Eeaters End1 <gen>)
      • Unit - Create 1 Dementor for Player 12 (Brown) at Point facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack-Move To Point_2
      • Custom script: call RemoveLocation(udg_Point)
      • Custom script: call RemoveLocation(udg_Point_2)
And search for "Jass NewGen Pack", this will make life easier. It adds functions to GUI and disables certain limits.

[edit]
Deleted nullifying globals.
 
Last edited:
Level 16
Joined
Oct 12, 2008
Messages
1,570
That last way works, and creates as much as you want with not a lot of triggers,,
But: You shouldnt nullify the points, they are Globals, and even if they were locals, Nullify them OUT the loop =),, otherwise it can only create 1 unit per loop,,
Tip: Never Nullify Globals (i thought so at least)
 
Level 7
Joined
Jul 20, 2008
Messages
377
Yeah, you don't null globals. No reason to, really. The reason you null locals is because the game still thinks that memory address is still in use, so the next time you use a local, it will not overwrite that spot in memory (ex: 0x0001) like it should be - it just goes to the next space (ex: 0x0002). You null it so it recognizes the fact that this memory address is ready to be overwritten by another variable.

With globals though, these variables persist so you will ALWAYS have access to that space in memory.
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
And a question for you:
Can i 'call DestroyGroup()' a global? Cause when i use an ability that uses a group, and i destroy it after, it wont delete the units in it (dummys) next time i use it, is that because the global doesnt exist anymore then?
So at global groups only
  • Unit Group - Clear MyGlobalGroup
??
 
Level 7
Joined
Jul 20, 2008
Messages
377
And a question for you:
Can i 'call DestroyGroup()' a global? Cause when i use an ability that uses a group, and i destroy it after, it wont delete the units in it (dummys) next time i use it, is that because the global doesnt exist anymore then?
So at global groups only
  • Unit Group - Clear MyGlobalGroup
??

Only if you're going to create a new group in place of an old group for a group variable should you destroy the group. For example:

"Pick every unit in 500 of X" and other such "group-generating" functions in GUI create a group. So yes, destroy whatever was in there before creating.
 
Level 5
Joined
Mar 25, 2008
Messages
150
  • Spawn
    • Events
      • Unit - A unit enters region 026 <gen>
    • Conditions
      • (Owner of (triggering unit)) Equal to Player 11 (Dark Green)
    • Actions
      • Unit - Order (Entering Unit) to Attack-Move To (Center of region 030 <gen>
And do this leak?

Well i use same triggers in my maps and works perfectly, i see no leaks in it
And small triggers usually not leak
 
Last edited:
Level 23
Joined
Nov 29, 2006
Messages
2,482
Small triggers are those who usually leaks in my opinion, due to lack of knowledge.
However, it's true, it's not critical compared to larger leaks. In this case though, you attack move to a "center of a region". The function will therefor always return a new location everytime you move to the region. Just like before I suggest you to store the "center of the region" in a variable and destroy it once you are done with it.
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Remember: Whenever you use a point in the map: It leaks if it is not set in a variable and destroyed after,, like:
Center of (bla region)
Random point in (blah region)
Center of (region) offset by 100 towards 50 degrees (leaks 2 times!!,, the (Center of(region)) AND the Whole point,, so for this you need 2 variables)
So: Whenever you move, order to move or create a unit or so, it leaks when not set in a variable,,
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Well i use same triggers in my maps and works perfectly, i see no leaks in it
And small triggers usually not leak

Leaks don't cause bugs. It's not because your triggers work that they don't have leaks. Leaks cause lag in the long run and has nothing to do with actual bugs. Besides that, it doesn't matter if your trigger is small or not, "Center of region" ALWAYS leaks, whether it's in a small trigger or a large one.

So replace "Center of region" by a point variable.
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Some addition to Eleandor:
Do NOT think the Point variable Does NOT leak, because it does, only the variable is destroyable!,,
  • Custom script: call RemoveLocation(udg_YourVariable)
(Only works for Point variables!)
 
Level 11
Joined
May 31, 2008
Messages
698
Whenever you use a point, like ordering a unit to attack move to a point, set it as a variable first. Set center of region to temp_Point[1]. Then at the end of your trigger remove the point with custom script ---> call RemoveLocation(udg_temp_Point[0])
Look at the 'Things that leak' thread. Its very helpful. Also if when you use custom script it says sumthing is wrong it might be something very small, even like you didnt capitalize something.
 
Status
Not open for further replies.
Top