Calculating percentages

I'm trying to calculate the percentage of the player's HP, but Ace is reverting all my decimals into zeroes, so my formula always returns a 0. How do I get around this?
Are you trying to calculate damage percentage of Max HP?

If so, you could multiply by 100 before dividing.

So Variable 1 = Max HP

     Variable 2 = Current HP

Variable 2 * 100

then Variable 2/Variable 1

It will calculate the percentage value without dipping into small decimals as the multiplication is done first.

EDIT: I'm not sure if you meant variables or just formulae for battles...
When evaluating a skills damage formula fails it will simply return 0 instead of raising an error message (preventing the game from crashing but also making the detection of flaws in formulas more complicated).

When you used a damage formula you could try:

- check for spelling errors

- reenter the code manually

- post the code in this thread for checkup 🙂

However, your code might look something like this:
a.hp * 100 / a.mhp

Edit: Just as Lustermx I'm not 100% sure I got your problem correctly...
Are you trying to calculate damage percentage of Max HP?


If so, you could multiply by 100 before dividing.


So Variable 1 = Max HP


     Variable 2 = Current HP


Variable 2 * 100


then Variable 2/Variable 1


It will calculate the percentage value without dipping into small decimals as the multiplication is done first.


EDIT: I'm not sure if you meant variables or just formulae for battles...
Oh thanks, that worked 😀 I was first dividing the current HP with the max HP, and I'd get results like 0,80 which Ace just turns into a 0. Multiplying by a 100 first did the trick!


Closed.

Original thread: https://forums.rpgmakerweb.com/threads/calculating-percentages.17284/