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

Mass variable for reason?

Status
Not open for further replies.
Level 7
Joined
Jun 15, 2010
Messages
218
Ok so i always see everyone having a new variable that sets the caster

  • Set Power_Slam_Caster = (Triggering unit)
What if i would cast another ability then Power Slam and use the same variable then whats the problem? will it bug? Couse i would prefer to use 1 variable that sets the (triggering unit) in all spell without waits.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,192
You really should be using a local for this sort of variable setting. Changing the values of globals is slower than those of locals due to the level of memory access (locals in stack, globals in main memeory).

Ofcourse blizzard did not bother letting GUI access locals.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I've always wanted to ask this similar kinda question...
Example:
We got 2 running trigger at the same time using same variable
Will it collide ?

Trigger 1:
  • Engulfing Flame
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Engulfing Flame
    • Actions
      • Set Caster = (Triggering unit)
      • Set Target = (Target unit of ability being cast)
      • Trigger - Turn on Looping Damage <gen>
  • Looping Damage
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit - Cause Caster to damage Target, dealing 20.00 damage of attack type Spells and damage type Normal
Trigger 2:
  • Thunderstorm
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Thunderstorm
    • Actions
      • Set Caster = (Triggering unit)
      • Set Target = (Target unit of ability being cast)
      • Set TargetLoc = (Position of Target)
      • Trigger - Turn on Ground Shake <gen>
  • Ground Shake
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Environment - Create a 1.00 second Normal ripple deformation at TargetLoc with starting radius 1024.00, ending radius 1024.00, and depth 64.00, using 1.00 second ripples spaced 512.00 apart
I'm not talking about MUI or leaking in triggers, I just wanna know whether a same set variable would collide with each other if used on the same time EVEN that trigger is, MUI ?
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,192
We got 2 running trigger at the same time using same variable
No you do not. It is impossible for 2 triggers to run at the same time...

You should easilly be aware of this by the fact that WC3 is only single threaded (next to interupt handlers and external components which are too small to consider). As such only 1 thing in the game can run at any time. It will always run 1 trigger before the other.

Because the variable is global, it can be subject to incorrect use as your example showed. 2 different systems reference the same variable but rely on it being un altered and thus it will bug as their usage collide. This is why local or private variables were created to prevent such collisions from occuring.

It is perfectly alright to use the same global in many different tasks as long as the tasks instantly free (same scope as a local variable). This is still incorrect use of a global as a local variable should be used instead.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
You're asking a different question, chasin255 asked about triggers without waits, yours had timers, which executes after some time. If you're triggers didn't have timers then using global variables like that would work properly.
 
Status
Not open for further replies.
Top