SirPlease / L4D2-Competitive-Rework

Just refreshing and optimizing the core files a bit, eh?
GNU General Public License v3.0
237 stars 128 forks source link

TickrateFixes gravity issues #376

Open Derpduck opened 2 years ago

Derpduck commented 2 years ago

Not sure how we arrived at this value for sv_gravity: https://github.com/SirPlease/L4D2-Competitive-Rework/blob/master/addons/sourcemod/scripting/TickrateFixes.sp#L132 But it doesn't seem to accurately mimic 30 tick / 800 sv_gravity behaviour, I think this value could be improved.

Jump height is not significantly changed by tickrate, however the time to land from a jump is different. Fall damage is affected, as it seems the acceleration while falling is different.

I did some testing with different tickrates and sv_gravity settings, some results below:

Jump Heights:

T: 30 / G: 800 [APEX] J-HEIGHT: 56.822204 / TIME: 0.300003
T: 30 / G: 800 [LAND] Z-VEL: -230.200027 / TIME: 0.599990

T: 100 / G: 800 [APEX] J-HEIGHT: 56.975982 / TIME: 0.310028
T: 100 / G: 800 [LAND] Z-VEL: -238.200073 / TIME: 0.610015

T: 100 / G: 750 [APEX] J-HEIGHT: 59.581939 / TIME: 0.330001
T: 100 / G: 750 [LAND] Z-VEL: -237.700073 / TIME: 0.650009

T: 100 / G: 765 [APEX] J-HEIGHT: 58.779815 / TIME: 0.320007
T: 100 / G: 765 [LAND] Z-VEL: -239.799804 / TIME: 0.640014

Fall Damage:

Very small fall:
T: 30 / G: 800 [FALL] DMG: 0.694448 / Z-VEL: -573.333374
T: 100 / G: 800 [FALL] DMG: 5.062499 / Z-VEL: -596.000000
T: 100 / G: 750 [FALL] DMG: 0.738525 / Z-VEL: -573.750000
T: 100 / G: 765 [FALL] DMG: 1.206683 / Z-VEL: -577.575866

Small fall:
T: 30 / G: 800 [FALL] DMG: 6.250000 / Z-VEL: -600.000000
T: 100 / G: 800 [FALL] DMG: 5.062499 / Z-VEL: -596.000000
T: 100 / G: 750 [FALL] DMG: 1.763916 / Z-VEL: -581.250000
T: 100 / G: 765 [FALL] DMG: 2.485725 / Z-VEL: -585.225891

Medium fall:
T: 30 / G: 800 [FALL] DMG: 34.027717 / Z-VEL: -653.333251
T: 100 / G: 800 [FALL] DMG: 45.562503 / Z-VEL: -668.000000
T: 100 / G: 750 [FALL] DMG: 30.767822 / Z-VEL: -648.750000
T: 100 / G: 765 [FALL] DMG: 34.571540 / Z-VEL: -654.076110

High fall:
T: 30 / G: 800 [FALL] DMG: 88.125091 / Z-VEL: -710.199951
T: 100 / G: 800 [FALL] DMG: 88.125244 / Z-VEL: -710.200073
T: 100 / G: 750 [FALL] DMG: 63.700424 / Z-VEL: -687.700073
T: 100 / G: 765 [FALL] DMG: 67.189964 / Z-VEL: -691.151184

Very high fall:
T: 30 / G: 800 [FALL] DMG: 306.249206 / Z-VEL: -839.999633
T: 100 / G: 750 [FALL] DMG: 282.135009 / Z-VEL: -828.750000
T: 100 / G: 765 [FALL] DMG: 301.188842 / Z-VEL: -837.676696

(Tried testing on 90 tick but the results weren't worth including, they were not much different than 100 tick so changing to 90 tick would not be an improvement)

I found a value of 765 for sv_gravity to be closer to default than the current value, but it could still use some adjustment. For smaller falls fall damage will be increased compared to normal, then at ~35 the damage starts being reduced compared to normal. This value still needs some adjustment, very small amounts of fall damage are increased, such as falls that do <1 damage on default settings, these can deal >1 damage on 765 gravity.

Plugin used for testing: https://github.com/Derpduck/Derpduck-L4D2-Scripts/blob/main/sourcemod/scripting/measure_jumps.sp

SirPlease commented 1 year ago

The plugin seems to print different values every now and then, even when standing still at the exact same spot. If you were to use math then the ideal sv_gravity for 100 tickrate based on your findings would be 773 (rounded). 🤔

Derpduck commented 1 year ago

I don't think there is an ideal gravity, gravity shouldn't be changed because it's a constant and the issue here is the rate of acceleration. Really we should modify the amount of fall damage taken since that is the only real issue at default gravity.

Inconsistencies with the plugin might just be a timing/rounding issue.