Problem With Damage Formulas

● ARCHIVED · READ-ONLY
Started by Demi_Fiend 6 posts View original ↗
  1. 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. 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. 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. Oh that makes a lot of sense. I just got it to work now.
    Thanks! @King Vectra
  5. No problem. Anything I can do to help ^_^
  6. 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.