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

vehicles: add support for amphibious vehicles #27251

Merged
merged 6 commits into from
Jan 3, 2019

Conversation

mlangsdorf
Copy link
Contributor

@mlangsdorf mlangsdorf commented Dec 23, 2018

Summary

SUMMARY: Features "vehicles: add support for amphibious vehicles"

Purpose of change

Fixes #20933
Remove the hardcoded limitations that require a vehicle either be a boat or a ground vehicle. Allow people to put wheels on their boats, or boat boards on their cars, and seamlessly transition between land and water travel.

Describe the solution

First, change vehicle::gain_moves() so even stationary vehicles gain moves and have an opportunity to call act_on_map(), which is necessary because vehicles sink in act_on_map(). This solves a corner case where a stationary vehicle wouldn't sink - you could take your boat out to the middle of a lake, remove all the boat boards, and it would still float.

Second, stop pretending boat boards are some kind of weird wheel. Boats float without taking on water when they have freeboard: their draft is less than the distance from the bottom of the hull to the top (aka the hull height). Approximate hull height based on the percent of the vehicle's footprint that is covered by boat boards, calculate draft from the vehicle dimensions and mass, and set a boolean as to whether the vehicle can float or not.

Then instead of having two different calculations for whether a vehicle is in water - one in buoyancy and the other in k_traction - have a single function check_falling_or_floating that also checks as to whether the vehicle is falling or has 2/3rds or more of its tiles in water. Continue to mercilessly destroy vehicles that are in water but can't float.

Generally simplify the logic for dealing with traction, which now deal exclusively with wheels. Vehicles act as boats (with water movement, etc) when they are in water, and sink if they can't float. Vehicles act as land vehicles if they aren't in water, and they don't move if they don't have enough wheels, whether or not they also have boat boards.

Please review and playtest carefully. This isn't as as big as the vehicle speed rework but it's still changing some fundamental vehicle interactions - for the better but still.

Describe alternatives you've considered

The vehicle efficiency test is randomly failing. I can't figure out why. I considered deleting the randomly failing vehicles but that seemed like poor form. Stale data was causing some tests to randomly start with the cruise velocity set to the water safe speed. Fixed by initializing the relevant values and explicitly calling safe_ground_velocity().

There needs to be a better solution for dealing with sunken vehicles.

Additional context

Built on top of #27225.

itsa_hmmwvvitsa_dukw
My HMMWV is actually a DUKW. It has boat boards, it has wheels, it drives on the ground, it floats on the water (barely).

itsa_hmmwvvitsa_dukw2
Driving on a bridge at 30mph.

itsa_hmmwvvitsa_dukw3
Moving across the lake, faster than my engine can handle.

itsa_hmmwvvitsa_dukw4
Back on dry land, no problem.

itsjustacanoe1
This canoe is just a canoe. It has no wheels.

itsjustacanoe2
It doesn't go places on land because it has no wheels.

@mlangsdorf mlangsdorf added <Enhancement / Feature> New features, or enhancements on existing Game: Mechanics Change Code that changes how major features work Vehicles Vehicles, parts, mechanics & interactions [C++] Changes (can be) made in C++. Previously named `Code` labels Dec 23, 2018
@mlangsdorf mlangsdorf force-pushed the boats_amphibious branch 3 times, most recently from 7f2ada7 to 025699e Compare December 24, 2018 03:39
@ZhilkinSerg ZhilkinSerg self-assigned this Dec 24, 2018
@mlangsdorf
Copy link
Contributor Author

I think I found the issue with the failing tests and should have fixed pushed shortly. Stale data was causing some tests to run with water_safe_velocity as the cruise velocity.

@mlangsdorf
Copy link
Contributor Author

Jenkins rebuild

@mlangsdorf mlangsdorf force-pushed the boats_amphibious branch 3 times, most recently from 465cc3a to 5c57e00 Compare December 26, 2018 15:12
@ZhilkinSerg
Copy link
Contributor

Can you include amphibious vehicle for testing purposes?

@mlangsdorf
Copy link
Contributor Author

mlangsdorf commented Dec 28, 2018

Sure! Amphibious truck added.

don't test mass when doing make_vehicle_efficiency_case.

Make the tests a little more robust and catch some possible
corner cases.
Give all vehicles a minimum amount of moves in gain_moves(), so that
act_on_map() will be called for every vehicle on the map.
stop treating boat boards as wheels and doing weird things with wheel
area traction calculations.  Instead, check if a vehicle is mostly in
the water, and if it is, whether it can float, or if it isn't, whether
it has sufficient wheels.  Now that these are entirely separate concepts,
a vehicle can be amphibious by giving it wheels and enough boat boards.

Revise the drag test to consistently give correct results and include
water drag numbers.
Merge the mulitple vehicles, vehicle parts, and vehicle base items JSON
files from Boats into 4 clearly named files.
Shorten the vehicle prototypes in Boats by using parts notation.
Add plastic, metal, and carbon fiber boat hulls.

Add a plastic hulled kayak and a carbon fiber hulled racing kayak.

Add an amphibious truck (aka DUKW) using metal hulls and demonstrating
an amphibious vehicle.
@ZhilkinSerg ZhilkinSerg merged commit 83b5b24 into CleverRaven:master Jan 3, 2019
@mlangsdorf mlangsdorf deleted the boats_amphibious branch January 3, 2019 20:10
@ZhilkinSerg ZhilkinSerg removed their assignment Jan 5, 2019
@kevingranade
Copy link
Member

This pull request has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there:

https://discourse.cataclysmdda.org/t/amphibious-monsters-and-vehicles-perhaps/22361/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing Game: Mechanics Change Code that changes how major features work Vehicles Vehicles, parts, mechanics & interactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable playermade amphibious vehicles
3 participants