• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Highest integer

Status
Not open for further replies.
Level 7
Joined
Nov 19, 2007
Messages
253
Hey all,

I want to ask you is there any way to detect the highest number(integer) between 8 different numbers(integers)? I am tracking hero kills and at the end of map i wan't to make something like board with highest kills etc..
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Something like this perhaps?

  • Actions
    • For each (Integer LoopInt) from 1 to 8, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Kills[LoopInt] Greater than Kills[10]
          • Then - Actions
            • Set Kills[10] = Kills[LoopInt]
            • Set TempPlayer = (Player(LoopInt))
          • Else - Actions
Well, Kills[X] is obviously the amount of kills (integer variable with array)
I use LoopInt (just a normal variable integer without array) instead of Integer A/B because Integer A/B is less efficient.

Since Kills[10] can never be reached (and is 0 I assume), I use that as a temporary integer to check the highest kills.
If the amount of kills of a certain player is higher than the temporary Kills[10], it will overwrite that variable and set the player variable to the one who has the amount of kills.

After the loop is done, you know which player has the highest kills ( = TempPlayer) and how many kills he has ( = Kills[10]).


Edit:
This doesn't calculate draws, in order to do that, create an if/then/else that checks when Kills[LoopInt] = Kills[10], then set Kills[11] (another temporary integer) to Kills[11] + 1.
The TempPlayer should now be a player variable with array and do: TempPlayer[Kills[11]] = (Player(LoopInt)).

I hope you understand all this :p
 
Level 18
Joined
Mar 7, 2005
Messages
824
Hey all,

I want to ask you is there any way to detect the highest number(integer) between 8 different numbers(integers)? I am tracking hero kills and at the end of map i wan't to make something like board with highest kills etc..

After reading your question, there's no need of complicated triggers.

Am I right, that you just want to show the player with the most kills on first place within a board?
Then just use a simple scoreboard and let them sort it by amount..
that's all.. pretty simple, just hide it the whole game and show it at the end, as your rating results.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
^Yeah, that might work. But if he want's to print text to screen it won't help.

Here's a trigger that takes a tie into account, it might need some optimizing though:

  • Untitled Trigger 013
    • Events
    • Conditions
    • Actions
      • Set Temp_Integer_1 = 0
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Set Temp_Player_Array[(Player number of (Player((Integer A))))] = Neutral Passive
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Temp_Integer_Array[(Integer A)] Greater than 0
              • Temp_Integer_Array[(Integer A)] Greater than or equal to Temp_Integer_Array[9]
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Temp_Integer_Array[(Integer A)] Equal to Temp_Integer_Array[9]
                • Then - Actions
                  • Set Temp_Integer_1 = (Temp_Integer_1 + 1)
                • Else - Actions
                  • Set Temp_Integer_1 = 1
                  • For each (Integer B) from 1 to 8, do (Actions)
                    • Loop - Actions
                      • Set Temp_Player_Array[(Player number of (Player((Integer B))))] = Neutral Passive
                  • Set Temp_Player = (Player((Integer A)))
              • Set Temp_Player_Array[(Player number of (Player((Integer A))))] = (Player((Integer A)))
              • Set Temp_Integer_Array[9] = Temp_Integer_Array[(Integer A)]
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Temp_Integer_1 Equal to 1
        • Then - Actions
          • Game - Display to (All players) the text: ((Name of Temp_Player) + has won!)
        • Else - Actions
          • For each (Integer B) from 1 to 8, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Temp_Player_Array[(Player number of (Player((Integer B))))] Not equal to Neutral Passive
                • Then - Actions
                  • Game - Display to (All players) the text: ((Name of Temp_Player_Array[(Player number of (Player((Integer B))))]) + has won with a tie!)
                • Else - Actions
 
Level 18
Joined
Mar 7, 2005
Messages
824
Hey all,

I want to ask you is there any way to detect the highest number(integer) between 8 different numbers(integers)? I am tracking hero kills and at the end of map i wan't to make something like board with highest kills etc..

As I said, if you read it you'll see, that he wants to show it in a board at the end, but yeah, he might change that and want to display it as text. According to this the scoreboard solution won't work then, just use one of the suggested triggered solutions for it then ;)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
^Yeah, that might work. But if he want's to print text to screen it won't help.

Here's a trigger that takes a tie into account, it might need some optimizing though:

  • Untitled Trigger 013
    • Events
    • Conditions
    • Actions
      • Set Temp_Integer_1 = 0
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Set Temp_Player_Array[(Player number of (Player((Integer A))))] = Neutral Passive
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Temp_Integer_Array[(Integer A)] Greater than 0
              • Temp_Integer_Array[(Integer A)] Greater than or equal to Temp_Integer_Array[9]
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Temp_Integer_Array[(Integer A)] Equal to Temp_Integer_Array[9]
                • Then - Actions
                  • Set Temp_Integer_1 = (Temp_Integer_1 + 1)
                • Else - Actions
                  • Set Temp_Integer_1 = 1
                  • For each (Integer B) from 1 to 8, do (Actions)
                    • Loop - Actions
                      • Set Temp_Player_Array[(Player number of (Player((Integer B))))] = Neutral Passive
                  • Set Temp_Player = (Player((Integer A)))
              • Set Temp_Player_Array[(Player number of (Player((Integer A))))] = (Player((Integer A)))
              • Set Temp_Integer_Array[9] = Temp_Integer_Array[(Integer A)]
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Temp_Integer_1 Equal to 1
        • Then - Actions
          • Game - Display to (All players) the text: ((Name of Temp_Player) + has won!)
        • Else - Actions
          • For each (Integer B) from 1 to 8, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Temp_Player_Array[(Player number of (Player((Integer B))))] Not equal to Neutral Passive
                • Then - Actions
                  • Game - Display to (All players) the text: ((Name of Temp_Player_Array[(Player number of (Player((Integer B))))]) + has won with a tie!)
                • Else - Actions

Thanks ^^
Exactly what I said, but you put it in a trigger xD (saves me some time :p).

Tr!KzZ: I thought he meant that he shows it in a text :p
I guess I didn't read it thoroughly :/
 
Status
Not open for further replies.
Top