diff --git a/SilentPatchSA/GeneralSA.cpp b/SilentPatchSA/GeneralSA.cpp index 3392c86..c49f778 100644 --- a/SilentPatchSA/GeneralSA.cpp +++ b/SilentPatchSA/GeneralSA.cpp @@ -23,6 +23,8 @@ static RwTexture*& ms_pRemapTexture = **AddressByVersion(0x59F1BD, auto SetEditableMaterialsCB = AddressByVersion(0x4C83E0, 0x4C8460, 0x4D2CE0); +void* (CEntity::*CEntity::orgGetColModel)(); + static void ResetEditableMaterials(std::pair* pData) { for ( auto* i = pData; i->first != nullptr; i++ ) diff --git a/SilentPatchSA/GeneralSA.h b/SilentPatchSA/GeneralSA.h index f08801a..4fc1dc4 100644 --- a/SilentPatchSA/GeneralSA.h +++ b/SilentPatchSA/GeneralSA.h @@ -196,9 +196,14 @@ public: uint8_t nStatus : 5; // control status // 0x36 //********* END CEntityInfo ************// +public: + static void* (CEntity::*orgGetColModel)(); + public: uint8_t GetStatus() const { return nStatus; } + void* GetColModel() { return std::invoke(orgGetColModel, this); } + bool IsVisible(); void SetPositionAndAreaCode( CVector position ); diff --git a/SilentPatchSA/PedSA.cpp b/SilentPatchSA/PedSA.cpp index 84f20ee..3fc9350 100644 --- a/SilentPatchSA/PedSA.cpp +++ b/SilentPatchSA/PedSA.cpp @@ -7,6 +7,9 @@ WRAPPER unsigned char CPed::GetWeaponSkill() { VARJMP(varGetWeaponSkill); } static void* varSetGunFlashAlpha = AddressByVersion(0x5DF400, 0x5DFC20, 0x5FC120); WRAPPER void CPed::SetGunFlashAlpha(bool bSecondWeapon) { WRAPARG(bSecondWeapon); VARJMP(varSetGunFlashAlpha); } +static void* varSay = AddressByVersion(0x5EFFE0, 0, 0); // TODO: Do +WRAPPER void CPed::Say(uint16_t phrase, uint32_t param2, float volume, bool param4, bool param5, bool param6) { VARJMP(varSay); } + static void* varGetTaskJetPack = AddressByVersion(0x601110, 0x601930, 0x620E70); WRAPPER CTaskSimpleJetPack* CPedIntelligence::GetTaskJetPack() const { VARJMP(varGetTaskJetPack); } diff --git a/SilentPatchSA/PedSA.h b/SilentPatchSA/PedSA.h index 94079bb..2bb79fb 100644 --- a/SilentPatchSA/PedSA.h +++ b/SilentPatchSA/PedSA.h @@ -312,6 +312,7 @@ public: unsigned char GetWeaponSkill(); void ResetGunFlashAlpha(); void SetGunFlashAlpha(bool bSecondWeapon); + void Say(uint16_t phrase, uint32_t param2 = 0, float volume = 1.0f, bool param4 = false, bool param5 = false, bool param6 = false); void RenderWeapon(bool bMuzzleFlash, bool bForShadow); void RenderForShadow(); diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index b6a4a3f..c606f3a 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -3701,6 +3701,11 @@ void Patch_SA_10() // Tug tow bar (misc_b instead of misc_a Nop( 0x6AF2CC, 1 ); InjectHook( 0x6AF2CC + 1, &CAutomobile::GetTowBarFrame, PATCH_CALL ); + + + // Play passenger's voice lines when killing peds with car, not only when hitting them damages player's vehicle + ReadCall( 0x5F05CA, CEntity::orgGetColModel ); + InjectHook( 0x5F05CA, &CVehicle::PlayPedHitSample_GetColModel ); } void Patch_SA_11() diff --git a/SilentPatchSA/VehicleSA.cpp b/SilentPatchSA/VehicleSA.cpp index 3fcc9ba..363c981 100644 --- a/SilentPatchSA/VehicleSA.cpp +++ b/SilentPatchSA/VehicleSA.cpp @@ -345,6 +345,21 @@ bool CVehicle::HasFirelaLadder() const return SVF::ModelHasFeature( m_nModelIndex.Get(), SVF::Feature::FIRELA_LADDER ); } +void* CVehicle::PlayPedHitSample_GetColModel() +{ + if ( this == FindPlayerVehicle() ) + { + CPed *pPassenger = PickRandomPassenger(); + if ( pPassenger != nullptr ) + { + constexpr uint16_t CONTEXT_GLOBAL_CAR_HIT_PED = 36; + pPassenger->Say( CONTEXT_GLOBAL_CAR_HIT_PED ); + } + } + + return GetColModel(); +} + void CVehicle::SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha) { RpGeometry* pGeometry = RpAtomicGetGeometry(pAtomic); @@ -421,6 +436,18 @@ void CVehicle::SetComponentRotation( RwFrame* component, eRotAxis axis, float an matrix.UpdateRW(); } +CPed* CVehicle::PickRandomPassenger() +{ + const unsigned int randomNum = static_cast((static_cast(rand()) / RAND_MAX) * 8.0); + for ( size_t i = 0; i < 8; i++ ) + { + const size_t index = (i + randomNum) % 8; + if ( m_apPassengers[index] != nullptr ) return m_apPassengers[index]; + } + + return nullptr; +} + void CHeli::Render() { double dRotorsSpeed, dMovingRotorSpeed; diff --git a/SilentPatchSA/VehicleSA.h b/SilentPatchSA/VehicleSA.h index c60d1a5..b22ffd7 100644 --- a/SilentPatchSA/VehicleSA.h +++ b/SilentPatchSA/VehicleSA.h @@ -261,8 +261,10 @@ public: //void CustomCarPlate_AfterRenderingStop(CVehicleModelInfo* pModelInfo); bool HasFirelaLadder() const; + void* PlayPedHitSample_GetColModel(); bool IsLawEnforcementVehicle(); + CPed* PickRandomPassenger(); static void SetComponentRotation( RwFrame* component, eRotAxis axis, float angle, bool absolute = true ); static void SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha);