• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

ANY hero stats rounded to nearest instead of rounded down

Status
Not open for further replies.
Level 16
Joined
May 2, 2011
Messages
1,351
is this the function you're talking about or there is another one?
  • Paladin
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Paladin
    • Actions
      • Set RealNumber = 0.50
      • Hero - Modify Strength of (Triggering unit): Add IntegerAllowed
or you mean in jass? I can do what you say in custom script?
 
Level 6
Joined
May 20, 2014
Messages
228
You don't really have to set it as a variable, but yes, that's the one you want to add the roundings to heroes.
 
Level 28
Joined
Sep 26, 2009
Messages
2,556
"Conversion - Convert Integer to Real" (aka I2R) and "Conversion - Convert Real to Integer" (aka R2I) are the function you are looking for to set the number.

Hero - Modify Strength of (Triggering unit): Set to (R2I(I2R(Attribute_of_hero) + 0.5)
What it does is basically this:
You convert attribute of hero (an integer) into real number. Then you add 0.5 to that number.


Doing just this:
Hero - Modify Strength of (Triggering unit): add R2I(0.5)
won't work imo. Afaik it will first convert the number into integer and then it will add that number to the unit. However converting 0.5 into integer is 0, so you end up adding nothing at all.


Edit:
I'm not even sure if the first one will work, because hero's attribute ingame is already an integer, so when the input is an integer, you cannot expect anything behind decimal point.
You would probably need to calculate how much of an attribute he should have.

To clarify:
Let's say hero's current Strength is equal to 39. When you do this:
  • Set IntegerVariable = (Strength of Unit)
  • Set RealVariable = (Conversion - Convert Integer to Real(Strength of Unit))
Both will return same number - 39 and 39.00 respectively. That is because the attribute itself is an integer number.
So doing this: 39.00 + 0.50 will get you 39.50, but after converting it back to integer, you will get 39 again.

If you set your hero in Object Editor like this:
Starting Strength = 20,
Strength per Level = 1.80;
then the ingame calculation for it is: Convert_to_Integer(Starting_strength + (Level * strength_per_level)).
For example at level 6 the calculation would be: Convert_to_Integer(20 + (6 * 1.80)) = conv_to_int (20 + 10.80)) = conv_to_int(30.80) = 30.

Now you probably want to round it up, so 30.8 would get rounded up to 31. That, however, requires you to somewhere save the "Starting Strength" and "Strength Per Level" manually. Then make trigger which fires when hero gains a level and you yourself will calculate how much Strength he is supposed to have.
  • Map Ini
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set startStrength = 20.00
    • Set strengthPerLevel = 1.80
  • Calculation
  • Events
    • Hero gains level
  • Conditions
    • Triggering unit is your specified hero
  • Actions
    • Hero - Modify Strength of (triggering unit) set to (Convert Real to Integer((startStrength + (Convert Integer to Real(Level of unit) * strengthPerLevel) + 0.50)))
The above calculates the attribute. For example for the level 6 it would be: (20.00 + (6 * 1.8) + 0.50) => (20.00 + 10.80 + 0.50) => 31.30 => converted back to integer = 31.
 
Last edited:
Level 24
Joined
Aug 1, 2013
Messages
4,658
The best thing you can do is create your own stat system.
Save each unit's strength, agility and intelligence in a hashtable or real arrays and adjust those when you acquire an item, level up, learn/use a skill, etc, etc, etc.
Also when you update those values, set the STR, AGI, INT of the hero to the integer (with roundings) of those values.

When you want to use those, the best is to get them directly from the hashtable but you can use the integers of the hero too.

The best thing is to make a function that calls a custom event.
Then there are triggers that react to that event and change the value accordingly.
example:
Make a trigger and use the custom event.
Set value = value + (3 * level of (attribute bonus) for (unit))


That way you can handle custom stats perfectly.

This does require you to make a lot of triggers that use that custom event, you might want to have a custom event manager to make them glitchless too.

It is your call.
 
Status
Not open for further replies.
Top