• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] How to see what three integers are highest?

Status
Not open for further replies.
Level 11
Joined
Feb 14, 2009
Messages
884
The only thing I can think of is multiple If/Then statements, but that's really not effective. There is no multiple variable comparison in GUI (that I know of), but that may be possible in JASS.
 
Level 5
Joined
Feb 6, 2008
Messages
134
no randomly player with highest integer number is viewed.

like
Player1 integer=1
Player2 integer=6
Player3 integer=4
etc...
Player 2 have highest integer vaule.



Wait please i try do this
 
Level 10
Joined
Mar 31, 2009
Messages
732
Well since a binary search is clearly not possible here...

JASS:
//** Get highest player value
// Requires the values of the players to search through to be in a variable.
// Substitute some function call or whatever you use to get this value as needed.
// 
// @param: none
// @returns: the native player number of the player with the highest player value
//**
function getHighestPlayerValue takes nothing returns integer
  local integer highestPlayerNum = 0
  local integer highestValue = 0
  local integer index = 0

  loop
    exitwhen index == 12
    if (udg_theVariableWhereYouStoredTheValues[index] > highestValue) then
      set highestPlayerNum = index
      set highestValue = udg_variable[index]
    endif
    set index = index + 1
  endloop
  return highestPlayerNum
endfunction
 
Level 11
Joined
Feb 14, 2009
Messages
884
If the number of players is lower than 12, wouldn't

JASS:
exitwhen index == 12

or

JASS:
set index = index + 1

cause problems?

Maybe you could count every human player in the game and then use the exitwhen command.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
The only way to do this in GUI is
  • Actions
    • Set Integer[1] = HighestInteger
    • If all conditions are True, Then do Then Actions, Else do Else Actions
      • If - Conditions
        • Integer[1] Less then or equal to Integer[2]
      • Then - Actions
        • Set Integer[2] = HighestInteger
      • Else - Actions
    • If all conditions are True, Then do Then Actions, Else do Else Actions
      • If - Conditions
        • HighestInteger Less then or equal to Integer[3]
      • Then - Actions
        • Set Integer[3] = HighestInteger
      • Else - Actions
    • If all conditions are True, Then do Then Actions, Else do Else Actions
      • If - Conditions
        • HighestInteger Less then or equal to Integer[4]
      • Then - Actions
        • Set Integer[4] = HighestInteger
      • Else - Actions
    • If all conditions are True, Then do Then Actions, Else do Else Actions
      • If - Conditions
        • HighestInteger Less then or equal to Integer[5]
      • Then - Actions
        • Set Integer[5] = HighestInteger
      • Else - Actions
    • If all conditions are True, Then do Then Actions, Else do Else Actions
      • If - Conditions
        • HighestInteger Less then or equal to Integer[6]
      • Then - Actions
        • Set Integer[6] = HighestInteger
      • Else - Actions
    • If all conditions are True, Then do Then Actions, Else do Else Actions
      • If - Conditions
        • HighestInteger Less then or equal to Integer[7]
      • Then - Actions
        • Set Integer[7] = HighestInteger
      • Else - Actions
    • If all conditions are True, Then do Then Actions, Else do Else Actions
      • If - Conditions
        • HighestInteger Less then or equal to Integer[8]
      • Then - Actions
        • Set Integer[8] = HighestInteger
      • Else - Actions
 
Level 9
Joined
May 27, 2006
Messages
498
I heard that you can't have more than one local in GUI... I mean, only the first custom scripted local gets registered, the others dont.
So that a trigger like this wouldn't work;
  • Actions
    • Custom script: local integer a = 1
    • Custom script: local integer b = 2
    • Custom script: local unit u = GetTriggerUnit()
    • Custom script: call SetUnitState(u, UNIT_STATE_LIFE, (a + b))
Not sure tho.
 
Last edited:
Level 5
Joined
Nov 25, 2004
Messages
65
i think the hint is that it has something to do with the math - max function. this function compares two values that determines which value is higher.

this trigger is for example:

Event:
Player - Player 1 (Red) types a chat message containing compare as An exact match

Condition:none

Action:
Game - Display to (All players) the text: (String((Max((Life of Peasant 0056 <gen>), (Life of Footman 0057 <gen>)))))

this triggers simply display the hit point of footman because it has more hit point than that of the peasant
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
Here, if you're too stupid to actually read what the Jass code does, this is what it does

Code:
For [B]all_numbers[/B] do:
    if [B]current_number[/B] is bigger then [B]biggest_number[/B] then set [B]biggest_number[/B] to [B]current_number[/B]

Is that so freaking hard to understand?
 
Level 11
Joined
Feb 14, 2009
Messages
884
Here, if you're too stupid to actually read what the Jass code does, this is what it does

Code:
For [B]all_numbers[/B] do
    if [B]current_number[/B] is bigger then [B]biggest_number[/B] then set [B]biggest_number[/B] to [B]current_number[/B]

Is that so freaking hard to understand?

Erm, did you even think he might not know JASS? Nobody was born knowing everything. Would you understand an advanced C++ app if the only thing you knew was "Hello World!"? If you're not used to programming, it's not that easy, you know...
 
Level 9
Joined
May 30, 2008
Messages
430
The only way to do this in GUI is (onix's edit)
  • Actions
  • For each intiger from 1 to 12 do actions
    • Actions
      • If all conditions are True, Then do Then Actions, Else do Else Actions
        • If - Conditions
          • Integer[intigerA] Greater then or equal to HighestInteger
        • Then - Actions
          • Set HighestInteger = Integer[IntigerA]
        • Else - Actions
i write it by my hands i am 2 lazy to open the world editor but i am sure it will work 100% and is leak free so u don't need nothing more
 
Level 11
Joined
Feb 14, 2009
Messages
884
You know how to read texts, right? Reading (Jass) code is the same, its like talking to the CPU (very indirectly on a technical level though).
You can even recreate that function in GUI (much worse but its possible).

Yes, I know all that. What I say is that there are people that DO NOT know how to program. Which means that they actually can't read code. Is it that terrible? Is he a retard just because he can't read JASS?
 
Level 9
Joined
May 30, 2008
Messages
430
Yes, I know all that. What I say is that there are people that DO NOT know how to program. Which means that they actually can't read code. Is it that terrible? Is he a retard just because he can't read JASS?

Jass is good for separate multiboards, long spells, and easy to make spells MPI and MPU and ofc to evade leaks if u are careful. Almost all other systems can be done in GUI but u need alot of expirience in it
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Yes, I know all that. What I say is that there are people that DO NOT know how to program. Which means that they actually can't read code. Is it that terrible? Is he a retard just because he can't read JASS?

It's not that they can't, it is that they don't even bother trying. I could figure what a small code like that does before I knew anything about programming or Jass.

Jass is good for separate multiboards, long spells, and easy to make spells MPI and MPU and ofc to evade leaks if u are careful. Almost all other systems can be done in GUI but u need alot of expirience in it

I find it hard to see how this relates to the last previous posts, or to the thread at all.
 
Level 2
Joined
Jun 4, 2007
Messages
8
Wll, we have two "only" ways now, but i will throw in a third:

  • Leaderboard - Create a leaderboard for (All players) titled Hello i count.
  • Set board = (Last created leaderboard)
  • Leaderboard - Hide board
  • -------- IntegerVar[A] is the integer variable you have connected to each player --------
  • For each (Integer A) from 1 to 8, do (Actions)
    • Loop-Actions
      • Leaderboard - Change the value for (Player((Integer A))) in (Last created leaderboard) to Integer[(Integer A)]
  • Leaderboard - Sort board by Value in decending order
  • Set TempPlayer = (Player in position 1 of board)
  • Set High = Integer[(Player number of TempPlayer)]
  • Bestenliste - Destroy board
I don't know if the hide board is needed :slp:
Now, in TempPlayer you have the leading player and High is his value.
 
Last edited:
Level 2
Joined
Jun 4, 2007
Messages
8
Hell, whats the english version of this one:
  • Leaderboard - Sort board by Value in Absteigend order
I have no idea, lol.
 
Status
Not open for further replies.
Top