[General] Hero Revival System

Level 5
Joined
Apr 13, 2017
Messages
157
So now, I'm currently working on hero revival system, and I just got the craziest idea: here is it

  • HeroRevival
    • Events
      • Unit - A unit Dies
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Owner of (Dying unit)) Equal to Player 1 (Red)
          • (Owner of (Dying unit)) Equal to Player 4 (Purple)
          • (Owner of (Dying unit)) Equal to Player 5 (Yellow)
          • (Owner of (Dying unit)) Equal to Player 6 (Orange)
          • (Owner of (Dying unit)) Equal to Player 7 (Green)
    • Actions
      • Countdown Timer - Start RevivalTime[(Player number of (Owner of (Dying unit)))] as a One-shot timer that will expire in 15.00 seconds
      • Countdown Timer - Create a timer window for RevivalTime[(Player number of (Owner of (Dying unit)))] with title Revive in:
      • Set RevivalTimeWindow = (Last created timer window)
      • Set PlayerNumberRevivalSystem[(Player number of (Owner of (Dying unit)))] = (Player number of (Owner of (Dying unit)))
      • Set HeroDied[PlayerNumberRevivalSystem[(Player number of (Owner of (Dying unit)))]] = (Dying unit)
      • Countdown Timer - Show RevivalTimeWindow for (Owner of (Dying unit))

The Array of the Countdown Timer is 10 so that when a unit Dies, it enters the Player number of the owner which is from 1 to 10. This is an automatic system HAHAHAHA

For the Revival:
  • HeroRevivalExpires
    • Events
      • Time - RevivalTime[1] expires
      • Time - RevivalTime[4] expires
      • Time - RevivalTime[5] expires
      • Time - RevivalTime[6] expires
      • Time - RevivalTime[7] expires
    • Conditions
    • Actions
      • Set RevivalPoint = (Center of SpawnHeroes <gen>)
      • Hero - Instantly revive HeroDied[1] at RevivalPoint, Show revival graphics
      • Hero - Instantly revive HeroDied[4] at RevivalPoint, Show revival graphics
      • Hero - Instantly revive HeroDied[5] at RevivalPoint, Show revival graphics
      • Hero - Instantly revive HeroDied[6] at RevivalPoint, Show revival graphics
      • Hero - Instantly revive HeroDied[7] at RevivalPoint, Show revival graphics
      • Custom script: call RemoveLocation(udg_RevivalPoint)

So, I need to ask if anybody can polish this? @IcemanBo , @Ralle, @millzy and other who are expert at GUI and JASS, please help me :)
 

Jampion

Code Reviewer
Level 13
Joined
Mar 25, 2016
Messages
1,298
I don't see the the purpose of the variable PlayerNumberRevivalSystem. It's an array, that has its index as value?
Try to reduce the number of function calls in your first trigger by storing (Player number of (Owner of (Dying unit))) in a variable.

The system is not MUI, as the second trigger will revive all currently dead heroes, when it runs.

You probably should store the timer windows in an array as well, so you can hide them when they expire.
 
Level 3
Joined
Jul 2, 2014
Messages
45
Or you could use a Hashtable

  • Timer Start
    • Events
      • Unit - A unit Dies
    • Conditions
      • YOUR CONDITONS HERE
    • Actions
      • Set tmp_Int = (Player number of (Owner of (Dying unit)))
      • Countdown Timer - Start RevivalTime[tmp_Int] as a One-shot timer that will expire in 15.00 seconds
      • Hashtable - Save tmp_Int as 0 of (Key (Last started timer)) in TimerHashtable
  • Timer Expire
    • Events
      • Time - RevivalTime[1] expires
      • ...
      • Time - RevivalTime[7] expires
    • Conditions
    • Actions
      • Set tmp_Int = (Load 0 of (Key (Expiring timer)) from TimerHashtable)
      • Hero - Instantly revive Heroes[tmp_Int] at (Center of (Playable map area)), Show revival graphics
 
Level 13
Joined
May 10, 2009
Messages
868
You don't need to use the "(Owner of (Dying unit))" function, because "Event Response - Triggering Player" works for that event too. I suggest you use it, because two functions won't be called just to get the same value.

Do what Jampion said regarding the Timer Window variable. Otherwise, when 2 heroes die within 15 seconds, the last one that died will overwrite that timer window variable, and it won't be possible to hide it when the first one revives. Also, it's not necessary to destroy it, because it's going to be used until the very end of the game (I suppose). Create a timer window for each player when your game starts, and hide it.

Another thing, since your trigger will be working as MPI, i.e. only one timer window/hero works for each player, you don't need to set the HeroDied variable every time one dies. You could define that variable when your game begins or a player selects a hero. Unless, a player owns more than 1 hero, but then a MUI revival system is required for that.

In your revive trigger, we can take advantage of loops, and compare which timer is associated with which player, so it's easier to hide a timer window and revive a hero.

  • CreateTimerWindow
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • For each (Integer myInteger) from 1 to 7, do (Actions)
        • Loop - Actions
          • Countdown Timer - Create a timer window for RevivalTime[myInteger] with title Revives in...
          • Set TimerWindow[myInteger] = (Last created timer window)
          • Countdown Timer - Hide (Last created timer window)
      • -------- As this is just a demonstration, I don't want to create a hero selection just to assign a new unit to the hero variables. --------
      • -------- So, I just pre-placed a few heroes and assigned them to the variables below --------
      • Set Hero[1] = Paladin 0003 <gen>
      • Set Hero[4] = Paladin 0006 <gen>
  • Hero Death
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • Or - Any (Conditions) are true
        • Conditions
          • (Triggering player) Equal to Player 1 (Red)
          • (Triggering player) Equal to Player 4 (Purple)
          • (Triggering player) Equal to Player 5 (Yellow)
          • (Triggering player) Equal to Player 6 (Orange)
          • (Triggering player) Equal to Player 7 (Green)
    • Actions
      • Countdown Timer - Start RevivalTime[(Player number of (Triggering player))] as a One-shot timer that will expire in 15.00 seconds
      • Countdown Timer - Show TimerWindow[(Player number of (Triggering player))] for (Triggering player)
  • Revive Hero
    • Events
      • Time - RevivalTime[1] expires
      • Time - RevivalTime[4] expires
      • Time - RevivalTime[5] expires
      • Time - RevivalTime[6] expires
      • Time - RevivalTime[7] expires
    • Conditions
    • Actions
      • Set ExpiredTimer = (Expiring timer)
      • For each (Integer myInteger) from 1 to 7, do (Actions)
        • Loop - Actions
          • -------- It seems that we do not have a Timer Comparison for GUI If-Statements dropdown menu --------
          • Custom script: if udg_RevivalTime[udg_myInteger] == udg_ExpiredTimer then
          • Set point = (Center of Spawn <gen>)
          • Hero - Instantly revive Hero[myInteger] at point, Show revival graphics
          • Countdown Timer - Hide TimerWindow[myInteger]
          • Custom script: call RemoveLocation(udg_point)
          • Custom script: endif
 

Attachments

  • ReviveHero.w3x
    18.2 KB · Views: 59
Top