Projectile hitting edges of commander's collision box causes unwanted hit on vehicle

Issue #119 resolved
Matt Hands created an issue

Projectiles that hit the edges of a commander's collision box get counted as an unwanted hit on the vehicle.

For a bullet this is just phantom, mid-air hit metal impact effects. But for a shell it can damage or destroy the vehicle, otherwise resulting in a phantom, mid-air shell deflection or explosion.

Comments (2)

  1. Matt Hands reporter

    Fixed with new commander hit detection system implemented in commit 97ac8df.

    Problem

    When projectile hits a VehicleWeapon, ProcessTouch first checks HitDriverArea. That's supposed to check whether we hit the commander's collision area, not the actual turret. If returns true then it checks HitDriver, which checks whether we've the commander is actually present & in an exposed position (otherwise we may have hit the commander's collision area but he's not there). If again returns true a hit on commander is registered, otherwise projectile's ProcessTouch exits & projectile continues in flight. This was the method in shells, which is sound, so I've made bullets work the same way.

    Problem is that HitDriverArea checks to see whether projectile hit the commander's HitPoints, which are 2 spheres - a big one for his torso & a small one for his head. That doesn't match the rectangular collision box, so it leaves 'spare bits' round the corner, which don't register as a commander hit and so are assumed to be a turret hit.

    Result = kaboom, shell ricochet or bullet ping - on thin air ! Tank may blow up.

    Secondary bug means even if commander hit is registered, ProcessTouch still calls TakeDamage on the vehicle itself, so hitting commander may blow tank up !

    Solution

    I've re-worked so that HitDriverArea does a very simple check whether we hit the commander's collision box, ignoring his HitPoints for now. It's simple to get a hit location that's relative to the turret mesh origin, and the way a turret is configured means any hit above a certain height can only be a hit on commander's col box, not the actual turret.

    Then if HitDriverArea returns true, the next call to HitDriver traces commander's HitPoints as well as checking he is present & exposed. SO if we hit the com's col box (HDA = true) but didn't bit the actual commander (HD = false), any projectile will just fly on & do no damage.

    Each turret needs the MinCommanderHitHeight setting, but I've done & added this for all turrets. It's easy: temporarily log relative hit offset, then stand on top of turret & spray bullets down into it's top surface. All hit offset Z values are tightly spaced as bullets strike the top of the turret col box. Note down highest, round up a little & that's the value.

    Also fixed secondary problem so that projectiles hitting commander only damage him and not the actual vehicle.

  2. Log in to comment