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

Local Variables and memory leaks.

Status
Not open for further replies.
Level 2
Joined
Aug 9, 2004
Messages
11
I know how to use locals and prevent leaks for the most part. One thing I don't know tho is how to find out the 'type' of thing I want to make a variable for...

eg..... if i want to remove the often used TempPoint, I use CS: call RemoveLocation( udg_TempPoint ) ..... (btw, do I need those spaces between the parenthesis?)

but if i wanted to create a local variable point (instead of having to resort to globals for everything, like I'm currently doing)

I'd assume I'd use CS: local point udg_TempPoint .... so why is it that to remove a temp point it's RemoveLocation and not RemovePoint? And what do i do to remove a local variable temppoint?

unit groups is another one I'd like to hear about.

I hope someone understands this, barring my bad english. Thank you.
 
Level 8
Joined
Apr 3, 2004
Messages
507
Your English is fine.

The point variable type is called Point in GUI (apparently they felt that would be more clear), but it's called Location in jass. So your custom script would be "local location udg_TempPoint".

The type for a unit group is simply Group. I believe the function to clear it is DestroyGroup(GroupVar).

You don't need spaces between the variable and the parentheses. That's just the way that the GUI writes jass, for some reason.

UnitGroups and Points are the two key variables to take care of, regarding memory leaks. If you haven't yet, make sure you read through this thread on wc3campaigns about Memory Leaks.
 
Level 2
Joined
Aug 9, 2004
Messages
11
Hmmm, is there any way I can make a local trigger?

For example, I want it so that when aunit dies near my hero (I have this part worked out,) that the hero gains a point in agility for 20 seconds or so....

I'm not sure what I'd have to do to get this to work, because obviously with globals whenever a unit would die, it'd retrigger the trigger so that the wait wouldn't finish.

*edit* btw I'm doing this with the modify hero attribute action, if it makes a difference (I'd think it would)

*edit2* how do we know if we need to detroy something or remove something.... same thing or not?
 
Status
Not open for further replies.
Top