re3/src/vehicles/Boat.cpp

81 lines
2 KiB
C++
Raw Normal View History

#include "common.h"
#include "patcher.h"
#include "Boat.h"
2019-07-11 00:22:01 +00:00
float &fShapeLength = *(float*)0x600E78;
float &fShapeTime = *(float*)0x600E7C;
float &fRangeMult = *(float*)0x600E80; //0.6f; // 0.75f gta 3
2019-07-25 20:34:29 +00:00
float &fTimeMult = *(float*)0x943008;
2019-07-11 00:22:01 +00:00
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);
}
WRAPPER CBoat* CBoat::ctor(int, uint8) { EAXJMP(0x53E3E0); }
2019-07-11 00:22:01 +00:00
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;
2019-07-24 17:30:09 +00:00
if ( Abs(pBoat->m_avec2dWakePoints[j].x - sector.x) < fDist
&& Abs(pBoat->m_avec2dWakePoints[i].y - sector.y) < fDist )
2019-07-11 00:22:01 +00:00
{
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;
2019-07-24 17:30:09 +00:00
CVector2D vecDist = pBoat->m_avec2dWakePoints[i] - CVector2D(vecVertex);
2019-07-11 00:22:01 +00:00
2019-07-24 17:30:09 +00:00
float fDist = vecDist.MagnitudeSqr();
2019-07-11 00:22:01 +00:00
if ( fDist < SQR(fMaxDist) )
2019-07-24 17:30:09 +00:00
return 1.0f - min(fRangeMult * Sqrt(fDist / SQR(fMaxDist)) + (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[i]) * fTimeMult, 1.0f);
2019-07-11 00:22:01 +00:00
}
return 0.0f;
}
WRAPPER void CBoat::FillBoatList(void) { EAXJMP(0x542250); }
class CBoat_ : public CBoat
{
public:
void dtor() { CBoat::~CBoat(); };
};
2019-07-11 00:22:01 +00:00
STARTPATCHES
InjectHook(0x53E790, &CBoat_::dtor, PATCH_JUMP);
ENDPATCHES