-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(content,balance): Vehicle collision damage logic update, new vehicle part flags #5926
feat(content,balance): Vehicle collision damage logic update, new vehicle part flags #5926
Conversation
…icle part flags Updated vehicle_move.cpp and map.cpp to include comments about impulse
Autofix has formatted code style violation in this PR. I edit commits locally (e.g: git, github desktop) and want to keep autofix
I do not want the automated commit
If you don't do this, your following commits will be based on the old commit, and cause MERGE CONFLICT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiles, and appears to indeed work very well! My humvee was able to barrel through trees for quite a while at 60 or 70 kmh before the battery got shocked to death. Other than the squishy car battery and some headlights, the vehicle made it remarkably undamaged through the whole affair despite crashing into several trees.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiled and load-tested, spawned in a technical truck and started going on a rampage. Seems to be working from what I've done so far, nothing odd happening at least from what I can see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, mostly. The code makes sense just needs a few changes.
Biggest one being in the vpart_reference&
loop either caching the value of part_info( p )
or using vp.info()
instead (maybe with a check that the part hasn't been removed yet to emulate what part_info( p )
is doing)
…icle part flags Worked in changes based on code review.
…icle part flags Updated vehicle.cpp (again) to work in comment that I had missed
Worked in changes requested by OrenAudeles. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure the new vehicle.cpp
file isn't supposed to exist lol. It was added with the most recent commit as the only change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay looks like the only thing left for me to nag about is getting rid of magic numbers and use velocity_constant
:D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not delay this any longer then. Looks good, it builds.
A NEW ERA OF MAD MAX IS UPON US
main
so it won't cause conflict when updatingmain
branch later.Purpose of change
Old vehicle collision damage logic has several issues with its implementation that cause game play issues.
Current system takes an arbitrary amount of energy out of both entities on collision, and applies damage based on that to both. This results it trucks or tanks hitting a bush and dealing hundreds if not thousands of points of damage to themselves.
With large vehicles there is no safe speed to impact any terrain, vehicle, critter or object without potentially causing significant damage, rams only contribute to critter collision damage, impacts with smashable terrain can collide several time times (up to 10) causing more damage than the terrains bash_strength without destroying it, pushing vehicles is difficult to do without incurring damage to both, shock damage is capable of causing significant damage in a vehicle upon impact with a bush, etc.
Collisions that do not destroy terrain and cause multiple follow up collisions can continue to deal damage to vehicle without the energy that should be required to do so.
Also, the damage code uses vmph (100xmph) as velocity and metric units for all other variables.
Describe the solution
Converted from vmph to m/s within damage code for consistency.
Changed damage calculation to be impulse based, instead of being based on deformation energy. Damage is generally lowered across the board for larger vehicles.
Implemented damage caps for collisions with terrain, furniture and critters based on the max health or bash_strength of the object in question. Unused impulse is returned to the vehicle, and potentially restores some of the speed loss of the collision. Set to not allow a vehicle to somehow gain speed due to shenanigans.
Added some additional debug messages to vehicle collisions for better troubleshooting.
These changes also reduce the frequency of vehicles hitting a tree with a bash_strength of 120 with more damage than required to break it several times before actually breaking it.
Rams are now set to actually apply their damage modification on impacts with terrain, allowing rams to be beneficial to more vehicles. This reduces the required impulse to destroy terrain, leading to less damage to the vehicle in question.
Vehicles are set to deal no damage to each other at speeds less than 6m/s (~13.5mph) so that players can push vehicles out of the way with theirs without causing significant damage to either vehicle.
Shock damage in vehicle on terrain collisions was set previously to occur for every collision, allowing for saplings to tear the batteries and clocks out of APCs. Shock damage is now reduced by the damage resistance of the colliding part before being called.
Two new JSON flags added for mitigating shock damage, with effects worked into the damage_all function.
SHOCK_IMMUNE: does exactly what it says on the tin, makes a part immune to shock damage. I have currently applied this to things that should not reasonably be taking any shock damage, like seat belts, harnesses, and the military black box.
SHOCK_RESISTANT: This is for objects that should be rather sturdily mounted in a vehicle, but could still be vulnerable to direct damage like seats or clocks. For purposes of shock damage, they receive half of the greatest (usually bash) damage resistance of any vehicle part sharing its location.
Neither JSON flag provides any protection against direct collision damage or damage from other sources.
There is a impulse_to_damage function in vehicle_move.cpp, with an attached constant currently set to 0.1 This seems to produce reasonable results, but can be fine tuned or potentially hooked up to other functions if desired.
Describe alternatives you've considered
Determining or guessing collision distance or time to derive force from impulse. These methods rely on too much guesswork for numbers that are not present. Simulating to determine them is out of the question, and using available data results in very bad estimates.
SHOCK_RESISTANT could instead inherit the damage resistance, or some fraction thereof, of the frame its mounted on.
Did not actually consider leaving in some old code that allowed for infinitely escalating collisions generating energy to ping pong vehicles about at hundreds of thousands of mph, but it would have been funny.
Testing
Repeated collision analysis, some of which is recorded in the relevant discord server development channel thread (Vehicle collision damage).
Pushed a sedan very slowly with a bus out of the way without damaging either vehicle. This is generally impossible in the current build.
Repeatedly slammed Vern Shultz and his APC into things for millions of damage until I got the damage numbers to a reasonable outcome.
Additional context
Screenshot of results with current code. An APC at 40mph hits a bush, ~12000 d_E / 400 results in about 30 damage to be passed around, 7 of which is given to the APC. This damaged the clock and car battery a little bit.
Poor clock. Old system is capable of dealing repeated damage to vehicle even when it does not have the energy to do so.
APCs can now drive a bit further into forests, though this does wreck the front plate.
And I corrected some runaway collision energy generation issues that popped up from the old code when you don't take a significant portion of the energy out of the system with every collision.
One of the many deaths of Vern Shultz