• 🏆 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!

Most of X

Status
Not open for further replies.
Level 5
Joined
Sep 21, 2012
Messages
68
is there a fast way to detect something like "unit that does the most damage on something..." or "unit that has the most HP in group ...",.... rather than do stuffs like if "a>b and a>c and a>d and a>e" then Display: "a has the most (damage, HP, ...)...." else if "b>a and b>c and b>d and b>e" then........

i don't know if i said it right for you guys to understand....
 
Level 12
Joined
Jun 15, 2016
Messages
472
Getting a unit with maximum something is not hard. Create 3 variables: a group of the units you want to check, an integer "maximum value" initially set to 0, and a "maximum unit". Then, run a loop on the group that goes like this: if a unit's X is greater than maximum value, set this unit to be maximum unit, and set this unit's X value to be maximum value. When this finishes you'll have the unit you want as maximum unit.

The bigger problem is what is X. If X is current health of the unit than there is a trigger for that, other values like damage need a workaround.
 
Status
Not open for further replies.
Top