[Release] Realistic Vehicle Failure

New version released

Version 0.5 adds the following new features and fixes:

  • Moved config to a separate file for easier updating
  • Prevents flipping an upside down car over
  • Vehicle will progressively slow down as damage increases
  • Balanced the damage and visual damage to be more consistent across vehicle classes and types
  • Changes to handling values are now multiplied from existing values instead of just setting values. Preserves the differences between vehicles more (ie. armoured cars should be somewhat tough)
  • Damage multiplier can be set for each vehicle class separately
  • Fix for not resetting handling while exiting the vehicle

Get it at GitHub using the link in the original post. Let me know if you find any problems or have other suggestions.

Enjoy!

2 Likes

@jens_s Love this script! Thank you for making it. I noticed a bit of a bug when using Basic Vehicle Actions. BVA allows the engine to be shut-off and when it’s shut-off the vehicle takes damage. Any way to remedy this or has it already been resolved with the latest update? Thanks again!

Just so you know if you dont, the damage isnt synced for other players, if i wreck my car, the other players dont see the damage.

1 Like

I have tried BVA and been able to reproduce the problem.
Turns out that BVA sets the fuel tank health to zero when you turn off the car. That is very bad behaviour. Here’s why:

  1. Disable my script
  2. Spawn a new healthy car
  3. Turn off the engine with BVA
  4. Get out of the car
  5. Shoot at the fuel tank
  6. Kaboom!

Takes only one shot, maybe two.

So even by itself BVA has a problem with explosions, but the same bug or bad implementation is what causes my script to register huge damage to the fuel tank, rendering the vehicle inoperable.

Thanks for reporting this. Being somewhat of a hermit, I haven’t tested the multiplayer functionality myself.

I believe that the way GTA Online and thus FiveM syncs players doesn’t really sync visual damage very well.
Having watched youtube videos like for example the Code Zero guys, it’s quite obvious that the damage to a specific vehicle looks different to each player. “Not on my screen” is a phrase heard quite often.
Hopefully the OneSync project does a better job.

In the meantime, I will disable the visual damage modifier in the default config, and add a note that it doesn’t sync if enabled.

2 Likes

Sweet, great script nevertheless, thanks for the release!

New version released

Version 0.6 adds the “Sunday Driver” feature.

While I realize that this feature isn’t very related to damage and failure, I decided to include it anyway, since releasing it as a separate script would create a conflict between the two scripts. I still plan to release it separately later.

So, what is it?

It enables very smooth acceleration and braking, and also makes it much easier to drive at a steady pace at lower speeds.
The smooth acceleration is achieved by manipulating the engine torque multiplier relative to the throttle position.
(For controllers, has no effect when using keyboard)

Smooth braking is achieved by manipulation the brake force handling line relative to the brake pressure.
(For controllers, has no effect when using keyboard)

You can still accelerate at full speed and brake at full force by pressing the triggers all the way.

On top of that it also disables the reversing when the vehicle comes to a stop and also eliminates the reversing lights coming on when stopping. To brake and then reverse, you need to release the brake completely first.

When the vehicle comes to a complete stop keep on braking to hold the vehicle with the brake lights on. Release the brake to turn off the brake lights.

Why?

It looks so much better if you are able to accelerate, brake and drive smoothly. Just try keeping a steady 35 mph in the city without this script. Nearly impossible. With this script it’s a lot easier. Try it and compare.

The brake-light mods I have seen keeps the brake lights on at all time when the vehicle is not moving. That’s a problem if you’re trying for example to escape the police by turning off your lights and hiding behind a bush.

If you attempt to mimic AI you will often give yourself away when the reversing lights flash briefly when coming to a stop. Not so anymore.

.

Hope this makes sense. If not, changing “sundayDriver = true” to “sundayDriver = false” in config.lua will disable this feature.

Get it at GitHub using the link in the original post. Let me know if you find any problems or have other suggestions.

Enjoy!

2 Likes

what a great update. The idea of having to almost shift into reverse by releasing the brake first is awesome. It adds realism a bit in my opinion just based on the time factor. That coupled with the brake lights is perfect.

Great idea, I will be testing this :smiley:

i did try myself for the script, but i stamped one time on a motor, and motor was disabled…

1 Like

I am unable to replicate the problem, except for one case: If the vehicle is badly damaged, but barely alive, stomping, kicking, hitting or shooting the vehicle will kill the engine. That’s by design.

If you are using an older version, there were some problems that should be fixed by now.

If you are still having problems with the newest version, please describe step by step what I need to do to reproduce the problem. That will help me a lot.

Just a quick note to developers modifying my script:
When you restart the script there’s a risk that the current vehicle behaves oddly afterwards.
Either get out of the car before restarting, or spawn a new cars after.

It’s not easily solved, so I’m not going to :wink:

Here’s the reason:

  1. When you get into a car, I save the default values of some handling.meta fields.
  2. While you’re driving I modify the handling.meta values, based on those saved default values
  3. When getting out of the car, I restore the default values.

If you restart the script while at step two, we jump straight to step one. Now those default values are actually the modified values. That gives some weird behavior.

2 Likes

Still can’t find that sweet spot I tried the numbers both ways… Head on into a wall at 80mph should totally destroy a prius. What do you recommend?

Are you planning any new features ?

If you increase the damagefactors, the car will sustain more damage. To totally destroy a Dilettante at 80 mph these values will do the trick. Haven’t had time to test other cars, so some may damage too easily and other may still be too tough.

	damageFactorEngine = 16.0
	damageFactorBody = 16.0
	damageFactorPetrolTank = 150.0

Some cars are more sensitive to engine damage, others to body damage, and still other to fuel tank damage.
It seems like fuel tank (called Petrol Tank to be consistent with the game code) is the most consistent across vehicles. More testing needed.

Two planned, when time permits:

  1. Better default values in config. Perhaps the option to choose from a few presets, since no setting will be perfect for every user.
  2. Limp mode: If enabled the car will never destroy completely, but will be able to drive slowly to the nearest mechanic.

Odd my current settings are:
damageFactorEngine = 80.0, – Sane values are 1 to 100. Higher values means more damage to vehicle. A good starting point is 10
damageFactorBody = 85.0, – Sane values are 1 to 100. Higher values means more damage to vehicle. A good starting point is 10
damageFactorPetrolTank = 60.0,

I was hitting headon with Semis, walls, guard rails. it ran out of fuel before becoming destroyed. I don’t get it.

PS I don’t have any other vehicle damage scripts running not even a hud. I took that out to see if it was the issue. Still no good after a clear and restart.

1 Like

That sounds like the script isn’t even active.

I can think of a couple of scenarios where this might happen:

1: The script has crashed
2: One or more of your settings are causing it to ignore the damage settings.

First off, if you have enabled the Sunday Driver feature, drive forward, then brake, and keep on braking and see if the car is standing still after stopping. If it goes into reverse by itself, the script is not running for some reason.

The second point is related to my laziness… I haven’t implemented checks for incorrect settings (yet). If you set some of the config settings to an integer where a floating point value is expected, FiveM will “ignore” some native calls.
For example a value of 10 may not work, while 10.0 will work. The settings you showed here looks fine, but other settings may be bad. It’s an easy mistake to make.
(I am confused as to why this happens since lua should handle ints and floats the same, but it may be related to the way calls are made to the native functions. If anyone knows how to handle this, please let me know)

If you comment out some of the settings (Thinking you don’t want or need them), the script will probably crash.

Also remember that you should not reload the script while in a car, since that may cause weird behavior. If you do, just spawn or steal a new car before testing.

If all else fails, send all your settings to me in a PM, and I will try them out here.

Update: Settings were fine, a reinstall of FiveM fixed the problems.

New version released

Version 1.0 adds Limp Mode.

Limp mode is disabled by default.
If enabled, the vehicle will not die completely. Instead it will slow down a lot, enabling you to drive to the nearest mechanic. That is, unless the mechanic is uphill, then the engine may not have enough torque to make it there.

You can still /repair once or twice to fix the engine just enough to be drivable at a reasonable speed.

The config file also has an optional alternative set of settings provided by ImDylan93, giving a different balance between cars, and some more resilience to damage.

Since no bugs have been found (yet) in the previous beta, and the limp mode was the final feature I had planned, and a very simple feature to implement, I decided to end the beta series and jump straight to version 1.0.

Enjoy!

Sometimes vehicles, stop/get damaged for no reason?

Remove the vehicle=lastVehicle and the other variables that get copied.

That would just prevent the damage multiplication. Kind of defeats the purpose of this script.

It’s a feature, not a bug.
In real life, when you damage a vehicle, there’s a risk of fluids leaking. The vehicle may still be drivable, but at some point the engine will die from a lack of oil or coolant.
In other words: Time of accident is not necessarily equal to time of engine death.

You can adjust the way this works by changing degradingFailureThreshold and cascadingFailureThreshold in the config file.
You can’t disable that feature entirely, since some other stuff depends on their values, but if If you set them to 120.0 and 110.0 respectively they’re pretty much without effect.