• 🏆 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!

Countdown Timer Reset

Status
Not open for further replies.
Level 29
Joined
Mar 10, 2009
Messages
5,016
EDIT: THIS THREAD IS SOLVED...


Hello, I was searching for hours for an answer to this question...

Is there anyway to NOT RESET the timer (countdown timer) or make the timer MUI when hero dies?...the thing is, even hashtables & indexing is not working...if anybody is kind enough to help, plz post triggers here, thanks!...+rep to those who solve this...

NOTE: Plz dont tell me to just make it MPI coz I want to do it the 'MUI' way...

Example:

Trigger 1
Event - Hero Dies
Actions - create timer for 10 seconds (<<<This is the problem, the timer will reset when another hero dies even using hashtables or indexing!)...

Trigger 2
Revives the hero when timer expires

THIS IS THE TRIGGER: I've set variables before, blah blah blah, nothing bloody works!

  • Hero Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • ((Triggering unit) is an illusion) Equal to False
    • Actions
      • Game - Display to (All players) the text: ((Proper name of (Triggering unit)) + ( Has been killed by + (Proper name of (Killing unit))))
      • Hashtable - Save Handle Of(Triggering unit) as (Key die) of (Key (Triggering unit)) in Hash
      • Hashtable - Save 10.00 as (Key time) of (Key (Triggering unit)) in Hash
      • Countdown Timer - Start Timer[(Load (Key die) of (Key (Triggering unit)) from Hash)] as a One-shot timer that will expire in (Load (Key time) of (Key (Triggering unit)) from Hash) seconds
      • Hashtable - Save Handle Of(Last started timer) as (Key timer) of (Key (Triggering unit)) in Hash
      • Countdown Timer - Create a timer window for (Load (Key timer) of (Key (Triggering unit)) in Hash) with title <Empty String>
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240
So you need MUI timer system for heroes?


  • Hero Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Custom script: local unit u = GetTriggerUnit()
      • Custom script: local integer i = GetHandleId(u)
      • Custom script: local timer t = LoadTimerHandle( udg_Hash , i , StringHash("timer") )
      • Custom script: local timerdialog td
      • Custom script: if t == null then
      • Custom script: set t = CreateTimer()
      • Custom script: call SaveTimerHandle( udg_Hash , i , StringHash("timer") , t )
      • Custom script: call SaveUnitHandle( udg_Hash , GetHandleId(t) , StringHash("unit") , u )
      • Custom script: call TriggerRegisterTimerExpireEvent( gg_trg_Hero_Revive , t )
      • Custom script: endif
      • Custom script: set td = CreateTimerDialog(t)
      • Custom script: call SaveTimerDialogHandle( udg_Hash , GetHandleId(t) , StringHash("window") , td )
      • Custom script: call TimerDialogSetTitle(td, GetHeroProperName(u))
      • Custom script: call TimerDialogDisplay(td, true)
      • Custom script: call TimerStart( t , 5. , false , null )
      • Custom script: set u = null
      • Custom script: set t = null
      • Custom script: set td = null
  • Hero Revive
    • Events
    • Conditions
    • Actions
      • Custom script: set udg_i1 = GetHandleId(GetExpiredTimer())
      • Custom script: set udg_u1 = LoadUnitHandle( udg_Hash , udg_i1 , StringHash("unit") )
      • Custom script: call DestroyTimerDialog( LoadTimerDialogHandle( udg_Hash , udg_i1 , StringHash("window") ) )
      • Hero - Instantly revive u1 at (Center of (Playable map area)), Show revival graphics


You need the following variables:
u1 (unit)
i1 (integer)
Hash (hashtable) remeber to initialize it.

The revive location leaks.

You can set the title with this line:
  • Custom script: call TimerDialogSetTitle(td, GetHeroProperName(u))
Replace
JASS:
GetHeroProperName(u)
.

You can set the death duration here:
  • Custom script: call TimerStart( t , 5. , false , null )
Replace the 5, you can use an equation.

And make sure you have the correct trigger name here:
  • Custom script: call TriggerRegisterTimerExpireEvent( gg_trg_Hero_Revive , t )
Replace the Hero_Revive if you change the trigger's name.

http://www.hiveworkshop.com/forums/pastebin.php?id=fg1inz
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Here are some comments of your trigger:

Saving a handle of the unit is absolutely useless here. This line is not needed.
  • Hashtable - Save Handle Of(Triggering unit) as (Key die) of (Key (Triggering unit)) in Hash
If you don't need this value in some other trigger, then don't save it into hashtable.
  • Hashtable - Save 10.00 as (Key time) of (Key (Triggering unit)) in Hash
The index you're referring to is the unit's handle. It will certainly fail since arrays only support upto 8092 indexes, from 0 to 8191, handles produce a number larger than that. All used indexes must be initialized in the variable editor, otherwise they wont work. If the initial size is 1, then only [0] will be initialized. Initializing = call CreateTimer().
  • Countdown Timer - Start Timer[(Load (Key die) of (Key (Triggering unit)) from Hash)] as a One-shot timer that will expire in...
 
Status
Not open for further replies.
Top