Issue with custom damage system (pistolwhipping)
#2

There are a few issues with your health/armor code in general.
If a player has 1.0 armor, a shot would only do one damage.
You need to calculate the overhead if a player has less armor than the damage done, and subtract the rest from their health.

Furthermore you use switch on a Float value. It works in this very case (since you check for 0, which is the equivalent to the Float 0.0).
switch does work on Float but it is the opposite of efficient since it generates a really large jump table.
That complete switch is unneccessary, just use if (since you only have 2 cases anyway).

Furthermore why OnPlayerTakeDamage? Do you want to have lagshooting on your server?
Use OnPlayerWeaponShot to avoid lagshooting and pistol whipping (pistol whipping is not a projectile, so it won't get called).
In case you do want to have lagshooting, simply check the damage value passed to the callback (pistol whipping does less damage than a bullet).

Also for the bodypart damage you could rather work with a multiplier value instead of hardcoding every case for every weapon.
Same for an armor hit, just do (eg) 10% less damage to armor.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)