• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Can someone explane me wait actions?

Status
Not open for further replies.
Level 14
Joined
Mar 4, 2009
Messages
1,156
i have wait action 0.5 seconds and it works good
and when i have wait action 1 second it doesn't do action at all or i maybe need to wait 1 hour.....

EVENT -unit begins casting an ability
CON -ability being cast equal to chain lightning
ACTION- pause target
wait 15 seconds
unpause target
move target instantly to casting unit

-action after waiting don´t work
 
Level 11
Joined
May 16, 2007
Messages
288
This is the problem of waits, if a unit casts a spell within 15 seconds of the chain lightning, it will get a new Target of spell effect / casting unit / etc, and won't unpause the correct unit.
The only way to make this trigger work correctly is using timers or an indexing system.
 
Level 14
Joined
Mar 4, 2009
Messages
1,156
This is the problem of waits, if a unit casts a spell within 15 seconds of the chain lightning, it will get a new Target of spell effect / casting unit / etc, and won't unpause the correct unit.
The only way to make this trigger work correctly is using timers or an indexing system.

That will never happen it cannot use the wrong target.....
for example trigger
unit is attacked
wait 15 sec
kill attacked unit
 
Level 17
Joined
Jun 12, 2007
Messages
1,261
It does it's a rule.

A unit is attacked (trigger runs).
Wait 15 seconds.
Kill attacking unit.

But what will happen if somebodies attacks within those 15 seconds? The trigger will restart. It will no longer do what it was going to do and instead start all over because of the event being run again.

This is solved by having no waits. As the trigger will then do everything in a matter of miliseconds.

This is a fact, get used to it. Also certain stored things get removed after an wait. I don't know what it is though.

So remove waits and use a timer.
 
Level 12
Joined
Mar 26, 2005
Messages
790
"The trigger will restart. It will no longer do what it was going to do and instead start all over because of the event being run again."

Thats not good explanation. The trigger itself will continue to execute actions, But if some unit attack within 15 sec, unit which attacked will be set as global variable for "attacking unit", so the attacking unit from the first trigger will be no more influent by that first trigger. It will kill the second attacking unit, and the second trigger would kill the same unit the first trigger did, but if it is dead, it is logical, that it cannot kill it twice.
 
Level 8
Joined
Apr 30, 2009
Messages
338
You would have to turn the units into local variables if you must have such long waits. There is no other way to 100% ensure that every instance of the trigger will work.

If you want to kill a unit 15 seconds after it does something, just use the

  • Events
    • Unit - Add 15 second Generic Expiration timer to (Triggering unit)
and you no longer have to use a wait
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Store the values in locals, as locals are not lost by waits.

The true problem with waits is they are longer than the duration specified and their duration varies from game to game and are thus unreliable for anything needing precision timing.
If you need exact timming, use timer objects.
 
Level 14
Joined
Mar 4, 2009
Messages
1,156
You would have to turn the units into local variables if you must have such long waits. There is no other way to 100% ensure that every instance of the trigger will work.

If you want to kill a unit 15 seconds after it does something, just use the

  • Events
    • Unit - Add 15 second Generic Expiration timer to (Triggering unit)
and you no longer have to use a wait
I just gived an example,what if i need to pause unit and unpause him for 15 seconds?
 
Level 9
Joined
Apr 25, 2009
Messages
468
Try this out:

  • Wait time
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Chain Lightning
    • Actions
      • Set Target_Unit = (Target unit of ability being cast)
      • Set Casting_Unit = (Casting unit)
      • Set Target_Location1 = (Position of Target_Unit)
      • Unit - Pause Target_Unit
      • Wait 15.00 seconds
      • Set Target_Location2 = (Position of Casting_Unit)
      • Unit - Move Target_Unit instantly to Target_Location2
      • Unit - Unpause Target_Unit
      • Set Target_Unit = No unit
      • Set Casting_Unit = No unit
      • Custom script: call RemoveLocation(udg_Target_Location1)
      • Custom script: call RemoveLocation(udg_Target_Location2)
If you want me to explain how that trigger works, just ask :)
 
Level 14
Joined
Mar 4, 2009
Messages
1,156
Store the values in locals, as locals are not lost by waits.

The true problem with waits is they are longer than the duration specified and their duration varies from game to game and are thus unreliable for anything needing precision timing.
If you need exact timming, use timer objects.

Im shure you know what to do but i dont know how to do that, can you send me the trigger?
 
Level 17
Joined
Jun 12, 2007
Messages
1,261
Try this out:

  • Wait time
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Chain Lightning
    • Actions
      • Set Target_Unit = (Target unit of ability being cast)
      • Set Casting_Unit = (Casting unit)
      • Set Target_Location1 = (Position of Target_Unit)
      • Unit - Pause Target_Unit
      • Wait 15.00 seconds
      • Set Target_Location2 = (Position of Casting_Unit)
      • Unit - Move Target_Unit instantly to Target_Location2
      • Unit - Unpause Target_Unit
      • Set Target_Unit = No unit
      • Set Casting_Unit = No unit
      • Custom script: call RemoveLocation(udg_Target_Location1)
      • Custom script: call RemoveLocation(udg_Target_Location2)
If you want me to explain how that trigger works, just ask :)

That's wont work, just telling.
 
Level 14
Joined
Mar 4, 2009
Messages
1,156
Thx you all for help but i got another solution,just the variables musn´t be changed in next 15 seconds
  • Untitled Trigger 008
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Teleport for untiblock (Neutral Hostile)
    • Actions
      • Set GENERICUNIT[1] = (Target unit of ability being cast)
      • Set GENERICUNIT[2] = (Casting unit)
      • Unit - Pause GENERICUNIT[1]
      • Set POINT = (Position of GENERICUNIT[2])
      • Wait 15.00 seconds
      • Unit - Unpause GENERICUNIT[1]
      • Unit - Move GENERICUNIT[1] instantly to POINT
      • Custom script: call RemoveLocation(udg_POINT)
BTW Im not shure is it needed but i saw many people seting variable unit (some unit) and than after action they set variable unit = no unit

is there any leak if you do this trigger?

EVENT-unit begins casting an ability
ACTION-kill target of ability being cast
 
Level 9
Joined
May 27, 2006
Messages
498
Unit variables dont leak afaik, but im not sure.

Your trigger will still fail, cause the variables get overwritten every time the ability is cast. To make your trigger fail-proof you need to use locals, which requires converting your trigger to simple jass code.
Also, use Unit starts an effect of an ability instead of Unit begins casting. Its just better and more precise.
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Airandius, at first, you were wrong,,
If you do:
Unit is Attacked
Wait 15 secs
Kill Attacked Unit

This would be MUI, if the (Attacked Unit) would still be there,, it would be MUI, but it wouldnt do something,,

Hanibon's trigger, on the other side, would succeed in doing the thing but makes it non-MUI, so it would still fail,,
Best way would be Jass, as said, because of the locals,,
So i recommend to convert to Jass and just replace those globals with locals,, that should work ;)
 
Status
Not open for further replies.
Top