Client: Added ammo pickup notifications, fix some impact effect assignments
and change the fadeout time on weapon pickup notifications.
This commit is contained in:
parent
000fb34006
commit
f1fdad0bb7
6 changed files with 128 additions and 5 deletions
|
@ -83,6 +83,7 @@ HUD_Init(void)
|
|||
g_hud5_spr = spriteframe("sprites/640hud5.spr", 0, 0.0f);
|
||||
g_hud6_spr = spriteframe("sprites/640hud6.spr", 0, 0.0f);
|
||||
g_hud7_spr = spriteframe("sprites/640hud7.spr", 0, 0.0f);
|
||||
HUD_AmmoNotify_Init();
|
||||
}
|
||||
|
||||
/* seperator for mainly ammo */
|
||||
|
@ -387,21 +388,39 @@ void
|
|||
HUD_DrawNotify(void)
|
||||
{
|
||||
vector pos;
|
||||
float a;
|
||||
|
||||
pos = g_hudmins + [g_hudres[0] - 192, g_hudres[1] - 128];
|
||||
|
||||
if (pSeatLocal->m_flPickupAlpha <= 0.0f) {
|
||||
pos[0] += 148;
|
||||
pos[1] += 16;
|
||||
HUD_AmmoNotify_Draw(pos);
|
||||
return;
|
||||
}
|
||||
|
||||
pos = g_hudmins + [g_hudres[0] - 192, g_hudres[1] - 128];
|
||||
Weapons_HUDPic(pSeatLocal->m_iPickupWeapon, 1, pos, pSeatLocal->m_flPickupAlpha);
|
||||
pSeatLocal->m_flPickupAlpha -= clframetime;
|
||||
a = bound(0.0, pSeatLocal->m_flPickupAlpha, 1.0);
|
||||
Weapons_HUDPic(pSeatLocal->m_iPickupWeapon, 1, pos, a);
|
||||
pos[0] += 148;
|
||||
pos[1] -= 32;
|
||||
HUD_AmmoNotify_Draw(pos);
|
||||
pSeatLocal->m_flPickupAlpha -= (clframetime * 0.5);
|
||||
}
|
||||
|
||||
void
|
||||
HUD_WeaponPickupNotify(int w)
|
||||
{
|
||||
switch (w) {
|
||||
case WEAPON_SNARK:
|
||||
case WEAPON_SATCHEL:
|
||||
case WEAPON_HANDGRENADE:
|
||||
case WEAPON_TRIPMINE:
|
||||
return;
|
||||
default:
|
||||
}
|
||||
|
||||
pSeatLocal->m_iPickupWeapon = w;
|
||||
pSeatLocal->m_flPickupAlpha = 1.0f;
|
||||
pSeatLocal->m_flPickupAlpha = 2.5f;
|
||||
}
|
||||
|
||||
/* main entry */
|
||||
|
|
98
src/client/hud_ammonotify.qc
Normal file
98
src/client/hud_ammonotify.qc
Normal file
|
@ -0,0 +1,98 @@
|
|||
|
||||
string g_ammo_spr;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float alpha;
|
||||
int count;
|
||||
} ammonote_t;
|
||||
ammonote_t g_ammonotify[12];
|
||||
|
||||
vector g_ammotype[12] = {
|
||||
[0/256, 72/128], // pistol
|
||||
[24/256, 72/128], // revolver
|
||||
[48/256, 72/128], // grenade
|
||||
[72/256, 72/128], // shell
|
||||
[96/256, 72/128], // arrow
|
||||
[120/256, 72/128], // rocket
|
||||
[0/256, 96/128], // uranium
|
||||
[24/256, 96/128], // hornet
|
||||
[48/256, 96/128], // grenade
|
||||
[72/256, 96/128], // satchel
|
||||
[96/256, 96/128], // snark
|
||||
[120/256, 96/128], // tripmine
|
||||
};
|
||||
|
||||
void
|
||||
HUD_AmmoNotify_Init(void)
|
||||
{
|
||||
g_ammo_spr = spriteframe("sprites/640hud7.spr", 0, 0.0f);
|
||||
}
|
||||
|
||||
void
|
||||
HUD_AmmoNotify_Draw(vector startpos)
|
||||
{
|
||||
vector pos = startpos;
|
||||
|
||||
for (int i = 0; i < 12; i++) {
|
||||
vector srcpos;
|
||||
float a;
|
||||
|
||||
/* make sure we skip any faded entries, and also null them */
|
||||
if (g_ammonotify[i].alpha <= 0.0f) {
|
||||
g_ammonotify[i].count = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* let's get the src img pos for our type */
|
||||
srcpos = g_ammotype[i];
|
||||
a = bound(0, g_ammonotify[i].alpha, 1.0);
|
||||
|
||||
drawsubpic(pos,
|
||||
[24,24],
|
||||
g_ammo_spr,
|
||||
srcpos,
|
||||
[24/256, 24/128],
|
||||
g_hud_color,
|
||||
a,
|
||||
DRAWFLAG_ADDITIVE
|
||||
);
|
||||
|
||||
drawfont = Font_GetID(FONT_20);
|
||||
string txt = sprintf("%i", g_ammonotify[i].count);
|
||||
float offs = stringwidth(txt, FALSE, [20,20]);
|
||||
drawstring(pos + [-offs - 8,4], sprintf("%i", g_ammonotify[i].count), [20,20], g_hud_color, a, DRAWFLAG_ADDITIVE);
|
||||
|
||||
g_ammonotify[i].alpha -= (clframetime * 0.5);
|
||||
pos -= [0, 32]; /* go up a notch */
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HUD_AmmoNotify_Insert(int type, int count)
|
||||
{
|
||||
if (count <= 0)
|
||||
return;
|
||||
|
||||
g_ammonotify[type].count += count;
|
||||
g_ammonotify[type].alpha = 2.5f;
|
||||
|
||||
}
|
||||
|
||||
/* called whenever we should check for pickup updates */
|
||||
void
|
||||
HUD_AmmoNotify_Check(player pl)
|
||||
{
|
||||
HUD_AmmoNotify_Insert(0, pl.ammo_9mm - pl.ammo_9mm_net);
|
||||
HUD_AmmoNotify_Insert(1, pl.ammo_357 - pl.ammo_357_net);
|
||||
HUD_AmmoNotify_Insert(2, pl.ammo_m203_grenade - pl.ammo_m203_grenade_net);
|
||||
HUD_AmmoNotify_Insert(3, pl.ammo_buckshot - pl.ammo_buckshot_net);
|
||||
HUD_AmmoNotify_Insert(4, pl.ammo_bolt - pl.ammo_bolt_net);
|
||||
HUD_AmmoNotify_Insert(5, pl.ammo_rocket - pl.ammo_rocket_net);
|
||||
HUD_AmmoNotify_Insert(6, pl.ammo_uranium - pl.ammo_uranium_net);
|
||||
HUD_AmmoNotify_Insert(7, pl.ammo_hornet - pl.ammo_hornet_net);
|
||||
HUD_AmmoNotify_Insert(8, pl.ammo_handgrenade - pl.ammo_handgrenade_net);
|
||||
HUD_AmmoNotify_Insert(9, pl.ammo_satchel - pl.ammo_satchel_net);
|
||||
HUD_AmmoNotify_Insert(10, pl.ammo_snark - pl.ammo_snark_net);
|
||||
HUD_AmmoNotify_Insert(11, pl.ammo_tripmine - pl.ammo_tripmine_net);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
|
||||
* Copyright (c) 2016-2021 Marco Hladik <marco@icculus.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -32,6 +32,7 @@ game_event.qc
|
|||
../../../valve/src/client/viewmodel.qc
|
||||
view.qc
|
||||
obituary.qc
|
||||
hud_ammonotify.qc
|
||||
hud.qc
|
||||
hud_weaponselect.qc
|
||||
scoreboard.qc
|
||||
|
|
|
@ -143,6 +143,8 @@ FX_Impact(impactType_t iType, vector vecPos, vector vNormal)
|
|||
pointparticles(FX_IMPACT_BLACKBITS, vecPos, vNormal, 1);
|
||||
pointparticles(FX_IMPACT_SMOKE_BROWN, vecPos, vNormal, 1);
|
||||
break;
|
||||
case IMPACT_GRATE:
|
||||
case IMPACT_VENT:
|
||||
case IMPACT_METAL:
|
||||
pointparticles(FX_IMPACT_SPARK, vecPos, vNormal, 1);
|
||||
pointparticles(FX_IMPACT_BLACKBITS, vecPos, vNormal, 1);
|
||||
|
@ -184,6 +186,7 @@ FX_Impact(impactType_t iType, vector vecPos, vector vNormal)
|
|||
break;
|
||||
case IMPACT_METAL:
|
||||
Sound_PlayAt(vecPos, "sfx_impact.metal");
|
||||
print("Metal shit\n");
|
||||
break;
|
||||
case IMPACT_SLOSH:
|
||||
Sound_PlayAt(vecPos, "sfx_impact.slosh");
|
||||
|
|
|
@ -105,6 +105,7 @@ class player:base_player
|
|||
|
||||
#ifdef CLIENT
|
||||
void Weapons_AmmoUpdate(entity);
|
||||
void HUD_AmmoNotify_Check(player pl);
|
||||
/*
|
||||
=================
|
||||
player::ReceiveEntity
|
||||
|
@ -162,6 +163,7 @@ player::ReceiveEntity(float new, float fl)
|
|||
Weapons_AmmoUpdate(this);
|
||||
|
||||
setorigin(this, origin);
|
||||
HUD_AmmoNotify_Check(this);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue