Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IFF Crosshair #871

Merged
merged 3 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions mp/src/game/client/hud_crosshair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#ifdef NEO
#include "weapon_neobasecombatweapon.h"
#include "neo_gamerules.h"
#endif

// memdbgon must be the last include file in a .cpp file!!!
Expand Down Expand Up @@ -81,6 +82,10 @@ CHudCrosshair::CHudCrosshair( const char *pElementName ) :
}
}

m_iTexIFFId = vgui::surface()->CreateNewTextureID();
constexpr const char *IFF_TEXTURE_NAME = "vgui/hud/x1";
vgui::surface()->DrawSetTextureFile(m_iTexIFFId, IFF_TEXTURE_NAME, false, false);

#endif

vgui::Panel *pParent = g_pClientMode->GetViewport();
Expand Down Expand Up @@ -373,6 +378,15 @@ void CHudCrosshair::Paint( void )
const bool bIsScoped = pNeoWep && pNeoWep->GetNeoWepBits() & NEO_WEP_SCOPEDWEAPON;
const int iXHairStyle = neo_cl_crosshair_style.GetInt();

trace_t iffTrace;
if (NEORules()->GetGameType() != NEO_GAME_TYPE_DM)
{
CTraceFilterSimpleList iffTraceFilter(COLLISION_GROUP_NONE);
iffTraceFilter.AddEntityToIgnore(pPlayer);
constexpr int IFF_TRACELINE_LENGTH = 8192; // a little over 200m
UTIL_TraceLine(pPlayer->Weapon_ShootPosition(), pPlayer->Weapon_ShootPosition() + pPlayer->GetAutoaimVector(0) * IFF_TRACELINE_LENGTH, MASK_SHOT_HULL, &iffTraceFilter, &iffTrace);
}

if (bIsScoped)
{
m_pCrosshair->DrawSelfCropped (
Expand All @@ -387,6 +401,16 @@ void CHudCrosshair::Paint( void )
#endif
);
}
else if (NEORules()->GetGameType() != NEO_GAME_TYPE_DM && iffTrace.m_pEnt != nullptr && iffTrace.m_pEnt->GetTeamNumber() == pPlayer->GetTeamNumber())
{
vgui::surface()->DrawSetTexture(m_iTexIFFId);
int iTexWide, iTexTall;
vgui::surface()->DrawGetTextureSize(m_iTexIFFId, iTexWide, iTexTall);
iTexWide >>= 2;
iTexTall >>= 2;
vgui::surface()->DrawSetColor(COLOR_RED);
vgui::surface()->DrawTexturedRect(iX - iTexWide, iY - iTexTall, iX + iTexWide, iY + iTexTall);
}
else if (m_iTexXHId[iXHairStyle] > 0)
{
vgui::surface()->DrawSetTexture(m_iTexXHId[iXHairStyle]);
Expand Down
1 change: 1 addition & 0 deletions mp/src/game/client/hud_crosshair.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class CHudCrosshair : public CHudElement, public vgui::Panel

#ifdef NEO
int m_iTexXHId[CROSSHAIR_STYLE__TOTAL] = {};
int m_iTexIFFId = NULL;
#endif

CPanelAnimationVar( bool, m_bHideCrosshair, "never_draw", "false" );
Expand Down