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

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