From 87567680fa2b51b77d0213ce2403a2c5d5d6a820 Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Sun, 4 Mar 2012 02:08:02 +0200 Subject: [PATCH] Colorize display digits red when ammo is too low --- data/defaultVT.cfg | 3 +++ data/qcsrc/server/cl_weaponsystem.qc | 27 ++++++++++++++++++++++++--- docs/TODO.txt | 2 -- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/data/defaultVT.cfg b/data/defaultVT.cfg index 9d29a078..5c90a8f6 100644 --- a/data/defaultVT.cfg +++ b/data/defaultVT.cfg @@ -650,6 +650,9 @@ set g_multijump 1 "Number of multiple jumps to allow (jumping again in the air), set g_multijump_add 0 "0 = make the current z velocity equal to jumpvelocity, 1 = add jumpvelocity to the current z velocity" set g_multijump_speed -125 "Minimum vertical speed a player must have in order to jump again" +set g_gundisplay_warn_load 10 "display digits will show in warning mode when weapon load is below this amount" +set g_gundisplay_warn_ammo 50 "display digits will show in warning mode when ammo is below this amount" + // effects r_glsl_postprocess 1 r_picmipsprites 0 // Voretournament uses sprites that should never be picmipped (team mate, typing, waypoints) diff --git a/data/qcsrc/server/cl_weaponsystem.qc b/data/qcsrc/server/cl_weaponsystem.qc index 26246b9e..8a9ff0d2 100644 --- a/data/qcsrc/server/cl_weaponsystem.qc +++ b/data/qcsrc/server/cl_weaponsystem.qc @@ -1592,6 +1592,9 @@ void W_SetupProjectileVelocity(entity missile, float pSpeed, float spread) void W_DisplayDigitThink() { self.nextthink = time; + float w_load, w_ammo; + w_load = self.owner.weapon_load[self.owner.weapon]; + w_ammo = self.owner.(self.owner.current_ammo); // the owner has switched to another weapon, remove the digits if(self.weapon != self.owner.weapon || self.owner.classname != "player" || self.deadflag != DEAD_NO) @@ -1633,21 +1636,39 @@ void W_DisplayDigitThink() string txt; if(self.team) // weapon load display { - if(self.owner.weapon_load[self.owner.weapon] <= 0) + if(w_load <= 0) { self.skin = 11; // unavailable digit return; } else { - txt = ftos(floor(self.owner.weapon_load[self.owner.weapon])); + txt = ftos(floor(w_load)); txt = substring(txt, self.cnt - 1, 1); } + + if(self.owner.weapon_load[self.owner.weapon] <= ceil(cvar("g_gundisplay_warn_load"))) + { + // in warning mode, only keep red color + if(!self.colormod) + self.colormod = '1 1 1'; + self.colormod_y = 0; + self.colormod_z = 0; + } } else // ammo display { - txt = ftos(floor(self.owner.(self.owner.current_ammo))); + txt = ftos(floor(w_ammo)); txt = substring(txt, self.cnt - 1, 1); + + if(w_ammo <= ceil(cvar("g_gundisplay_warn_ammo"))) + { + // in warning mode, only keep red color + if(!self.colormod) + self.colormod = '1 1 1'; + self.colormod_y = 0; + self.colormod_z = 0; + } } if((!txt || txt == "")) diff --git a/docs/TODO.txt b/docs/TODO.txt index 815c730c..72c537fc 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -136,6 +136,4 @@ - 0.7: Make sure all effects work for spectators too (such as the macro earthquake effect) -- 0.7 | 0.8: Make display digits red when ammo or load are too low - - 0.7 | 0.8: The stomach gurgle sound duration does not match the pitch properly \ No newline at end of file -- 2.39.2