Ask and ye shall receive:
float getPTH(float oa, float da) {
float base_pth = 90.0;
// avoid discontinuities
oa = oa <= 0 ? 1.0 : oa;
da = da <= 0 ? 1.0 : da;
if (oa == da) {
return base_pth;
}
else if (oa > da) {
return ((((oa/((da/3.5)+oa))*300)*0.3)+(((((oa*3.25)+10000)-(da*3.25))/100)*0.7))-50;
}
else {
float big_af = 91.0/4000; // big adjustment factor
float small_af = 140.0/9; // small adjustment factor
// Maclaurin Series approximations
// https://en.wikipedia.org/wiki/Taylor_series#List_of_Maclaurin_series_of_some_common_functions
// exp(x)
float x = (oa - da)*big_af/base_pth;
float exp_approx =
1
+ x
+ x*x/2
+ x*x*x/6
+ x*x*x*x/24
+ x*x*x*x*x/120
+ x*x*x*x*x*x/720;
// can add more terms for better accuracy
// log(x)
// since oa < da, |x| < 1
x = 1 - oa/da;
float log_approx =
- x
- x*x/2
- x*x*x/3
- x*x*x*x/4
- x*x*x*x*x/5
- x*x*x*x*x*x/6
- x*x*x*x*x*x*x/7;
// can add more terms for better accuracy
return base_pth*exp_approx + small_af*log_approx;
}
}
Sample Data (http://www.cpp.sh/9v4a7):
Assuming OA = 2820:
0, 174.123
100, 170.977
200, 167.818
300, 164.675
400, 161.55
500, 158.441
600, 155.347
700, 152.27
800, 149.207
900, 146.159
1000, 143.125
1100, 140.105
1200, 137.099
1300, 134.106
1400, 131.125
1500, 128.157
1600, 125.201
1700, 122.256
1800, 119.323
1900, 116.402
2000, 113.491
2100, 110.591
2200, 107.701
2300, 104.821
2400, 101.951
2500, 99.0908
2600, 96.24
2700, 93.3983
2800, 90.5655
2900, 87.7631
3000, 85.0343
3100, 82.3776
3200, 79.7908
3300, 77.2714
3400, 74.8172
3500, 72.4261
3600, 70.0962
3700, 67.8256
3800, 65.6123
3900, 63.4547
4000, 61.3512
4100, 59.3
4200, 57.2998
4300, 55.3491
4400, 53.4463
4500, 51.5903
4600, 49.7796
4700, 48.0131
4800, 46.2895
4900, 44.6077
5000, 42.9664
5100, 41.3648
5200, 39.8016
5300, 38.2759
5400, 36.7866
5500, 35.333
5600, 33.9139
5700, 32.5286
5800, 31.1762
5900, 29.8558
6000, 28.5667
6100, 27.308
Suggestion for the Game Guide:
When PTH < 90, the game will calculate a close approximation of:
pth = 90exp((91/360000)(oa - da)) + (140/9)*log(oa/da)