Fixed ammo granting from SCM - SA 1.0

This commit is contained in:
Silent 2018-01-28 18:30:52 +01:00
parent a4bae15050
commit 1f8b44384e
3 changed files with 21 additions and 1 deletions

View File

@ -14,6 +14,8 @@ WRAPPER CTaskSimpleJetPack* CPedIntelligence::GetTaskJetPack() const { VARJMP(va
static void* varRenderJetPack = AddressByVersion<void*>(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;
@ -91,3 +93,9 @@ void CPed::RenderForShadow()
if ( pJetPackTask )
pJetPackTask->RenderJetPack(this);
}
void CPed::GiveWeapon_SP(uint32_t weapon, uint32_t ammo, bool flag)
{
if ( ammo == 0 ) ammo = 1;
(this->*(orgGiveWeapon))( weapon, ammo, flag );
}

View File

@ -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

View File

@ -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()