diff --git a/source/cl_hud.c b/source/cl_hud.c index 842deec..3910901 100644 --- a/source/cl_hud.c +++ b/source/cl_hud.c @@ -70,6 +70,8 @@ void M_DrawPic (int x, int y, qpic_t *pic); double HUD_Change_time;//hide hud when not chagned double bettyprompt_time; double nameprint_time; +double hud_maxammo_starttime; +double hud_maxammo_endtime; char player_name[16]; @@ -564,14 +566,38 @@ int maxammoopac; void HUD_MaxAmmo(void) { - maxammoy -= cl.time * 0.003; - maxammoopac -= 5; + char* maxammo_string = "Max Ammo!"; - Draw_ColoredStringCentered(maxammoy, "MAX AMMO!", 255, 255, 255, maxammoopac, 1); + int start_y = 55; + int end_y = 45; + int diff_y = end_y - start_y; - if (maxammoopac <= 0) { - domaxammo = false; + float text_alpha = 1.0f; + + int pos_y; + + double start_time, end_time; + + // For the first 0.5s, stay still while we fade in + if (hud_maxammo_endtime > sv.time + 1.5) { + start_time = hud_maxammo_starttime; + end_time = hud_maxammo_starttime + 0.5; + + text_alpha = (sv.time - start_time) / (end_time - start_time); + pos_y = start_y; } + // For the remaining 1.5s, fade out while we fly upwards. + else { + start_time = hud_maxammo_starttime + 0.5; + end_time = hud_maxammo_endtime; + + float percent_time = (sv.time - start_time) / (end_time - start_time); + + pos_y = start_y + diff_y * percent_time; + text_alpha = 1 - percent_time; + } + + Draw_ColoredStringCentered(pos_y, maxammo_string, 255, 255, 255, (int)(255 * text_alpha), 1); } /* @@ -1554,13 +1580,8 @@ void HUD_Draw (void) HUD_Point_Change(); HUD_Achievement(); - if (domaxammo == true) { - if (maxammoopac <= 0) { - maxammoopac = 255; - maxammoy = 100; - } + if (hud_maxammo_endtime > sv.time) HUD_MaxAmmo(); - } // This should always come last! if (screenflash_duration > sv.time) diff --git a/source/cl_parse.c b/source/cl_parse.c index bd827f5..0a533e4 100644 --- a/source/cl_parse.c +++ b/source/cl_parse.c @@ -21,7 +21,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" -extern qboolean domaxammo; +extern double hud_maxammo_starttime; +extern double hud_maxammo_endtime; + qboolean crosshair_pulse_grenade; extern int EN_Find(int num,char *string); @@ -1193,7 +1195,8 @@ void CL_ParseServerMessage (void) SCR_UsePrint (MSG_ReadByte (),MSG_ReadShort (),MSG_ReadByte ()); break; case svc_maxammo: - domaxammo = true; + hud_maxammo_starttime = sv.time; + hud_maxammo_endtime = sv.time + 2; break; case svc_pulse: