How do I Simpler Math Formula

  • Is there a simpler way of finding X?

    X = random((Player.WeaponMinDmg - 10%),(Player.WeaponMaxDmg + 10%))

    And is this how I remove/add 10 percent of the weapon damage?

    Basically, I want to find minimum and maximum damage of the weapon, let's say 50 min and 80 max. Then I want the computer to minus 10% from the minimum and add 10% onto the maximum. Then I want the computer to randomly select between those two variables. So it would end up selecting a random number between 45 and 88, with these current values.

    I know how to do the Math part I am just not sure how it translates into Construct 2 logic and so on.

  • % is modulo. (remainder after division)

    to get percentage you divide by 100.

    so to get ten percent of player.weaponmindmg, you would do player.weaponmindmg/100*10

    so put that in place of where you have "10%"

  • But if I do that for lets say 100 damage.

    100 / 100 * 10 = 10.

    I want ten percent below 100, so 90. Not ten percent of current value.

  • well.. if you can find ten percent.. and you want ten percent below.. Subtract!

    Player.WeaponMinDmg - (Player.WeaponMinDmg/100*10)

    EDIT: you could also multiply by .9 for the minus and 1.1 for the plus. I guess that's a bit more direct.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So, I think I got this.

    X = (PlayerWeaponMinDMG * 0.9)

    Y = (PlayerWeaponMaxDMG * 1.1)

    Z = random((X),(Y)) Random will pick a value between the two values given right? Not just either or?

    TrueDamage = Z - Player.DEF

    Correct?

    Edit: Checked the manual. I want to use "random". The other option would be "choose", which I do not want.

  • Yes! I believe that's it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)