[Snippet] [TF2]adding damage fall off on weapons using linear regression
This code snippet is useless for me at the moment, but might prove useful in the future for future projects.
PHP Code:
your grenade launcher does 100 damage, you want it to go half lower from distance and half higher when closer max distance = 1024 minimum = 512 multiplier = 0.5 falloff = (100 * 0.5) = 50 sinusoidal (50-100)/(1024-512) = -50/512 y intercept becomes 100 - (-50/512(512) -50/512 * 512 = -50 base - -50 = 150 or 1.5x as your damage ramp up finally your damage will be -50/512 * distance vectors + 150 y intercept let's say you shot the grenade from 786 units -50/512(786) = -75 -75 + 150 = 75; 75 damage from 786 units! 512 units, aka minimum damage fall off distance = -50/512(512) + 150 = 100 now the farthest distance in tf2, 1024 = -50/512(1024) + 150 = 50 thus it's correct! |
| All times are GMT -4. The time now is 18:33. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.