I want to make a trigger when players run out of lives it ends the game in defeat. Ive been trying different things but nothing is working. Anyone know how I could go about doing this.
I want to make a trigger when players run out of lives it ends the game in defeat. Ive been trying different things but nothing is working. Anyone know how I could go about doing this.
In the trigger where you reduce the player's life by 1, check after the reduction if his number of lives has reached 0. If so, end the game in defeat.
I personally use vespene as my life counter.
Lose Game
Events
Unit - Any Unit dies
Local Variables
Dying Hero = (Triggering unit) <Unit>
Conditions
(Owner of (Triggering unit)) <= 14
((Unit type of (Triggering unit)) is Hero) == true
(Player (Triggering player) Vespene) <= 0
Actions
UI - Display "You are all out of lives. Better l..." for (Player group((Owner of Dying Hero))) to Subtitle area
General - Wait 10.0 Game Time seconds
Game - End game in Defeat for player (Owner of Dying Hero) (Show dialogs, Show score screen)
That is the lose trigger I use. Let me know if it works for you.
Thanks a lot guys. Awesome! I got everything to work with both of your inputs. The only problem I ran into was the delay wait timer thing on the other guys post. It was causing a out of bounds error i removed it and it solved the issue.
The timer can be adjusted easily to work for your needs. On my map my res timer is 15 seconds so a 10 second delay is fine. However, I really should have pointed that out for you.
I am glad to hear its working. See below for my exact trigger. One thing that I think is better about this setup is it allows you to maintain exp on the current hero.
Hero Revive
Events
Unit - Any Unit dies
Local Variables
Dying Hero = (Triggering unit) <Unit>
Conditions
(Owner of (Triggering unit)) <= 14
((Unit type of (Triggering unit)) is Hero) == true
(Player (Triggering player) Vespene) >= 1
Actions
UI - Display "Your hero has died. You will be re..." for (Player group((Owner of Dying Hero))) to Subtitle area
Player - Modify player (Owner of Dying Hero) Vespene: Subtract 1
General - Wait 15.0 Real Time seconds
General - Custom Script: UnitRevive (lv_dyingHero);
Camera - Follow for player (Owner of Dying Hero) (Unit group(Dying Hero)) with the camera and Clear Current Target
Camera - Lock camera input for player (Owner of Dying Hero)
Unit - Set (Triggering unit) Life (Percent) to 100.0
Unit - Move Dying Hero instantly to (Center of Level 1 Spawn) (No Blend)
Just pay attention to the custom script section. There is a tutorial out there that shows this fairly well also.
I tend to always use my variables, however I occasionally forget and use triggering unit. The only time it would matter is if the trigger is really long with wait periods to where the 'triggering unit' may be lost. Thanks for pointing it out though because I would prefer to clean it up.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I want to make a trigger when players run out of lives it ends the game in defeat. Ive been trying different things but nothing is working. Anyone know how I could go about doing this.
In the trigger where you reduce the player's life by 1, check after the reduction if his number of lives has reached 0. If so, end the game in defeat.
I mean what exact triggers should i use to do it though like event / conditions / actions. Im fairly new to triggers still.
@x05matt25x
I personally use vespene as my life counter.
Lose Game
Events
Unit - Any Unit dies
Local Variables
Dying Hero = (Triggering unit) <Unit>
Conditions
(Owner of (Triggering unit)) <= 14
((Unit type of (Triggering unit)) is Hero) == true
(Player (Triggering player) Vespene) <= 0
Actions
UI - Display "You are all out of lives. Better l..." for (Player group((Owner of Dying Hero))) to Subtitle area
General - Wait 10.0 Game Time seconds
Game - End game in Defeat for player (Owner of Dying Hero) (Show dialogs, Show score screen)
That is the lose trigger I use. Let me know if it works for you.
**Edited just to clean up the trigger
Thank you for the info I will try it after I get out of class. What way do you use to respawn them if they have a life to spare.
Just to guesstimate and totally rip off what he put, you could use something like this i think
Respawn
Thanks a lot guys. Awesome! I got everything to work with both of your inputs. The only problem I ran into was the delay wait timer thing on the other guys post. It was causing a out of bounds error i removed it and it solved the issue.
@x05matt25x:
The timer can be adjusted easily to work for your needs. On my map my res timer is 15 seconds so a 10 second delay is fine. However, I really should have pointed that out for you.
I am glad to hear its working. See below for my exact trigger. One thing that I think is better about this setup is it allows you to maintain exp on the current hero.
Hero Revive
Events
Unit - Any Unit dies
Local Variables
Dying Hero = (Triggering unit) <Unit>
Conditions
(Owner of (Triggering unit)) <= 14
((Unit type of (Triggering unit)) is Hero) == true
(Player (Triggering player) Vespene) >= 1
Actions
UI - Display "Your hero has died. You will be re..." for (Player group((Owner of Dying Hero))) to Subtitle area
Player - Modify player (Owner of Dying Hero) Vespene: Subtract 1
General - Wait 15.0 Real Time seconds
General - Custom Script: UnitRevive (lv_dyingHero);
Camera - Follow for player (Owner of Dying Hero) (Unit group(Dying Hero)) with the camera and Clear Current Target
Camera - Lock camera input for player (Owner of Dying Hero)
Unit - Set (Triggering unit) Life (Percent) to 100.0
Unit - Move Dying Hero instantly to (Center of Level 1 Spawn) (No Blend)
Just pay attention to the custom script section. There is a tutorial out there that shows this fairly well also.
what are you guys doing? why do you set a dying hero variable and then continue to use triggering unit?
@b0ne123: Go
I tend to always use my variables, however I occasionally forget and use triggering unit. The only time it would matter is if the trigger is really long with wait periods to where the 'triggering unit' may be lost. Thanks for pointing it out though because I would prefer to clean it up.