Skip to content
23 changes: 21 additions & 2 deletions Client/game_sa/CVehicleSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1470,8 +1470,27 @@ bool CVehicleSA::IsWheelCollided(BYTE eWheelPosition)

int CVehicleSA::GetWheelFrictionState(BYTE eWheelPosition)
{
auto vehicle = static_cast<CAutomobileSAInterface*>(GetInterface());
return vehicle->m_wheelFrictionState[eWheelPosition];
switch (static_cast<VehicleClass>(GetVehicleInterface()->m_vehicleClass))
{
case VehicleClass::BIKE:
case VehicleClass::BMX:
{
auto* bikeInterface = static_cast<CBikeSAInterface*>(GetVehicleInterface());
if (!bikeInterface)
return false;

return bikeInterface->m_aiWheelState[eWheelPosition];
}
default:
{
auto* vehicleInterface = static_cast<CAutomobileSAInterface*>(GetVehicleInterface());
if (!vehicleInterface)
return false;

return vehicleInterface->m_wheelFrictionState[eWheelPosition];
}
}
return false;
}

void CVehicleSA::SetTaxiLightOn(bool bLightOn)
Expand Down
27 changes: 21 additions & 6 deletions Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4205,13 +4205,28 @@ bool CLuaVehicleDefs::SetVehicleModelWheelSize(const unsigned short usModel, con

int CLuaVehicleDefs::GetVehicleWheelFrictionState(CClientVehicle* pVehicle, unsigned char wheel)
{
if (wheel < 0 || wheel > 3)
throw std::invalid_argument("Invalid wheel number");
eClientVehicleType vehicleType = pVehicle->GetVehicleType();

if (CClientVehicleManager::GetVehicleType(pVehicle->GetModel()) != CLIENTVEHICLE_CAR)
throw std::invalid_argument("Invalid vehicle type");

return pVehicle->GetWheelFrictionState(wheel);
switch (vehicleType)
{
case CLIENTVEHICLE_CAR:
case CLIENTVEHICLE_MONSTERTRUCK:
case CLIENTVEHICLE_QUADBIKE:
{
if (wheel < 0 || wheel > 3)
throw std::invalid_argument("Invalid wheel number");
return pVehicle->GetWheelFrictionState(wheel);
}
case CLIENTVEHICLE_BIKE:
case CLIENTVEHICLE_BMX:
{
if (wheel < 0 || wheel > 1)
throw std::invalid_argument("Invalid wheel number");
return pVehicle->GetWheelFrictionState(wheel);
}
default:
throw std::invalid_argument("Invalid vehicle type");
}
}

std::variant<bool, CLuaMultiReturn<float, float, float>> CLuaVehicleDefs::GetVehicleModelDummyDefaultPosition(unsigned short vehicleModel,
Expand Down
Loading