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

[Solved] Simple Leak/Variable Question

Status
Not open for further replies.
Level 2
Joined
Dec 17, 2010
Messages
18
So, like any responsible mapper, I am trying to make sure my triggers don't leak, but I can't figure out how to destroy a particular type of variable, namely, a "Unit" (NOT unit group) variable. For some reason, all the tutorials I can find skip over destroying a "Unit" variable, so if any one could let me know what the custom script is, I would greatly appreciate it. Thanks a ton!!
 
You don't need to "destroy" units. If you don't need them anymore, you can either kill them or remove them from the map. (Using "Unit - Remove Unit")

Remember, you aren't destroying the variable, you are destroying/removing the thing that it is "pointing" to. So if you still need the thing it is pointing to, you shouldn't destroy it. :) Usually locations and stuff like that are just used for that specific trigger, so you want to destroy those.
 
Level 2
Joined
Dec 17, 2010
Messages
18
ahh, that explains why I couldn't find the command in any of the tutorials. Thanks a ton!
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
The decay of units or usage of the remove action is destroying them. And you should get rid of them if you do not need them anymore. The only relevant advantage units possess in contrast to most other objects is that they are additionally controlled outside of jass script by the hardcoded game engine, may trigger events and they get removed after their decay after death on default. But frankly, I monitor them properly anyway to improve the management. You often need to attach data to units during their life cycle or pick them all. Would be funny for newb mapmakers if there were not the native group enum functions.
 
Level 2
Joined
Dec 17, 2010
Messages
18
i'm not sure I qualify as a newb...I've been making maps since before WC III (good old starcraft I world editor!), but I've never made a serious hobby of it, and I know next to nothing about JASS. I started getting into variables only about two years ago when I started making more complicated units and triggers. Basically, there are certain events which will only affect one unit on the map at a time (a particular hero owned by a particular player) so rather than using the "unit group" function, I just used the "unit" function. Whenever I use "unit group" (or any function like it) I make sure to destroy the group afterward using the "call DestroyGroup(udg_whatever)" function. I was just wondering if i needed to use an equivalent function to remove a unit variable, but it turns out I don't!
 
Status
Not open for further replies.
Top