mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-29 15:23:02 +05:00
Account for SA-MP patches for GetWeaponSkill in RenderWeaponPedsForPC
This commit is contained in:
parent
7ce4c99cb9
commit
21d6ed5cc3
3 changed files with 24 additions and 3 deletions
|
@ -3,7 +3,7 @@
|
||||||
#include "VehicleSA.h"
|
#include "VehicleSA.h"
|
||||||
|
|
||||||
static void* varGetWeaponSkill = AddressByVersion<void*>(0x5E6580, 0x5E6DA0, 0x6039F0);
|
static void* varGetWeaponSkill = AddressByVersion<void*>(0x5E6580, 0x5E6DA0, 0x6039F0);
|
||||||
WRAPPER unsigned char CPed::GetWeaponSkill() { VARJMP(varGetWeaponSkill); }
|
WRAPPER uint8_t CPed::GetWeaponSkill() { VARJMP(varGetWeaponSkill); }
|
||||||
static void* varSetGunFlashAlpha = AddressByVersion<void*>(0x5DF400, 0x5DFC20, 0x5FC120);
|
static void* varSetGunFlashAlpha = AddressByVersion<void*>(0x5DF400, 0x5DFC20, 0x5FC120);
|
||||||
WRAPPER void CPed::SetGunFlashAlpha(bool bSecondWeapon) { WRAPARG(bSecondWeapon); VARJMP(varSetGunFlashAlpha); }
|
WRAPPER void CPed::SetGunFlashAlpha(bool bSecondWeapon) { WRAPARG(bSecondWeapon); VARJMP(varSetGunFlashAlpha); }
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ void CPed::RenderWeapon(bool bWeapon, bool bMuzzleFlash, bool bForShadow)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dual weapons
|
// Dual weapons
|
||||||
if ( CWeaponInfo::GetWeaponInfo(weaponSlots[m_bActiveWeapon].m_eWeaponType, GetWeaponSkill())->hexFlags >> 11 & 1 )
|
if ( CWeaponInfo::GetWeaponInfo(weaponSlots[m_bActiveWeapon].m_eWeaponType, GetWeaponSkillForRenderWeaponPedsForPC())->hexFlags >> 11 & 1 )
|
||||||
{
|
{
|
||||||
*RwFrameGetMatrix(pFrame) = RpHAnimHierarchyGetMatrixArray(pAnimHierarchy)[RpHAnimIDGetIndex(pAnimHierarchy, 34)];
|
*RwFrameGetMatrix(pFrame) = RpHAnimHierarchyGetMatrixArray(pAnimHierarchy)[RpHAnimIDGetIndex(pAnimHierarchy, 34)];
|
||||||
|
|
||||||
|
@ -132,3 +132,10 @@ void CPed::GiveWeapon_SP(uint32_t weapon, uint32_t ammo, bool flag)
|
||||||
if ( ammo == 0 ) ammo = 1;
|
if ( ammo == 0 ) ammo = 1;
|
||||||
(this->*(orgGiveWeapon))( weapon, ammo, flag );
|
(this->*(orgGiveWeapon))( weapon, ammo, flag );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t CPed::GetWeaponSkillForRenderWeaponPedsForPC_SAMP()
|
||||||
|
{
|
||||||
|
uint8_t (CPed::*funcCall)();
|
||||||
|
Memory::ReadCall( 0x7330A2, funcCall );
|
||||||
|
return std::invoke( funcCall, this );
|
||||||
|
}
|
|
@ -309,7 +309,7 @@ public:
|
||||||
bool IsPlayer() const
|
bool IsPlayer() const
|
||||||
{ return pedType == 0 || pedType == 1; }
|
{ return pedType == 0 || pedType == 1; }
|
||||||
|
|
||||||
unsigned char GetWeaponSkill();
|
uint8_t GetWeaponSkill();
|
||||||
void ResetGunFlashAlpha();
|
void ResetGunFlashAlpha();
|
||||||
void SetGunFlashAlpha(bool bSecondWeapon);
|
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 Say(uint16_t phrase, uint32_t param2 = 0, float volume = 1.0f, bool param4 = false, bool param5 = false, bool param6 = false);
|
||||||
|
@ -320,6 +320,15 @@ public:
|
||||||
static void (CPed::*orgGiveWeapon)(uint32_t weapon, uint32_t ammo, bool flag);
|
static void (CPed::*orgGiveWeapon)(uint32_t weapon, uint32_t ammo, bool flag);
|
||||||
void GiveWeapon_SP( uint32_t weapon, uint32_t ammo, bool flag );
|
void GiveWeapon_SP( uint32_t weapon, uint32_t ammo, bool flag );
|
||||||
|
|
||||||
|
// Extension to accommodate for SA-MP hooking GetWeaponSkill in RenderWeaponPedsForPC dynamically
|
||||||
|
static inline uint8_t (CPed::*orgGetWeaponSkillForRenderWeaponPedsForPC)() = &GetWeaponSkill;
|
||||||
|
uint8_t GetWeaponSkillForRenderWeaponPedsForPC()
|
||||||
|
{
|
||||||
|
return std::invoke( orgGetWeaponSkillForRenderWeaponPedsForPC, this );
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t GetWeaponSkillForRenderWeaponPedsForPC_SAMP();
|
||||||
|
|
||||||
template<uint16_t blackSample>
|
template<uint16_t blackSample>
|
||||||
void Say_SampleBlackList(uint16_t phrase, uint32_t param2 = 0, float volume = 1.0f, bool param4 = false, bool param5 = false, bool param6 = false)
|
void Say_SampleBlackList(uint16_t phrase, uint32_t param2 = 0, float volume = 1.0f, bool param4 = false, bool param5 = false, bool param6 = false)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2588,6 +2588,11 @@ BOOL InjectDelayedPatches_10()
|
||||||
// Weapons rendering
|
// Weapons rendering
|
||||||
if ( !bOutfit )
|
if ( !bOutfit )
|
||||||
{
|
{
|
||||||
|
if ( bSAMP )
|
||||||
|
{
|
||||||
|
CPed::orgGetWeaponSkillForRenderWeaponPedsForPC = &CPed::GetWeaponSkillForRenderWeaponPedsForPC_SAMP;
|
||||||
|
}
|
||||||
|
|
||||||
InjectHook(0x5E7859, RenderWeapon);
|
InjectHook(0x5E7859, RenderWeapon);
|
||||||
InjectHook(0x732F30, RenderWeaponPedsForPC, PATCH_JUMP);
|
InjectHook(0x732F30, RenderWeaponPedsForPC, PATCH_JUMP);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue