So, I have spent a while testing vehicle damage on debug mode and looking at the Lua code and I have discovered I few things about vehicle damage that might be useful to other players and modders and I wanted to share it with you all:
* The system for wear and tear of parts is quite similar to the one for weapon damage in the sense that there is a strong aspect of random chance to it. A random number is generated every "update" and if you get an unlucky roll the part will be degraded a little bit.
* Vehicles only degrade while they are being driven. Your tires don't lose pressure over time while parked or anything like that. Edit: Some notes on this; I am referring only to tires, brakes mufflers and suspensions here (which are most of the parts that actually degrade with use), your engine can still degrade over time if left running (so long as the hood is absent or at 0% condition) and you can still lose gasoline from a damaged gas tank (so long as the engine is running). I also did not test if parts degrade on a vehicle that is being towed, but I would assume yes.
* Tires will sometimes lose pressure when you are driving the vehicle, though.
* The speed at which you are driving and how hard you are steering are important factors that greatly impact the chances of wearing down your tires, suspension and brakes. The faster you are going and the tighter the turns you are making, the higher the chance of getting a damage 'tick' to those 3 types of part.
* It is still unclear to me, however, if driving slowly will necessarily result in less wearing down of parts per distance traveled, since traveling for a longer time should result in a larger total number of 'updates' that can potentially cause damage each.
* Brakes suffer wear and tear quite fast. The code does have increased chances for damage ticks when braking at higher speeds, but in practice I have experienced high damaging even while driving relatively slowly due to the effect I stated above.
* Driving offroad massively increases the chances of wearing down your tires (up to 13x more).
* Mufflers will suffer wear and tear under the same circumstances as your suspensions. Presumably to simulate it hitting the ground on a bumpy road.
* The bumping from driving over corpses does not seem to actually deal any damage to your suspension or tires. It's purely a audiovisual effect for the time being.
* As of yet, it doesn't really seem like the suspensions take more damage when they are being driven offroad, over the curb or anything like that.
* All of the parts can only take integer damage (i.e. full numbers), there isn't a hidden 0.001% damage that your parts are slowly taking all of the time or anything like that.
* The vehicle's battery and gas tank are somewhat an exception to this rule in that the battery charge and gas amount are each defined by a float number (Not their actual condition though, that is still an integer).
* The amount of fuel consumed by an idling engine is very small, practically negligible and quite unrealistic. It would take many days to empty a full tank this way.
* Despite patch notes stating that this bug has been fixed, parking a car near an active generator seems to still charge the battery. Looking at some of the code found in the 'Vehicles.lua' file, this seems very much intentional, rather than a bug. Edit: This is no longer the case as of version 41.73, I might have gotten my patch note versions mixed up, sorry about that.
* The whole way power is consumed is very unrealistic. Headlights, radio, lightbars and sirens each consume the exact same amount of electricity each, whereas in the real world a set of automotive incandescent lights would consume something on the 100 watts+ range and a regular radio only 20-40 watts. Leaving your headlights active should completely drain the charge of even a modern vehicle in less than a day, but in Zomboid it takes about 5 days for headlights to achieve the same. The AC consumes more electricity than the rest, but not much more, whereas real life vehicular AC systems work on the KiloWatt range. The engine starter is the worst offender as starting your engine eats up a huge chunk out of your battery charge (2.5% total). Old car batteries from the 90s could hold 600 Watt/Hours worth of charge, whereas a car engine starter consumes 1kW, so a full battery should be able to power a starter for 36 minutes straight which is enough to start an old and stubborn-to-start engine half a dozen hundreds of times, whereas in the game you can only start the engine 40 times on a full battery charge which is more than 10 times less efficiency than what you should get even with the technology from the era and forces you to to leave your engine running constantly when you really should be worried about saving gasoline instead. I really wish the devs would change this to be more realistic. Sorry about the mini rant...
* Honking doesn't seem to consume any battery charge at all.
* The condition of the AC/Heater doesn't seem to affect anything, it still works fine even at 0% condition. Probably a bug or oversight that will eventually be fixed.
* Having closed or open windows does affect the temperature inside your car! Closed windows will make your car be very hot during summer days and lukewarm during the winter. Open, smashed or removed windows will equalize the temperature with the exterior and prevent the AC from working effectively. This is a really neat feature!
* Some vehicles have far more powerful AC/Heaters than others. The Mercia Lang 4000 seems to have the most powerful one of all.
* The AC in some vehicles can reduce the temperature inside to below zero! It would be an interesting little strategy to put icecream on the passenger seat and have it not melt by having the AC always on, basically having your own mobile fridge, but this feature has not been implemented (yet, hopefully).
* Damage from crashes is different from the one for wear and tear in the sense that it is less random. Only the amount of damage each part takes it's random, but it is clamped to a tight range and heavily dependent on the speed of the crash.
* There is an upper bound to the amount of damage your car can take from a single crash. Your sports car won't be instantly totaled from a 125 miles/hour crash.
* The crash system seems to only interpret crashes as being "from the front" or "from behind", you never take damage only from the sides.
* This also means that crashes straight from the front or back will still damage your doors and side windows.
* Crashes from the front will damage your headlights, engine (sometimes), hood, windshield and doors.
* Crashes from the back will damage your taillights, trunk (but not on all vehicles, open bed trucks seem to be immune to this), trunk lid, muffler, rear windshield and doors.
* The engine will not take damage from crashes if the hood isn't damaged itself.
* The engine will take damage from overheating if the hood is in poor condition or missing. (I don't follow the logic here, but it's the way it works in the game)
* Having a severely damaged trunk or trunk lid will cause stored items to drop in the road as you are driving. Forgetting to close your trunk, however, doesn't cause items to fall off.
* Open bed trucks are currently immune to this due to the fact they don't have a lid and never take trunk damage, but there is some commented out code that implies those open beds were meant to drop out your items if you were driving really fast.
* Some parts seem to never take any damage due to crashes (battery, gas tank, tires, brakes, suspension, seats, glove box, heater, radio and lightbars).
* With the exception of tires, brakes and suspension, all of those parts I just listed don't seem to actually ever take damage from anything besides bad mechanics causing damage to them while taking them out or installing them (with the exception of lightbars, glove boxes and heaters, which can't take damage even this way).
* Headlights and taillights only take damage from crashes, they don't wear out from actual use (there is a comment on the code saying this is on the ToDo list)
* There is a relatively high chance that you will damage vehicle parts by 1% when you are uninstalling them from a vehicle. The lower your mechanics skills, the higher the chance. After you reach mechanics level 7, this chance is eliminated.
* There is another, different and parallel check, that gives a chance to not only fail, but to also damage a vehicle part when you are either uninstalling or installing it on a vehicle. This one will damage a part by a random amount between 5% and 10%.
Some Updates on Fuel Consumption:
* As I have mentioned, while idle your engine will consume basically no gasoline. Most of your gasoline will be consumed while you are actually driving your car around. On the other hand, your battery does get discharged very fast by the engine starter, so currently the best strategy is to leave the engine running unless you aren't going to drive again for several in-game hours.
* There are two main factors that control the consumption of gasoline, the first is the speed you are going (which simulates the effect of aerodynamic drag) and the second one is how far away you are from a gear shift (which is realistic since real world engines do have specific RPM bands where they operate at their highest efficiency). If you use cruise control to keep your car always going at that specific speed where the RPM needle stays right in the middle between a gear-swift up and gear-swift down, then that should give you the best kilometrage.
* The 'quality' rating on engines does affect the rate of gasoline consumption, but this is a very slight effect; even the high end of quality ratings (around 60) will only increase efficiency by about 20%.
* Having a damaged gas tank (condition lower than 70%) will cause you to lose gasoline over time when the engine is running. The more damaged it is, the faster you will lose it. No gasoline is lost when the engine is turned off, however.
* Having the AC turned on does increase the consumption of gasoline slightly. This is realistic since those draw so much power that the alternator has to work extra hard, however there is no accounting for it drawing more power when the car is turned off, so having the AC turned on when the car isn't running draws the same charge from the battery as when the engine is on.
* The AC will have a more powerful cooling or heating effect when the engine is turned on though.