HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Advanced Leaderboard refuses to work properly.

06-16-2004, 06:05 PM#1
ChaosWolfs
I made a kill leaderboard, but it refuses to work like I want it to. Only my name works. Heres the big problem. Theres 5 players on a team with 1 computer. So you have Team 1 + Team 2. Any units summoned go to the computer on their team and attack the other team. So if I summoned an army of footmen, it should get added to the right owners unit group (1). So my army of footmen's kills should register to the leaderboard. Im always red and it works for me, but no one else.

Below is the Leaderboard Updating.
Code:
Events
    Unit - A unit Dies
Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Killing unit) is in Owners[1]) Equal to True
        Then - Actions
            Set Kills[1] = (Kills[1] + 1)
            Leaderboard - Change the value for Player 1 (Red) in (Last created leaderboard) to Kills[1]
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Killing unit) is in Owners[2]) Equal to True
        Then - Actions
            Set Kills[2] = (Kills[2] + 1)
            Leaderboard - Change the value for Player 2 (Blue) in (Last created leaderboard) to Kills[2]
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Killing unit) is in Owners[3]) Equal to True
        Then - Actions
            Set Kills[3] = (Kills[3] + 1)
            Leaderboard - Change the value for Player 3 (Teal) in (Last created leaderboard) to Kills[3]
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Killing unit) is in Owners[4]) Equal to True
        Then - Actions
            Set Kills[4] = (Kills[4] + 1)
            Leaderboard - Change the value for Player 4 (Purple) in (Last created leaderboard) to Kills[4]
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Killing unit) is in Owners[5]) Equal to True
        Then - Actions
            Set Kills[5] = (Kills[5] + 1)
            Leaderboard - Change the value for Player 5 (Yellow) in (Last created leaderboard) to Kills[5]
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Killing unit) is in Owners[6]) Equal to True
        Then - Actions
            Set Kills[6] = (Kills[6] + 1)
            Leaderboard - Change the value for Player 6 (Orange) in (Last created leaderboard) to Kills[6]
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Killing unit) is in Owners[7]) Equal to True
        Then - Actions
            Set Kills[7] = (Kills[7] + 1)
            Leaderboard - Change the value for Player 7 (Green) in (Last created leaderboard) to Kills[7]
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Killing unit) is in Owners[8]) Equal to True
        Then - Actions
            Set Kills[8] = (Kills[8] + 1)
            Leaderboard - Change the value for Player 8 (Pink) in (Last created leaderboard) to Kills[8]
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Killing unit) is in Owners[9]) Equal to True
        Then - Actions
            Set Kills[9] = (Kills[9] + 1)
            Leaderboard - Change the value for Player 9 (Gray) in (Last created leaderboard) to Kills[9]
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Killing unit) is in Owners[10]) Equal to True
        Then - Actions
            Set Kills[10] = (Kills[10] + 1)
            Leaderboard - Change the value for Player 10 (Light Blue) in (Last created leaderboard) to Kills[10]
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            (Color of (Owner of (Killing unit))) Equal to Dark Green
        Then - Actions
            Set Kills[11] = (Kills[11] + 1)
            Leaderboard - Change the value for Player 11 (Dark Green) in (Last created leaderboard) to Kills[11]
        Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            (Color of (Owner of (Killing unit))) Equal to Brown
        Then - Actions
            Set Kills[12] = (Kills[12] + 1)
            Leaderboard - Change the value for Player 12 (Brown) in (Last created leaderboard) to Kills[12]
        Else - Actions
            Do nothing

Below is the Trigger to set units to their owner's groups.

Code:
Owners of Units
    Events
        Unit - A unit enters Red 1 <gen>
        Unit - A unit enters Blue 2 <gen>
        Unit - A unit enters Teal 3 <gen>
        Unit - A unit enters Purple 4 <gen>
        Unit - A unit enters Yellow 5 <gen>
        Unit - A unit enters Orange 6 <gen>
        Unit - A unit enters Green 7 <gen>
        Unit - A unit enters Pink 8 <gen>
        Unit - A unit enters Gray 9 <gen>
        Unit - A unit enters Light Blue 10 <gen>
    Conditions
    Actions
        Unit Group - Add (Entering unit) to Owners[(Player number of (Owner of (Entering unit)))]
06-16-2004, 08:24 PM#2
Vexorian
Looks fine, the only thing that could be happening is something not adding the units to the Owners[2..] array, most likelly perhaps you aren't initializing the array, (go to the variables dialog and check if the starting max index of the arrays match the number they should have.
06-16-2004, 08:34 PM#3
Xinlitik
I dont see anything wrong, but this might help you make it easier to read:

For each Integer A from 1 to 12 , do
If killing unit is in owners[integer a] then
set kills[integer a] = kills[integer a] + 1
else do nothing
06-16-2004, 08:48 PM#4
ChaosWolfs
Quote:
Originally Posted by Lord Vexorian
Looks fine, the only thing that could be happening is something not adding the units to the Owners[2..] array, most likelly perhaps you aren't initializing the array, (go to the variables dialog and check if the starting max index of the arrays match the number they should have.

Thx a lot. I did a lot of testing with one other person and was wondering why they weren't adding to owners[2] etc. Since I finished the testing and read your post. It fixed everything. Now I got to combine my triggers again..
06-16-2004, 08:55 PM#5
-={tWiStÄr}=-
Quote:
Originally Posted by Xinlitik
I dont see anything wrong, but this might help you make it easier to read:

For each Integer A from 1 to 12 , do
If killing unit is in owners[integer a] then
set kills[integer a] = kills[integer a] + 1
else do nothing
lol... sorry chaos.. no offence but Xinlitik just turned ur half a page code into a 5 line code.. but the code looks fine. hmm i bet you its because you used "Last Created Leaderboard" try in the trigger where you create it, set it to a variable also.
and at the end for 11 and 12, the computer players you switched to color.. use owner instead because who knows.. for some reason color may not cut it because player 1 CAN have blue units.
edit: whoops i was writing when u posted.
06-16-2004, 08:58 PM#6
ChaosWolfs
Quote:
Originally Posted by -={tWiStÄr}=-
lol... sorry chaos.. no offence but Xinlitik just turned ur half a page code into a 5 line code.. but the code looks fine. hmm i bet you its because you used "Last Created Leaderboard" try in the trigger where you create it, set it to a variable also.
and at the end for 11 and 12, the computer players you switched to color.. use owner instead because who knows.. for some reason color may not cut it because player 1 CAN have blue units.
edit: whoops i was writing when u posted.


I tried that. Player 1 can have blue units, but doesn't register as a blue unit. It register as red's unit. The unit may look like it belongs to Blue, but the game thinks it looks like red. And I didn't changed Player 11-12 cause that was my old trigger.
06-17-2004, 01:00 AM#7
ChaosWolfs
Quote:
Originally Posted by Xinlitik
I dont see anything wrong, but this might help you make it easier to read:

For each Integer A from 1 to 12 , do
If killing unit is in owners[integer a] then
set kills[integer a] = kills[integer a] + 1
else do nothing

I tried it. Found a big bug with it. No one can have any more kills then red. Not even 1. Everyone either has less or the exact same amount as red.
06-17-2004, 02:25 AM#8
Xinlitik
I'll bet that that is because your Integer A is being overwritten somewhere else. Create an integer variable and instead of using for each integer A/B, use For each integer variable and choose your variable. In place of integer A you would put your variable IE owners[yourvariable]. Dont use that integer variable for anything else.

Edit: What I mean is that because Integer A is a global variable, any trigger that uses Integer A will replace whatever value it had before.

So, if you had for each integer A from 1 to 3 that means that if you were running your kills trigger, integer A would go from 5 or whatever to 1 then 2 then 3 because the other trigger also changed the max value of Integer A. So... player 1 would have more kills because the chances of getting another trigger to overwrite on the first run of it are small; however, as you get higher and it's run for longer, the chances rise.
06-18-2004, 01:18 PM#9
Vexorian
I don't think so since there are no waits in the for each integer a thing
06-18-2004, 07:32 PM#10
Xinlitik
In my map, I had tons of integer A loops working without waits and they started overrunning eachother. Then again, they ran A LOT...one instance was every time a unit died.