Attribute Percentage [Solved]

Anonynn
26 Feb 2017, 07:29Hey all! One more question that I was curious about. Is it possible to increase an INT attribute by a percent? For example,
if (player.blahblah = 10) {
player.blargh = player.blargh + 10%
}
Or something like that?
Thank you very much!
Dcoder
26 Feb 2017, 10:03player.blargh = player.blargh * 1.1

Anonynn
26 Feb 2017, 19:10player.blargh = player.blargh * 1.1
Ohh, I thought * was multiplication.
So is 1.1 = 10%? Or is that 1.1%?
Thanks Dcoder!
The Pixie
26 Feb 2017, 21:520.1 is 10%, and 1.1 is 110%. If you want to add 10% to the amount, that is the same as 110% it, so multiplying by 1.1 is the same as adding 10%.
hegemonkhan
26 Feb 2017, 22:11a 'percent' itself is specifically out of 100:
(A/B) * 100 = N%
if you just want a percentage/decimal/fraction of that Value:
(A/B) * VALUE
if you want to increase a Value by a percentage/decimal/fraction of its Value:
VALUE + (VALUE * (A/B))
... argh... I hate math... and I have difficulty explaining it...
wait for someone who can explain math rations/fraction/percentages/etc, better... laughs
if you want this: to increase a Value by a percentage/decimal/fraction of its Value, here's some examples/explanations of it:
player.blargh = player.blargh + player.blargh * (11/10) // 11/10 = 110/100 = 1.1 = 1% // M% = (N/100) // using fractions/ratios (division), though I think it'll get truncated
for examples:
player.blargh = 100
player.blargh = 100 + (100 * (11/10)) = 100 + 110 = 210
player.blargh = 100
player.blargh = 100 + (100 * (1/10)) = 100 + 10 = 110
player.blargh = 50
player.blargh = 50 + (50 * (11/10)) = 50 + 55 = 105
player.blargh = 50
player.blargh = 50 + (50 * (1/10)) = 50 + 5 = 55
player.blargh = 75
player.blargh = 75 + (75 * (7/32)) = 75 + ~16 = ~ 91
I've not worked with double (decimals/fractions: floats/floating points/doubles) before, so I don't know if quest's parser can handle doubles with integers/ints or if you have to have everything as doubles for the equations-work, and then convert the double into an integer when done.
You'll have to play around a bit with how quest handles doubles. Or... you just use the fraction/ratio (division) method... but just be aware again, I think it'll truncate it.

Anonynn
26 Feb 2017, 22:15Thank you everyone! I appreciate it :D Math was never my strong suit! I appreciate the explanations.
Anonynn.