From acc89ff4a710ed71d517e1f65578ea7f38af6941 Mon Sep 17 00:00:00 2001 From: RenechCDDA <84619419+RenechCDDA@users.noreply.github.com> Date: Mon, 20 May 2024 15:17:40 +0100 Subject: [PATCH] Better vehicle dragging (#72515) * Better pushing, with granularity * better variable names --- src/grab.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/grab.cpp b/src/grab.cpp index 5a18753a42f51..c58c4f41a5560 100644 --- a/src/grab.cpp +++ b/src/grab.cpp @@ -74,7 +74,10 @@ 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(); @@ -82,6 +85,7 @@ bool game::grabbed_veh_move( const tripoint &dp ) 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 vehpos = grabbed_vehicle->global_pos3(); for( int p : wheel_indices ) { @@ -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,