Stinger fixes

This commit is contained in:
Sergeanur 2020-09-02 20:55:28 +03:00
parent 16e10d788a
commit fa7334c74f

View File

@ -101,7 +101,7 @@ CStinger::CheckForBurstTyres()
const CVector firstPos = pSpikes[0]->GetPosition(); const CVector firstPos = pSpikes[0]->GetPosition();
const CVector lastPos = pSpikes[NUM_STINGER_SEGMENTS - 1]->GetPosition(); const CVector lastPos = pSpikes[NUM_STINGER_SEGMENTS - 1]->GetPosition();
float dist = (lastPos - firstPos).Magnitude(); float dist = (lastPos - firstPos).Magnitude();
if (dist > 0.1f) return; if (dist < 0.1f) return;
CVehicle *vehsInRange[16]; CVehicle *vehsInRange[16];
int16 numObjects; int16 numObjects;
@ -122,41 +122,38 @@ CStinger::CheckForBurstTyres()
if (pAutomobile == nil && pBike == nil) continue; if (pAutomobile == nil && pBike == nil) continue;
int wheelId = 0; float maxWheelDistToSpike = sq(((CVehicleModelInfo*)CModelInfo::GetModelInfo(vehsInRange[i]->GetModelIndex()))->m_wheelScale + 0.1f);
float wheelScaleSq = sq(((CVehicleModelInfo*)CModelInfo::GetModelInfo(vehsInRange[i]->GetModelIndex()))->m_wheelScale);
for (; wheelId < 4; wheelId++) { for (int wheelId = 0; wheelId < 4; wheelId++) {
if ((pAutomobile != nil && pAutomobile->m_aSuspensionSpringRatioPrev[wheelId] < 1.0f) || if ((pAutomobile != nil && pAutomobile->m_aSuspensionSpringRatioPrev[wheelId] < 1.0f) ||
(pBike != nil && pBike->m_aSuspensionSpringRatioPrev[wheelId] < 1.0f)) (pBike != nil && pBike->m_aSuspensionSpringRatioPrev[wheelId] < 1.0f)) {
break; CVector vecWheelPos;
} if (pAutomobile != nil)
vecWheelPos = pAutomobile->m_aWheelColPoints[wheelId].point;
else if (pBike != nil)
vecWheelPos = pBike->m_aWheelColPoints[wheelId].point;
if (wheelId >= 4) continue; for (int32 spike = 0; spike < NUM_STINGER_SEGMENTS; spike++) {
if ((pSpikes[spike]->GetPosition() - vecWheelPos).Magnitude() < maxWheelDistToSpike) {
CVector vecWheelPos; if (pBike) {
if (pAutomobile != nil) if (wheelId < 2)
vecWheelPos = pAutomobile->m_aWheelColPoints[wheelId].point; vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_LF, true);
else if (pBike != nil) else
vecWheelPos = pBike->m_aWheelColPoints[wheelId].point; vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_LR, true);
}
for (int32 spike = 0; spike < NUM_STINGER_SEGMENTS; spike++) { else {
if ((pSpikes[spike]->GetPosition() - vecWheelPos).Magnitude() < wheelScaleSq) { switch (wheelId) {
if (pBike) { case 0: vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_LF, true); break;
if (wheelId < 2) case 1: vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_LR, true); break;
vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_LF, true); case 2: vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_RF, true); break;
else case 3: vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_RR, true); break;
vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_LR, true); }
} else { }
switch (wheelId) { vecWheelPos.z += 0.15f;
case 0: vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_LF, true); break; for (int j = 0; j < 4; j++)
case 1: vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_LR, true); break; CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, vecWheelPos, vehsInRange[i]->GetRight() * 0.1f);
case 2: vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_RF, true); break;
case 3: vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_RR, true); break;
} }
} }
vecWheelPos.z += 0.15f; // BUG? doesn't that break the burst of other tires?
for (int j = 0; j < 4; j++)
CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, vecWheelPos, vehsInRange[i]->GetRight() * 0.1f);
} }
} }
} }