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

[Solved]About Removing Leaks

Status
Not open for further replies.
Level 5
Joined
Jun 13, 2017
Messages
83
If i want to remove Location or Group leak with custom script i always put it at the end of the trigger but i am not sure if it is right so i made 2 triggers now just to show what i mean.

On this one the removelocation is at the end not in the picked group
  • Troll Boss 2 Loc
    • Events
      • Unit - A unit enters Troll Dungeon Boss Entrance 2 <gen>
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set Dung_TP[1] = (Center of Troll Dungeon Heroes Loc 2 <gen>)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in Troll Dungeon Respawn 1 <gen> matching (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True)) and do (Actions)
        • Loop - Actions
          • Camera - Apply Dungeon 1 Copy 2 <gen> for (Owner of (Picked unit)) over 0.00 seconds
          • Unit - Move (Picked unit) instantly to Dung_TP[1], facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_Dung_TP[1])

On this one it is on the end of the picked group
  • Troll Boss 2 Loc
    • Events
      • Unit - A unit enters Troll Dungeon Boss Entrance 2 <gen>
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set Dung_TP[1] = (Center of Troll Dungeon Heroes Loc 2 <gen>)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in Troll Dungeon Respawn 1 <gen> matching (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True)) and do (Actions)
        • Loop - Actions
          • Camera - Apply Dungeon 1 Copy 2 <gen> for (Owner of (Picked unit)) over 0.00 seconds
          • Unit - Move (Picked unit) instantly to Dung_TP[1], facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_Dung_TP[1])
This is a small but i do have some much bigger triggers with a lot of leaks to remove. What i want to know is if i put it like the first one it should always be the last to read in the trigger right?
Same for group leak should i put it at the end of group or like the first one after Remove location of course i am talking about (Call DestroyGroup) not the one i am using above.
 
Level 6
Joined
Jun 4, 2017
Messages
172
If i want to remove Location or Group leak with custom script i always put it at the end of the trigger but i am not sure if it is right so i made 2 triggers now just to show what i mean.
It's not completely right, if you remove the leak only at the end of the trigger it might be fine, but you might also have changed the value of that variable multiple times in the trigger without removing the previous value first. You need to remove the leak before overwriting the value.
In your case the first trigger is the correct one because you remove the location after its use is finished(the actions after a loop happen when the loop is finished, not in the meantime). In the second trigger the loop will do correctly only the first loop and then the location is removed so the point that will be used for the next loops will be the default point(center of playable map area, I think).
 
Level 10
Joined
Jun 20, 2017
Messages
333
I think something like this would work?
  • Troll Boss 2 Loc
  • Events
  • Unit - A unit enters Troll Dungeon Boss Entrance 2 <gen>
  • Conditions
  • ((Entering unit) is A Hero) Equal to True
  • Actions
  • Set Dung_TP[1] = (Center of Troll Dungeon Heroes Loc 2 <gen>)
  • Set UnitGroup = (Units in Troll Dungeon Respawn 1 <gen> matching (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True))
  • Unit Group - Pick every unit in UnitGroup and do (Actions)
    • Loop - Actions
      • Camera - Apply Dungeon 1 Copy 2 <gen> for (Owner of (Picked unit)) over 0.00 seconds
      • Unit - Move (Picked unit) instantly to Dung_TP[1], facing Default building facing degrees
  • Custom script: call RemoveLocation (udg_Dung_TP[1])
  • Custom script: call DestroyGroup(udg_UnitGroup)
 
Level 6
Joined
Jun 4, 2017
Messages
172
BTW is there any different between the 2 destroy groups?
1-Call Destroygroup(udg...)
2-set_bjwanttodestroygroup=true


I think something like this would work?
  • Troll Boss 2 Loc
  • Events
  • Unit - A unit enters Troll Dungeon Boss Entrance 2 <gen>
  • Conditions
  • ((Entering unit) is A Hero) Equal to True
  • Actions
  • Set Dung_TP[1] = (Center of Troll Dungeon Heroes Loc 2 <gen>)
  • Set UnitGroup = (Units in Troll Dungeon Respawn 1 <gen> matching (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True))
  • Unit Group - Pick every unit in UnitGroup and do (Actions)
    • Loop - Actions
      • Camera - Apply Dungeon 1 Copy 2 <gen> for (Owner of (Picked unit)) over 0.00 seconds
      • Unit - Move (Picked unit) instantly to Dung_TP[1], facing Default building facing degrees
  • Custom script: call RemoveLocation (udg_Dung_TP[1])
  • Custom script: call DestroyGroup(udg_UnitGroup)
Yes, it should work fine, but there is no reason to create a unit group variable when you can remove the group leak immediately by using "set_bjwantDestroyGroup=true" that destroys the group after the loop is finished.
You should use the unit group variable when you have to keep track of the group.
ye i wasn't clear on that any leak i remove at the end, is not used multiple times, so i should keep doing it like the first one then.

Thanks :)
I'm happy that I've been helpful :)
 
Status
Not open for further replies.
Top