Hi everyone,
So here's the problem, I tried to make a skill that will use the current hp of the character who attack as a bonus percentage to his "normal attack" which goes like this:
(1+ (a.hp / a.mhp)) * 2 * a.atk -b.def
If a.hp = 50; a.mhp = 100; a.atk = 100; b.def = 4; the answer should be "296", but instead it give me "196"... The variance is at "0", the criticals are not allowed, no attribute, it's HP Damage type, so I really don't know where my formula is wrong :/
P.S: As a normal attack calculation I use "a.atk * 2 - b.def" instead of the normal "a.atk * 4-b.def * 2".
Skill Damage Formula Calculation problem
● ARCHIVED · READ-ONLY
-
-
It's because all of the values you're calculating are integers, and thus a.hp/a.mhp is always rounded down to 0. Try something like this instead:
(a.hp.to_f / a.mhp.to_f + 1) * 2 * a.atk - b.def
That should force the calculation as floats instead. -
Well it actually works and I've learned something new, thanks x2 ;)
-
you can also instead of using (a.hp.to_f / a.mhp.to_f + 1) just use 1 + a.hp_rate wich returns the current HP %.
-
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.