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

Problem with Countdown Timers

Status
Not open for further replies.
Level 31
Joined
Apr 17, 2009
Messages
3,571
Hey Guys,

I'm working on the respawn "system" of my Dead Space map.
The idea is simple: Hero gets killed, countdown timer 20 sec appears, 20 sec later hero gets revived at specific position.

My problem is that I don't know how to indicate the expiration of the timer.
I know there is this event. Timer expires.
But it's specific, not general.
I would have to create a trigger for every single player.
There must be another way.

This what I have till now:
It leaks because of Wait.

  • RespawnTimerCreation
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is a Hero) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • GameMode Equal to 1
        • 'THEN'-Actions
          • Set TempPosition[1] = HeroStartPosition[(Random integer number between 1 and 11)]
        • 'ELSE'-Actions
      • -------- //////////////////////////////////////////////////////////////// --------
      • Set Deaths[(Player number of (Owner of (Triggering unit)))] = (Deaths[(Player number of (Owner of (Triggering unit)))] + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • ((Killing unit) is a Hero) Equal to True
        • 'THEN'-Actions
          • Set Kills[(Player number of (Owner of (Killing unit)))] = (Kills[(Player number of (Owner of (Triggering unit)))] + 1)
          • Game - Display to (All players) the text: (PlayerColourName[(Player number of (Owner of (Dying unit)))] + ( has been killed by + PlayerColourName[(Player number of (Owner of (Killing unit)))]))
        • 'ELSE'-Actions
          • Game - Display to (All players) the text: (PlayerColourName[(Player number of (Owner of (Dying unit)))] + ( has been killed by + creeps!))
      • -------- //////////////////////////////////////////////////////////////// --------
      • Countdown-Timer - Start RespawnTimer[(Player number of (Owner of (Dying unit)))] as a Einmalig timer that will expire in 20.00 seconds
      • Countdown-Timer - Create a timer window for (Last started timer) with title Respawn in:
      • Set RespawnTimerWindow[(Player number of (Owner of (Dying unit)))] = (Last created timer window)
      • Countdown-Timer - Hide (Last created timer window)
      • Countdown-Timer - Show RespawnTimerWindow[(Player number of (Owner of (Dying unit)))] for (Owner of (Dying unit))
      • Wait 20.00 seconds
      • Countdown-Timer - Destroy RespawnTimerWindow[(Player number of (Owner of (Dying unit)))]
      • Hero - Instantly revive (Dying unit) at TempPosition[1], Hide revival graphics
      • Camera - Pan camera for (Owner of (Dying unit)) to TempPosition[1] over 1.00 seconds
      • Game - Display to (All players matching ((Owner of (Dying unit)) Gleich (Matching player))) the text: |c000080FFY|c000683...


Can somebody help me with this?
There must be a more comfortable and MUI way.

+rep for every help
chilla_gorilla
 
Nop if you do this:
  • Trigger
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • For each (Integer A) from 1 to 12, do (Actions)
      • Loop - Actions
        • Trigger - Add to Trigger3 <gen> the event (Time - RespawnTimer[(IntegerA)] expires)
  • Trigger2
  • Events
    • Unit - A unit dies
  • Conditions
    • ((Triggering unit) is a Hero) Equal to True
  • Actions
    • Set TempPosition[Player number of (Owner of (Triggering unit))] = (Position of (Triggering unit))
    • Countdown-Timer - Start RespawnTimer[(Player number of (Owner of (Triggering unit)))] as a One-shot timer that will expire in 20.00 seconds
    • Countdown-Timer - Create a timer window for (Last started timer) with title Respawn in:
    • Set RespawnTimerWindow[(Player number of (Owner of (Triggering unit)))] = (Last created timer window)
    • Countdown-Timer - Hide (Last created timer window)
    • Countdown-Timer - Show RespawnTimerWindow[(Player number of (Owner of (Triggering unit)))] for (Owner of (Triggering unit))
    • Set Hero[Player number of (Owner of (Triggering unit))] = (Triggering unit)
  • Trigger3
  • Events
  • Conditions
  • Actions
    • Custom script: local integer i = 0
    • For each (Integer B) from 1 to 12, do (Actions)
      • Loop - Actions
        • Custom script: if GetExpiredTimer() == udg_RespawnTimer[GetForLoopIndexB()] then
        • Custom script: set i = i + 1
        • Custom script: endif
    • Custom script: set udg_Integer = i
    • Countdown-Timer - Destroy RespawnTimerWindow[Integer]
    • Hero - Instantly revive Hero[Integer] at TempPosition[Integer], Hide revival graphics
    • Camera - Pan camera for (Player(Integer)) to TempPosition[Integer] over 1.00 seconds
    • Game - Display to (Player Group(Player(Integer)))) the text: |c000080FFY|c000683...
    • Custom script: call RemoveLocation (udg_TempPosition[udg_Integer])
Prefer "Triggering unit" over "Dying unit". It procs faster.
Create an "Integer" variable and call it "Integer" (well, at least this is what I did in my example). :]
 
Level 6
Joined
Dec 6, 2009
Messages
168
Hi^^ Do this:
  • Untitled Trigger 003
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
    • Actions
      • Hashtable - Create a hashtable
      • Set Hash = (Last created hashtable)
      • Set Dying_Hero[1] = (Triggering unit)
      • Set Dying_Point[1] = (Position of Dying_Hero[1])
      • Countdown Timer - Start Timer[0] as a One-shot timer that will expire in 6.00 seconds
      • Set Timer[0] = (Last started timer)
      • Hashtable - Save Handle OfTimer[0] as (Key Timer[0]) of (Key (Last started timer)) in Hash
      • Trigger - Turn on Untitled Trigger 004 <gen>
  • Untitled Trigger 004
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Remaining time for Timer[0]) Less than 0.01
        • Then - Actions
          • Hero - Instantly revive Dying_Hero[1] at Dying_Point[1], Hide revival graphics
          • Custom script: call RemoveLocation (udg_Dying_Point[1])
          • Hashtable - Clear Hash
          • Trigger - Turn off (This trigger)
        • Else - Actions
I don't know how to remove ''Dying_Hero[1]'' in Custom script, so if you do that it will be compleated, else this is it^^
 
Level 31
Joined
Apr 17, 2009
Messages
3,571
I found this in a map of Cloudwolf:

  • Death
    • Ereignisse
      • Einheit - A unit Stirbt
    • Bedingungen
      • ((Triggering unit) is Ein Held) Gleich True
    • Aktionen
      • Countdown-Timer - Start death_timer[(Player number of (Triggering player))] as a Einmalig timer that will expire in (3.00 x (Real((Hero level of (Triggering unit))))) seconds
      • Countdown-Timer - Create a timer window for (Last started timer) with title ((Name of (Triggering player)) + Revives)
      • Set death_window[(Player number of (Triggering player))] = (Last created timer window)
      • Wait until ((Remaining time for death_timer[(Player number of (Triggering player))]) Kleiner gleich 0.00), checking every 1.00 seconds
      • Countdown-Timer - Destroy death_window[(Player number of (Triggering player))]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Bedingungen
          • Or - Any (Conditions) are true
            • Bedingungen
              • (Owner of (Triggering unit)) Gleich Spieler 1 (Rot)
              • (Owner of (Triggering unit)) Gleich Spieler 2 (Blau)
              • (Owner of (Triggering unit)) Gleich Spieler 3 (Blaugrau)
              • (Owner of (Triggering unit)) Gleich Spieler 4 (Lila)
              • (Owner of (Triggering unit)) Gleich Spieler 5 (Gelb)
        • 'THEN'-Aktionen
          • Kamera - Pan camera for (Owner of (Triggering unit)) to (Center of Alliance Respawn <gen>) over 2.00 seconds
          • Held - Instantly revive (Triggering unit) at (Center of Alliance Respawn <gen>), Zeigen revival graphics
        • 'ELSE'-Aktionen
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Bedingungen
          • Or - Any (Conditions) are true
            • Bedingungen
              • (Owner of (Triggering unit)) Gleich Spieler 6 (Orange)
              • (Owner of (Triggering unit)) Gleich Spieler 7 (Grün)
              • (Owner of (Triggering unit)) Gleich Spieler 8 (Rosa)
              • (Owner of (Triggering unit)) Gleich Spieler 9 (Grau)
              • (Owner of (Triggering unit)) Gleich Spieler 10 (Hellblau)
        • 'THEN'-Aktionen
          • Kamera - Pan camera for (Owner of (Triggering unit)) to (Center of Horde Respawn <gen>) over 2.00 seconds
          • Held - Instantly revive (Triggering unit) at (Center of Horde Respawn <gen>), Zeigen revival graphics
        • 'ELSE'-Aktionen
Does this leak or is it MUI?
  • Wait until ((Remaining time for death_timer[(Player number of (Triggering player))]) Kleiner gleich 0.00), checking every 1.00 seconds
His locations are leaking, aren't they?
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Here you go. The heroes now respawn indefinitely.

I keyed the hero to the timer.

I wasn't sure what you wanted to do with the respawn location, so I just made the hero spawn at their starting location. If you want to change that, just save the point to a hashtable or to an array. The
  • Set TempPosition[(Player number of (Owner of (Triggering unit)))] = HeroStartPosition[(Player number of (Owner of (Triggering unit)))]
line leaks now.

The windows are also shown to P1 to show it works.
 

Attachments

  • Dead Space 1.02.w3x
    4 MB · Views: 85
Status
Not open for further replies.
Top