# Problem With Damage Formulas

Discussion in 'RPG Maker VX Ace' started by Demi_Fiend, Jul 6, 2017.

Not open for further replies.
1. ### Demi_FiendChaos Hero

Messages:
67
16
Location:
Earth
First Language:
English
Primarily Uses:
RMVXA
I'm having an issue with one of my damage formulas.
The formula is: a.atk * (5/32) * (7/20) * 100. In this scenario, the user's attack stat is 5.
Problem is, the damage output always comes out to 0 for some odd reason. I've even calculated the formula, and it comes out to around 27.34. I've done it in a blank project and the same thing happened. Am I doing something wrong, or is it an issue with the maker?

2. ### Lord VectraMaster Eventer

Messages:
187
324
Location:
The Abyss
First Language:
English
Primarily Uses:
RMVXA
It is because you put the division in parenthesis. The program rounds all numbers, so the program just rounded all them divisions to equal 0. It'll work without the parenthesis. Why?

Let's say you have 1/2 * 2. That equals 1, right? Now reverse them to 2 * 1/2. You get the same answer. As long as the numbers you are dividing don't change, it'll work either way. I made this excessively long damage formula and I had (2/3) and it rounded it to 0 which made my damage formula 0. Took me FOREVER to realize that lol.

3. ### AndarVeteran

Messages:
28,692
6,596
Location:
Germany
First Language:
German
Primarily Uses:
RMMV
The damage formula uses integers to store values, which means that any fragment of 1 gets reduced to zero. You need to reorder the formula to make sure the divisions come last and it will work

Remove the parenthesis and start with the 100* instead of multiplying it last and the result should be mostly correct.

4. ### Demi_FiendChaos Hero

Messages:
67
16
Location:
Earth
First Language:
English
Primarily Uses:
RMVXA
Oh that makes a lot of sense. I just got it to work now.
Thanks! @King Vectra

5. ### Lord VectraMaster Eventer

Messages:
187
324
Location:
The Abyss
First Language:
English
Primarily Uses:
RMVXA
No problem. Anything I can do to help ^_^

6. ### bgillispGlobal Moderators

Messages:
12,409
12,642
Location:
USA
First Language:
English
Primarily Uses:
RMVXA