I am trying to have my attacks get weaker depending on my current HP's. But I don't want it to get down to virtually nothing.
The formula I am trying to use is:
a.atk * [[[[a.hp / a.mhp] * 100] + 10] / 110]
For some reason MV is doing 2457 damage with my a.atk = 27. It should be doing 27 damage with me at full life and 6.9 damage at 1 HP.
Harold has an ATK of 27 and Max HP's of 544.
When he is at full life he does 2457 damage. (should be doing 27)
When he is at 543 of 544 life he is doing 25 damage (should be doing 26.9)
When he is at 273 of 544 life he is doing 12 damage (should be doing 14.7)
When he is at 272 of 544 life he is doing 1230 damage (should be doing 14.7)
When he is at 271 of 544 life he is doing 12 damage again (should be doing14.6)
When he is at 1 life he is doing 0 damage (should be doing 6.9)
If I set it to a.atk * [a.hp / a.mhp] it works fine but if I am below 11 HP's I do 0 damage. I wanted to always be able to do some damage which is why I used the above formula.
Does anyone have a clue as to why MV is giving me these weird numbers? Even if I change the HP's and the ATK values it still gives the weird results.
Thanks for any advise,
Kuzac73
PS. I do not have any plugins running just to be sure it was not something messing with the numbers.
MV is doing some weird math.... need help.
● ARCHIVED · READ-ONLY
-
-
you're using the wrong brackets in your formula, you need to use () and not []
[] are array indicators in programming.
additionally, keep in mind that MV uses integer mathematics - any partial numbers are cut off.
11/10 -> 1 or 99/100 ->0 and so on, because integers like the variables only store full numbers.
EDIT:
You can reduce the cutoff error by multiplying first instead of dividing first,
a.hp*100/a.mhp -
You need to use regular brackets () instead of squared ones [].
-
Awesome! Thank you! I had no clue that the bracket types mattered. It has always been the [] style of brackets in all the screen shots and videos I have seen. It works perfectly now!