Calculating percentages

Status
Not open for further replies.

Celianna

Tileset artist
Veteran
Joined
Mar 1, 2012
Messages
10,557
Reaction score
5,592
First Language
Dutch
Primarily Uses
RMMV
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?
 

Lustermx

Veteran
Veteran
Joined
Mar 17, 2012
Messages
252
Reaction score
147
Primarily Uses
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...
 
Last edited by a moderator:

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
564
Reaction score
275
First Language
German
Primarily Uses
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...
 
Last edited by a moderator:

Celianna

Tileset artist
Veteran
Joined
Mar 1, 2012
Messages
10,557
Reaction score
5,592
First Language
Dutch
Primarily Uses
RMMV
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 :D 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.
 
Last edited by a moderator:
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,864
Messages
1,017,056
Members
137,573
Latest member
nikisknight
Top