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

Better vehicle dragging #72515

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/grab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,18 @@ bool game::grabbed_veh_move( const tripoint &dp )

//vehicle movement: strength check. very strong humans can move about 2,000 kg in a wheelbarrow.
int mc = 0;
int str_req = grabbed_vehicle->total_mass() / 100_kilogram; //strength required to move vehicle.
// worst case scenario strength required to move vehicle.
const int max_str_req = grabbed_vehicle->total_mass() / 10_kilogram;
// actual strength required to move vehicle.
int str_req = 0;
// ARM_STR governs dragging heavy things
int str = u.get_arm_str();

//if vehicle is rollable we modify str_req based on a function of movecost per wheel.

const auto &wheel_indices = grabbed_vehicle->wheelcache;
if( grabbed_vehicle->valid_wheel_config() ) {
str_req = max_str_req / 10;
//determine movecost for terrain touching wheels
const tripoint_bub_ms vehpos = grabbed_vehicle->pos_bub();
for( int p : wheel_indices ) {
Expand All @@ -98,8 +102,10 @@ bool game::grabbed_veh_move( const tripoint &dp )
}
//finally, adjust by the off-road coefficient (always 1.0 on a road, as low as 0.1 off road.)
str_req /= grabbed_vehicle->k_traction( get_map().vehicle_wheel_traction( *grabbed_vehicle ) );
// If it would be easier not to use the wheels, don't use the wheels.
str_req = std::min( str_req, max_str_req );
} else {
str_req *= 10;
str_req = max_str_req;
//if vehicle has no wheels str_req make a noise. since it has no wheels assume it has the worst off roading possible (0.1)
if( str_req <= str ) {
sounds::sound( grabbed_vehicle->global_pos3(), str_req * 2, sounds::sound_t::movement,
Expand Down
Loading