Losing Lives on the Leaderboard

WrathMonkey

New Member
Reaction score
5
Okay, I've already come to this board with help with my TD leaderboard, but it didn't get resolved the first time. I was suggested to get a multiboard, but why would I need one when I could just make it so that each player's score is their kills, and Dark Green's score are the lives? I've seen it done on loads of TD's, so I know it's possible. I've even seen some set brown to Number of Creeps on the map, such as in Green TD, but I think I'm fine with just displaying the Lives. So, what's the problem here with my triggers?

"Leaderboard
Events
Time - Elapsed game time is 5.00 seconds
Conditions
Actions
Leaderboard - Create a leaderboard for (All players) titled Kills and Lives
Custom script: set bj_wantDestroyGroup=true
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
If (((Picked player) slot status) Equal to Is playing) then do (Leaderboard - Add (Picked player) to (Last created leaderboard) with label (Name of (Picked player)) and value 0) else do (Do nothing)
Leaderboard - Show (Last created leaderboard)
Leaderboard - Change the value for Player 11 (Dark Green) in (Last created leaderboard) to 25

Lose Life
Events
Unit - A unit enters Checkpoint <gen>
Conditions
((Triggering unit) is Undead) Equal to True
Actions
Player Group - Pick every player in Player Group - Player 11 (Dark Green) and do (Leaderboard - Change the value for Player 11 (Dark Green) in (Last created leaderboard) to 0)
Unit - Remove (Triggering unit) from the game
Set ALL_Kills[(Player number of Player 11 (Dark Green))] = (ALL_Kills[(Player number of Player 11 (Dark Green))] - 1)
Leaderboard - Change the value for Player 11 (Dark Green) in (Last created leaderboard) to ALL_Kills[(Player number of Player 11 (Dark Green))]"

Everytime a creep enters the Checkpoint, it goes straight from 25 to -1, and goes down from there. Why doesn't it go from 25 to 24, and so on each time a creep enters the Checkpoint?
 

demotry241

Don't Ever Categorize Yourself.
Reaction score
105
the reason it goes straight to -1 is because..


the variable

All_Kills[11] = 0


you only change the value of the lives.. in the leaderboard.. not the actual life variable itself

so unit enters region

set all_kills[(Player number of Player 11 (Dark Green)] to all_kills[(Player number of Player 11 (Dark Green)] - 1)


is equal to 0-1 = -1

i suggest in the first trigger.. at the last add.. set all_kills[11] = 25
 

Dmshu

New Member
Reaction score
9
Because the "12th" index of the All_Kills[11] array = 0 (assuming you havn't killed anything and had a trigger updating the variable correctly)

0 - 1 = -1

I say 12th because an array starts at 0, but the gui player number goes from 1-12 instead of 0-11.

To fix: instead of changing value change the variable you use for lives or kills or whatever.
 

demotry241

Don't Ever Categorize Yourself.
Reaction score
105
Because the "12th" index of the All_Kills[11] array = 0 (assuming you havn't killed anything and had a trigger updating the variable correctly)

0 - 1 = -1

I say 12th because an array starts at 0, but the gui player number goes from 1-12 instead of 0-11.

To fix: instead of changing value change the variable you use for lives or kills or whatever.
huh...
dude Unit_Kills[Player Number] there wont be any zero.
 

Dmshu

New Member
Reaction score
9
I didn't say it equaled 0 in gui.

But if you were to use the player number function in jass it will return 0 like it should.

Basically it is just a pet peeve that the gui version doesn't return what it really should be returning just so it doesn't confuse people who never have seen a programming language.
 

demotry241

Don't Ever Categorize Yourself.
Reaction score
105
Because the "12th" index of the All_Kills[11] array = 0 (assuming you havn't killed anything and had a trigger updating the variable correctly)

0 - 1 = -1

I say 12th because an array starts at 0, but the gui player number goes from 1-12 instead of 0-11.

To fix: instead of changing value change the variable you use for lives or kills or whatever.

so this makes no sense ...since its used for jass... and you didnt even specify its for jass.. you only state that gui player number goes from 1-12, rather than 0-11.. -.-, anyway.. refer to 2nd post for the answer in this problem.
 

Dmshu

New Member
Reaction score
9
If it came off confusing to you then sorry I didn't mean it to.

I just didn't want to tell him that the 11th index spot equaled zero because technically it isn't the 11th index. The first post wasn't a jass answer and it explained to him why the leaderboard was going from 25 to -1 and what he should do to fix that.

I refreshed before I replied to make sure it hadn't been answered already but by the time I typed it out you got in first and had I known that I wouldn't of even posted it.
 

WrathMonkey

New Member
Reaction score
5
Well, apparently what I've written has even confused me. I can't understand even the smallest bit of it.. I can usually wrap my mind around these things, but I don't know what's going on...

Can someone write a trigger for losing lives and it showing up on DG's score in the Leaderboard? Because I can't seem to set my variable "Lives" to just equal 25..
 

demotry241

Don't Ever Categorize Yourself.
Reaction score
105
don't worry don't worry XD

anyway.. the only problem why from 25 goes straight to -1 is because the value of the variable of unit_Kills[Player number 11=11] is set to 0,

so that is why
when a unit enters the region

set unit kills[11] = unit kills[11] -1 = -1 xD..

he only changed the value of the leaderboard not the actual value of the variable. xD




add this and its all good.


event:
map initialization

condition none

action
set unit_kills[11] = 25
 

Dmshu

New Member
Reaction score
9
demo's answer is correct, but I suggest you make a new integer array variable called Player_Lives so you can keep track of both kills and lives instead of having you total kills = total kills - lives lost.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top