diff --git a/SilentPatchSA/PedSA.cpp b/SilentPatchSA/PedSA.cpp index f35a5a9..9b0eb4b 100644 --- a/SilentPatchSA/PedSA.cpp +++ b/SilentPatchSA/PedSA.cpp @@ -51,46 +51,10 @@ void CPed::RenderWeapon(bool bWeapon, bool bMuzzleFlash, bool bForShadow) RwFrame* pFrame = RpClumpGetFrame(reinterpret_cast(m_pWeaponObject)); *RwFrameGetMatrix(pFrame) = RpHAnimHierarchyGetMatrixArray(pAnimHierarchy)[RpHAnimIDGetIndex(pAnimHierarchy, bHasParachute ? 3 : 24)]; - if ( bHasParachute ) + auto renderOneWeapon = [this](bool bWeapon, bool bMuzzleFlash, bool bForShadow, bool bRightGun) { - const RwV3d vecParachuteTranslation = { 0.1f, -0.15f, 0.0f }; - const RwV3d vecParachuteRotation = { 0.0f, 1.0f, 0.0f }; - RwMatrixTranslate(RwFrameGetMatrix(pFrame), &vecParachuteTranslation, rwCOMBINEPRECONCAT); - RwMatrixRotate(RwFrameGetMatrix(pFrame), &vecParachuteRotation, 90.0f, rwCOMBINEPRECONCAT); - } + RwFrameUpdateObjects(RpClumpGetFrame(reinterpret_cast(m_pWeaponObject))); - RwFrameUpdateObjects(pFrame); - if ( bForShadow ) - RpClumpForAllAtomics(reinterpret_cast(m_pWeaponObject), ShadowCameraRenderCB); - else - { - if ( bWeapon ) - { - RpClumpRender(reinterpret_cast(m_pWeaponObject)); - } - - if ( bMuzzleFlash && m_pMuzzleFlashFrame != nullptr ) - { - RwScopedRenderState zWrite(rwRENDERSTATEZWRITEENABLE); - RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE); - - SetGunFlashAlpha(false); - RpAtomic* atomic = reinterpret_cast(GetFirstObject(m_pMuzzleFlashFrame)); - RpAtomicRender( atomic ); - } - } - - // Dual weapons - if ( CWeaponInfo::GetWeaponInfo(weaponSlots[m_bActiveWeapon].m_eWeaponType, GetWeaponSkillForRenderWeaponPedsForPC())->hexFlags >> 11 & 1 ) - { - *RwFrameGetMatrix(pFrame) = RpHAnimHierarchyGetMatrixArray(pAnimHierarchy)[RpHAnimIDGetIndex(pAnimHierarchy, 34)]; - - const RwV3d vecParachuteRotation = { 1.0f, 0.0f, 0.0f }; - const RwV3d vecParachuteTranslation = { 0.04f, -0.05f, 0.0f }; - RwMatrixRotate(RwFrameGetMatrix(pFrame), &vecParachuteRotation, 180.0f, rwCOMBINEPRECONCAT); - RwMatrixTranslate(RwFrameGetMatrix(pFrame), &vecParachuteTranslation, rwCOMBINEPRECONCAT); - - RwFrameUpdateObjects(pFrame); if ( bForShadow ) RpClumpForAllAtomics(reinterpret_cast(m_pWeaponObject), ShadowCameraRenderCB); else @@ -105,11 +69,34 @@ void CPed::RenderWeapon(bool bWeapon, bool bMuzzleFlash, bool bForShadow) RwScopedRenderState zWrite(rwRENDERSTATEZWRITEENABLE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE); - SetGunFlashAlpha(true); + SetGunFlashAlpha(bRightGun); RpAtomic* atomic = reinterpret_cast(GetFirstObject(m_pMuzzleFlashFrame)); RpAtomicRender( atomic ); } } + }; + + if ( bHasParachute ) + { + const RwV3d vecParachuteTranslation = { 0.1f, -0.15f, 0.0f }; + const RwV3d vecParachuteRotation = { 0.0f, 1.0f, 0.0f }; + RwMatrixTranslate(RwFrameGetMatrix(pFrame), &vecParachuteTranslation, rwCOMBINEPRECONCAT); + RwMatrixRotate(RwFrameGetMatrix(pFrame), &vecParachuteRotation, 90.0f, rwCOMBINEPRECONCAT); + } + + renderOneWeapon(bWeapon, bMuzzleFlash, bForShadow, false); + + // Dual weapons + if ( CWeaponInfo::GetWeaponInfo(weaponSlots[m_bActiveWeapon].m_eWeaponType, GetWeaponSkillForRenderWeaponPedsForPC())->hexFlags >> 11 & 1 ) + { + *RwFrameGetMatrix(pFrame) = RpHAnimHierarchyGetMatrixArray(pAnimHierarchy)[RpHAnimIDGetIndex(pAnimHierarchy, 34)]; + + const RwV3d vecParachuteRotation = { 1.0f, 0.0f, 0.0f }; + const RwV3d vecParachuteTranslation = { 0.04f, -0.05f, 0.0f }; + RwMatrixRotate(RwFrameGetMatrix(pFrame), &vecParachuteRotation, 180.0f, rwCOMBINEPRECONCAT); + RwMatrixTranslate(RwFrameGetMatrix(pFrame), &vecParachuteTranslation, rwCOMBINEPRECONCAT); + + renderOneWeapon(bWeapon, bMuzzleFlash, bForShadow, true); } if ( bMuzzleFlash ) ResetGunFlashAlpha();