Making Hero Respawn Times Proportionate to Level, HP and MP

Shanflower

New Member
Reaction score
2
Hi all,

I am making a Dota-based game, and I'm having problems setting the respawn times of heroes who die.

Ideally, the hero takes X seconds to respawn, where X is:
- Level of the hero when he died * 2
plus
- Max hitpoints of the hero when he died / 90
plus
- Max mana of the hero when he died / 80

I tried this:
Trigger:
  • Events
    • Time - Every 5.00 seconds of game time
    • Actions
    • Unit Group - Pick every unit in (Units owned by Player 3 (Teal) matching (((Picked unit) is A Hero) Equal to True)) and do (Actions)
      • Loop - Actions
        • Set respawntime[(Player number of (Owner of (Picked unit)))] = (((Hero level of (Picked unit)) x 2) + (((Integer((Max life of (Picked unit)))) / 90) + ((Integer((Max mana of (Picked unit)))) / 80)))
    • -------- Repeat above for every player (there are ten players) --------

and then, in another trigger:
Trigger:
  • Events
    • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
    • Actions
      • Countdown Timer - Start herorespawntimer[(Player number of (Owner of (Dying unit)))] as a One-shot timer that will expire in (Real(respawntime[(Player number of (Owner of (Dying unit)))])) seconds
      • Countdown Timer - Create a timer window for (Last started timer) with title ((Name of (Owner of (Dying unit))) + respawns in: )
      • -------- -- --------
      • Wait (Real(respawntime[(Player number of (Owner of (Dying unit)))])) seconds
    • Hero - Instantly revive (Dying unit) at (Center of (Playable map area)), Show revival graphics


As you can see it creates MASSIVE lag, and doesn't work. I'm okay with GUI coding but utterly clueless to custom script (JASS and whatnot)...

Any help with how I can make it work (laglessly) is appreciated :)
 

Psiblade94122

In need of sleep
Reaction score
138
detect when a unit dies
if the unit is a hero
then
Set respawn time to whatever you want (respawn time is a real/integer variable (not sure if timers use reals or integers)
Set Hero Death [Player number of owner of (dieing unit)) = Dieing unit
Countdown Timer - Start herorespawntimer{player number of (owner of (dieing unit))) as a one shot timer for (respawn time) seconds
Creat timer windwo blah blah
Set timer window [player number (owner of (dieing unit))) - last created timer window

Make a trigger for each player with the event
Timer window [1]
\\1 will be replaced by a number for each player, this applies for all uses of 1 past this comment
Set Integer[1] = 1
instantly revive hero death [Integer]
Destroy timer window [1]
 

millz-

New Member
Reaction score
25
You just had to calculate the respawning time when the hero dies. Move your setting of respawntime[] to the unit dies trigger, and change "Picked Unit" to "Dying Unit/Triggering Unit"
 

Shanflower

New Member
Reaction score
2
I'll try both, thanks!

(Erm, how does the rep thing work? Do I +rep for this? Sorry I'm rather new here)
 

Lifespiker

New Member
Reaction score
1
Yep, I think the biggest issue there was when you say (Dying Unit) at the end of the revival trigger. After a Wait time the trigger has lost what unit this even is! Must set it to a variable as far as I understand. This holds true for all KINDS of triggers. Setting things to variables will save you from pulling out your hair many times.

Lifespiker
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top