Skip to content
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

Rework vehicle out-of-control behavior. #1807

Closed
kevingranade opened this issue Jun 28, 2013 · 2 comments

Comments

Projects
None yet
3 participants
@kevingranade
Copy link
Member

commented Jun 28, 2013

Currently a vehicle with no driver goes out of control and starts yawing and losing speed rapidly. This results in the vehicle probably going off the road very rapidly (no idea how realistic this is, but it's un-fun in-game) and coming to stop in an extremely short time (this is definitely unrealistic, especially since it's quite different from simply disabling cruise control).

This seems to stem from the vehicle being considered "skidding" even if it's motion is aligned with its facing. At this point rolling resistance is multiplied by 10, leading to the vehicle coming to a stop very rapidly. Replacing the simple "out of control" check with a vector comparison between vehicle facing and momentum in order to determine drag might be all that's required to make this behave more sensibly.

A nice additional option would be to brick the accelerator and tie the steering wheel to allow vehicles to be used as autonomous weapons (bonus points for putting bombs in them). This could be something done from the vehicle interaction menu which requires a rope or similar and something to prop the accelerator.

The effect would be to reduce the frequency of vehicle turning, and to keep the cruise control going (or just thrust every turn?) even with no driver in control. This would also be nice for other activities, like fighting zombies in the back seat, or firing LAWs.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@mlangsdorf

This comment has been minimized.

Copy link
Contributor

commented Aug 15, 2018

-    int base_slowdown = veh.skidding ? 50 : 5;
-    if( should_fall ) {
-        // Just air resistance
-        base_slowdown = 1;
-    }
+    int base_slowdown;
+    if( should_fall ) {
+        // Just air resistance
+        base_slowdown = 1;
+    } else {
+        base_slowdown = 5 + std::floor( 5 * sin( abs( veh.face.dir() - veh.move.dir() ) ) )
+    }

That puts base slowdown at the following values, based on the difference between facing and movement:

Difference Slowdown
0 5
10 12
20 20
30 27
40 33
50 39
60 43
70 47
80 49
90 50
100 49
110 47
120 43
130 39
140 33
150 27
160 20
170 12
180 5

I'm probably going to implement this as part of the "move slowdown calculations inside vehicle:: where it belongs" PR. Unless people hate it.

@mlangsdorf

This comment has been minimized.

Copy link
Contributor

commented Aug 15, 2018

The logic is that for that table is slowdown is basically air resistance and ground friction. For most CDDA vehicles, air resistance is possibly symmetrical along the vehicle's intended axis of movement, but gets worse the more the vehicle rotates away from that axis, maxing at 90 degrees.

If that's not appropriate, 5 + 45/180 * angle of difference is a simple calculation that increases skid friction by 50% from base for every 10 degrees of skew between facing and movement.

mlangsdorf added a commit to mlangsdorf/Cataclysm-DDA that referenced this issue Aug 16, 2018

vehicles: skidding slowdown depends on direction
Change the amount of slowdown generated when a vehicle is skidding
or otherwise out of control to be 1x to 10x its slowdown while
under control, depending on the angle difference between the
vehicle's facing and movement, maxing out at 90 degree difference.

In the process, refactor the function slightly so it checks for
falling from the vehicle:: instead of taking it as an argument
from the map:: call.

Fixes CleverRaven#1807.

Warning: Car-fu is much more effective, because uncontrolled vehicles
keep moving forward for much longer. Also, skids are more dangerous,
because the vehicle doesn't stop nearly as quickly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.