• 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.

[Solved] Timers

Status
Not open for further replies.
Level 14
Joined
Dec 29, 2009
Messages
931
Yes, me again.

I'm working on the hero revival system for my map,
and I checked the tutorials section and couldn't find anything to help.

What I have thus far is this:
  • HR Timer Set
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • (Triggering unit) Equal to HS_PlayerHero[(Player number of (Owner of (Triggering unit)))]
      • ((Owner of (Triggering unit)) slot status) Equal to Is playing
      • ((Owner of (Triggering unit)) controller) Equal to User
    • Actions
      • Countdown Timer - Start HR_ReviveTimer[(Player number of (Owner of (Triggering unit)))] as a One-shot timer that will expire in 30.00 seconds
      • Set HR_ReviveTimer[(Player number of (Owner of (Triggering unit)))] = (Last started timer)
      • Countdown Timer - Create a timer window for HR_ReviveTimer[(Player number of (Owner of (Triggering unit)))] with title ((Name of (Owner of (Triggering unit))) + - )
      • Set HR_ReviveTimerWindow[(Player number of (Owner of (Triggering unit)))] = (Last created timer window)
  • HR Timer End 1
    • Events
      • Time - HR_ReviveTimer[1] expires
    • Conditions
    • Actions
      • Hero - Instantly revive HS_PlayerHero[1] at HR_RevivePoint[1], Hide revival graphics
      • Set HR_TempLoc = (Position of HS_PlayerHero[1])
      • Special Effect - Create a special effect at HR_TempLoc using war3mapImported\HolyAwakening.mdx
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation(udg_HR_TempLoc)
      • Camera - Pan camera for Player 1 (Red) to HR_RevivePoint[1] over 0.00 seconds
      • Selection - Clear selection for Player 1 (Red)
      • Selection - Select HS_PlayerHero[1] for Player 1 (Red)
Now, the problem is, if I stick with this, I'll have to make 8 seperate triggers for each of the player's timers.
This is a hassle, and although it could be done, I thought I might ask if there is a better way first.

Any help provided is appreciated, of course. :)
 
Level 7
Joined
May 11, 2010
Messages
278
Here's the system i use.
  • Start
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set playergroup = (Player group((Owner of (Triggering unit))))
      • Game - Display to playergroup the text: Your hero will be r...
      • -------- save the time of respawn. 10 in this case. --------
      • Hashtable - Save 10.00 as (Key respawntime) of (Key (Triggering unit)) in respawntable
      • Unit Group - Add (Triggering unit) to respawngroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Respawn <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Respawn <gen>
        • Else - Actions
  • Respawn
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in respawngroup and do (Actions)
        • Loop - Actions
          • Set respawntime = (Load (Key respawntime) of (Key (Picked unit)) from respawntable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • respawntime Greater than 0.00
            • Then - Actions
              • Hashtable - Save (respawntime - 1.00) as (Key respawntime) of (Key (Picked unit)) in respawntable
            • Else - Actions
              • Set player = (Owner of (Picked unit))
              • Set TempPoint3 = (Center of Region 001 <gen>)
              • Hero - Instantly revive (Picked unit) at TempPoint3, Show revival graphics
              • Camera - Pan camera for player to TempPoint3 over 0.20 seconds
              • Selection - Select (Picked unit) for player
              • Custom script: call RemoveLocation(udg_TempPoint)
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in respawntable
              • Unit Group - Remove (Picked unit) from respawngroup
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in respawngroup) Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
Pretty much copy-pasted from my current project. added the comment and removed a thing specific to the project.

make sure to create the hashtable during map initialization.
  • Hashtable - Create a hashtable
  • Set respawntable = (Last created hashtable)
 
Level 14
Joined
Dec 29, 2009
Messages
931
This is what you need.

I was a little confused as to which part I needed to be looking at.

Are those 3 seperate systems, or are they all part of one?
-also, if they're part of one, any particular reason majority of them are disabled?

Here's the system i use.
  • Start
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set playergroup = (Player group((Owner of (Triggering unit))))
      • Game - Display to playergroup the text: Your hero will be r...
      • -------- save the time of respawn. 10 in this case. --------
      • Hashtable - Save 10.00 as (Key respawntime) of (Key (Triggering unit)) in respawntable
      • Unit Group - Add (Triggering unit) to respawngroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Respawn <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Respawn <gen>
        • Else - Actions
  • Respawn
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in respawngroup and do (Actions)
        • Loop - Actions
          • Set respawntime = (Load (Key respawntime) of (Key (Picked unit)) from respawntable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • respawntime Greater than 0.00
            • Then - Actions
              • Hashtable - Save (respawntime - 1.00) as (Key respawntime) of (Key (Picked unit)) in respawntable
            • Else - Actions
              • Set player = (Owner of (Picked unit))
              • Set TempPoint3 = (Center of Region 001 <gen>)
              • Hero - Instantly revive (Picked unit) at TempPoint3, Show revival graphics
              • Camera - Pan camera for player to TempPoint3 over 0.20 seconds
              • Selection - Select (Picked unit) for player
              • Custom script: call RemoveLocation(udg_TempPoint)
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in respawntable
              • Unit Group - Remove (Picked unit) from respawngroup
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in respawngroup) Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
Pretty much copy-pasted from my current project. added the comment and removed a thing specific to the project.

make sure to create the hashtable during map initialization.
  • Hashtable - Create a hashtable
  • Set respawntable = (Last created hashtable)

This seems reasonable enough.
I'll take a closer look at both systems and see which one is better to use:)

Thanks to both of you. +rep of course.
 
Level 14
Joined
Dec 29, 2009
Messages
931
Oh, I forgot to mention that the trigger called Respawn should be initially off.

Right, I noticed that. :p

Thanks!

EDIT: Just remembered, the whole point I made this thread was because I needed a timer window.
I knew how to make the hero respawn, I just couldn't figure out the windows. Taking a look at these,
they're far better than what I add, so I'm very grateful for that. But...

I still require the timer windows. c:
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Right, I noticed that. :p

Thanks!

EDIT: Just remembered, the whole point I made this thread was because I needed a timer window.
I knew how to make the hero respawn, I just couldn't figure out the windows. Taking a look at these,
they're far better than what I add, so I'm very grateful for that. But...

I still require the timer windows. c:

u can use hashtable, use timer array where the custom value or player index and add event, save to hashtable the unit, like key1: Timer Handle Id, key2: 1, save unit
when timer expire gethandleid and just load unit from hashtable so dont need 8-12 expire trigger just 1
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
uhm what?

This is the first time I've used hashtables.


http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/hashtables-mui-133407/

just use a integer and custom script for get the timer handle id (its unique, cant ahve 2 timer same time same handleid, thats why usefull identify what timer ran out, sadly cant use array for this because the handle id is higher than 8192 and array cant handle higher index, so u are forced to use hashtable what is similiar like 2d array (example: a[x][y]))

in expire trigger u can get the expiredtimer handle id with custom script like

"udg_your_integer_variable = GetHandleId(GetExpiredTimer())"

(u need udg_ prefix for identify the gui variable :p so your variable name is your_integer_variable in gui and in jass/custom script udg_your_integer_variable)
 
Level 14
Joined
Dec 29, 2009
Messages
931
Alright thanks. Also @ Shoto Why in the hell does your trigger make everything red? xD
I copied what you had almost entirely, changing a few conditions and whatnot, and yeah..

All the team colors are switched to red. Any particular reason why this is happening?
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Alright thanks. Also @ Shoto Why in the hell does your trigger make everything red? xD
I copied what you had almost entirely, changing a few conditions and whatnot, and yeah..

All the team colors are switched to red. Any particular reason why this is happening?

in posted trigger i dont really watched anything what chance the team color, anyway in loop u can cache (store to variable, like u = picked unit) the picked unit :)
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
u can try this too if u want countdown window, this change the color?
if yes then with ur editor have something

  • Map init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hashtable = (Last created hashtable)
  • Hero die
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
    • Actions
      • Set unit = (Triggering unit)
      • Custom script: set udg_Timer = CreateTimer()
      • Custom script: set udg_Id = GetHandleId(udg_Timer)
      • Countdown Timer - Create a timer window for Timer with title (Name of unit)
      • Countdown Timer - Hide (Last created timer window)
      • Countdown Timer - Show (Last created timer window) for (Triggering player)
      • Countdown Timer - Start Timer as a One-shot timer that will expire in (Real((((Hero level of unit) x 3) + 5))) seconds
      • Trigger - Add to Timer Expired <gen> the event (Time - Timer expires)
      • Hashtable - Save Handle Of(Triggering unit) as 0 of Id in Hashtable
      • Hashtable - Save Handle Of(Last created timer window) as 1 of Id in Hashtable
  • Timer Expired
    • Events
    • Conditions
    • Actions
      • Set Timer = (Expiring timer)
      • Custom script: set udg_Id = GetHandleId(udg_Timer)
      • Countdown Timer - Destroy (Load 1 of Id in Hashtable)
      • Set unit = (Load 0 of Id in Hashtable)
      • Set Point = (Position of unit)
      • Hero - Instantly revive unit at Point, Show revival graphics
      • Custom script: call RemoveLocation(udg_Point)
      • Custom script: call DestroyTimer(udg_Timer)
      • Hashtable - Clear all child hashtables of child Id in Hashtable
 

Attachments

  • 1_Timer_Revive.w3x
    17.6 KB · Views: 66
  • vars.JPG
    vars.JPG
    18.9 KB · Views: 143
Level 14
Joined
Dec 29, 2009
Messages
931
u can try this too if u want countdown window, this change the color?
if yes then with ur editor have something

  • Map init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hashtable = (Last created hashtable)
  • Hero die
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
    • Actions
      • Set unit = (Triggering unit)
      • Custom script: set udg_Timer = CreateTimer()
      • Custom script: set udg_Id = GetHandleId(udg_Timer)
      • Countdown Timer - Create a timer window for Timer with title (Name of unit)
      • Countdown Timer - Hide (Last created timer window)
      • Countdown Timer - Show (Last created timer window) for (Triggering player)
      • Countdown Timer - Start Timer as a One-shot timer that will expire in (Real((((Hero level of unit) x 3) + 5))) seconds
      • Trigger - Add to Timer Expired <gen> the event (Time - Timer expires)
      • Hashtable - Save Handle Of(Triggering unit) as 0 of Id in Hashtable
      • Hashtable - Save Handle Of(Last created timer window) as 1 of Id in Hashtable
  • Timer Expired
    • Events
    • Conditions
    • Actions
      • Set Timer = (Expiring timer)
      • Custom script: set udg_Id = GetHandleId(udg_Timer)
      • Countdown Timer - Destroy (Load 1 of Id in Hashtable)
      • Set unit = (Load 0 of Id in Hashtable)
      • Set Point = (Position of unit)
      • Hero - Instantly revive unit at Point, Show revival graphics
      • Custom script: call RemoveLocation(udg_Point)
      • Custom script: call DestroyTimer(udg_Timer)
      • Hashtable - Clear all child hashtables of child Id in Hashtable

Thank you that was what I needed. :p

It changed the player colors? o_O
Sorry, I can't help you here, it does not do that on my map...

That's fine, I'm sure it was some stupid mistake I made and I just didn't see it. ^^ Thanks anyway :)
 
Status
Not open for further replies.
Top