Question about triggers and variables

world23wc3

Member
Reaction score
6
Hi!

I've been quite unsure about this question I've had for some time now and I thought that it was time to ask for help now.
Let's say that I have this trigger
Trigger:
  • Example
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Firebolt (Neutral Hostile)
    • Actions
      • Set example_unit = (Target unit of ability being cast)
      • Wait 20.00 seconds
      • Unit - Kill example_unit


What if the trigger is runned twice but from different units, Will it create two instaces of the variable "example_unit" or will the first targeted unit be set to example unit and then the other one override the variable with it's targeted unit? Do I need to create many IF, THEN ACTIONS, ELSE ACTIONS?
Please help me, I hope I made myself as clear as possible.
 

Happy

Well-Known Member
Reaction score
71
afaik just the second "example_unit" dies. The "example_unit" gets overridden.
 

jnZ

I
Reaction score
64
and thats where local variables come in handy. they are pretty easy to use via custom scripts aswell.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
612
You could do it this way.
Trigger:
  • Example
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Firebolt (Neutral Hostile)
    • Actions
      • Custom script: local unit Target = GetSpellTargetUnit()
      • Wait 20.00 seconds
      • Custom script: set udg_example_unit = Target
      • Unit - Kill example_unit
      • Custom script: set Target = null

This will ensure that example_unit will refer to the targeted unit 20 seconds after casting.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top