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

Small problem in spotting a leak

Status
Not open for further replies.
Level 6
Joined
Jul 13, 2006
Messages
140
I'm positive that this trigger leaks but, I have actually had no problems with it in relation to slowdowns, and other similar triggers (similar in that they all pick some specific units and does something).

  • Trigger 1
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Player - Add ((Number of living C units owned by Player 1 (Red)) x 3) to Player 1 (Red) Current gold
      • Player - Add ((Number of living CF units owned by Player 1 (Red)) x 3) to Player 1 (Red) Current gold
      • Player - Add ((Number of living Ca units owned by Player 1 (Red)) x 4) to Player 1 (Red) Current gold
      • Player - Add ((Number of living SW units owned by Player 1 (Red)) x 3) to Player 1 (Red) Current gold
      • Player - Add ((Number of living EC units owned by Player 1 (Red)) x 4) to Player 1 (Red) Current gold
      • Player - Add ((Number of living ECF units owned by Player 1 (Red)) x 4) to Player 1 (Red) Current gold
      • Player - Add ((Number of living SF units owned by Player 1 (Red)) x 1) to Player 1 (Red) Current gold
      • Player - Add ((Number of living T units owned by Player 1 (Red)) x 2) to Player 1 (Red) Current gold
      • Player - Add ((Number of living EC units owned by Player 1 (Red)) x 1) to Player 1 (Red) Current gold
      • Player - Add ((Number of living ME units owned by Player 1 (Red)) x 5) to Player 1 (Red) Current gold
Although this one is a better example:

  • Trigger 2
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Player - Add 5 to Player 10 (Light Blue) Current gold
      • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) of type Peasant) and do (Actions)
        • Loop - Actions
          • Unit - Replace (Picked unit) with a Rifleman using The old unit's relative life and mana
      • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue)) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Attack-Move To (Random point in (Playable map area))
      • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) of type Workshop) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to train/upgrade to a Mortar Team
          • Unit - Create 1 Peasant for Player 10 (Light Blue) at (Position of (Picked unit)) facing Default building facing degrees
      • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) of type Arcane Sanctum) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to train/upgrade to a Spell Breaker
      • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) of type Human Shipyard) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to train/upgrade to a Human Frigate
          • Unit - Order (Picked unit) to train/upgrade to a Human Transport Ship
          • Unit - Order (Picked unit) to train/upgrade to a Human Battleship
      • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) of type Barracks) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to train/upgrade to a Footman
          • Unit - Order (Picked unit) to train/upgrade to a Footman
      • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) of type Expanded Barracks) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to train/upgrade to a Footman
          • Unit - Order (Picked unit) to train/upgrade to a Footman
          • Unit - Order (Picked unit) to train/upgrade to a Knight
          • Unit - Order (Picked unit) to train/upgrade to a Knight
      • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) of type Stable) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to train/upgrade to a Knight
          • Unit - Order (Picked unit) to train/upgrade to a Knight
      • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) of type Castle) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to train/upgrade to a Footman
          • Unit - Order (Picked unit) to train/upgrade to a Knight
          • Unit - Order (Picked unit) to train/upgrade to a Footman
          • Unit - Order (Picked unit) to train/upgrade to a Knight
          • Unit - Order (Picked unit) to train/upgrade to a Mortar Team
      • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) of type Town Hall) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to train/upgrade to a Footman
Edit: If I set the location in the second example to a variable, then won't that set it to just one point instead of a different point for every unit?
Oh and in the second example, doesn't it work by just using the set bj_wantDestroyGroup = true custom script thing?
 
Last edited:
The first might leak because I'm fairly sure it uses a unit group but nothing you can fix in GUI
though the second one leaks a bunch of unit groups.
It also leaks a location ((Random point in (Playable map area))).

What you need to do is store these into variables, then destroy them after they are done being used.

  • Custom script: call RemoveLocation(udg_YourPointVariable)
  • Custom script: call DestroyGroup(udg_YourUnitGroupVariable)
 
Level 6
Joined
Jul 13, 2006
Messages
140
Uh, the problem with the location variable is: won't that set it to just one point instead of a different point for every unit?

Edit: Oh and um doesn't it work with the set bj_wantDestroyGroup = true? Because that would probably be less tedious (in the second example).
 
Level 6
Joined
Jul 13, 2006
Messages
140
Aren't these leak-free?

  • Trigger 1
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Set Number = (Number of living C units owned by Player 1 (Red))
      • Player - Add (Number x 3) to Player 1 (Red) Current gold
      • Set Number = (Number of living CF units owned by Player 1 (Red))
      • Player - Add (Number x 3) to Player 1 (Red) Current gold
      • Set Number = (Number of living Ca units owned by Player 1 (Red))
      • Player - Add (Number x 4) to Player 1 (Red) Current gold
      • Set Number = (Number of living SW units owned by Player 1 (Red))
      • Player - Add (Number x 3) to Player 1 (Red) Current gold
  • Trigger 2
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Player - Add 5 to Player 10 (Light Blue) Current gold
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) of type Builder) and do (Actions)
        • Loop - Actions
          • Unit - Replace (Picked unit) with a Rifleman using The old unit's relative life and mana
      • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue)) and do (Actions)
        • Loop - Actions
          • Set AMPoint = (Random point in (Playable map area))
          • Unit - Order (Picked unit) to Attack-Move To AMPoint
          • Custom script: call RemoveLocation(udg_AMPoint)
      • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) of type Workshop) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to train/upgrade to a Mortar Team
          • Unit - Create 1 Builder for Player 10 (Light Blue) at (Position of (Picked unit)) facing Default building facing degrees
      • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) of type Barracks) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to train/upgrade to a Knight
 
Level 6
Joined
Jul 13, 2006
Messages
140
How about now then? Do they leak or not?
Oh and if they don't leak: is this an efficient way to prevent leaks?

  • Trigger 1
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Set Number = (Number of living C units owned by Player 1 (Red))
      • Player - Add (Number x 3) to Player 1 (Red) Current gold
      • Custom script: set bj_wantDestroyGroup = true
      • Set Number = (Number of living CF units owned by Player 1 (Red))
      • Player - Add (Number x 3) to Player 1 (Red) Current gold
      • Custom script: set bj_wantDestroyGroup = true
      • Set Number = (Number of living Ca units owned by Player 1 (Red))
      • Player - Add (Number x 4) to Player 1 (Red) Current gold
      • Custom script: set bj_wantDestroyGroup = true
      • Set Number = (Number of living SW units owned by Player 1 (Red))
      • Player - Add (Number x 3) to Player 1 (Red) Current gold
  • Trigger 2
  • Events
    • Time - Every 60.00 seconds of game time
  • Conditions
  • Actions
    • Player - Add 5 to Player 10 (Light Blue) Current gold
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) of type Builder) and do (Actions)
    • Loop - Actions
      • Unit - Replace (Picked unit) with a Rifleman using The old unit's relative life and mana
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue)) and do (Actions)
      • Loop - Actions
        • Set AMPoint = (Random point in (Playable map area))
        • Unit - Order (Picked unit) to Attack-Move To AMPoint
        • Custom script: call RemoveLocation(udg_AMPoint)
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) of type Workshop) and do (Actions)
      • Loop - Actions
      • Unit - Order (Picked unit) to train/upgrade to a Mortar Team
      • Unit - Create 1 Builder for Player 10 (Light Blue) at (Position of (Picked unit)) facing Default building facing degrees
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) of type Barracks) and do (Actions)
      • Loop - Actions
        • Unit - Order (Picked unit) to train/upgrade to a Knight
 
Last edited:
Level 6
Joined
Jul 13, 2006
Messages
140
Or wait, isn't it more efficient like this?

  • Custom script: set bj_wantDestroyGroup = true
  • Player - Add ((Number of living C units owned by Player 1 (Red)) x 4) to Player 1 (Red) Current gold
  • Custom script: set bj_wantDestroyGroup = true
  • Player - Add ((Number of living Ca units owned by Player 1 (Red)) x 4) to Player 1 (Red) Current gold
But the point is that I want to prevent these kinds of periodic triggers from leaking.
 
Status
Not open for further replies.
Top