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

Why is this trigger leaking?

Status
Not open for further replies.
Level 9
Joined
May 28, 2007
Messages
365
  • Set TempUnit = (Matching unit)
  • Set TempPoint = (Position of TempUnit)
  • Set TempUnitGroup1 = (Units in TempReg3 matching (((Terrain type at TempPoint) Equal to Dungeon - Lava) and ((Unit-type of (Matching unit)) Equal to Escaper)))
  • Set TempUnitGroup2 = (Units in TempReg3 matching (((Terrain type at TempPoint) Equal to Northrend - Ice) and ((Unit-type of (Matching unit)) Equal to Escaper)))
  • Unit Group - Pick every unit in TempUnitGroup1 and do (Actions)
    • Loop - Actions
      • Unit - Explode (Picked unit)
      • Special Effect - Create a special effect attached to the origin of (Picked unit) using Doodads\Cinematic\FireTrapUp\FireTrapUp.mdl
      • Special Effect - Destroy (Last created special effect)
  • Unit Group - Pick every unit in TempUnitGroup2 and do (Actions)
    • Loop - Actions
      • Set TempPoint2 = (Position of (Picked unit))
      • Unit - Move (Picked unit) instantly to (TempPoint2 offset by 15.00 towards (Facing of (Picked unit)) degrees)
  • Custom script: call DestroyGroup( udg_TempUnitGroup2 )
  • Custom script: call DestroyGroup( udg_TempUnitGroup1 )
  • Custom script: call RemoveLocation(udg_TempPoint2)
  • Custom script: call RemoveLocation(udg_TempPoint)
I thought I removed all leaks, but it still leaks. This is for a slide on ice/kill on lava trigger.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,191
Inside the second unit pick, you leak 2 locations per unit (1 due to you forgetting to remove the one stored in the variable before the next location is put in it and the second because you create a location via polar projection that you never remove).

You have to remove all locations you make unless you are using them as a constant in JASS which you clearly are not.

Also your trigger will not work, as you refer a matching unit when there can not be one.

I see you clearly do not understand what variables are so. . .

A variable holds a value. Thus once set it will always return that value. Inorder to change its value you have to update it (re set it) to a new value.

Set TempUnit = (Matching unit)
Will set TempUnit to what the matching unit is currently, thus if the matching unit changes as the trigger progresses, the unit that TempUnit refers to will be the same (not the current matching unit). You would have to update it every time the matching unit chhanges via "Set TempUnit = (Matching unit)" to get it to store the current matching unit.
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
  • Unit Group - Pick every unit in TempUnitGroup2 and do (Actions)
    • Loop - Actions
      • Set TempPoint2 = (Position of (Picked unit))
      • Set TempPoint3 = TempPoint2 offset by 15.00 towards (Facing of (Picked unit)
      • Unit - Move (Picked unit) instantly to (TempPoint3 ) degrees
      • Custom script: call RemoveLocation(udg_TempPoint2)
      • Custom script: call RemoveLocation(udg_TempPoint3)
Meh, DSG was faster
 
Level 9
Joined
May 28, 2007
Messages
365
  • Unit Group - Pick every unit in TempUnitGroup2 and do (Actions)
    • Loop - Actions
      • Set TempPoint2 = (Position of (Picked unit))
      • Set TempPoint3 = ((Position of (Picked unit)) offset by 15.00 towards (Facing of (Picked unit)) degrees)
      • Unit - Move (Picked unit) instantly to TempPoint3
      • Custom script: call RemoveLocation(udg_TempPoint2)
      • Custom script: call RemoveLocation(udg_TempPoint3)
Alright, I got that, but the map is still leaking.

  • Set TempUnitGroup1 = (Units in TempReg3 matching (((Terrain type at (Position of (Matching unit))) Equal to Dungeon - Lava) and ((Unit-type of (Matching unit)) Equal to Escaper)))
I think this is the thing leaking because it makes locations, but I can't use variables because it has to be a matching unit

  • Unit Group - Pick every unit in TempUnitGroup2 and do (Actions)
    • Loop - Actions
      • Set TempPoint2 = (Position of (Picked unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Terrain type at TempPoint2) Equal to Northrend - Ice
        • Then - Actions
          • Set TempPoint3 = ((Position of (Picked unit)) offset by 15.00 towards (Facing of (Picked unit)) degrees)
          • Unit - Move (Picked unit) instantly to TempPoint3
        • Else - Actions
          • Do nothing
      • Custom script: call RemoveLocation(udg_TempPoint2)
      • Custom script: call RemoveLocation(udg_TempPoint3)
This ended up fixing the problem.
 
Last edited by a moderator:
Level 7
Joined
Aug 5, 2005
Messages
218
  • Lava Kill
    • Events
      • Time - Every 0.12 seconds of game time
    • Conditions
    • Actions
      • Set tempGroup = (Units of type Runner)
      • Unit Group - Pick every unit in tempGroup and do (Actions)
        • Loop - Actions
          • Set tempPoint = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
              • Or - Any (Conditions) are true
                • Conditions
                  • (Terrain type at tempPoint) Equal to Dungeon - Lava
                  • (Terrain type at tempPoint) Equal to Northrend - Snow
            • Then - Actions
              • Unit - Kill (Picked unit)
            • Else - Actions
          • Custom script: call RemoveLocation(udg_tempPoint)
      • Custom script: call DestroyGroup(udg_tempGroup)
  • Slide
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Set tempGroup = (Units of type Runner)
      • Unit Group - Pick every unit in tempGroup and do (Actions)
        • Loop - Actions
          • Set tempPoint = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain type at tempPoint) Equal to Northrend - Ice
            • Then - Actions
              • Set tempPoint1 = (tempPoint offset by 4.00 towards (Facing of (Picked unit)) degrees)
              • Unit - Move (Picked unit) instantly to tempPoint1
              • Custom script: call RemoveLocation(udg_tempPoint1)
            • Else - Actions
          • Custom script: call RemoveLocation(udg_tempPoint)
      • Custom script: call DestroyGroup(udg_tempGroup)
The first one is lava/snow, the second one is ice for sliding. I just copied those from my Build Your Own Maze map.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,191
Never run a trigger / timer at the delay of 0.01, as that is 100 updates per second which considering 15 updates per second is barly noticable you are wasting a lot of processing power. Also WC3 defaults the FPS cap at 60 so anything faster than the FPS rate is pointless as you can not see any change.

Rather run it every 0.02 seconds (50 runs per second) or even better still at 0.04 seconds (25 runs per seconds which is the same rate as a PAL signal for TVs) to save processing power. If you really want it smooth go for 0.03 but anyrate faster than that is just a total waste of recources.
 
Level 7
Joined
Aug 5, 2005
Messages
218
Yeah I know that's an old trigger though. Now I don't do anything more than 0.03 and even that seems like too slow at times not because of how it looks, but for a shockwave-effect (pulsing damage every tick to nearby units).
 
Status
Not open for further replies.
Top