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

Points and unit groups are NEVER ERASED!

Status
Not open for further replies.
Level 2
Joined
Jun 17, 2004
Messages
10
Or so I've heard:

http://www.elilz.com/catfaq.php?catchose=Custom Text

Q: Do I have to delete points and unit groups? What does "set bjWantDestroyGroup = true" mean?

A: You should not use bjWantDestroyGroup, I'll explain why it exists at the end.

Any time you create an object in a trigger it will exist until you destroy it or the map ends.

You can think of them all as being similar to units. Imagine you have a trigger that creates a unit, then attaches a special effect to that unit. When your trigger ends, you still have a unit with a special effect attached. If you run this trigger many times, you will end up with many units with special effects attached. The same thing happens for a point. You create a random point in a region, then attach a special effect to that point. When the trigger ends you still have a point and a special effect. If you run this trigger many times you will end up with many points and many special effects. In both cases you will need to destroy the points, units, and special effects if you don't want them to build up.

Variables are not objects, they are handles for objects. You assign a point to a variable the same way you would assign a unit.

If you want to create a unit, use it for something, and then destroy it, then you will need to store that unit in a variable so you can access it later:

1. create a unit
2. store that unit in [variable]
3. do something to unit in [variable]
4. remove unit in [variable]


If you do this every time you create a unit, then units won't build up over time. Points follow the same rules. Create your point, assign it to a variable, do something with it, and then destroy it. Otherwise they will build up over time.

The problem is that the GUI functions skip steps 2 and 4. They create a group and use it, but without ever assigning it to a variable or destroying it.

Blizzard people figured out the problem, but they couldn't find a good solution (I'm not making this up, Brett told us earlier). They could decompose every "each unit in group" function in every Blizzard map, but that would take forever. What they wanted to do was make the "each unit in group" function destroy the group that it was using. They couldn't do that exactly though, because the group may not be temporary! If you have a group variable chances are you don't want your group destroyed every time you use a for each function on it. What they did instead was sort of a cross between the two approaches. They modified the for each function to delete the group that was passed to it ONLY IF "bjWantDestroyGroup == true". Then all they had to do was set bjWantDestroyGroup before every "for each unit" function that did NOT use a group variable.

If you are making a map from scratch then don't do this! Do exactly the same thing as for units and points. Make a unit group variable named "TempGroup", and do the 4 step process above.

However if your map is short and your triggers don't run very often you probably don't care. If you only leak 1000 points during your entire map then it won't really matter.

I can't find this written anywhere else, but the implications are kind of scary...can anyone confirm or disprove this?
 
Status
Not open for further replies.
Top