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,17 +122,11 @@ 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;
}
if (wheelId >= 4) continue;
CVector vecWheelPos; CVector vecWheelPos;
if (pAutomobile != nil) if (pAutomobile != nil)
vecWheelPos = pAutomobile->m_aWheelColPoints[wheelId].point; vecWheelPos = pAutomobile->m_aWheelColPoints[wheelId].point;
@ -140,13 +134,14 @@ CStinger::CheckForBurstTyres()
vecWheelPos = pBike->m_aWheelColPoints[wheelId].point; vecWheelPos = pBike->m_aWheelColPoints[wheelId].point;
for (int32 spike = 0; spike < NUM_STINGER_SEGMENTS; spike++) { for (int32 spike = 0; spike < NUM_STINGER_SEGMENTS; spike++) {
if ((pSpikes[spike]->GetPosition() - vecWheelPos).Magnitude() < wheelScaleSq) { if ((pSpikes[spike]->GetPosition() - vecWheelPos).Magnitude() < maxWheelDistToSpike) {
if (pBike) { if (pBike) {
if (wheelId < 2) if (wheelId < 2)
vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_LF, true); vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_LF, true);
else else
vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_LR, true); vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_LR, true);
} else { }
else {
switch (wheelId) { switch (wheelId) {
case 0: vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_LF, true); break; case 0: vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_LF, true); break;
case 1: vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_LR, true); break; case 1: vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_LR, true); break;
@ -154,12 +149,14 @@ CStinger::CheckForBurstTyres()
case 3: vehsInRange[i]->BurstTyre(CAR_PIECE_WHEEL_RR, 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? vecWheelPos.z += 0.15f;
for (int j = 0; j < 4; j++) for (int j = 0; j < 4; j++)
CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, vecWheelPos, vehsInRange[i]->GetRight() * 0.1f); CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, vecWheelPos, vehsInRange[i]->GetRight() * 0.1f);
} }
} }
} }
}
}
} }
void void