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

Variables and destroying them.

Status
Not open for further replies.
Level 2
Joined
May 1, 2008
Messages
3
Does the trigger leak if i set point to a variable? Does it create a new leak everytime the spell is casted, or will the variable replace the old data?

And does the custom remove trigger code work in loop triggers?

If some variables doesnt replace the old data, what would they be? Like a real, integer, unit, unit group..etc..

I dont want to destroy those what will replace the old, because that would just take a unnessessary action if the spell is going to trigger multiple times in the game.

And destroying triggers, should i put it behind the "trigger turn off" action, or do i need to remove that turn off action from the trigger?

(and from that leak tutorial) Does this remove the current trigger, or do i need to write that trigger name somewhere that custom script?

call DestroyTrigger(GetTriggeringTrigger())

And can i destroy other triggers from another trigger? Like a example: "i have a doom trigger and duke trigger" if i want to remove that duke trigger, could i destroy it from the doom trigger?

And after the match, will the carbage collector remove all memory leaks, or will they be in the memory untill you reset computer?

Thats all questions i guess. :cool:
 
Does the trigger leak if i set point to a variable? Does it create a new leak everytime the spell is casted, or will the variable replace the old data?

Yes. If you don't remove the point (known as a "location" as well) like this:
  • Custom script: call RemoveLocation(udg_MyVariableName)
It will leak. Also, it will leak everytime the spell is cast, unless you are setting it to another variable to represent some constant location or something weird like that. Anyway, for example:
  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
It will create a new point each time the trigger is ran. Since it isn't being removed and serves no purpose anymore, it counts as a leak. ;)

And does the custom remove trigger code work in loop triggers?

Yes, it works fine. :)

If some variables doesnt replace the old data, what would they be? Like a real, integer, unit, unit group..etc..

All the variable-types will replace the previous data it held. For example:
  • Set IntegerV = 5
  • Set IntegerV = 16
IntegerV will now be 16, and it will no longer hold its previous value. Arrays can help if you need some variable to store multiple values. They consist of the variable name and an integer from 0-8192 to represent the index. For example:
  • Set IntegerArray[0] = 55
  • Set IntegerArray[1] = 34
Now IntegerArray[0] holds "55" as its value and IntegerArray[1] holds "34" as its value. Of course, using the same index will still overwrite the previous value. So if you set IntegerArray[0] to hold 22, it would no longer hold "55".

I dont want to destroy those what will replace the old, because that would just take a unnessessary action if the spell is going to trigger multiple times in the game.

I'm not sure what you mean. :(

And destroying triggers, should i put it behind the "trigger turn off" action, or do i need to remove that turn off action from the trigger?

You can turn the trigger off before destroying it, but it isn't really necessary. You can just directly destroy it. Just be careful though, once a trigger is destroyed, it will never work again.

(and from that leak tutorial) Does this remove the current trigger, or do i need to write that trigger name somewhere that custom script?

call DestroyTrigger(GetTriggeringTrigger())

It removes the trigger in which the current event was fired. In most cases, it is simply the trigger the actions are in. For triggers without events, GetTriggeringTrigger() might return "null" or as some other trigger. For example:
  • Funfun
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Custom script: call DestroyTrigger(GetTriggeringTrigger())
This will destroy the trigger "Funfun". You won't need to worry about the null case, it only occurs when there is no event at all.

And can i destroy other triggers from another trigger? Like a example: "i have a doom trigger and duke trigger" if i want to remove that duke trigger, could i destroy it from the doom trigger?

Yes. The way you would do it is like this:
  • Custom script: call DestroyTrigger(gg_trg_TriggerName)
If the trigger you wanted to destroy was named "Doom", you would destroy it like this:
  • Custom script: call DestroyTrigger(gg_trg_Doom)
And after the match, will the carbage collector remove all memory leaks, or will they be in the memory untill you reset computer?

They'll stop being in memory after finishing the game/quitting or exiting the application. I forget which. But they will definitely be gone from memory after exiting wc3.

If you need clarification or have any more questions, feel free to ask. ;)
 
Status
Not open for further replies.
Top