• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Issues with Timers

Status
Not open for further replies.
Level 30
Joined
Jan 31, 2010
Messages
3,551
Hey there. Recently, I have tried to make a new trigger in my map, the one that will create timers on top of the screen whenever a Hero dies, counting down to the zero and revival. However, the timers are quite messed up - when more than one appear - they both start ticking the other one's time, and after they finish, the timers stay on top of the screen, showing zero and massively ruining the visual feeling on the map. Can somebody help me with pointing out what am I doing wrong, how to optimize and fix it? Thanks in forward!
  • Revive Heroes
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Dying unit) is A Hero) Equal to True
          • (Unit-type of (Dying unit)) Not equal to Hero - (Dummy)
        • Then - Actions
          • Set kill_count[(Player number of (Owner of (Killing unit)))] = (kill_count[(Player number of (Owner of (Killing unit)))] + 1)
          • Set death_count[(Player number of (Owner of (Triggering unit)))] = (death_count[(Player number of (Owner of (Triggering unit)))] + 1)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is A Hero) Equal to True
          • (Unit-type of (Dying unit)) Not equal to Hero - (Dummy)
        • Then - Actions
          • Countdown Timer - Start ReviveTimer[(Player number of (Owner of (Dying unit)))] as a One-shot timer that will expire in ((Real((Level of (Triggering unit)))) x 4.00) seconds
          • Countdown Timer - Create a timer window for ReviveTimer[(Player number of (Owner of (Dying unit)))] with title (Name of (Owner of (Dying unit)))
          • Set ReviveTimerWindow[(Player number of (Owner of (Dying unit)))] = (Last created timer window)
          • Wait ((Real((Hero level of (Triggering unit)))) x 4.00) seconds
          • Countdown Timer - Destroy ReviveTimerWindow[(Player number of (Owner of (Dying unit)))]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Owner of (Dying unit)) is in ElvenPlayersActive) Equal to True
            • Then - Actions
              • Hero - Instantly revive (Triggering unit) at (Center of NE Base <gen>), Show revival graphics
              • Camera - Pan camera for (Owner of (Dying unit)) to (Center of NE Base <gen>) over 0.00 seconds
            • Else - Actions
              • Hero - Instantly revive (Triggering unit) at (Center of NA Base <gen>), Show revival graphics
              • Camera - Pan camera for (Owner of (Dying unit)) to (Center of NA Base <gen>) over 0.00 seconds
          • Selection - Select (Reviving Hero) for (Owner of (Dying unit))
        • Else - Actions
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
a piece of advice, you should merge your if/then/else to;
  • ((Dying unit) is A Hero) Equal to True
  • (Unit-type of (Dying unit)) Not equal to Hero - (Dummy)
    • all actions here in the THEN part, inclluding the countdown timer coz
    • you are repeating this line again...
- this is your problem >>> Wait ((Real((Hero level of (Triggering unit)))) x 4.00) seconds,
coz the timer you created is a global one...
- better for this is to store the timer into a hashtable, then destroy it with the ID of the dying hero...
- if you dont understand what I mean, then feel free to edit my timer system in my map >>> http://www.hiveworkshop.com/forums/map-development-202/smells-like-dota-no-187045/
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Here's a test map: Link

It should be easy to configure.


  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hash = (Last created hashtable)
      • Set HRTrig = Hero Revive <gen>
  • 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: set td = CreateTimerDialog(t)
      • 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(udg_HRTrig , t )
      • Custom script: call SaveTimerDialogHandle( udg_Hash , GetHandleId(t) , StringHash("window") , td )
      • Custom script: else
      • Custom script: set td = LoadTimerDialogHandle( udg_Hash , GetHandleId(t) , StringHash("window") )
      • Custom script: endif
      • Custom script: call TimerDialogSetTitle(td, GetHeroProperName(u))
      • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
      • Custom script: call TimerDialogDisplay(td, true)
      • Custom script: endif
      • Set r1 = ((Real((Hero level of (Triggering unit)))) x 2.00)
      • Custom script: call TimerStart( t , udg_r1, 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 TimerDialogDisplay( LoadTimerDialogHandle( udg_Hash , udg_i1 , StringHash("window") ), false )
      • Hero - Instantly revive u1 at (Center of (Playable map area)), Show revival graphics
Adjust the revive time by setting the r1 variable. You can add the kills and revive thingies.
 
Status
Not open for further replies.
Top