I am currently trying to make defense a % damage reduction through my damage formula.
I tried this:
r = (a.atk * a.mat) * (b.def / 100) ; (a.atk * a.mat) - r
For some reason, this always returns as (a.atk * a.mat).
Any ideas? Thanks in advance!
The integer r is rounded down , if b.def is smaller than 100 then it will always result in zero.
Try the following (without the variable, but it's the same formula):
(1.0 - b.def/100) * (a.atk * a.mat)
Writing it 1.0 instead of 1 at the beginning should switch the interpreter to float values and allow it to calculate the rest correctly.
Thank you for your swift reply Ander; however, it is still returning just the (a.atk * a.mat).
Any other thoughts?
then type it in the following way:
(100 - b.def) * a.atk * a.mat / 100
If that still returns the same, then the problem is not with the formula but in another part, and you need to give us screenshots of the skill and examples of enemies/actors.
((1 - b.def/100.0) * (a.atk * a.mat)).to_i
Success! Thank you all for your help. Andar, your second formula works perfectly.
You can now close the threat, much appreciated!
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.