• 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] Counting the number of kills?

Status
Not open for further replies.
Level 3
Joined
Feb 6, 2009
Messages
24
Sooooo... i made this trigger
  • reddy
    • Events
      • Unit - A unit owned by Neutral Hostile Dies
    • Conditions
    • Actions
      • If ((Owner of (Killing unit)) Equal to Player 1 (Red)) then do (Leaderboard - Change the value for Player 1 (Red) in (Last created leaderboard) to (KillCount + 1)) else do (Do nothing)
      • If ((Owner of (Killing unit)) Equal to Player 2 (Blue)) then do (Leaderboard - Change the value for Player 2 (Blue) in (Last created leaderboard) to (KillCount_Copy + 1)) else do (Do nothing)
      • If ((Owner of (Killing unit)) Equal to Player 3 (Teal)) then do (Leaderboard - Change the value for Player 3 (Teal) in (Last created leaderboard) to (KillCount_Copy_2 + 1)) else do (Do nothing)
      • If ((Owner of (Killing unit)) Equal to Player 4 (Purple)) then do (Leaderboard - Change the value for Player 4 (Purple) in (Last created leaderboard) to (KillCount_Copy_3 + 1)) else do (Do nothing)
      • If ((Owner of (Killing unit)) Equal to Player 5 (Yellow)) then do (Leaderboard - Change the value for Player 5 (Yellow) in (Last created leaderboard) to (KillCount_Copy_4 + 1)) else do (Do nothing)
      • If ((Owner of (Killing unit)) Equal to Player 6 (Orange)) then do (Leaderboard - Change the value for Player 6 (Orange) in (Last created leaderboard) to (KillCount_Copy_5 + 1)) else do (Do nothing)
and to me, it's suposed to work always, like.. keep counting. But that's the problem, it only counts to 1. it doesn't goes beyond that. Could someone tell me what's wrong?
 
Level 12
Joined
Mar 16, 2006
Messages
992
Last created leaderboard.

That trigger has so many more things wrong with it than just that, however.
 
Level 3
Joined
Feb 6, 2009
Messages
24
Could you tell me what's wrong besides that then? i'm new into map modding so a few(many) things can go wrong some times :bored:
btw, there's only one leaderboard and it's created before the killcount trigger works.
 
Level 2
Joined
Feb 22, 2009
Messages
24
the problem you have: you say: show me that "variable+1"

and thats it...


you are not saying: make that variable +1 and then show me the result:
Solution:

  • If ((Owner of (Killing unit)) Equal to Player 1 (Red)) then do
    • Actions
      • Set KillCount = KillCount+1
      • (Leaderboard - Change the value for Player 1 (Red) in (Last created leaderboard) to (KillCount)) else do (Do nothing)
    • If ((Owner of (Killing unit)) Equal to Player 2 (Blue)) then do
      • Set KillCount_Copy = KillCount_Copy +1
      • (Leaderboard - Change the value for Player 2 (Blue) in (Last created leaderboard) to KillCount_Copy else do (Do nothing)
Advanced Solution: Make a Variable Type: Integer , Array with 12 width..if you dont understand what i mean read an array tutorial, or just use the solution above
  • Better Solution
    • Actions
      • Unit - A unit owned by Neutral Hostile dies
    • Conditions
    • Actions
      • Playergroup - Pick every player in (All allies of Player1 (Red)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Conditions
              • (Owner of (Killing unit)) equals (Picked player)
            • Then Actions
              • Set KillingCount[(Player number of (Picked player))] = (KillingCount[(Player number of (Picked player))] + 1)
              • Leaderboard - Change the value for (Picked player) in (Last created leaderboard) to (String(KillingCount[(Player number of (Picked player))]))
            • Else Actions
              • Do Nothing
 
Level 3
Joined
Feb 6, 2009
Messages
24
the problem you have: you say: show me that "variable+1"

and thats it...


you are not saying: make that variable +1 and then show me the result:
Solution:

  • If ((Owner of (Killing unit)) Equal to Player 1 (Red)) then do
    • Actions
      • Set KillCount = KillCount+1
      • (Leaderboard - Change the value for Player 1 (Red) in (Last created leaderboard) to (KillCount)) else do (Do nothing)
    • If ((Owner of (Killing unit)) Equal to Player 2 (Blue)) then do
      • Set KillCount_Copy = KillCount_Copy +1
      • (Leaderboard - Change the value for Player 2 (Blue) in (Last created leaderboard) to KillCount_Copy else do (Do nothing)

hmm... thanks man, i'm gonna do that now and test it :smile:

edit: yep, it worked fine, thanks man, and thx to other people that posted here.
 
Level 2
Joined
Feb 22, 2009
Messages
24
You can give reputation for good answers...just klick the button under the User Data ;)

PS: I wrote you an advanced solution...there you have to change things only once ... you maybe have to look, which players you take .. .maybe "players controlled by a user" or something...
 
Level 3
Joined
Feb 6, 2009
Messages
24
you mean to see if the player is a computer player or a person? i don't have any problems with that on the map i'm making, because there really is no problem in having a computer player.

So, i've got another problem here, diferent from the other one(wich is solved).
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Unit-type of (Killing unit)) Equal to Soul Archer
    • Then - Actions
      • Special Effect - Create a special effect attached to the origin of (Killing unit) using Abilities\Spells\Undead\DeathPact\DeathPactCaster.mdl
      • Unit - Set life of (Killing unit) to ((Life of (Killing unit)) + 20.00)
      • Unit - Set life of (Killing unit) to ((Mana of (Killing unit)) + 20.00)
    • Else - Actions
      • Do nothing
once again, i guess it's suposed to work, but once the unit kills, it's life regens by 40, the mana doesn't regens at all, or the life regens 200, and mana 10, or they loose life instead of gaining it. what's wrong here? :bored:

Before i did that trigger, i used an trigger that made an item to the hero, wich would regen the 20 health and mana automaticaly, but the problem with that is, what if the hero is with the inventory full? then the item would be dropped, and i don't want that to happen, that's why i changed... but's messy and buggy :sad:
 
Level 15
Joined
Dec 18, 2007
Messages
1,098
You could just use a variable array instead of multiple copies of the variable. Just check the array checkbox and change the index to (Player Number of Owner of Killing Unit - 1). That way, you do not need so many actions and conditions.
I think there is a tutorial in the tutorial's section about arrays, take a look, its really helpful.
 
Level 2
Joined
Feb 22, 2009
Messages
24
  • Unit - Set life of (Killing unit) to ((Life of (Killing unit)) + 20.00)
  • Unit - Set life of (Killing unit) to ((Mana of (Killing unit)) + 20.00)
Take a closer look to that lines: If i were a Computer i would set the Life of the unit to (actual Mana + 20) ... hope this little hint help you ;)

To the other Question: When using Pick All Players in Group you have to have a close look to the Players you wanna do something with...dont take All Players, as in the progress you may change some to take different tasks and then you have to remember that you dont want that Player to do the "Picked - Actions"...so define those carefully!
 
Last edited:
Level 3
Joined
Feb 6, 2009
Messages
24
Hmmm, thanks guys. i'm gonna check later the array tutorial(if there's one) . As for Iluva's reply, errr, i'm sorry... i don't get it. :bored:
 
Status
Not open for further replies.
Top