diff --git a/src/vehicle.cpp b/src/vehicle.cpp index cbecefe5fb3f6..a12fa24680ccf 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -3484,6 +3484,22 @@ units::mass vehicle::total_mass() const return mass_cache; } +units::mass vehicle::weight_on_wheels() const +{ + const units::mass vehicle_mass = total_mass(); + units::mass animal_mass = 0_gram; + for( const int e : engines ) { + const vehicle_part &vp = parts[e]; + if( vp.info().fuel_type == fuel_type_animal ) { + monster *mon = get_monster( e ); + if( mon != nullptr && mon->has_effect( effect_harnessed ) ) { + animal_mass += mon->get_weight(); + } + } + } + return vehicle_mass - animal_mass; +} + const point &vehicle::rotated_center_of_mass() const { // TODO: Bring back caching of this point @@ -4576,7 +4592,7 @@ float vehicle::k_traction( float wheel_traction_area ) const if( fraction_without_traction == 0 ) { return 1.0f; } - const float mass_penalty = fraction_without_traction * to_kilogram( total_mass() ); + const float mass_penalty = fraction_without_traction * to_kilogram( weight_on_wheels() ); float traction = std::min( 1.0f, wheel_traction_area / mass_penalty ); add_msg_debug( debugmode::DF_VEHICLE, "%s has traction %.2f", name, traction ); diff --git a/src/vehicle.h b/src/vehicle.h index bfc19867efb65..2c44c357eab1e 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -1526,6 +1526,9 @@ class vehicle // get the total mass of vehicle, including cargo and passengers units::mass total_mass() const; + // Get the total mass of the vehicle minus the weight of any creatures that are + // powering it; ie, the mass of the vehicle that the wheels are supporting + units::mass weight_on_wheels() const; // Gets the center of mass calculated for precalc[0] coordinates const point &rotated_center_of_mass() const;