# How do I Simpler Math Formula

Get help using Construct 2

### » Sat Sep 03, 2016 7:42 am

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.
B
58
S
15
G
13
Posts: 826
Reputation: 17,775

### » Sat Sep 03, 2016 8:03 am

% 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%"
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

### » Sat Sep 03, 2016 8:37 am

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.
B
58
S
15
G
13
Posts: 826
Reputation: 17,775

### » Sat Sep 03, 2016 8:48 am

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.
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

### » Sat Sep 03, 2016 10:28 am

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.
B
58
S
15
G
13
Posts: 826
Reputation: 17,775

### » Sat Sep 03, 2016 10:55 am

Yes! I believe that's it.
B
88
S
43
G
71
Posts: 601
Reputation: 43,669