From a688d94e9dd7c227b1eb9391ea52bcdd8c82150c Mon Sep 17 00:00:00 2001 From: Wizzard <25581244+Wizzard@users.noreply.toomuchslop.com> Date: Tue, 19 Sep 2023 16:41:13 -0400 Subject: [PATCH] Rainbow watermark + cvar dz_watermark_rainbow --- src/cvars.c | 2 ++ src/hooks.c | 21 ++++++++++++++++++++- src/include/cvars.h | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/cvars.c b/src/cvars.c index 3c2e485..7a7ae1a 100644 --- a/src/cvars.c +++ b/src/cvars.c @@ -13,6 +13,7 @@ DECL_CVAR(crosshair); DECL_CVAR(tracers); DECL_CVAR(clmove); DECL_CVAR(watermark); +DECL_CVAR(watermark_rainbow); bool cvars_init(void) { REGISTER_CVAR(bhop, 1); @@ -25,6 +26,7 @@ bool cvars_init(void) { REGISTER_CVAR(tracers, 1); REGISTER_CVAR(clmove, 0); REGISTER_CVAR(watermark, 1); + REGISTER_CVAR(watermark_rainbow, 1); return true; } diff --git a/src/hooks.c b/src/hooks.c index 716d753..7b786bb 100644 --- a/src/hooks.c +++ b/src/hooks.c @@ -71,12 +71,31 @@ void h_CL_CreateMove(float frametime, usercmd_t* cmd, int active) { /*----------------------------------------------------------------------------*/ +rgb_t rainbow_color(float time) { + const float frequency = 0.1f; + + unsigned char r = (sin(frequency * time + 0) * 127.5f + 127.5f); + unsigned char g = (sin(frequency * time + 2.0f) * 127.5f + 127.5f); + unsigned char b = (sin(frequency * time + 4.0f) * 127.5f + 127.5f); + + return (rgb_t){ r, g, b }; +} + int h_HUD_Redraw(float time, int intermission) { int ret = ORIGINAL(HUD_Redraw, time, intermission); if (dz_watermark->value) { + /* Determine the color for the watermark */ + rgb_t color; + + if (dz_watermark_rainbow->value) { + color = rainbow_color(time); + } else { + color = (rgb_t){ 0, 255, 255 }; // default color + } + /* Watermark */ - engine_draw_text(5, 5, "https://git.deadzone.lol/Wizzard/goldsource-cheat", (rgb_t){ 0, 255, 255 }); + engine_draw_text(5, 5, "https://git.deadzone.lol/Wizzard/goldsource-cheat", color); } esp(); diff --git a/src/include/cvars.h b/src/include/cvars.h index c3ec99e..f2cfa4e 100644 --- a/src/include/cvars.h +++ b/src/include/cvars.h @@ -40,6 +40,7 @@ DECL_CVAR_EXTERN(crosshair); DECL_CVAR_EXTERN(tracers); DECL_CVAR_EXTERN(clmove); DECL_CVAR_EXTERN(watermark); +DECL_CVAR_EXTERN(watermark_rainbow); /*----------------------------------------------------------------------------*/