• 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.

Hello :)

Status
Not open for further replies.
Level 6
Joined
May 4, 2012
Messages
187
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?
 
Level 5
Joined
Feb 3, 2012
Messages
107
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
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
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())
    • Custom script: local integer kills = LoadInteger(udg_Hash, ID, 0) + 1
    • Custom script: call SaveInteger (udg_Hash, ID, 0, kills)
    • Hashtable - Clear all child of (Key(Handle(Triggering Unit))) in Hash
    • Custom script: if kills >= 100 then
    • Game - Win the game for Owner of Killing Unit
    • Game - Defeat for the other players
    • Custom script: endif
 
Last edited:

Br0

Br0

Level 4
Joined
May 4, 2012
Messages
102
[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.
 
Level 6
Joined
May 4, 2012
Messages
187
Sorry for the late reply.... Thanks for the replies anyway, all of them are helpful to ME, because I'm still a newbie, how could I repay you? D:

Hehehe thank you very much....... +rep
 
Status
Not open for further replies.
Top