From ca95865c8c7899a27352bc4a27fb838a5fa03303 Mon Sep 17 00:00:00 2001 From: cypress Date: Sat, 28 Oct 2023 12:09:06 -0400 Subject: [PATCH] Draw on-screen Bouncing Betty prompt --- source/cl_hud.c | 26 ++++++++++++++++++++++++++ source/cl_parse.c | 6 +++++- source/gl_screen.c | 26 ++++++++++++++++++++++++++ source/pr_cmds.c | 26 ++++++++++++++++++++++++++ source/protocol.h | 1 + source/screen.h | 2 ++ 6 files changed, 86 insertions(+), 1 deletion(-) diff --git a/source/cl_hud.c b/source/cl_hud.c index 70fd040..db2f186 100644 --- a/source/cl_hud.c +++ b/source/cl_hud.c @@ -66,6 +66,7 @@ int x_value, y_value; void M_DrawPic (int x, int y, qpic_t *pic); double HUD_Change_time;//hide hud when not chagned +double bettyprompt_time; extern cvar_t waypoint_mode; @@ -1348,6 +1349,28 @@ void HUD_Weapon (void) Draw_String (x_value, y_value, str); } +/* +=============== +HUD_BettyPrompt +=============== +*/ +void HUD_BettyPrompt (void) +{ + char str[32]; + char str2[32]; + + strcpy(str, va("Tap SWAP then press %s to\n", GetGrenadeButtonL())); + strcpy(str2, "place a Bouncing Betty\n"); + + int x, x2; + x = (vid.width - strlen(str)*8)/2; + x2 = (vid.width - strlen(str2)*8)/2; + + Draw_String(x, 60, str); + Draw_String(x2, 72, str2); + Draw_Pic (x + 20*8 - 4, 56, GetButtonIcon("+grenade")); +} + /* =============== HUD_Draw @@ -1383,6 +1406,9 @@ void HUD_Draw (void) return; } + if (bettyprompt_time > sv.time) + HUD_BettyPrompt(); + HUD_Blood(); HUD_Rounds(); HUD_Perks(); diff --git a/source/cl_parse.c b/source/cl_parse.c index a226457..b0b1e2a 100644 --- a/source/cl_parse.c +++ b/source/cl_parse.c @@ -1021,7 +1021,7 @@ void CL_ParseLimbUpdate (void) #define SHOWNET(x) if(cl_shownet.value==2)Con_Printf ("%3i:%s\n", msg_readcount-1, x); - +extern double bettyprompt_time; void CL_ParseServerMessage (void) { int cmd; @@ -1114,6 +1114,10 @@ void CL_ParseServerMessage (void) case svc_pulse: crosshair_pulse_grenade = true; break; + + case svc_bettyprompt: + bettyprompt_time = sv.time + 4; + break; case svc_stufftext: Cbuf_AddText (MSG_ReadString ()); diff --git a/source/gl_screen.c b/source/gl_screen.c index bb0e485..c5ca059 100644 --- a/source/gl_screen.c +++ b/source/gl_screen.c @@ -339,6 +339,32 @@ char *GetUseButtonL () return " "; } +char *GetGrenadeButtonL () +{ + int j; + int l; + char *b; + l = strlen("+grenade"); + + for (j=0 ; j<256 ; j++) + { + b = keybindings[j]; + if (!b) + continue; + if (!strncmp (b, "+grenade", l) ) + { + if (!strcmp(Key_KeynumToString(j), "SELECT") || + !strcmp(Key_KeynumToString(j), "LTRIGGER") || + !strcmp(Key_KeynumToString(j), "RTRIGGER") || + !strcmp(Key_KeynumToString(j), "HOME")) + return " "; + else + return " "; + } + } + return " "; +} + char *GetPerkName (int perk) { switch (perk) diff --git a/source/pr_cmds.c b/source/pr_cmds.c index a335efd..de4be2b 100644 --- a/source/pr_cmds.c +++ b/source/pr_cmds.c @@ -3231,6 +3231,31 @@ void PF_GrenadePulse(void) MSG_WriteByte (&client->message,svc_pulse); } +/* +================= +PF_BettyPrompt + +draws status on hud on +how to use bouncing +betty. + +nzp_bettyprompt() +================= +*/ +void PF_BettyPrompt(void) +{ + client_t *client; + int entnum; + + entnum = G_EDICTNUM(OFS_PARM0); + + if (entnum < 1 || entnum > svs.maxclients) + return; + + client = &svs.clients[entnum-1]; + MSG_WriteByte (&client->message, svc_bettyprompt); +} + /* ================= PF_MaxZombies @@ -3848,6 +3873,7 @@ PF_SongEgg, // #500 PF_MaxAmmo, // #501 PF_GrenadePulse, // #502 PF_MaxZombies, // #503 +PF_BettyPrompt, // #504 PF_Fixme, }; diff --git a/source/protocol.h b/source/protocol.h index fd73829..aa1f73f 100644 --- a/source/protocol.h +++ b/source/protocol.h @@ -151,6 +151,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define svc_songegg 44 // [string] track name #define svc_maxammo 45 #define svc_pulse 46 +#define svc_bettyprompt 47 // // client to server diff --git a/source/screen.h b/source/screen.h index a0da579..390e9ca 100644 --- a/source/screen.h +++ b/source/screen.h @@ -29,6 +29,8 @@ void SCR_SizeDown (void); void SCR_BringDownConsole (void); void SCR_CenterPrint (char *str); void SCR_UsePrint (int type, int cost, int weapon); +qpic_t *GetButtonIcon (char *buttonname); +char *GetGrenadeButtonL(); void SCR_BeginLoadingPlaque (void); void SCR_EndLoadingPlaque (void);