r5769 - in trunk/data/qcsrc: client common server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Fri Feb 6 02:17:06 EST 2009
Author: div0
Date: 2009-02-06 02:17:06 -0500 (Fri, 06 Feb 2009)
New Revision: 5769
Modified:
trunk/data/qcsrc/client/sbar.qc
trunk/data/qcsrc/common/constants.qh
trunk/data/qcsrc/server/cl_client.qc
trunk/data/qcsrc/server/g_world.qc
Log:
[ 2555913 ] Strength and invincibility timer
Modified: trunk/data/qcsrc/client/sbar.qc
===================================================================
--- trunk/data/qcsrc/client/sbar.qc 2009-02-06 07:09:46 UTC (rev 5768)
+++ trunk/data/qcsrc/client/sbar.qc 2009-02-06 07:17:06 UTC (rev 5769)
@@ -1491,6 +1491,59 @@
return offset + sbar_fontsize_y * '0 1 0';
}
+void CSQC_Strength_Timer() {
+ float stat_items;
+ stat_items = getstati(STAT_ITEMS);
+ if not(stat_items & IT_STRENGTH)
+ if not(stat_items & IT_INVINCIBLE)
+ return;
+
+ if (getstati(STAT_HEALTH) <= 0)
+ return;
+
+ vector pos, picsize, number_position;
+ float strength_time, invincibility_time, countdown_fontsize;
+
+ picsize = '40 40 0';
+ countdown_fontsize = 22;
+
+ //element will be positioned on the right side of the screen:
+ pos_x = vid_conwidth - picsize_x - 10; //margin 10 from right border
+ number_position_x = pos_x - 5/*margin to the left from image*/ - countdown_fontsize*2/*width of text*/;
+
+ pos_y = 180;
+ number_position_y = pos_y;
+
+ //now calculate the values Sbar_DrawXNum() will be called with:
+ number_position_x = number_position_x - sbar_x; //relative to sbar coordinates
+ number_position_y = number_position_y - sbar_y; //relative to sbar coordinates
+ number_position_y += 10; //center number vertically to the icon
+
+ pos_z = number_position_z = 0;
+
+ //strength
+ if (stat_items & IT_STRENGTH) {
+ drawpic(pos, "gfx/sb_str", picsize, '0 0.086 0.953'/*strength color*/, 1, DRAWFLAG_NORMAL);
+ strength_time = getstatf(STAT_STRENGTH_FINISHED) - time;
+ if (strength_time > 0) { //show countdown once we received the valid stats-value
+ Sbar_DrawXNum(number_position, ceil(strength_time), 2, countdown_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
+ }
+
+ //add some margin to the invincibility icon
+ pos_y += picsize_y + 10;
+ number_position_y += picsize_y + 10;
+ }
+
+ //invincibility
+ if (stat_items & IT_INVINCIBLE) {
+ drawpic(pos, "gfx/sb_invinc", picsize, '0.976 0 0.165'/*invincibility color*/, 1, DRAWFLAG_NORMAL);
+ invincibility_time = getstatf(STAT_INVINCIBLE_FINISHED) - time;
+ if (invincibility_time > 0) { //show countdown once we received the valid stats-value
+ Sbar_DrawXNum(number_position, ceil(invincibility_time), 2, countdown_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
+ }
+ }
+}
+
void Sbar_Draw (void)
{
float i;
@@ -1821,7 +1874,9 @@
// that is, 96 pixels mini scoreboard size, needing 16 pixels
// to the right!
}
-
+
+ //show strength/invincibility ICON and timer:
+ CSQC_Strength_Timer();
if(gametype == GAME_KEYHUNT)
{
Modified: trunk/data/qcsrc/common/constants.qh
===================================================================
--- trunk/data/qcsrc/common/constants.qh 2009-02-06 07:09:46 UTC (rev 5768)
+++ trunk/data/qcsrc/common/constants.qh 2009-02-06 07:17:06 UTC (rev 5769)
@@ -229,6 +229,8 @@
const float STAT_WEAPONS = 35;
const float STAT_SWITCHWEAPON = 36;
const float STAT_GAMESTARTTIME = 37;
+const float STAT_STRENGTH_FINISHED = 38;
+const float STAT_INVINCIBLE_FINISHED = 39;
const float CTF_STATE_ATTACK = 1;
const float CTF_STATE_DEFEND = 2;
const float CTF_STATE_COMMANDER = 3;
Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc 2009-02-06 07:09:46 UTC (rev 5768)
+++ trunk/data/qcsrc/server/cl_client.qc 2009-02-06 07:17:06 UTC (rev 5769)
@@ -1780,6 +1780,8 @@
self.health = spectatee.health;
self.impulse = 0;
self.items = spectatee.items;
+ self.strength_finished = spectatee.strength_finished;
+ self.invincible_finished = spectatee.invincible_finished;
self.weapons = spectatee.weapons;
self.switchweapon = spectatee.switchweapon;
self.weapon = spectatee.weapon;
Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc 2009-02-06 07:09:46 UTC (rev 5768)
+++ trunk/data/qcsrc/server/g_world.qc 2009-02-06 07:17:06 UTC (rev 5769)
@@ -543,6 +543,9 @@
addstat(STAT_SWITCHWEAPON, AS_INT, switchweapon);
addstat(STAT_GAMESTARTTIME, AS_FLOAT, stat_game_starttime);
Nagger_Init();
+
+ addstat(STAT_STRENGTH_FINISHED, AS_FLOAT, strength_finished);
+ addstat(STAT_INVINCIBLE_FINISHED, AS_FLOAT, invincible_finished);
next_pingtime = time + 5;
InitializeEntity(self, cvar_changes_init, INITPRIO_CVARS);
More information about the nexuiz-commits
mailing list