• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

How do I time Actions of a trigger

Status
Not open for further replies.
Level 2
Joined
Nov 11, 2021
Messages
7
I wanna make my trigger do one action for a specefic event, then wait a certain amount of time and do another action for the same event
can anyone explain how i do that?
 
Level 2
Joined
Nov 11, 2021
Messages
7
didnt work. would the wait command be inbetween two triggers in order to work? or how does it know which one to do first and which after the wait
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
If you post your triggers it's far easier for us to help you: How To Post Your Trigger

Waits are tricky because Event Responses are not guaranteed to work after a Wait and they often aren't safe to use after a Wait. There's a lot to learn about how they work since their behavior can be inconsistent with one another. Just know that most of them act like global Variables which are set in response to their associated Event.

So for example when a unit dies, before Conditions/Actions execute, the Event Response (Dying unit), (Triggering unit), and (Killing unit) are all set automatically for you. This can be an issue since the values of these Event Responses are shared globally amongst all of your triggers and like any other global variable they can only have one value set at a time. When Waits are used they create a window of opportunity for things to change, which can result in a trigger referencing the wrong Event Response or just flat out not working because their original values have been set to something else.

Here's an example of an Event Response failing after a Wait. (Target point of ability being cast) is set to null after a Wait, meaning it will no longer exist. This will result in the Footman spawning at the center of the map instead of where you cast the ability. The center of the map is the default point for when an invalid position is given.
  • Target point issue
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Shockwave
    • Actions
      • Wait 2.00 seconds
      • Unit - Create 1 Footman for Player 1 (Red) at (Target point of ability being cast) facing Default building facing degrees

Here's a working exception to the rules and a very useful Event Response. (Triggering unit) is safe to use after Waits because it acts like a local variable:
  • Events
  • Unit - A unit Starts the effect of an ability
  • Conditions
  • Actions
  • Wait 2.00 seconds
  • Unit - Kill (Triggering unit)
(Triggering unit) is always set to the unit mentioned in the Event -> A unit does something...


Regarding weird behavior, here's a good example.
  • Weird behavior
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Not equal to Dummy
    • Actions
      • Unit - Create 1 Dummy for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit - Order (Last created unit) to Night Elf Mountain Giant - Taunt.
      • Game - Display to (All players) for 30.00 seconds the text: (Name of (Casting unit))
      • Unit - Kill (Casting unit)
I made this trigger which says that whenever a non-Dummy unit casts a spell (ability), a Dummy unit is created which casts an instant speed Taunt ability in response. Note that Dummy units are designed to have no cast delay for their spells which is why I say "instant speed". This instant speed behavior is actually part of the reason why this weird behavior happens in the first place.

Anyway, here's where it gets weird, the (Casting unit) which I attempt to Kill is set to null after this action:
  • Unit - Order (Last created unit) to Night Elf Mountain Giant - Taunt.
This means that it's not set to anything. I'm not sure why this happens but I do know that the Dummy unit casting an ability is the cause. It's probably because two units are casting abilities at the "same time" and that causes things to break.

Long story short, smart use of global Variables, Event Responses, local variables, etc. can help remedy all of these issues.
 
Last edited:
Level 2
Joined
Nov 11, 2021
Messages
7
hey, thank you very much for your answer. i think i kinda found a way to do what i wanted in the meantime.
good to know anyways that sometimes triggers and actions can conflict with one another in unforseen ways
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
hey, thank you very much for your answer. i think i kinda found a way to do what i wanted in the meantime.
good to know anyways that sometimes triggers and actions can conflict with one another in unforseen ways
If you post your triggers it will help clear everything up, I'm still not entirely sure what you want to do.
 
Last edited:
Level 2
Joined
Nov 11, 2021
Messages
7
If you post your triggers it will help clear everything up, I'm still not entirely sure what you want to do.
i actually wanted to remake the morph effect from obsidian statue (since my morphs are broken for some reason)
first i went about it in a needlessly complicated way and the wait trigger didn't work. since i'm pretty unexperienced with triggers i thought there was no easy way to time them and posted this here
now i have made a way simler trigger that works
basically
generic unit even: unit casts a dummy spell
play morph animation
queue morph alternate animation
wait a certain time
replace unit (obsidian statue) with destroyer

i needed the wait command to exactly time the replace when during the animation process it should happen
 
Level 2
Joined
Nov 11, 2021
Messages
7
ahh oh no it didnt work actually. its something with using a custom morph ability even if it's modelled exactly on the normal one, that seems to crash my game
 
Last edited:
Status
Not open for further replies.
Top