automobile fixes

This commit is contained in:
aap 2020-05-27 22:32:57 +02:00
parent d8749c2305
commit 2a1b9281e4
4 changed files with 28 additions and 24 deletions

View File

@ -3232,7 +3232,7 @@ CAutomobile::VehicleDamage(float impulse, uint16 damagedPiece)
if(impulse > 25.0f && GetStatus() != STATUS_WRECKED){ if(impulse > 25.0f && GetStatus() != STATUS_WRECKED){
if(bIsLawEnforcer && if(bIsLawEnforcer &&
FindPlayerVehicle() && FindPlayerVehicle() == m_pDamageEntity && FindPlayerVehicle() && FindPlayerVehicle() == m_pDamageEntity &&
GetStatus() != STATUS_ABANDONED && GetStatus() != STATUS_ABANDONED &&
FindPlayerVehicle()->m_vecMoveSpeed.Magnitude() >= m_vecMoveSpeed.Magnitude() && FindPlayerVehicle()->m_vecMoveSpeed.Magnitude() >= m_vecMoveSpeed.Magnitude() &&
FindPlayerVehicle()->m_vecMoveSpeed.Magnitude() > 0.1f) FindPlayerVehicle()->m_vecMoveSpeed.Magnitude() > 0.1f)
FindPlayerPed()->SetWantedLevelNoDrop(1); FindPlayerPed()->SetWantedLevelNoDrop(1);
@ -3276,6 +3276,7 @@ CAutomobile::VehicleDamage(float impulse, uint16 damagedPiece)
case CAR_PIECE_BONNET: case CAR_PIECE_BONNET:
GetComponentWorldPosition(CAR_BONNET, pos); GetComponentWorldPosition(CAR_BONNET, pos);
dmgDrawCarCollidingParticles(pos, impulse); dmgDrawCarCollidingParticles(pos, impulse);
if(GetModelIndex() != MI_DODO)
if(Damage.ApplyDamage(COMPONENT_DOOR_BONNET, impulse*impulseMult, pHandling->fCollisionDamageMultiplier)){ if(Damage.ApplyDamage(COMPONENT_DOOR_BONNET, impulse*impulseMult, pHandling->fCollisionDamageMultiplier)){
SetDoorDamage(CAR_BONNET, DOOR_BONNET); SetDoorDamage(CAR_BONNET, DOOR_BONNET);
doubleMoney = true; doubleMoney = true;
@ -3286,7 +3287,7 @@ CAutomobile::VehicleDamage(float impulse, uint16 damagedPiece)
case CAR_PIECE_BUMP_REAR: case CAR_PIECE_BUMP_REAR:
GetComponentWorldPosition(CAR_BUMP_REAR, pos); GetComponentWorldPosition(CAR_BUMP_REAR, pos);
dmgDrawCarCollidingParticles(pos, impulse); dmgDrawCarCollidingParticles(pos, impulse);
if(Damage.ApplyDamage(COMPONENT_BUMPER_FRONT, impulse*impulseMult, pHandling->fCollisionDamageMultiplier)){ if(Damage.ApplyDamage(COMPONENT_BUMPER_REAR, impulse*impulseMult, pHandling->fCollisionDamageMultiplier)){
SetBumperDamage(CAR_BUMP_REAR, VEHBUMPER_REAR); SetBumperDamage(CAR_BUMP_REAR, VEHBUMPER_REAR);
doubleMoney = true; doubleMoney = true;
} }
@ -3542,8 +3543,8 @@ CAutomobile::AddWheelDirtAndWater(CColPoint *colpoint, uint32 belowEffectSpeed)
int i; int i;
CVector dir; CVector dir;
static RwRGBA grassCol = { 8, 24, 8, 255 }; static RwRGBA grassCol = { 8, 24, 8, 255 };
static RwRGBA dirtCol = { 64, 64, 64, 255 }; static RwRGBA gravelCol = { 64, 64, 64, 255 };
static RwRGBA dirttrackCol = { 64, 32, 16, 255 }; static RwRGBA mudCol = { 64, 32, 16, 255 };
static RwRGBA waterCol = { 48, 48, 64, 0 }; static RwRGBA waterCol = { 48, 48, 64, 0 };
if(!belowEffectSpeed) if(!belowEffectSpeed)
@ -3565,7 +3566,7 @@ CAutomobile::AddWheelDirtAndWater(CColPoint *colpoint, uint32 belowEffectSpeed)
for(i = 0; i < 4; i++){ for(i = 0; i < 4; i++){
dir.z = CGeneral::GetRandomNumberInRange(0.03f, 0.06f); dir.z = CGeneral::GetRandomNumberInRange(0.03f, 0.06f);
CParticle::AddParticle(PARTICLE_WHEEL_DIRT, colpoint->point, dir, nil, CParticle::AddParticle(PARTICLE_WHEEL_DIRT, colpoint->point, dir, nil,
CGeneral::GetRandomNumberInRange(0.02f, 0.06f), dirtCol); CGeneral::GetRandomNumberInRange(0.02f, 0.06f), gravelCol);
} }
return 1; return 1;
case SURFACE_MUD_DRY: case SURFACE_MUD_DRY:
@ -3574,7 +3575,7 @@ CAutomobile::AddWheelDirtAndWater(CColPoint *colpoint, uint32 belowEffectSpeed)
for(i = 0; i < 4; i++){ for(i = 0; i < 4; i++){
dir.z = CGeneral::GetRandomNumberInRange(0.03f, 0.06f); dir.z = CGeneral::GetRandomNumberInRange(0.03f, 0.06f);
CParticle::AddParticle(PARTICLE_WHEEL_DIRT, colpoint->point, dir, nil, CParticle::AddParticle(PARTICLE_WHEEL_DIRT, colpoint->point, dir, nil,
CGeneral::GetRandomNumberInRange(0.02f, 0.06f), dirttrackCol); CGeneral::GetRandomNumberInRange(0.02f, 0.06f), mudCol);
} }
return 0; return 0;
default: default:
@ -4404,7 +4405,7 @@ CAutomobile::SpawnFlyingComponent(int32 component, uint32 type)
(component == COMPGROUP_BONNET || component == COMPGROUP_BOOT || component == CAR_WINDSCREEN)){ (component == COMPGROUP_BONNET || component == COMPGROUP_BOOT || component == CAR_WINDSCREEN)){
obj->m_vecMoveSpeed.z *= -1.5f; obj->m_vecMoveSpeed.z *= -1.5f;
obj->m_vecMoveSpeed.z += 0.04f; obj->m_vecMoveSpeed.z += 0.04f;
}else{ }else{p
obj->m_vecMoveSpeed.z *= 0.25f; obj->m_vecMoveSpeed.z *= 0.25f;
} }
obj->m_vecMoveSpeed.x *= 0.75f; obj->m_vecMoveSpeed.x *= 0.75f;
@ -4420,7 +4421,7 @@ CAutomobile::SpawnFlyingComponent(int32 component, uint32 type)
dist += GetUp(); dist += GetUp();
if(GetUp().z > 0.0f){ if(GetUp().z > 0.0f){
// simulate fast upward movement if going fast // simulate fast upward movement if going fast
float speed = CVector2D(m_vecMoveSpeed).MagnitudeSqr(); float speed = CVector2D(m_vecMoveSpeed).Magnitude();
obj->GetMatrix().Translate(GetUp()*speed); obj->GetMatrix().Translate(GetUp()*speed);
} }
} }
@ -4452,8 +4453,11 @@ CAutomobile::RemoveBonnetInPedCollision(void)
if(Damage.GetDoorStatus(DOOR_BONNET) == DOOR_STATUS_SWINGING && if(Damage.GetDoorStatus(DOOR_BONNET) == DOOR_STATUS_SWINGING &&
Doors[DOOR_BONNET].RetAngleWhenOpen()*0.4f < Doors[DOOR_BONNET].m_fAngle){ Doors[DOOR_BONNET].RetAngleWhenOpen()*0.4f < Doors[DOOR_BONNET].m_fAngle){
// BUG? why not COMPGROUP_BONNET? #ifdef FIX_BUGS
obj = SpawnFlyingComponent(CAR_BONNET, COMPGROUP_BONNET);
#else
obj = SpawnFlyingComponent(CAR_BONNET, COMPGROUP_DOOR); obj = SpawnFlyingComponent(CAR_BONNET, COMPGROUP_DOOR);
#endif
// make both doors invisible on car // make both doors invisible on car
SetComponentVisibility(m_aCarNodes[CAR_BONNET], ATOMIC_FLAG_NONE); SetComponentVisibility(m_aCarNodes[CAR_BONNET], ATOMIC_FLAG_NONE);
Damage.SetDoorStatus(DOOR_BONNET, DOOR_STATUS_MISSING); Damage.SetDoorStatus(DOOR_BONNET, DOOR_STATUS_MISSING);
@ -4514,13 +4518,16 @@ CAutomobile::SetDoorDamage(int32 component, eDoors door, bool noFlyingComponents
status = DOOR_STATUS_MISSING; status = DOOR_STATUS_MISSING;
} }
if(status == DOOR_STATUS_SMASHED){ switch(status){
case DOOR_STATUS_SMASHED:
// show damaged part // show damaged part
SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_DAM); SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_DAM);
}else if(status == DOOR_STATUS_SWINGING){ break;
case DOOR_STATUS_SWINGING:
// turn off angle cull for swinging doors // turn off angle cull for swinging doors
RwFrameForAllObjects(m_aCarNodes[component], CVehicleModelInfo::SetAtomicFlagCB, (void*)ATOMIC_FLAG_NOCULL); RwFrameForAllObjects(m_aCarNodes[component], CVehicleModelInfo::SetAtomicFlagCB, (void*)ATOMIC_FLAG_NOCULL);
}else if(status == DOOR_STATUS_MISSING){ break;
case DOOR_STATUS_MISSING:
if(!noFlyingComponents){ if(!noFlyingComponents){
if(door == DOOR_BONNET) if(door == DOOR_BONNET)
SpawnFlyingComponent(component, COMPGROUP_BONNET); SpawnFlyingComponent(component, COMPGROUP_BONNET);
@ -4531,6 +4538,7 @@ CAutomobile::SetDoorDamage(int32 component, eDoors door, bool noFlyingComponents
} }
// hide both // hide both
SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_NONE); SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_NONE);
break;
} }
} }

View File

@ -11,7 +11,7 @@ CDamageManager::CDamageManager(void)
{ {
ResetDamageStatus(); ResetDamageStatus();
m_fWheelDamageEffect = 0.75f; m_fWheelDamageEffect = 0.75f;
field_24 = 1; field_18 = 1;
} }
void void
@ -28,12 +28,8 @@ CDamageManager::FuckCarCompletely(void)
m_wheelStatus[0] = WHEEL_STATUS_MISSING; m_wheelStatus[0] = WHEEL_STATUS_MISSING;
// wheels 1-3 not reset? // wheels 1-3 not reset?
m_doorStatus[0] = DOOR_STATUS_MISSING; for(i = 0; i < ARRAY_SIZE(m_doorStatus); i++)
m_doorStatus[1] = DOOR_STATUS_MISSING; m_doorStatus[i] = DOOR_STATUS_MISSING;
m_doorStatus[2] = DOOR_STATUS_MISSING;
m_doorStatus[3] = DOOR_STATUS_MISSING;
m_doorStatus[4] = DOOR_STATUS_MISSING;
m_doorStatus[5] = DOOR_STATUS_MISSING;
for(i = 0; i < 3; i++){ for(i = 0; i < 3; i++){
#ifdef FIX_BUGS #ifdef FIX_BUGS

View File

@ -86,7 +86,7 @@ public:
uint8 m_doorStatus[6]; uint8 m_doorStatus[6];
uint32 m_lightStatus; uint32 m_lightStatus;
uint32 m_panelStatus; uint32 m_panelStatus;
uint32 field_24; uint8 field_18;
CDamageManager(void); CDamageManager(void);

View File

@ -780,7 +780,7 @@ CVehicle::ShufflePassengersToMakeSpace(void)
return false; return false;
if (pPassengers[1] && if (pPassengers[1] &&
!(m_nGettingInFlags & CAR_DOOR_FLAG_LR) && !(m_nGettingInFlags & CAR_DOOR_FLAG_LR) &&
IsRoomForPedToLeaveCar(COMPONENT_DOOR_REAR_LEFT, nil)) { IsRoomForPedToLeaveCar(CAR_DOOR_LR, nil)) {
if (!pPassengers[2] && !(m_nGettingInFlags & CAR_DOOR_FLAG_RR)) { if (!pPassengers[2] && !(m_nGettingInFlags & CAR_DOOR_FLAG_RR)) {
pPassengers[2] = pPassengers[1]; pPassengers[2] = pPassengers[1];
pPassengers[1] = nil; pPassengers[1] = nil;
@ -797,7 +797,7 @@ CVehicle::ShufflePassengersToMakeSpace(void)
} }
if (pPassengers[2] && if (pPassengers[2] &&
!(m_nGettingInFlags & CAR_DOOR_FLAG_RR) && !(m_nGettingInFlags & CAR_DOOR_FLAG_RR) &&
IsRoomForPedToLeaveCar(COMPONENT_DOOR_REAR_RIGHT, nil)) { IsRoomForPedToLeaveCar(CAR_DOOR_RR, nil)) {
if (!pPassengers[1] && !(m_nGettingInFlags & CAR_DOOR_FLAG_LR)) { if (!pPassengers[1] && !(m_nGettingInFlags & CAR_DOOR_FLAG_LR)) {
pPassengers[1] = pPassengers[2]; pPassengers[1] = pPassengers[2];
pPassengers[2] = nil; pPassengers[2] = nil;
@ -814,7 +814,7 @@ CVehicle::ShufflePassengersToMakeSpace(void)
} }
if (pPassengers[0] && if (pPassengers[0] &&
!(m_nGettingInFlags & CAR_DOOR_FLAG_RF) && !(m_nGettingInFlags & CAR_DOOR_FLAG_RF) &&
IsRoomForPedToLeaveCar(COMPONENT_DOOR_FRONT_RIGHT, nil)) { IsRoomForPedToLeaveCar(CAR_DOOR_RF, nil)) {
if (!pPassengers[1] && !(m_nGettingInFlags & CAR_DOOR_FLAG_LR)) { if (!pPassengers[1] && !(m_nGettingInFlags & CAR_DOOR_FLAG_LR)) {
pPassengers[1] = pPassengers[0]; pPassengers[1] = pPassengers[0];
pPassengers[0] = nil; pPassengers[0] = nil;
@ -1192,7 +1192,7 @@ CVehicle::ProcessCarAlarm(void)
{ {
uint32 step; uint32 step;
if(m_nAlarmState == 0 || m_nAlarmState == -1) if(!IsAlarmOn())
return; return;
step = CTimer::GetTimeStepInMilliseconds(); step = CTimer::GetTimeStepInMilliseconds();