diff --git a/src/objects/Stinger.cpp b/src/objects/Stinger.cpp index d0e6919f..7996db00 100644 --- a/src/objects/Stinger.cpp +++ b/src/objects/Stinger.cpp @@ -51,6 +51,7 @@ CStinger::Init(CPed *pPed) } bIsDeployed = true; m_vPos = pPed->GetPosition(); + m_vPos.z -= 1.0f; m_fMax_Z = Atan2(-pPed->GetForward().x, pPed->GetForward().y) + HALFPI; for (i = 0; i < NUM_STINGER_SEGMENTS; i++) { @@ -61,7 +62,7 @@ CStinger::Init(CPed *pPed) CVector2D fwd2d(pPed->GetForward().x, pPed->GetForward().y); for (i = 0; i < ARRAY_SIZE(m_vPositions); i++) - m_vPositions[i] = fwd2d * Sin(DEGTORAD(i)); + m_vPositions[i] = fwd2d * 1.8f * Sin(DEGTORAD(i)); m_nSpikeState = STINGERSTATE_NONE; m_nTimeOfDeploy = CTimer::GetTimeInMilliseconds(); diff --git a/src/objects/Stinger.h b/src/objects/Stinger.h index d1b57ce7..250cf62d 100644 --- a/src/objects/Stinger.h +++ b/src/objects/Stinger.h @@ -11,16 +11,17 @@ public: #define NUM_STINGER_SEGMENTS (12) +enum { + STINGERSTATE_NONE = 0, + STINGERSTATE_DEPLOYING, + STINGERSTATE_DEPLOYED, + STINGERSTATE_UNDEPLOYING, + STINGERSTATE_REMOVE, +}; + class CStinger { - enum { - STINGERSTATE_NONE = 0, - STINGERSTATE_DEPLOYING, - STINGERSTATE_DEPLOYED, - STINGERSTATE_UNDEPLOYING, - STINGERSTATE_REMOVE, - }; - +public: bool bIsDeployed; uint32 m_nTimeOfDeploy; CVector m_vPos; @@ -30,7 +31,6 @@ class CStinger CStingerSegment *pSpikes[NUM_STINGER_SEGMENTS]; class CPed *pOwner; uint8 m_nSpikeState; -public: CStinger(); void Init(CPed *pPed); void Remove(); diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp index 8dd517a2..9160319b 100644 --- a/src/peds/CopPed.cpp +++ b/src/peds/CopPed.cpp @@ -95,7 +95,7 @@ CCopPed::CCopPed(eCopType copType, int32 modifier) : CPed(PEDTYPE_COP) field_624 = 0; m_pStinger = new CStinger; if (m_pPointGunAt) - m_pPointGunAt->CleanUpOldReference((CEntity**)&m_pPointGunAt); + m_pPointGunAt->CleanUpOldReference(&m_pPointGunAt); m_pPointGunAt = nil; } @@ -601,7 +601,7 @@ CCopPed::CopAI(void) } } -// --MIAMI: Done except commented things +// --MIAMI: Done void CCopPed::ProcessControl(void) { @@ -611,15 +611,13 @@ CCopPed::ProcessControl(void) CPed::ProcessControl(); if (m_bThrowsSpikeTrap) { - // TODO(Miami) - /* if (CGame::currArea != AREA_MALL) ProcessStingerCop(); - */ return; } - // TODO(Miami): CStinger::Process + if (m_pStinger && m_pStinger->bIsDeployed && m_pStinger->m_nSpikeState == STINGERSTATE_DEPLOYED && CGame::currArea != AREA_MALL) + m_pStinger->Process(); if (bWasPostponed) return; @@ -858,4 +856,36 @@ CCopPed::ProcessHeliSwat(void) SetInTheAir(); bKnockedUpIntoAir = true; } +} + +// --MIAMI: Done +void +CCopPed::ProcessStingerCop(void) +{ + if (m_pStinger->bIsDeployed || FindPlayerVehicle() && (FindPlayerVehicle()->IsCar() || FindPlayerVehicle()->IsBike())) { + if (m_pStinger->bIsDeployed) { + m_pStinger->Process(); + } else { + CVector2D vehDist = GetPosition() - FindPlayerVehicle()->GetPosition(); + CVector2D dirVehGoing = FindPlayerVehicle()->m_vecMoveSpeed; + if (vehDist.MagnitudeSqr() < sq(30.0f)) { + if (dirVehGoing.MagnitudeSqr() > 0.0f) { + vehDist.Normalise(); + dirVehGoing.Normalise(); + if (DotProduct2D(vehDist, dirVehGoing) > 0.8f) { + float angle = (CrossProduct2D(vehDist, dirVehGoing - vehDist) < 0.0f ? + FindPlayerVehicle()->GetForward().Heading() - HALFPI : + HALFPI + FindPlayerVehicle()->GetForward().Heading()); + + SetHeading(angle); + m_fRotationCur = angle; + m_fRotationDest = angle; + m_pStinger->Deploy(this); + } + } + } + } + } else { + ClearPursuit(); + } } \ No newline at end of file diff --git a/src/peds/CopPed.h b/src/peds/CopPed.h index 35244bed..190d619e 100644 --- a/src/peds/CopPed.h +++ b/src/peds/CopPed.h @@ -45,6 +45,7 @@ public: void ScanForCrimes(void); void CopAI(void); void ProcessHeliSwat(void); + void ProcessStingerCop(void); }; #ifndef PED_SKIN