HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Adding a decimal value to a hero attribute?

12-26-2006, 03:26 AM#1
Baron Crinkle
I have an ability I would like to use to add a fraction of a point to a hero's stats with each usage, but seem to be unable to enter decimal values--only whole numbers. Is there a trick to doing this?
12-26-2006, 03:30 AM#2
wyrmlord
A hero's attribute can only be an integer. Here are some suggestions:

1. Have variables that will keep track of each decimal of a point is added, when that number reaches 1 or more, add a point to a hero attribute.

2. (Not really recommended) Make all the attributes of all the heroes 10/100 times larger, and then adjust the bonuses in the gameplay constants accordingly.

3. Just forget about adding decimal amounts.
12-26-2006, 03:49 AM#3
ixmike88
Quote:
Originally Posted by wyrmlord
A hero's attribute can only be an integer. Here are some suggestions:

1. Have variables that will keep track of each decimal of a point is added, when that number reaches 1 or more, add a point to a hero attribute.

2. (Not really recommended) Make all the attributes of all the heroes 10/100 times larger, and then adjust the bonuses in the gameplay constants accordingly.

3. Just forget about adding decimal amounts.

? A simple example can be DotA, it uses decimals for attributes.

Simply convert a real to an integer. (I think :))
12-26-2006, 03:53 AM#4
wyrmlord
Collapse JASS:
native          SetHeroAgi          takes unit whichHero, integer newAgi, boolean permanent returns nothing
native          SetHeroInt          takes unit whichHero, integer newInt, boolean permanent returns nothing
native          SetHeroStr          takes unit whichHero, integer newStr, boolean permanent returns nothing

These functions which set the values for a hero's attributes don't take real values. That's about all I can say since I've never found a point to having attributes as real numbers.
12-26-2006, 11:08 AM#5
rulerofiron99
This might be what you're looking for:

Trigger:
AddStr
Collapse Events:
Unit - Unit starts effect of ability
Collapse Conditions:
Ability being cast = MySpellForAddingStr
Collapse Actions:
Set strBonus[Player number of owner of triggering unit] = strBonus[player num of owner of trigger unit] + 0.2
Collapse If / then / else
Collapse If
strBonus[player number of owner of trigger unit] is greater than 1
Collapse Then
Set strBonus[player num of owner of trigger unit] = strBonus[player number of owner of trigger unit] - 1.0
Hero - add 1 strength to triggering unit
Collapse Else
Do nothing


Hope it helps!
12-26-2006, 11:34 AM#6
The)TideHunter(
Hero attributes are actually reals, but the infomation of reals are stored somewhere else, while you can retreive the infomation as a integer.

Say a heros strength is 3.9, it will show 3 and it will only get the effect of 3.
But if a hero gets 0.1 more strength, it will show 4 and get effect of 4.
This is proven by the way the object editor adds attribute points per level, it changes in decimal.

Although this is not editable through GUI or Jass in real wise.
So dont try it, its not possible.
Heros attributes will always be shown as integers, as thats the way the engine is designed.
12-26-2006, 04:06 PM#7
BertTheJasser
Maybe add some custom natives, but I have no clue how to do it. If you want to go so far, ask Pipedream, he' surely knows the answer to (almost) all your qeuestions ;D.

Another maybe dumb method (which surly will not work), would be to convert an real value via return bug into an integer and than add this integer points to the hero as bonus-state. As I said, bullshit, just thought beaming through my head.

Btw. Merry X-mas
12-26-2006, 04:11 PM#8
Vexorian
return bugging reals should not ever work.

A way, in theory would be making the attribute bonus skills add decimal values using shift, that might work and if it does you can add them.

But I think that keeping track of the bonus with a real variable is the most practicaly way so far