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

Safer vehicle grabbing/dragging #76338

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

ShnitzelX2
Copy link
Contributor

Summary

Bugfixes "safer vehicle grabbing/dragging"

Purpose of change

Fixes #14169

Grabbing and moving a single-tile vehicle (e.g. a fridge) works fine, and doing the same with a non-solid vehicle (e.g. a bicycle) also works fine. But if you're moving a solid vehicle like a car, you can get undesirable behavior as shown in this video:
https://github.com/user-attachments/assets/0af6c9d0-c62d-4e79-9607-51db7cb2748f
In short: player/vehicle collisions, and the player phasing through the vehicle, along with the error messages for unboarding the vehicle unexpectedly.

Describe the solution

We don't want the player to phase into a vehicle using grabbing, nor do we want them to get hit by the grabbed vehicle. Therefore, restrictions are applied to grabbing and moving vehicles to make the behavior less error-prone and more realistic.
(see video below)

  • Grabbing vehicles distinguishes between those with and without solid parts, and those with only one tile; behavior for non-solid vehicles and single-tile vehicles remains the same.
  • Vehicles with solid parts and wheels can be grabbed and dragged only forward/backward with near-parallel movement and will not change facing direction, but can be steered (if controls are intact, and to a maximum of 45 degrees from vehicle's face) to turn them along the steered direction with a push/pull. If there's a collision with the player during a steered push/pull, the vehicle will move to avoid it if possible.
  • Vehicle with solid parts and no wheels are moved like a single-tile vehicle; the above conditions do not apply. If you need to move a normal vehicle easily without driving it (e.g. for development), set your strength very high.
  • You no longer can get into a vehicle with solid parts while grabbing it.
  • fixes to some missing grab releases
  • vehicle->face updates to avoid drawing bugs in tiled graphics

Describe alternatives you've considered

It's not very possible to fix these bugs without changing how vehicles are grabbed/dragged.

Testing

Manually tested every case from this list within reason: tests.txt
All tests passed locally

Additional context

Better explained with a short video:
https://github.com/user-attachments/assets/37fcb01a-66cd-4917-9c87-3a823655c06a

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Sep 10, 2024
@github-actions github-actions bot removed the astyled astyled PR, label is assigned by github actions label Sep 11, 2024
@github-actions github-actions bot added the astyled astyled PR, label is assigned by github actions label Sep 11, 2024
@Night-Pryanik
Copy link
Contributor

Will it perchance fix #58027?

@ShnitzelX2
Copy link
Contributor Author

For vehicles with solid parts, yes; otherwise, no. Like Patrik said in #58027, that behavior is more or less a feature for convenience's sake rather than a bug when it comes to non-solid vehicles, which is why I didn't include the issue or change the behavior. It probably doesn't need the bug label.

-grabbing vehicles distinguishes between those with and without solid parts, and those with only one tile
-can't board a solid vehicle you're grabbing
-vehicles with solid parts can't change angle when dragged and can only be dragged with near-parallel movement, but can be steered (if controls are intact) to turn them with a push/pull
-you can't get into a vehicle with solid parts while grabbing it
-fixes to some missing grab releases, vehicle->face updates
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Sep 13, 2024
@HadeanLake
Copy link
Contributor

I often use motorized foldable bicycle with foldable shopping basket at the back.
The shopping cart basket is solid not boardable and this will cause issue when trying to drag this vehicle in some places
2024-09-13-140257_1920x1080_scrot
Well this basket may be in need to be switched to be non-solid, like industrial trash can, but still, shouldnt 3x1 vehicle with solid part at the back be turnable in this situation?

@HadeanLake
Copy link
Contributor

HadeanLake commented Sep 13, 2024

2024-09-13-142343_1920x1080_scrot

also, cant drag unmodified portable generator
And food vendor cart

@ShnitzelX2
Copy link
Contributor Author

shouldnt 3x1 vehicle with solid part at the back be turnable in this situation?

Not in the way that vehicles are currently, as there is a chance you'll clip into it if you reverse it. I don't have much experience with shopping cart VPs, so I don't know if they should be non-solid. It makes sense that they would be; a person can climb into a shopping cart.

unmodified portable generator

This is an edge case vehicle, as it has wheels and controls but no driver's seat, and a stow board for a single solid tile. I would recommend that the stow board gets replaced with a non-solid storage tile, as this is a portable generator, and a stow board is described as a "wall" that "prevents people from seeing through it".

food vendor cart

Also an edge case, as it has two sets of wheels and solid tiles but no controls. In real life, you'd pick up and drag a food cart or attach it to a vehicle if it wasn't already. Most food carts have some kind of pivoting wheel, though, and ours doesn't -- in fact, it doesn't even have wheel mounts! The behavior's logical as-is: you can't steer the cart, but you can still move it back and forth.

I'm not planning on including these suggestions in this PR, it's large enough already.

@HadeanLake
Copy link
Contributor

Most food carts have some kind of pivoting wheel, though, and ours doesn't --

10 inch wheels are not described to be on pivots, but they have "STEERABLE" flag, just like shopping cart wheels.

in fact, it doesn't even have wheel mounts!

They do not have "NEEDS_WHEEL_MOUNT_LIGHT" flag (or any other wheel mount flag). The wheel (the set of wheels) itself assumed to include the pivot-mounts, I think

@ShnitzelX2
Copy link
Contributor Author

Yeah, you're right, wheel_10 should be named "swivel caster wheels" or something more descriptive. If a vehicle has a valid wheel configuration AND only has wheel_10 for wheels, it should ignore the angle check. A solid cart with swivel wheels designed to be pushed simply isn't moved the same way as a car is, and what I wrote assumes the solid vehicle is car-like, which covers most cases.

Case in point, the food cart is the only solid vehicle with more than one tile that uses wheel_10, so it can addressed in a follow-up, especially since pushing a food cart in particular is pretty low-priority.

@Maleclypse Maleclypse merged commit 3626dcf into CleverRaven:master Sep 14, 2024
26 checks passed
ShnitzelX2 added a commit to ShnitzelX2/Cataclysm-DDA that referenced this pull request Sep 16, 2024
-also fixes bad vehicle comparison from CleverRaven#76338
Maleclypse added a commit that referenced this pull request Sep 21, 2024
Follow-up to #76338: convenience balances to safer vehicle grabbing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vehicles unexpectedly flip 180 degrees when pushed/pulled
4 participants