diff --git a/SilentPatchSA/PedSA.cpp b/SilentPatchSA/PedSA.cpp index 4c66eff..c8e12da 100644 --- a/SilentPatchSA/PedSA.cpp +++ b/SilentPatchSA/PedSA.cpp @@ -14,6 +14,8 @@ WRAPPER CTaskSimpleJetPack* CPedIntelligence::GetTaskJetPack() const { VARJMP(va static void* varRenderJetPack = AddressByVersion(0x67F6A0, 0x67FEC0, 0x6AB110); WRAPPER void CTaskSimpleJetPack::RenderJetPack(CPed* pPed) { WRAPARG(pPed); VARJMP(varRenderJetPack); } +void (CPed::*CPed::orgGiveWeapon)(uint32_t weapon, uint32_t ammo, bool flag); + RwObject* GetFirstObject(RwFrame* pFrame) { RwObject* pObject = nullptr; @@ -90,4 +92,10 @@ void CPed::RenderForShadow() auto* pJetPackTask = pPedIntelligence->GetTaskJetPack(); if ( pJetPackTask ) pJetPackTask->RenderJetPack(this); -} \ No newline at end of file +} + +void CPed::GiveWeapon_SP(uint32_t weapon, uint32_t ammo, bool flag) +{ + if ( ammo == 0 ) ammo = 1; + (this->*(orgGiveWeapon))( weapon, ammo, flag ); +} diff --git a/SilentPatchSA/PedSA.h b/SilentPatchSA/PedSA.h index 69869c3..9b78ff9 100644 --- a/SilentPatchSA/PedSA.h +++ b/SilentPatchSA/PedSA.h @@ -312,6 +312,9 @@ public: void RenderWeapon(bool bMuzzleFlash, bool bForShadow); void RenderForShadow(); + + static void (CPed::*orgGiveWeapon)(uint32_t weapon, uint32_t ammo, bool flag); + void GiveWeapon_SP( uint32_t weapon, uint32_t ammo, bool flag ); }; class NOVMT CPlayerPed : public CPed diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index a7041a4..bf4114f 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -3497,6 +3497,15 @@ void Patch_SA_10() // Credits =) ReadCall( 0x5AF87A, Credits::PrintCreditText ); InjectHook( 0x5AF8A4, Credits::PrintSPCredits ); + + + // Fixed ammo from SCM + { + void* pGiveWeapon; + ReadCall( 0x47D335, pGiveWeapon ); + CPed::orgGiveWeapon = *(decltype(CPed::orgGiveWeapon)*)&pGiveWeapon; + InjectHook( 0x47D335, &CPed::GiveWeapon_SP ); + } } void Patch_SA_11()