diff --git a/game/client/c_baseanimating.cpp b/game/client/c_baseanimating.cpp index 69403fd9e5..08dab27762 100644 --- a/game/client/c_baseanimating.cpp +++ b/game/client/c_baseanimating.cpp @@ -5611,7 +5611,7 @@ void C_BaseAnimating::DrawClientHitboxes( float duration /*= 0.0f*/, bool monoco b = ( int ) ( 255.0f * hullcolor[j][2] ); } - debugoverlay->AddBoxOverlay( position, pbox->bbmin, pbox->bbmax, angles, r, g, b, 0 ,duration ); + debugoverlay->AddBoxOverlay( position, pbox->bbmin, pbox->bbmax, angles, r, g, b, 127 ,duration ); } } @@ -5647,7 +5647,7 @@ void C_BaseAnimating::DrawServerHitboxes( float duration /*= 0.0f*/, bool monoco b = ( int ) ( 255.0f * hullcolor[j][2] ); } - debugoverlay->AddBoxOverlay( m_vecHitboxServerPositions[i], pbox->bbmin, pbox->bbmax, m_angHitboxServerAngles[i], r, g, b, 0 ,duration ); + debugoverlay->AddBoxOverlay( m_vecHitboxServerPositions[i], pbox->bbmin, pbox->bbmax, m_angHitboxServerAngles[i], r, g, b, 127 ,duration ); } } diff --git a/game/client/c_baseplayer.cpp b/game/client/c_baseplayer.cpp index be3c7cbdbc..73d7b03621 100644 --- a/game/client/c_baseplayer.cpp +++ b/game/client/c_baseplayer.cpp @@ -2135,9 +2135,11 @@ void C_BasePlayer::Simulate() ResetLatched(); } + static ConVarRef cl_showimpacts("cl_showimpacts"); + static ConVarRef cl_showfirebullethitboxes("cl_showfirebullethitboxes"); bool shouldShowFireBulletHitbox = m_nTickBaseFireBullet <= m_nTickBase && m_nTickBaseFireBullet != -1; - if (shouldShowFireBulletHitbox) + if (shouldShowFireBulletHitbox && (cl_showimpacts.GetInt() == 1 || cl_showimpacts.GetInt() == 3 || cl_showfirebullethitboxes.GetBool())) { DrawServerHitboxes(60.0f, true); m_nTickBaseFireBullet = -1; diff --git a/game/client/cstrike/c_cs_player.cpp b/game/client/cstrike/c_cs_player.cpp index ebbd6e92c8..6751644ae9 100644 --- a/game/client/cstrike/c_cs_player.cpp +++ b/game/client/cstrike/c_cs_player.cpp @@ -2230,7 +2230,7 @@ void C_CSPlayer::Simulate( void ) static ConVarRef cl_showimpacts("cl_showimpacts"); - if ((cl_showimpacts.GetInt() == 1 || cl_showimpacts.GetInt() == 3) && m_iBulletServerPositionCount > 0 && m_lastBulletDiameter != -1.0f) + if ((cl_showimpacts.GetInt() == 1 || cl_showimpacts.GetInt() == 3) && m_lastBulletDiameter != -1.0f) { auto weaponInfo = GetActiveWeapon(); diff --git a/game/client/in_main.cpp b/game/client/in_main.cpp index e4323f5294..b4006e281f 100644 --- a/game/client/in_main.cpp +++ b/game/client/in_main.cpp @@ -98,7 +98,7 @@ ConVar thirdperson_platformer( "thirdperson_platformer", "0", 0, "Player will ai ConVar thirdperson_screenspace( "thirdperson_screenspace", "0", 0, "Movement will be relative to the camera, eg: left means screen-left" ); ConVar sv_noclipduringpause( "sv_noclipduringpause", "0", FCVAR_REPLICATED | FCVAR_CHEAT, "If cheats are enabled, then you can noclip with the game paused (for doing screenshots, etc.)." ); -ConVar cl_showimpacts("cl_showimpacts", "0", FCVAR_NONE, "Shows client (red) and server (blue) bullet impact point (1=both, 2=client-only, 3=server-only)" ); +ConVar cl_showimpacts("cl_showimpacts", "0"); ConVar cl_showfirebullethitboxes( "cl_showfirebullethitboxes", "0" ); extern ConVar cl_mouselook; diff --git a/game/shared/cstrike/cs_player_shared.cpp b/game/shared/cstrike/cs_player_shared.cpp index bd8a7aa55d..7f5ea8df5d 100644 --- a/game/shared/cstrike/cs_player_shared.cpp +++ b/game/shared/cstrike/cs_player_shared.cpp @@ -8,6 +8,8 @@ #include "debugoverlay_shared.h" #ifndef CLIENT_DLL #include "player.h" +#else +#include "cdll_client_int.h" #endif #include "weapon_csbase.h" #include "decals.h" @@ -455,10 +457,6 @@ void CCSPlayer::FireBullet( GetBulletTypeParameters( iBulletType, flPenetrationPower, flPenetrationDistance, flBulletDiameter ); -#ifdef CLIENT_DLL - m_lastBulletDiameter = flBulletDiameter; -#endif - Vector vecBulletDiameterMaxs(flBulletDiameter, flBulletDiameter, flBulletDiameter); vecBulletDiameterMaxs /= 2.0f; Vector vecBulletDiameterMins(-flBulletDiameter, -flBulletDiameter, -flBulletDiameter); @@ -500,25 +498,35 @@ void CCSPlayer::FireBullet( CBasePlayer *lastPlayerHit = NULL; MDLCACHE_CRITICAL_SECTION(); +#ifdef CLIENT_DLL + static ConVarRef cl_showfirebullethitboxes("cl_showfirebullethitboxes"); + if (cl_showfirebullethitboxes.GetBool()) + { + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer* lagPlayer = UTIL_PlayerByIndex(i); + + if ( lagPlayer && !lagPlayer->IsLocalPlayer() && IsLocalPlayer()) + { + lagPlayer->DrawClientHitboxes(60, true); + lagPlayer->m_nTickBaseFireBullet = int(lagPlayer->GetTimeBase() / TICK_INTERVAL); + } + } + } +#else if ( m_pCurrentCommand->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ON_BULLET || m_pCurrentCommand->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ALWAYS_ON ) { for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer* lagPlayer = UTIL_PlayerByIndex(i); -#ifdef CLIENT_DLL - if( lagPlayer && !lagPlayer->IsLocalPlayer() && IsLocalPlayer()) - { - lagPlayer->DrawClientHitboxes(60, true); - lagPlayer->m_nTickBaseFireBullet = int(lagPlayer->GetTimeBase() / TICK_INTERVAL); - } -#else + if( lagPlayer ) { lagPlayer->RecordServerHitboxes(this); } -#endif } } +#endif while ( fCurrentDamage > 0 ) { @@ -564,34 +572,63 @@ void CCSPlayer::FireBullet( flDamageModifier = 0.99f; } - if ( m_pCurrentCommand->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ON_HIT || m_pCurrentCommand->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ALWAYS_ON ) - { #ifdef CLIENT_DLL - // draw red client impact markers - NDebugOverlay::SweptBox(vecSrc, tr.endpos, vecBulletDiameterMins, vecBulletDiameterMaxs, QAngle( 0, 0, 0), 255,0,0,127, 60 ); + m_lastBulletDiameter = flBulletDiameter; +#endif - if ( tr.m_pEnt && tr.m_pEnt->IsPlayer() ) +#ifdef CLIENT_DLL + static ConVarRef cl_showimpacts("cl_showimpacts"); + + if (cl_showimpacts.GetInt() == 1 || cl_showimpacts.GetInt() == 2) + { + NDebugOverlay::SweptBox(vecSrc, + tr.endpos, + vecBulletDiameterMins, + vecBulletDiameterMaxs, + QAngle(0, 0, 0), + 255, + 0, + 0, + 127, + 60.0f); + } + + if (tr.m_pEnt && tr.m_pEnt->IsPlayer()) + { + C_BasePlayer* player = ToBasePlayer(tr.m_pEnt); + + if (cl_showimpacts.GetInt() == 1 + || cl_showimpacts.GetInt() == 2) { - C_BasePlayer *player = ToBasePlayer( tr.m_pEnt ); - player->DrawClientHitboxes( 60, true ); - player->m_nTickBaseFireBullet = int(player->GetTimeBase() / TICK_INTERVAL); + player->DrawClientHitboxes(60.0f, true); } + player->m_nTickBaseFireBullet = int(player->GetTimeBase() + / TICK_INTERVAL); + } #else - if ( tr.m_pEnt && tr.m_pEnt->IsPlayer() ) + if ( m_pCurrentCommand->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ON_HIT || m_pCurrentCommand->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ALWAYS_ON ) + { + if (m_iBulletServerPositionCount.Get() + < MAX_PLAYER_BULLET_SERVER_POSITIONS) + { + m_vecBulletServerPositions.Set( + m_iBulletServerPositionCount.Get(), + tr.endpos); + m_vecServerShootPosition.Set( + m_iBulletServerPositionCount.Get(), + vecSrc); + m_iBulletServerPositionCount.Set( + m_iBulletServerPositionCount.Get() + 1); + } + + if ( tr.m_pEnt && tr.m_pEnt->IsPlayer() ) { CBasePlayer *player = ToBasePlayer( tr.m_pEnt ); player->RecordServerHitboxes( this ); } - - if (m_iBulletServerPositionCount.Get() < MAX_PLAYER_BULLET_SERVER_POSITIONS) - { - m_vecBulletServerPositions.Set(m_iBulletServerPositionCount.Get(), tr.endpos); - m_vecServerShootPosition.Set(m_iBulletServerPositionCount.Get(), vecSrc); - m_iBulletServerPositionCount.Set(m_iBulletServerPositionCount.Get() + 1); - } -#endif } +#endif //calculate the damage based on the distance the bullet travelled. flCurrentDistance += tr.fraction * flDistance; diff --git a/tier2/renderutils.cpp b/tier2/renderutils.cpp index 1c4870d8d3..faf50f6e21 100644 --- a/tier2/renderutils.cpp +++ b/tier2/renderutils.cpp @@ -666,6 +666,8 @@ static void DrawExtrusionFace( const Vector& start, const Vector& end, void RenderWireframeSweptBox( const Vector &vStart, const Vector &vEnd, const QAngle &angles, const Vector &vMins, const Vector &vMaxs, Color c, bool bZBuffer ) { + InitializeStandardMaterials(); + CMatRenderContextPtr pRenderContext( g_pMaterialSystem ); pRenderContext->Bind( bZBuffer ? s_pWireframe : s_pWireframeIgnoreZ );