Problem with variables

● ARCHIVED · READ-ONLY
Started by DarlesLSF 5 posts View original ↗
  1. I'm creating a battle damage formula for my CBS. Below the maths:

    Hero atk = Hero's attack
    Random damage = Hero's attack
    Hero atk x 3
    Hero atk - Monster def
    Hero atk / 3
    Random damage / 100
    Random damage x 70-80
    Hero atk + Random Damage

    Monster life - Hero atk

    But in the end, only reduces the value until the variable "Hero atk / 3" and the rest in bold dont count on the math. But when i change the values to Random damage / 10 and Random damage x 7-8 or 1-10 works fine, only with higher values dont work.
    Anyone knows why that happen?
  2. The variables only store full numbers, any partials will be cut off.

    Examples:
    101/100 will result in 1
    99/100 will result in 0

    You need to make divisions last, not first, to reduce this effect.

    If that doesn't help, please give a screenshot of your event commands to allow us to check the details you forgot above.
  3. Idk if you will understand, because its in portuguese, but here is the screenshot:
    0tgwufQ.png
    variable 16 = random damage
    variable 12 = monster's def
    variable 14 = monster's life
  4. as I assumed and as I told you, your order of operations is wrong.
    you need to muliply the random damage before you divide it

    let's assume your ATK-Value is 50.
    So your random damage variable has the following operations:
    set to 50
    divide 50 by 100 , resulting in ZERO
    Multiply 0 by random 70..80 - which remains zero
    no damage added

    you need to multiply first
    set variable to 50 (or whatever the atk is in reality)
    multiply variable by 70..80, resulting in a high number
    divide by 100
  5. Andar said:
    as I assumed and as I told you, your order of operations is wrong.
    you need to muliply the random damage before you divide it

    let's assume your ATK-Value is 50.
    So your random damage variable has the following operations:
    set to 50
    divide 50 by 100 , resulting in ZERO
    Multiply 0 by random 70..80 - which remains zero
    no damage added

    you need to multiply first
    set variable to 50 (or whatever the atk is in reality)
    multiply variable by 70..80, resulting in a high number
    divide by 100

    Man, u save me haha
    Thx a lot, now it works :D