summaryrefslogtreecommitdiffstats
path: root/src/vehicles/Boat.cpp
diff options
context:
space:
mode:
authorFire-Head <Fire-Head@users.noreply.github.com>2019-07-11 02:22:01 +0200
committerFire-Head <Fire-Head@users.noreply.github.com>2019-07-11 02:22:01 +0200
commita644c4e9ceb440f53e31dd39f11a9a3c859ffb44 (patch)
tree8c94be03df7ea2887212e244860a83795a4b21c4 /src/vehicles/Boat.cpp
parentthe great reorganization (diff)
downloadre3-a644c4e9ceb440f53e31dd39f11a9a3c859ffb44.tar
re3-a644c4e9ceb440f53e31dd39f11a9a3c859ffb44.tar.gz
re3-a644c4e9ceb440f53e31dd39f11a9a3c859ffb44.tar.bz2
re3-a644c4e9ceb440f53e31dd39f11a9a3c859ffb44.tar.lz
re3-a644c4e9ceb440f53e31dd39f11a9a3c859ffb44.tar.xz
re3-a644c4e9ceb440f53e31dd39f11a9a3c859ffb44.tar.zst
re3-a644c4e9ceb440f53e31dd39f11a9a3c859ffb44.zip
Diffstat (limited to '')
-rw-r--r--src/vehicles/Boat.cpp63
1 files changed, 63 insertions, 0 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