how do you calculated diminishing return?

Post » Sun Sep 21, 2014 7:05 pm

In my combat mod strength (derived from several factors) is used to calculate knock back force similar to this:

Strength * Weapon mass * stamina = Force

However I do not want a 200 strength actor to do 200% the force of a 100 strength actor. How do I express this so that a 200 strength actor only does a fraction more (say more or less about 50%) = 150 force not 200.

But then a 400 strength actor should only do say about 75% = 175 force not 200 and not 400.

I hope that makes sense....

I need some kind of "square of" something I think.

User avatar
Vickytoria Vasquez
 
Posts: 3456
Joined: Thu Aug 31, 2006 7:06 pm

Post » Sun Sep 21, 2014 9:11 am

You could maybe use a square root to calculate the modifier. For instance, if you do the square root of the Strength times ten, you get something that looks like this:

50  strength    ->    sqrt(50)  * 10  =   70.71100 strength    ->    sqrt(100) * 10  =  100.00200 strength    ->    sqrt(200) * 10  =  141.42300 strength    ->    sqrt(300) * 10  =  173.20400 strength    ->    sqrt(400) * 10  =  200.00

http://www.creationkit.com/Sqrt_-_Math

User avatar
sally coker
 
Posts: 3349
Joined: Wed Jul 26, 2006 7:51 pm

Post » Sun Sep 21, 2014 3:35 am

SKSE has a log function. I'm assuming it's base 10 as it's not specified.

For any value 100 or greater use the equation below (otherwise, use your previous function):

Knockback = 100*(2-0.5^(LOG10(Strength/100)/LOG10(2)))

Strength -> Knockback

100 = 100

150 = 133.3

200 = 150

250 = 160

300 = 166.7

350 = 171.4

400 = 175

You will approach a knockback limit of 200 as your strength increases to infinite.

Edit: Picture and papyrus form for clarity as that equation is kind of busy. Hopefully I did this right...

http://imgur.com/SeztlDD

float Function GetKnockbackPercent(float afStrength)    if afStrength > 100.0        return 100.0*(2.0 - Math.Pow(0.5, Math.Log(afStrength/100.0)/Math.Log(2.0)))    else        return afStrength    endIfendFunction
User avatar
Lily Evans
 
Posts: 3401
Joined: Thu Aug 31, 2006 11:10 am


Return to V - Skyrim