Display hitmarker even if it is a sniper rifle

This commit is contained in:
Kamay Xutax 2024-09-11 15:33:32 +02:00
parent 497a61b029
commit 8b6782c26c

View file

@ -1087,13 +1087,6 @@ void CWeaponCSBase::DefaultTouch(CBaseEntity *pOther)
// no crosshair for sniper rifles // no crosshair for sniper rifles
bool bCrosshairVisible = crosshair.GetBool() && GetCSWpnData().m_WeaponType != WEAPONTYPE_SNIPER_RIFLE; bool bCrosshairVisible = crosshair.GetBool() && GetCSWpnData().m_WeaponType != WEAPONTYPE_SNIPER_RIFLE;
if ( !bCrosshairVisible
#if ALLOW_WEAPON_SPREAD_DISPLAY
&& !weapon_debug_spread_show.GetBool()
#endif
)
return;
float fHalfFov = DEG2RAD(pPlayer->GetFOV()) * 0.5f; float fHalfFov = DEG2RAD(pPlayer->GetFOV()) * 0.5f;
int iCrosshairDistance; int iCrosshairDistance;
@ -1207,21 +1200,22 @@ void CWeaponCSBase::DefaultTouch(CBaseEntity *pOther)
int iCenterX = ScreenWidth() / 2; int iCenterX = ScreenWidth() / 2;
int iCenterY = ScreenHeight() / 2; int iCenterY = ScreenHeight() / 2;
if ( bCrosshairVisible )
{
if ( cl_crosshair_picture.GetBool() ) if ( cl_crosshair_picture.GetBool() )
{ {
static auto pCrosshairMaterial = materials->FindMaterial( "crosshair/crosshair", TEXTURE_GROUP_OTHER ); static auto pCrosshairMaterial = materials->FindMaterial( "crosshair/crosshair", TEXTURE_GROUP_OTHER );
static auto pCrosshairHitMaterial = materials->FindMaterial( "crosshair/crosshair_hit", TEXTURE_GROUP_OTHER ); static auto pCrosshairHitMaterial = materials->FindMaterial( "crosshair/crosshair_hit",
TEXTURE_GROUP_OTHER );
CMatRenderContextPtr pRenderContext( materials ); CMatRenderContextPtr pRenderContext( materials );
CMaterialReference refCrosshair;
refCrosshair.Init( pCrosshairMaterial );
int nViewportX, nViewportY, nViewportWidth, nViewportHeight; int nViewportX, nViewportY, nViewportWidth, nViewportHeight;
pRenderContext->GetViewport( nViewportX, nViewportY, nViewportWidth, nViewportHeight ); pRenderContext->GetViewport( nViewportX, nViewportY, nViewportWidth, nViewportHeight );
if ( bCrosshairVisible )
{
CMaterialReference refCrosshair;
refCrosshair.Init( pCrosshairMaterial );
pRenderContext->DrawScreenSpaceRectangle( refCrosshair, pRenderContext->DrawScreenSpaceRectangle( refCrosshair,
nViewportWidth / 2 nViewportWidth / 2
- pCrosshairMaterial->GetMappingWidth() / 2, - pCrosshairMaterial->GetMappingWidth() / 2,
@ -1235,6 +1229,7 @@ void CWeaponCSBase::DefaultTouch(CBaseEntity *pOther)
nViewportY + nViewportHeight - 1, nViewportY + nViewportHeight - 1,
nViewportWidth, nViewportWidth,
nViewportHeight ); nViewportHeight );
}
static float flDisplayCurrentTime = 0.0f; static float flDisplayCurrentTime = 0.0f;
static float flDisplayTime = 1.0F; static float flDisplayTime = 1.0F;
@ -1270,6 +1265,8 @@ void CWeaponCSBase::DefaultTouch(CBaseEntity *pOther)
} }
} }
else else
{
if ( bCrosshairVisible )
{ {
// draw horizontal crosshair lines // draw horizontal crosshair lines
int iInnerLeft = iCenterX - iCrosshairDistance - iBarThickness / 2; int iInnerLeft = iCenterX - iCrosshairDistance - iBarThickness / 2;
@ -1300,6 +1297,7 @@ void CWeaponCSBase::DefaultTouch(CBaseEntity *pOther)
int y1 = y0 + iBarThickness; int y1 = y0 + iBarThickness;
DrawCrosshairRect( x0, y0, x1, y1, bAdditive ); DrawCrosshairRect( x0, y0, x1, y1, bAdditive );
} }
}
static float flDisplayCurrentTime = 0.0f; static float flDisplayCurrentTime = 0.0f;
static float flDisplayTime = 1.0F; static float flDisplayTime = 1.0F;
@ -1346,7 +1344,6 @@ void CWeaponCSBase::DefaultTouch(CBaseEntity *pOther)
} }
} }
} }
}
#if ALLOW_WEAPON_SPREAD_DISPLAY #if ALLOW_WEAPON_SPREAD_DISPLAY
// show accuracy brackets // show accuracy brackets