From 2c8961c0d1f2575692336bc68427534b77329d27 Mon Sep 17 00:00:00 2001 From: Silent Date: Tue, 27 Jul 2021 22:17:10 +0200 Subject: [PATCH] Add wind animations when driving a Quadbike Contributed by Wesser --- SilentPatchSA/SilentPatchSA.cpp | 17 +++++++++++++++++ SilentPatchSA/VehicleSA.cpp | 5 +++++ SilentPatchSA/VehicleSA.h | 4 +++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index a715d74..ee11305 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -4295,6 +4295,12 @@ void Patch_SA_10() Patch( 0x5593E4 + 1, "%.0fkgs" ); + // Add wind animations when driving a Quadbike + // By Wesser + InjectHook(0x5E69BC, &CVehicle::IsOpenTopCarOrQuadbike, PATCH_CALL); + Nop(0x5E69BC + 5, 3); + + #if FULL_PRECISION_D3D // Test - full precision D3D device Patch( 0x7F672B+1, *(uint8_t*)(0x7F672B+1) | D3DCREATE_FPU_PRESERVE ); @@ -5797,6 +5803,17 @@ void Patch_SA_NewBinaries_Common() ReadCall( getPad, orgGetPad ); InjectHook( getPad, getPadAndSetFlag ); } + + + // Add wind animations when driving a Quadbike + // By Wesser + { + auto isOpenTopCar = pattern("8B 11 8B 82 9C 00 00 00 FF D0").get_one(); + + InjectHook(isOpenTopCar.get(), &CVehicle::IsOpenTopCarOrQuadbike, PATCH_CALL); + Nop(isOpenTopCar.get(5), 5); + + } } diff --git a/SilentPatchSA/VehicleSA.cpp b/SilentPatchSA/VehicleSA.cpp index 476436c..70f4e70 100644 --- a/SilentPatchSA/VehicleSA.cpp +++ b/SilentPatchSA/VehicleSA.cpp @@ -101,6 +101,11 @@ bool CVehicle::IgnoresRotorFix() const return SVF::ModelHasFeature( m_nModelIndex.Get(), SVF::Feature::_INTERNAL_NO_ROTOR_FADE ); } +bool CVehicle::IsOpenTopCarOrQuadbike() const +{ + return IsOpenTopCar() || m_dwVehicleSubClass == VEHICLE_QUAD; +} + static void* varVehicleRender = AddressByVersion(0x6D0E60, 0x6D1680, 0x70C0B0); WRAPPER void CVehicle::Render() { VARJMP(varVehicleRender); } static void* varIsLawEnforcementVehicle = AddressByVersion(0x6D2370, 0x6D2BA0, 0x70D8C0); diff --git a/SilentPatchSA/VehicleSA.h b/SilentPatchSA/VehicleSA.h index 6f2c770..7fe9074 100644 --- a/SilentPatchSA/VehicleSA.h +++ b/SilentPatchSA/VehicleSA.h @@ -221,7 +221,7 @@ public: virtual bool IsDoorMissing(unsigned int door); virtual bool IsDoorMissing(eDoors door); // check if car has roof as extra - virtual bool IsOpenTopCar(); + virtual bool IsOpenTopCar() const; // remove ref to this entity virtual void RemoveRefsToVehicle(CEntity* entity); virtual void BlowUpCar(CEntity* damager, unsigned char bHideExplosion); @@ -279,6 +279,8 @@ public: bool IgnoresLightbeamFix() const; bool IgnoresRotorFix() const; + bool IsOpenTopCarOrQuadbike() const; + void DoHeadLightBeam( int type, CMatrix& m, bool right ) { std::invoke( orgDoHeadLightBeam, this, type, m, right );