• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

How do I remove the leaks in this trigger?

Status
Not open for further replies.
Level 12
Joined
Jan 13, 2008
Messages
559
  • Move to Hero
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units of type Inventory) and do (Actions)
        • Loop - Actions
          • Unit - Move (Picked unit) instantly to (Position of player_hero[((Player number of (Owner of (Picked unit))) - 1)])
      • Unit Group - Pick every unit in (Units of type Inventory [Potions]) and do (Actions)
        • Loop - Actions
          • Unit - Move (Picked unit) instantly to (Position of player_hero[((Player number of (Owner of (Picked unit))) - 1)])
I checked the thread about leaks but I am not sure how to delete array leaks like this one. Could someone help me here? Thanks
 
Level 9
Joined
Apr 23, 2010
Messages
312
You have to set the units into a group variable, loop through the variable, then add a custom script outside of the loop destroying the variable to prevent the leak. Also you are leaking locations, set the location of your hero to a variable inside the loop as well and also add a custom script at the end to remove the location.

For the group:
  • Custom script: call DestroyGroup(udg_YourGroupVariable)
For the location:
  • Custom script: call RemoveLocation(udg_YourLocationVariable)
 
Level 12
Joined
Jan 13, 2008
Messages
559
alright. Thank you.
  • Move to Hero
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set inventory_unitGroup = (Units of type Inventory)
      • Unit Group - Pick every unit in inventory_unitGroup and do (Actions)
        • Loop - Actions
          • Set inventory_heroLocation = (Position of player_hero[((Player number of (Owner of (Picked unit))) - 1)])
          • Unit - Move (Picked unit) instantly to inventory_heroLocation
      • Custom script: call DestroyGroup(udg_inventory_unitGroup)
      • Custom script: call RemoveLocation(udg_inventory_heroLocation)
      • Set inventory_unitGroup = (Units of type Inventory [Potions])
      • Unit Group - Pick every unit in inventory_unitGroup and do (Actions)
        • Loop - Actions
          • Set inventory_heroLocation = (Position of player_hero[((Player number of (Owner of (Picked unit))) - 1)])
          • Unit - Move (Picked unit) instantly to inventory_heroLocation
      • Custom script: call DestroyGroup(udg_inventory_unitGroup)
      • Custom script: call RemoveLocation(udg_inventory_heroLocation)
this should do the job :p
 
Level 9
Joined
Apr 23, 2010
Messages
312
alright. Thank you.
  • Move to Hero
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set inventory_unitGroup = (Units of type Inventory)
      • Unit Group - Pick every unit in inventory_unitGroup and do (Actions)
        • Loop - Actions
          • Set inventory_heroLocation = (Position of player_hero[((Player number of (Owner of (Picked unit))) - 1)])
          • Unit - Move (Picked unit) instantly to inventory_heroLocation
      • Custom script: call DestroyGroup(udg_inventory_unitGroup)
      • Custom script: call RemoveLocation(udg_inventory_heroLocation)
      • Set inventory_unitGroup = (Units of type Inventory [Potions])
      • Unit Group - Pick every unit in inventory_unitGroup and do (Actions)
        • Loop - Actions
          • Set inventory_heroLocation = (Position of player_hero[((Player number of (Owner of (Picked unit))) - 1)])
          • Unit - Move (Picked unit) instantly to inventory_heroLocation
      • Custom script: call DestroyGroup(udg_inventory_unitGroup)
      • Custom script: call RemoveLocation(udg_inventory_heroLocation)
this should do the job :p

Looks good, just put the remove location script right after you move the unit, otherwise you only remove one location leak.
 
Status
Not open for further replies.
Top