Problem With Damage Formulas

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

Thread Status:
Not open for further replies.
  1. Demi_Fiend

    Demi_Fiend Chaos Hero Veteran

    Messages:
    67
    Likes Received:
    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?
     
    #1
  2. Lord Vectra

    Lord Vectra Master Eventer Veteran

    Messages:
    187
    Likes Received:
    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.
     
    #2
  3. Andar

    Andar Veteran Veteran

    Messages:
    28,692
    Likes Received:
    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.
     
    #3
  4. Demi_Fiend

    Demi_Fiend Chaos Hero Veteran

    Messages:
    67
    Likes Received:
    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
     
    #4
  5. Lord Vectra

    Lord Vectra Master Eventer Veteran

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

    bgillisp Global Moderators Global Mod

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

    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.

     
    #6
Thread Status:
Not open for further replies.

Share This Page