Animated Phoenix hood scoop

This commit is contained in:
Silent 2017-06-23 00:11:17 +02:00
parent ebd4732411
commit 9236463f88
5 changed files with 72 additions and 4 deletions

View File

@ -3423,6 +3423,16 @@ void Patch_SA_10()
// Properly initialize all CVehicleModelInfo fields // Properly initialize all CVehicleModelInfo fields
ReadCall( 0x4C75E4, orgVehicleModelInfoCtor ); ReadCall( 0x4C75E4, orgVehicleModelInfoCtor );
InjectHook( 0x4C75E4, VehicleModelInfoCtor ); InjectHook( 0x4C75E4, VehicleModelInfoCtor );
// Animated Phoenix hood scoop
auto* automobilePreRender = &(*(decltype(CAutomobile::orgPreRender)**)(0x6B0AD2 + 2))[17];
CAutomobile::orgPreRender = *automobilePreRender;
Patch(automobilePreRender, &CAutomobile::PreRender_Stub);
InjectHook(0x6C7E7A, &CAutomobile::PreRender_Stub);
InjectHook(0x6CEAEC, &CAutomobile::PreRender_Stub);
InjectHook(0x6CFADC, &CAutomobile::PreRender_Stub);
} }
void Patch_SA_11() void Patch_SA_11()

View File

@ -2,3 +2,4 @@
#include "TimerSA.h" #include "TimerSA.h"
int& CTimer::m_snTimeInMilliseconds = **AddressByVersion<int**>(0x4242D1, 0x53F6A1, 0x406FA1); int& CTimer::m_snTimeInMilliseconds = **AddressByVersion<int**>(0x4242D1, 0x53F6A1, 0x406FA1);
float& CTimer::m_fTimeStep = **AddressByVersion<float**>(0x41DE4F + 2, 0, 0);

View File

@ -5,6 +5,7 @@ class CTimer
{ {
public: public:
static int& m_snTimeInMilliseconds; static int& m_snTimeInMilliseconds;
static float& m_fTimeStep;
}; };
#endif #endif

View File

@ -18,6 +18,10 @@ static void* varVehicleRender = AddressByVersion<void*>(0x6D0E60, 0x6D1680, 0x70
WRAPPER void CVehicle::Render() { VARJMP(varVehicleRender); } WRAPPER void CVehicle::Render() { VARJMP(varVehicleRender); }
static void* varIsLawEnforcementVehicle = AddressByVersion<void*>(0x6D2370, 0x6D2BA0, 0x70D8C0); static void* varIsLawEnforcementVehicle = AddressByVersion<void*>(0x6D2370, 0x6D2BA0, 0x70D8C0);
WRAPPER bool CVehicle::IsLawEnforcementVehicle() { VARJMP(varIsLawEnforcementVehicle); } WRAPPER bool CVehicle::IsLawEnforcementVehicle() { VARJMP(varIsLawEnforcementVehicle); }
static void* varSetComponentRotation = AddressByVersion<void*>(0x6DBA30, 0, 0);
WRAPPER void CVehicle::SetComponentRotation( RwFrame* component, int axis, float angle, bool absolute ) { VARJMP(varSetComponentRotation); }
void (CAutomobile::*CAutomobile::orgPreRender)();
static int32_t random(int32_t from, int32_t to) static int32_t random(int32_t from, int32_t to)
{ {
@ -250,6 +254,16 @@ void CPlane::Fix_SilentPatch()
} }
} }
void CAutomobile::PreRender()
{
(this->*(orgPreRender))();
if ( FLAUtils::GetExtendedID( &m_nModelIndex ) == 603 )
{
ProcessPhoenixBlower();
}
}
void CAutomobile::Fix_SilentPatch() void CAutomobile::Fix_SilentPatch()
{ {
ResetFrames(); ResetFrames();
@ -285,3 +299,30 @@ void CAutomobile::ResetFrames()
} }
} }
} }
void CAutomobile::ProcessPhoenixBlower()
{
if ( m_pCarNode[20] == nullptr ) return;
float finalAngle = 0.0f;
if ( m_fGasPedal > 0.0f )
{
if ( m_fSpecialComponentAngle < 1.3f )
{
finalAngle = m_fSpecialComponentAngle = std::min( m_fSpecialComponentAngle + 0.1f * CTimer::m_fTimeStep, 1.3f );
}
else
{
finalAngle = m_fSpecialComponentAngle + (std::sin( (CTimer::m_snTimeInMilliseconds % 10000) / 70.0f ) * 0.13f);
}
}
else
{
if ( m_fSpecialComponentAngle > 0.0f )
{
finalAngle = m_fSpecialComponentAngle = std::max( m_fSpecialComponentAngle - 0.05f * CTimer::m_fTimeStep, 0.0f );
}
}
SetComponentRotation( m_pCarNode[20], 0, finalAngle, true );
}

View File

@ -117,7 +117,10 @@ class NOVMT CVehicle : public CPhysical
protected: protected:
BYTE __pad1[752]; BYTE __pad1[752];
CVehicleFlags m_nVehicleFlags; CVehicleFlags m_nVehicleFlags;
BYTE __pad2[160]; BYTE __pad2[108];
float m_fGasPedal;
float m_fBrakePedal;
BYTE __pad6[44];
signed int m_nTimeTillWeNeedThisCar; signed int m_nTimeTillWeNeedThisCar;
BYTE __pad4[56]; BYTE __pad4[56];
CEntity* pDamagingEntity; CEntity* pDamagingEntity;
@ -134,12 +137,14 @@ public:
{ return pDamagingEntity; } { return pDamagingEntity; }
virtual void Render() override; virtual void Render() override;
virtual void PreRender() override;
bool CustomCarPlate_TextureCreate(CVehicleModelInfo* pModelInfo); bool CustomCarPlate_TextureCreate(CVehicleModelInfo* pModelInfo);
void CustomCarPlate_BeforeRenderingStart(CVehicleModelInfo* pModelInfo); void CustomCarPlate_BeforeRenderingStart(CVehicleModelInfo* pModelInfo);
//void CustomCarPlate_AfterRenderingStop(CVehicleModelInfo* pModelInfo); //void CustomCarPlate_AfterRenderingStop(CVehicleModelInfo* pModelInfo);
bool IsLawEnforcementVehicle(); bool IsLawEnforcementVehicle();
void SetComponentRotation( RwFrame* component, int axis, float angle, bool absolute );
static void SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha); static void SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha);
}; };
@ -152,12 +157,22 @@ public:
CBouncingPanel m_aBouncingPanel[3]; CBouncingPanel m_aBouncingPanel[3];
BYTE padding[320]; BYTE padding[320];
float m_fRotorSpeed; float m_fRotorSpeed;
BYTE __moarpad[312]; BYTE __moarpad[264];
float m_fSpecialComponentAngle;
BYTE __pad3[44];
public: public:
inline void PreRender_Stub()
{ CAutomobile::PreRender(); }
virtual void PreRender() override;
void Fix_SilentPatch(); void Fix_SilentPatch();
void ResetFrames(); void ResetFrames();
void ProcessPhoenixBlower();
static void (CAutomobile::*orgPreRender)();
}; };
class NOVMT CHeli : public CAutomobile class NOVMT CHeli : public CAutomobile