• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Hero revival system

Status
Not open for further replies.
Level 7
Joined
Aug 15, 2012
Messages
318
Here is my hero revival system used in my rpg I would like to make it so that it revives for more than 1 player and unit heres the trigger if anyone has any ideas on how to improve this I would like to make it as good as possible.


  • Hero Revival
    • Events
      • Unit - A unit Dies
    • Conditions
      • (((Dying unit) is A Hero) Equal to True) and (((Owner of (Dying unit)) is an enemy of Neutral Hostile) Equal to True)
    • Actions
      • Set Hero_loc = (Center of Respawn <gen>)
      • Game - Display to (All players) for 15.00 seconds the text: ((|cffff0000 + (Name of (Owner of (Dying unit)))) + (|r + ( has been killed by a + (|cffff0000 + ((Name of (Killing unit)) + |r)))))
      • Countdown Timer - Start OURTIMER as a One-shot timer that will expire in 15.00 seconds
      • Countdown Timer - Create a timer window for (Last started timer) with title Hero Revival
      • Set Timer_window = (Last created timer window)
      • Countdown Timer - Show (Last created timer window) for (Owner of (Dying unit))
      • Wait 15.00 seconds
      • Countdown Timer - Destroy Timer_window
      • Hero - Instantly revive (Dying unit) at Hero_loc, Show revival graphics
      • Camera - Pan camera for (Owner of (Dying unit)) to Hero_loc over 0.00 seconds
      • Custom script: call RemoveLocation(udg_Hero_loc)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
First of all: never use "Dying Unit". Use "Triggering Unit" instead (especially if you're gonna use waits).
Another problem:
  • Set Hero_loc = (Center of Respawn <gen>)
  • Wait 15.00 seconds
  • Custom script: call RemoveLocation(udg_Hero_loc)
You cannot put a wait between setting/removing a location! Because it still has the chance to leak and your effort will be in vain.

Chaosy said:
2. uses wait = bad
Doesn't have to be true.

This will work (I hope, quickly changed a few things here and there):
  • Revive Hero
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Custom script: local integer udg_PlayerNumber = GetPlayerId(GetTriggerPlayer())+1
      • Countdown Timer - Start DeathTimer[PlayerNumber] as a One-shot timer that will expire in 15.00 seconds
      • Countdown Timer - Create a timer window for DeathTimer[PlayerNumber] with title Revived in:
      • Set DeathTimerWindow[PlayerNumber] = (Last created timer window)
      • Countdown Timer - Hide (Last created timer window)
      • Countdown Timer - Show (Last created timer window) for (Triggering player)
      • Wait 14.70 seconds
      • Countdown Timer - Destroy DeathTimerWindow[PlayerNumber]
      • Set TempLoc1 = (Center of Respawn <gen>)
      • Hero - Instantly revive (Triggering unit) at TempLoc1, Show revival graphics
      • Camera - Pan camera for (Triggering player) to TempLoc1 over 0.00 seconds
      • Custom script: call RemoveLocation(udg_TempLoc1)
      • Custom script: set udg_TempLoc1 = null
Variables:
  • "PlayerNumber": integer variable.
  • "DeathTimer": timer variable, array.
  • "DeathTimerWindow": timer window variable, array.
  • "TempLoc1": location variable (because you only need 3 temporary location variables for the entire game, don't create more than that!)

Edit: this still doesn't have the flexibility that Chaosy wanted, but that can easily be fixed by using a hashtable as a look-up table to see the countdown/wait time for each unit type.
This may not be very clear to you, but if you don't need different revive times for different unit types, then there's no reason to explain this any further :D.
 
Try something like this:
  • SimpleHeroRevievSystem
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • ((Triggering unit) is an illusion) Equal to False
    • Actions
      • -------- Save Unit Into Variable --------
      • Set WriteInteger = (WriteInteger + 1)
      • Set HeroUnit[WriteInteger] = (Triggering unit)
      • Set RevievLocation[WriteInteger] = (Position of (Triggering unit))
      • -------- Wait --------
      • Wait 10.00 seconds
      • -------- Read Unit From Variable --------
      • Set ReadInteger = (ReadInteger + 1)
      • Hero - Instantly revive HeroUnit[ReadInteger] at RevievLocation[ReadInteger], Hide revival graphics
      • -------- Clean Leaks Below --------
      • Custom script: call RemoveLocation( udg_RevievLocation[udg_ReadInteger] )
      • -------- Try To Reset Counter --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WriteInteger Equal to ReadInteger
        • Then - Actions
          • Set WriteInteger = 0
          • Set ReadInteger = 0
        • Else - Actions
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
and my rpg is meant to only have 1 hero per player :p but I had 2 and killed them both at same time and they both revived fine
Oh okay.
Yeah, I know the hero will revive just fine, but since the timer/timer window uses an array based on the player number, the timers would bug. That's why it's only supposed to be used for 1 hero :D.
Anyways, since that seems to be the case, you could use it.
 
Level 7
Joined
Aug 15, 2012
Messages
318

shitty part is this counter acts with my creep revive would have to rework it ignore creeps unless you already have one with it I just didnt notice I dont understand custom scripts completly yet only some basics with them

Why are you ignoring my post >.>
I spend 2 min making that shit ^_^
It's the most simple way to make MUI stuff.

also didnt ignore it I have been busy trying to fix other problems that might not work with my other systems I apoligize if I offended you
 
shitty part is this counter acts with my creep revive.



also didnt ignore it I have been busy trying to fix other problems that might not work with my other systems I apoligize if I offended you

Nah it's ok, I get used to it, just wanted to see did you get the idea how I made that. That example of mine will work for up to 8.191 units (if they all die at same time, or in that interval before first revive). And that's number you will never reach ^_^

You can using same analogy, create timer windows and everything else you need. It's simple as that.
 
Level 7
Joined
Aug 15, 2012
Messages
318
Nah it's ok, I get used to it, just wanted to see did you get the idea how I made that. That example of mine will work for up to 8.191 units (if they all die at same time, or in that interval before first revive). And that's number you will never reach ^_^

You can using same analogy, create timer windows and everything else you need. It's simple as that.

I kinda understand how you did it I havnt worked alot with hashables just some minor stuff gotta learn more about them im slowly getting better at this :) but hey practice makes perfect and I actually like your method gunna give it a try see if it works with my other systems in a bit here btw nice job on your RPG going to have to try it when I am not working on mine.
 
Level 7
Joined
Aug 15, 2012
Messages
318
You can always upload map, it's much easier for us to point you in right direction :)
Not to mention terrain and other stuff we can check for you.

I can show you what I have atm for terrain n shit any input/ideas are appreaciated ill try to impliment this is my first major map im making so want it to be as good as it can be I didnt start with initial water level so I have to use the shitty cliffs for it :( unless somehow I can fix with newgen doubt it tho I reimported the whole map with it to try n fix earlier
 
Status
Not open for further replies.
Top