Client: add the Quake style crosshair (and make it respect the crosshair cvar...)

This commit is contained in:
Marco Cawthorne 2023-04-17 00:11:41 -07:00
parent ac9cd39ca6
commit 2aed2e5f72
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
12 changed files with 34 additions and 19 deletions

View File

@ -76,6 +76,7 @@ struct
float m_flDamageIndicator;
} g_seatslocal[4], *pSeatLocal;
void HUD_DrawQuakeCrosshair(void);
void HUD_DrawAmmo1(void);
void HUD_DrawAmmo2(void);
void HUD_DrawAmmo3(void);

View File

@ -459,6 +459,20 @@ HUD_DrawDamageIndicator(void)
pSeatLocal->m_flDamageIndicator -= clframetime;
}
var bool autocvar_crosshair = 1;
void
HUD_DrawQuakeCrosshair(void)
{
const string quakeCross = "+";
if (autocvar_crosshair == 0)
return;
float crossLength = Font_StringWidth(quakeCross, FALSE, FONT_20) / 2;
vector crossPos = g_hudmins + (g_hudres / 2) + [-crossLength,-crossLength];
Font_DrawText(crossPos, quakeCross, FONT_20);
}
/* main entry */
void
HUD_Draw(void)

View File

@ -22,7 +22,6 @@ vector g_vecHUDNums[8] =
[168 / 256, 92 / 128],
[188 / 256, 92 / 128],
[208 / 256, 92 / 128],
[188 / 256, 92 / 128],
[208 / 256, 92 / 128]
};

View File

@ -343,7 +343,7 @@ player::ReceiveEntity(float new, float flChanged)
SetRenderMode(RM_DONTRENDER);
SetRenderFX(RFX_GLOWSHELL);
SetRenderColor([0.5, 0.5, 0.5]);
SetRenderAmt(0.25f);
SetRenderAmt(0.1f);
} else if (HasQuadDamage()) {
SetRenderFX(RFX_GLOWSHELL);
SetRenderColor([0.5, 0.5, 1.0]);

View File

@ -170,6 +170,15 @@ weapontype_t w_crowbar_type(player pl)
return WPNTYPE_CLOSE;
}
void
w_crowbar_crosshair(player pl)
{
#ifdef CLIENT
HUD_DrawQuakeCrosshair();
#endif
}
weapon_t w_crowbar =
{
.name = "axe",
@ -183,7 +192,7 @@ weapon_t w_crowbar =
.secondary = __NULL__,
.reload = __NULL__,
.release = __NULL__,
.postdraw = __NULL__,
.postdraw = w_crowbar_crosshair,
.precache = w_crowbar_precache,
.pickup = __NULL__,
.updateammo = __NULL__,

View File

@ -174,10 +174,9 @@ w_grenadelauncher_crosshair(player pl)
{
#ifdef CLIENT
vector aicon_pos;
Cross_DrawSub(g_cross_spr, [24,24], [72/128,24/128], [0.1875, 0.1875]);
aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42];
HUD_DrawQuakeCrosshair();
HUD_DrawAmmo2();
drawsubpic(

View File

@ -151,8 +151,7 @@ w_lightning_crosshair(player pl)
#ifdef CLIENT
vector aicon_pos;
Cross_DrawSub(g_cross_spr, [24,24], [72/128,0], [0.1875, 0.1875]);
HUD_DrawQuakeCrosshair();
HUD_DrawAmmo2();
aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42];

View File

@ -158,8 +158,7 @@ w_nailgun_crosshair(player pl)
#ifdef CLIENT
vector aicon_pos;
Cross_DrawSub(g_cross_spr, [24,24], [48/128,0], [0.1875, 0.1875]);
HUD_DrawQuakeCrosshair();
HUD_DrawAmmo2();
aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42];

View File

@ -188,9 +188,7 @@ w_rocketlauncher_hud(player pl)
vector laser_pos;
vector aicon_pos;
Cross_DrawSub(g_cross_spr, [24,24], [24/128,48/128], [0.1875, 0.1875]);
/* ammo counters */
HUD_DrawQuakeCrosshair();
HUD_DrawAmmo2();
/* ammo icon */

View File

@ -155,10 +155,9 @@ void
w_shotgun_crosshair(player pl)
{
#ifdef CLIENT
Cross_DrawSub(g_cross_spr, [24,24], [48/128,24/128], [0.1875, 0.1875]);
HUD_DrawAmmo2();
vector aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42];
HUD_DrawQuakeCrosshair();
HUD_DrawAmmo2();
drawsubpic(aicon_pos, [24,24], g_hudsgammo, [0, 0], [1,1], g_hud_color, pSeatLocal->m_flAmmo2Alpha, DRAWFLAG_ADDITIVE);
#endif
}

View File

@ -156,8 +156,7 @@ w_supernailgun_crosshair(player pl)
#ifdef CLIENT
vector aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42];
Cross_DrawSub(g_cross_spr, [24,24], [0,48/128], [0.1875, 0.1875]);
HUD_DrawQuakeCrosshair();
HUD_DrawAmmo2();
drawsubpic(aicon_pos, [24,24], g_hudsngammo, [0, 0], [1,1], g_hud_color, pSeatLocal->m_flAmmo2Alpha, DRAWFLAG_ADDITIVE);

View File

@ -178,8 +178,7 @@ w_supershotgun_hud(player pl)
aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42];
Cross_DrawSub(g_cross_spr, [24,24], [0.1875,0], [0.1875, 0.1875]);
HUD_DrawQuakeCrosshair();
HUD_DrawAmmo2();
drawsubpic(aicon_pos, [24,24], g_hudssgammo, [0, 0], [1,1], g_hud_color, pSeatLocal->m_flAmmo2Alpha, DRAWFLAG_ADDITIVE);