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!
Hi Everybody! I'm new here, and I want to ask some question. What trigger should I use, so that when a hero/unit reaches 100 kills ( or any number) the game is won?
use integers.
Event
A Unit Dies
Conditions
And Multiple Conditions
-Dying Unit equal to (whateva ur enemy is)
-Killing Unit equal to Player 1 (Red)
Actions
Set (redkills) = (redkills+1)
then make another trigger
Event
Every 1 second
Conditions
redkills equal to 100
Event
Game - Victory Player 1 (Red)
note that this trigger needs to be applied to all players if it is multiplayer. good luck
I made these with custom scripts so you can just "Copy/Paste" instead of having to figure out how to do these.
This will save each PLAYER kills. When any of the players reaches 100 kills, you do the thing to win the game.
Kills
Events
Unit - A Unit dies
Conditions
Actions
Set i = (Player Number of (Owner of (Killing Unit)))
Set Kills[i] = (Kills[i] + 1)
Custom script: if udg_Kills[i] >= 100 then
Game - Win the game
Custom script: endif
If you want to do it via UNIT kills (instead of PLAYER kills) you can use a Hashtable. I'll make an example saving each unit kills as 0 of KillingUnit ID in a Hashtable.
Init
Events
Map Initialization
Conditions
Actions
Custom script: set udg_Hash = InitHashtable()
Kills
Events
Unit - A Unit dies
Conditions
Actions
Custom script: local integer ID = GetHandleId(GetKillingUnit())
[trigger=KillTracker]Events
Unit - A unit Dies
Conditions
Actions
Set kills[(Player number of (Owner of (Killing unit)))] = (kills[(Player number of (Owner of (Killing unit)))] + 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
kills[(Player number of (Owner of (Killing unit)))] Greater than or equal to 100
Then - Actions
Game - Victory (Owner of (Killing unit)) (Show dialogs, Skip scores)
Player Group - Pick every player in (All enemies of (Owner of (Killing unit))) and do (Actions)
Loop - Actions
Game - Defeat (Picked player) with the message: You lost the game!
Else - Actions
[/trigger]
If you wanted a way to visually represent this you could use leaderboards as the simplest solution.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.