View Single Post
EightBitz
Senior Member
 
Join Date: May 2013
Posts: 1,458

Old December 8th, 2017, 03:13 AM
Quote:
Originally Posted by Bob G View Post
Another Round function challenge for you all: Ability that grants +1 to perception skill at 3rd level, and gains an additional +1 at 7th, 11th, 15th and 19th levels.

field[abValue].value += round(field[xTotalLev].value-2 / 4, 0, -1) + 1

~Apply bonus to Perception skill
hero.child[skPercep].field[Bonus].value += field[abValue].value

Somehow, the bonus at 3rd level delivers a result of +3. I am baffled as to how it arrived at that result. Any ideas?
I would also put the value you want to round in a variable first. Then round the variable. I've found that to eliminate a lot of issues.

Code:
var bonus as number
var roundbonus as number

bonus = field[xTotalLev].value-2
roundbonus = round(bonus/4,0,-1) + 1

field[abValue].value += roundbonus

~Apply bonus to Perception skill
hero.child[skPercep].field[Bonus].value += field[abValue].value
It's a few more lines, but it makes things more readable.
EightBitz is offline   #6 Reply With Quote