Skip to content

Commit

Permalink
Better vehicle dragging (#72515)
Browse files Browse the repository at this point in the history
* Better pushing, with granularity

* better variable names
  • Loading branch information
RenechCDDA committed Mar 25, 2024
1 parent 84e437f commit 94b74cf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/grab.cpp
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

0 comments on commit 94b74cf

Please sign in to comment.