• 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] Death timer can i use the same as i already have (Variable)

Status
Not open for further replies.
Level 19
Joined
Feb 15, 2008
Messages
2,184
Death timer can i use the same as i already have (Variable) [solved]

I have a timer that starts the game. Can i use same variables for death timer or do i need new ones?
Trigger

  • Timer
    • Events
    • Conditions
    • Actions
      • Countdown Timer - Start Timer as a One-shot timer that will expire in 3.00 seconds
      • Countdown Timer - Create a timer window for Timer with title Game starts in:
      • Set TimerWindow = (Last created timer window)
      • Countdown Timer - Show TimerWindow
  • Timer Ends
    • Events
      • Time - Timer expires
    • Conditions
    • Actions
      • Unit - Unpause all units
  • Destroy
    • Events
      • Time - Timer expires
    • Conditions
    • Actions
      • Custom script: call DestroyTimer(udg_Timer)
      • Countdown Timer - Destroy (Last created timer window)
And how will this trigger look like?
 
Last edited:
Level 28
Joined
Sep 26, 2009
Messages
2,520
What I meant is the following.

a) If you do this, it will work.
  • Trigger1
    • Events
      • *some event*
    • Conditions
    • Actions
      • Countdown Timer - Start timer_var as a One-shot timer that will expire in 30.00 seconds
  • Trigger2
    • Events
      • Time - timer_var expires
    • Conditions
    • Actions
      • -------- some actions --------
  • Trigger3
    • Events
      • Time - timer_var expires
    • Conditions
    • Actions
      • -------- some other actions --------
This will work, because you use 1 timer. It does not matter how many triggers are started by one timer.
As you can see in the example triggers I posted, one timer fired 2 other triggers upon expiration.


b) However if you do this, it wll not work.
  • Trigger1
    • Events
      • *some event*
    • Conditions
    • Actions
      • Countdown Timer - Start timer_var as a One-shot timer that will expire in 30.00 seconds
      • Countdown Timer - Start timer_var as a One-shot timer that will expire in 50.00 seconds
  • Trigger2
    • Events
      • Time - timer_var expires
    • Conditions
    • Actions
      • -------- some actions --------
If you think that the first trigger will start the second trigger 30 seconds later and then after another 20 seconds, then you are wrong.
The above will not work like that.
The reason for that is because the first time (the 30 seconds) gets replaced by the other time (by the 50 seconds).

So actually, the second trigger would be fired only once - after 50 seconds.


If you want the first trigger to fire the second one 2 times, you have two options:
1) re-use the timer by setting it again
  • *after the first timer finishes (e.g. after 30 seconds elapsed)*
  • Countdown Timer - Start timer_var as a One-shot timer that will expire in 20.00 seconds
2) use 2 timers (either 2 different timer variables, or 1 timer array)
In this case triggers would look like this:
  • Trigger1
    • Events
    • Conditions
    • Actions
      • Countdown Timer - Start timer_arr[1] as a One-shot timer that will expire in 30.00 seconds
      • Countdown Timer - Start timer_arr[2] as a One-shot timer that will expire in 50.00 seconds
  • Trigger2
    • Events
      • Time - timer_arr[1] expires
      • Time - timer_arr[2] expires
    • Conditions
    • Actions
      • -------- some actions --------
Since the above uses 2 different timers, they do not replace one another, which means the second trigger will be fired 2 times.
 
Level 19
Joined
Feb 15, 2008
Messages
2,184
  • Timer Copy
    • Events
    • Conditions
    • Actions
      • Countdown Timer - Start Timer as a One-shot timer that will expire in 6.00 seconds
      • Countdown Timer - Create a timer window for Timer_2 with title Your Hero Revives I...
      • Set Timer_Window_2 = (Last created timer window)
      • Countdown Timer - Show TimerWindow
  • Destroy Copy
    • Events
      • Time - Timer_2 expires
    • Conditions
    • Actions
      • Custom script: call DestroyTimer(udg_Timer_2)
      • Countdown Timer - Destroy (Last created timer window)
Must have done something wrong?

i meant like. if my hero dies it should only be able for me to see the death timer. Help me pls.
 
Level 19
Joined
Feb 15, 2008
Messages
2,184
  • HeroDies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Not equal to Neutral Hostile
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Trigger - Run Timer 2 <gen> (checking conditions)
  • Timer 2
    • Events
    • Conditions
    • Actions
      • Countdown Timer - Start Timer_2 as a One-shot timer that will expire in 6.00 seconds
      • Countdown Timer - Create a timer window for Timer_2 with title Your Hero Revives I...
      • Set Timer_Window_2 = (Last created timer window)
      • Countdown Timer - Show Timer_Window_2
  • Timer 2 Ends
    • Events
      • Time - Timer_2 expires
    • Conditions
    • Actions
      • Trigger - Run Revive <gen> (checking conditions)
  • Revive
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is alive) Equal to False
        • Then - Actions
          • Set loc = ((Owner of (Triggering unit)) start location)
          • Camera - Pan camera for (Player((Player number of (Owner of (Triggering unit))))) to loc over 0.00 seconds
          • Hero - Instantly revive Player_MMA[(Player number of (Owner of (Triggering unit)))] at loc, Hide revival graphics
          • Animation - Play Player_MMA[(Player number of (Owner of (Triggering unit)))]'s birth animation
          • Countdown Timer - Hide DeathTimerWindow[(Player number of (Owner of (Triggering unit)))]
          • Special Effect - Create a special effect at loc using Abilities\Spells\Other\Awaken\Awaken.mdl
          • Special Effect - Destroy (Last created special effect)
          • Selection - Select (Triggering unit) for (Owner of (Triggering unit))
          • Custom script: call RemoveLocation(udg_loc)
        • Else - Actions
  • Destroy Copy
    • Events
      • Time - Timer_2 expires
    • Conditions
    • Actions
      • Countdown Timer - Destroy (Last created timer window)
Not working what have i done wrong?
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Revive trigger checks if triggering unit is alive, when there is no triggering unit (since the trigger does not fire upon any unit-involved event)


Edit:

Looks like I solved it by writing it completely anew. Since I haven't really worked with timers before, I'll post the triggers here for others to point out my mistakes.

  • Revive Initialization 1
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Revive_Hash = (Last created hashtable)
      • For each (Integer Revive_Loop) from 0 to 11, do (Actions)
        • Loop - Actions
          • Trigger - Add to Revive Resurrection <gen> the event (Time - Revive_Timer[Revive_Loop] expires)
          • Custom script: set udg_Revive_ID = GetHandleId(udg_Revive_Timer[udg_Revive_Loop])
          • Hashtable - Save Revive_Loop as (Key TimerID) of Revive_ID in Revive_Hash
  • Revive Initialization 2
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • For each (Integer Revive_Loop) from 0 to 11, do (Actions)
        • Loop - Actions
          • Countdown Timer - Create a timer window for Revive_Timer[Revive_Loop] with title Your Hero Revives I...
          • Set Revive_TimerWindow[Revive_Loop] = (Last created timer window)
          • Countdown Timer - Hide Revive_TimerWindow[Revive_Loop]
  • Revive Death
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Not equal to Neutral Hostile
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set Revive_ID = ((Player number of (Triggering player)) - 1)
      • Set Revive_Unit[Revive_ID] = (Triggering unit)
      • Countdown Timer - Start Revive_Timer[Revive_ID] as a One-shot timer that will expire in 6.00 seconds
      • Countdown Timer - Show Revive_TimerWindow[Revive_ID] for (Triggering player)
  • Revive Resurrection
    • Events
    • Conditions
    • Actions
      • Set Revive_ID = (Load (Key TimerID) of (Key (Expiring timer)) from Revive_Hash)
      • Countdown Timer - Hide Revive_TimerWindow[Revive_ID] for (Player((Revive_ID + 1)))
      • -------- --------------------------------------------------------------------------------- --------
      • Set loc = ((Player((Revive_ID + 1))) start location)
      • Camera - Pan camera for (Player((Revive_ID + 1))) to loc over 0.00 seconds
      • Hero - Instantly revive Revive_Unit[Revive_ID] at loc, Hide revival graphics
      • Animation - Play Revive_Unit[Revive_ID]'s birth animation
      • Special Effect - Create a special effect at loc using Abilities\Spells\Other\Awaken\Awaken.mdl
      • Special Effect - Destroy (Last created special effect)
      • Selection - Select Revive_Unit[Revive_ID] for (Player((Revive_ID + 1)))
      • Custom script: call RemoveLocation(udg_loc)
 
Last edited:

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
bah, I was almost finished.
  • Melee Initialization
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Custom script: set udg_id = GetHandleId(GetTriggerUnit()) / 1000000
      • Custom script: call BJDebugMsg(I2S(udg_id))
      • Countdown Timer - Start timers[id] as a One-shot timer that will expire in 2.00 seconds
      • Set timers[id] = (Last started timer)
      • Countdown Timer - Create a timer window for timers[id] with title Respawn in
      • Set timersWindow[id] = (Last created timer window)
      • Wait 2.00 seconds
      • Custom script: set udg_id = GetHandleId(GetTriggerUnit()) / 1000000
      • Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
      • Countdown Timer - Destroy timersWindow[id]
 
Status
Not open for further replies.
Top