Vehicle shock damage changes explained

The latest experimental (42428d678ad4a77a89678fcdd4decd2289dacbf3) includes a fix from me to what I’ve been calling “Shock Damage” - damage from collisions with things that damages parts other than the one that was hit.

The old system had some issues, the most notable of which was that any damage that wasn’t from a vehicle-vehicle collision would be applied from (0, 0), which is usually the seat with the controls. This would mean that, especially if you lengthened your vehicle, parts that were far away from the front of the car would be damaged by ramming into stuff. It would damage any part, but with a random chance, decreasing with distance.

Now, colliding with things (notably monsters) will deal damage from the correct location. It deals shock damage all the time, but only to frames.

The end result is that you will be repairing the front of your car more often and the back of your car never. It also means that you can be more conservative with armor, and only apply it to the front. Extra bumpers in the front will work better too, as they will actually absorb some of the shock damage. You also won’t have seatbelts or gas tanks or solar panels exploding for no apparent reason.

For full details, see https://github.com/CleverRaven/Cataclysm-DDA/pull/4856

Something I noticed when testing, should parts get unmounted when the frame under them is destroyed? It looks like there’s no actual down side to frames getting broken except perhaps preventing you from mounting new stuff. I went ahead and merged because frames broken from shock having little impact (ha) is MUCH preferable to the previous behavior.

There’s no direct downside to them being broken, except that frames with 0 HP could be destroyed if they take more damage, and if that happens anything mounted on them will be forcibly dismounted. (Only the (0, 0) frame is immune to this)

Shock damage doesn’t cause parts to shatter into pieces like collision or smashing damage does - but it could. I don’t think it should, though, but am open to suggestions.

whoops, here’s a bug:


Ran over 4 zombears at about 120 MPH, my seat was unmounted from under me, dropping me on the ground, and my horrifically wrecked car coasted to a stop.
The game thought I was still boarded on the vehicle, so spammed messages. Perhaps a “fling_player()” or similar is in order if an occupied seat is destroyed.

Also, that debug message should only be shown once, and then just auto-assume the player is leaving the vehicle, rather than spamming over and over…

But yes, it should at the very least dismount the player from the vehicle.

I believe that bug existed before the shock damage changes anyway, I noticed it a lot while spawning single tiled vehicles from the debug menu.

I would think in most situations, the frame would only take as much damage as the rest of the parts, so they would either break at the same time, or the other parts would break before the frame. The only time I can think of this not being the case would be if the car took damage from something underneath, like a mine.

I think my original issue was premature, I just didn’t test the vehicle to destruction.

What If separating vehicle parts created separate vehicle instances with said parts attached rather than dropping piles of scrap, Either that or have a chance of dropping the pieces as highly damaged items.

But that code tho

That’s feasible, and we’re planning on doing it, but it’s rather complicated.

It’d be very nice to have. And it’s not wholly complicated, just…

  • Detecting a car has been sheared in two? Easily done, all the code to do that already exists to prevent you removing parts that do that.
  • Removing all offending parts from one car? Not too difficult, easy to find using the code that finds the shear point.
  • Building a new car with all the parts removed from the first one? This is the tricky part, especially placing it correctly.