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

[Trigger] TempPoint variable in every trigger: is it safe?

Status
Not open for further replies.
Level 7
Joined
Jun 1, 2009
Messages
104
A question about TempPoint: is it safe to use a single variable in hundreds of triggers?
Although TempPoint is destroyed ASAP after it was used, in same trigger, with no "Wait" functions, is it possible that another trigger still manages to redirect TempPoint before it was destroyed?
Any known examples of this theoretical issue?
Any limits of TempPoint usage that I should know?
Do I need to create multiple TempPoint variables, or even make a new one for each trigger?
Thanks!
 
Last edited:
A question about TempPoint: is it safe to use a single variable in hundreds of triggers?
Yes.
is it possible that another trigger still manages to redirect TempPoint before it was destroyed?
No.
Any limits of TempPoint usage that I should know?
Not necessarily a limit, but I always leave my TempLocation variable as an array variable due to offset locations and distance between points condition checks.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,190
As long as none of the actions the point or group is used for trigger an event it is fine to use a single variable. If they do trigger an event then the currently executing trigger will yield for the event response and that can lead to a sort of race condition with access to the variable which can result in leaks and double destroys.

For this reason local variables are best for this. Sadly GUI lacks this feature.
 
Last edited:
Level 7
Joined
Jun 1, 2009
Messages
104
I always leave my TempLocation variable as an array variable due to offset locations and distance between points condition checks.

Yeah, it's quite convenient when you need to operate with multiple points at same time. As I understood, I don't need to make a personal TempPoint or a personal TempPoint Array Index for every new trigger? That's good news!
 
Level 39
Joined
Feb 27, 2007
Messages
4,992
Is it possible that another trigger still manages to redirect TempPoint before it was destroyed?
Any known examples of this theoretical issue?
As long as none of the actions the point or group is used for trigger an event it is file to use a single variable. If they do trigger an event then the currently executing trigger will yield for the event response and that can lead to a sort of race condition with access to the variable which can result in leaks and double destroys.
Here's an example of what DSG described. The TempPoint in the second trigger will be leaked because the first trigger temporarily interrupts the second when the water elemental is created. The TempEffect is still destroyed properly because the variable is not overwritten by the first trigger.

  • Events
    • Unit - A unit enters (Playable map area)
  • Conditions
  • Actions
    • Set TempPoint = Center of Region001 <gen>
    • Unit - Move (Triggering Unit) instantly to TempPoint
    • Custom script: call RemoveLocation(udg_TempPoint)
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) equal to spell
  • Actions
    • Set TempPoint = (Target location of ability being cast)
    • Special Effect - Create an effect at TempPoint using SomeModel.mdx
    • Set TempEffect = (Last created special effect)
    • Unit - Create 1 Water Elemental at TempPoint facing Default building facing degrees
    • Special Effect - Destroy TempEffect
    • Custom script: call RemoveLocation(udg_TempPoint)
 
Level 12
Joined
Feb 5, 2018
Messages
521
Well you can use local points for single triggers that does not use loop triggers.

  • X
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Custom script: local location udg_TempLoc
      • Custom script: set udg_TempLoc = GetUnitLoc(GetTriggerUnit())
      • Special Effect - Create a special effect at TempLoc using Abilities\Spells\Other\ANrm\ANrmTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation (udg_TempLoc)
 
Status
Not open for further replies.
Top