summaryrefslogtreecommitdiffstats
path: root/src/vehicles
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/vehicles/Boat.cpp63
-rw-r--r--src/vehicles/Boat.h44
2 files changed, 105 insertions, 2 deletions
diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp
index 076a910e..9b462971 100644
--- a/src/vehicles/Boat.cpp
+++ b/src/vehicles/Boat.cpp
@@ -2,6 +2,17 @@
#include "patcher.h"
#include "Boat.h"
+float &fShapeLength = *(float*)0x600E78;
+float &fShapeTime = *(float*)0x600E7C;
+float &fRangeMult = *(float*)0x600E80; //0.6f; // 0.75f gta 3
+float &fTimeMult = *(float*)0xA0FCF4;
+
+float MAX_WAKE_LENGTH = 50.0f;
+float MIN_WAKE_INTERVAL = 1.0f;
+float WAKE_LIFETIME = 400.0f;
+
+CBoat * (&CBoat::apFrameWakeGeneratingBoats)[4] = *(CBoat * (*)[4])*(uintptr*)0x8620E0;
+
CBoat::CBoat(int mi, uint8 owner)
{
ctor(mi, owner);
@@ -9,6 +20,58 @@ CBoat::CBoat(int mi, uint8 owner)
WRAPPER CBoat* CBoat::ctor(int, uint8) { EAXJMP(0x53E3E0); }
+
+bool CBoat::IsSectorAffectedByWake(CVector2D sector, float fSize, CBoat **apBoats)
+{
+ uint8 numVerts = 0;
+
+ if ( apFrameWakeGeneratingBoats[0] == NULL )
+ return false;
+
+ for ( int32 i = 0; i < 4; i++ )
+ {
+ CBoat *pBoat = apFrameWakeGeneratingBoats[i];
+ if ( !pBoat )
+ break;
+
+ for ( int j = 0; j < pBoat->m_nNumWakePoints; j++ )
+ {
+ float fDist = (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[j]) * fShapeTime + float(j) * fShapeLength + fSize;
+
+ if ( fabs(pBoat->m_avec2dWakePoints[j].x - sector.x) < fDist
+ && fabs(pBoat->m_avec2dWakePoints[i].y - sector.y) < fDist )
+ {
+ apBoats[numVerts] = pBoat;
+ numVerts = 1; // += ?
+ break;
+ }
+ }
+ }
+
+ return numVerts != 0;
+}
+
+float CBoat::IsVertexAffectedByWake(CVector vecVertex, CBoat *pBoat)
+{
+ for ( int i = 0; i < pBoat->m_nNumWakePoints; i++ )
+ {
+ float fMaxDist = (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[i]) * fShapeTime + float(i) * fShapeLength;
+
+ float fX = pBoat->m_avec2dWakePoints[i].x - vecVertex.x;
+ float fY = pBoat->m_avec2dWakePoints[i].y - vecVertex.y;
+
+ float fDist = fY * fY + fX * fX;
+
+ if ( fDist < SQR(fMaxDist) )
+ return 1.0f - min(fRangeMult * sqrt(fDist / SQR(fMaxDist)) + (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[i]) * fTimeMult, 1.0f);
+ }
+
+ return 0.0f;
+}
+
+WRAPPER void CBoat::FillBoatList(void) { EAXJMP(0x542250); }
+
+
STARTPATCHES
InjectHook(0x53E790, &CBoat::dtor, PATCH_JUMP);
ENDPATCHES \ No newline at end of file
diff --git a/src/vehicles/Boat.h b/src/vehicles/Boat.h
index 6d6482a4..41fed2ff 100644
--- a/src/vehicles/Boat.h
+++ b/src/vehicles/Boat.h
@@ -6,12 +6,52 @@ class CBoat : public CVehicle
{
public:
// 0x288
- uint8 stuff1[57];
+ float field_288;
+ float field_28C;
+ float field_290;
+ float field_294;
+ float field_298;
+ float field_29C;
+ float field_2A0;
+ float field_2A4;
+ float m_fMovingHiRotation;
+ int32 _unk0;
+ RwFrame *m_aBoatNodes[4];
+ uint8 m_nBoatFlags;
bool m_bIsAnchored;
- uint8 stuff[450];
+ char _pad0[2];
+ float field_2C4;
+ int32 _unk1;
+ float field_2CC;
+ CEntity *field_2D0;
+ bool _unk2;
+ char _pad1[3];
+ float m_fAccelerate;
+ float m_fBrake;
+ float m_fSteeringLeftRight;
+ uint8 m_nPadID;
+ char _pad2[3];
+ int32 _unk3;
+ float m_fTurnForceZ;
+ CVector m_vecMoveForce;
+ float field_2FC;
+ uint16 field_300;
+ uint16 m_nNumWakePoints;
+ CVector2D m_avec2dWakePoints[32];
+ float m_afWakePointLifeTime[32];
CBoat(int, uint8);
CBoat* ctor(int, uint8);
void dtor() { this->CBoat::~CBoat(); };
+
+ static CBoat *(&apFrameWakeGeneratingBoats)[4];
+
+ static bool IsSectorAffectedByWake(CVector2D sector, float fSize, CBoat **apBoats);
+ static float IsVertexAffectedByWake(CVector vecVertex, CBoat *pBoat);
+ static void FillBoatList(void);
};
static_assert(sizeof(CBoat) == 0x484, "CBoat: error");
+
+extern float MAX_WAKE_LENGTH;
+extern float MIN_WAKE_INTERVAL;
+extern float WAKE_LIFETIME; \ No newline at end of file