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

[Snippet]Get hero str/agi/int bouns per level

Level 26
Joined
Aug 18, 2009
Messages
4,097
Bonus Str/Agi/Int is unit type-specific, so the unit type should be the input. The maximum hero level can be modified in the gameplay constants, so just iterating to level 11 does not cut it. GetHeroStr/Agi/Int already returns integer, hence why you try to calculate the average. You do not need to acquire the individual steps, just take the lvl 1 state, take the level max state, get the difference and divide by levels amount. You can determine the max hero lvl by trying to lvl it to a very high value and then take the resulting GetHeroLevel. Dummy placement should not matter. If you were to pick such a costy implementation as you currently have, you may consider caching the results in a hashtable. Unit types are static, therefore limited anyway.
 
Bonus Str/Agi/Int is unit type-specific, so the unit type should be the input.

Oops, you're right ^^.

The maximum hero level can be modified in the gameplay constants

Yes.

so just iterating to level 11 does not cut it

What do you mean?

You do not need to acquire the individual steps, just take the lvl 1 state, take the level max state, get the difference and divide by levels amount.

I've tried it, sometimes it work not properly, use average is more accurate.

GetHeroStr/Agi/Int already returns integer

Fixed.

Dummy placement should not matte

Fixed.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
There is IsUnitIdType, you do not have to create a unit to check the classifications it inherits from the type. Also you currently do not remove the dummy on the return true path.

If the max hero lvl is higher than your iteration end, then you may only lose accuracy, if it is lower, you count zeroes but divide by more levels than available --> result shrinks.
 

Kazeon

Hosted Project: EC
Level 33
Joined
Oct 12, 2011
Messages
3,449
why even people would use this? since those bonuses are constant.. they can directly check it at OE..

EDIT:
and how if the max level is not 10?

JASS:
        loop
            exitwhen i > 10
            call SetHeroLevel(dummy,i,false)
            set agi = GetHeroAgi(dummy,false)
            set Hero_Attr[i] = agi - lastAgi
            set lastAgi = agi
            set i = i + 1
        endloop
        return (Hero_Attr[2]+Hero_Attr[3]+Hero_Attr[4]+Hero_Attr[5]+Hero_Attr[6]+Hero_Attr[7]+Hero_Attr[8]+Hero_Attr[9]+Hero_Attr[10]+Hero_Attr[11])/10
it's not efficient.. just do this
1. Set dummy level to 1 and get the attribute
2. Set dummy to max level and get the attribute
3. Calculate them: (attribute at max level - attribute at level 1) / (maxLevel - 1)
then user can also configure the max level

it's something like
JASS:
set att1 = GetHeroInt(dummy, false)
call SetHeroLevel(dummy, maxLevel, false)
set att2 = GetHeroInt(dummy, false)
return (att2 - att1) / (maxLevel - 1)

but still, the problem is that user could get attribute bonus easily at OE.. :p
 
Top