[nexuiz-commits] r7991 - in branches/nexuiz-2.0: . data/gfx/hud data/qcsrc/client data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Wed Sep 30 02:54:57 EDT 2009
Author: div0
Date: 2009-09-30 02:54:56 -0400 (Wed, 30 Sep 2009)
New Revision: 7991
Added:
branches/nexuiz-2.0/data/gfx/hud/sb_kh_bluearrow.tga
branches/nexuiz-2.0/data/gfx/hud/sb_kh_pinkarrow.tga
branches/nexuiz-2.0/data/gfx/hud/sb_kh_redarrow.tga
branches/nexuiz-2.0/data/gfx/hud/sb_kh_yellowarrow.tga
Modified:
branches/nexuiz-2.0/.patchsets
branches/nexuiz-2.0/data/qcsrc/client/sbar.qc
branches/nexuiz-2.0/data/qcsrc/server/cl_client.qc
branches/nexuiz-2.0/data/qcsrc/server/keyhunt.qc
branches/nexuiz-2.0/data/qcsrc/server/keyhunt.qh
Log:
r7988 | div0 | 2009-09-29 15:20:19 -0400 (Tue, 29 Sep 2009) | 2 lines
better CTF indicators
r7989 | div0 | 2009-09-29 16:18:57 -0400 (Tue, 29 Sep 2009) | 2 lines
keyhunt: new HUD (less buggy I hope)... but needs to be tuned still. Not for 2.5.2.
r7990 | div0 | 2009-09-30 01:47:26 -0400 (Wed, 30 Sep 2009) | 2 lines
keyhunt HUD: show states of all keys like before, but also show indicators for their carriers (and a jumping arrows effect if RUN HERE is active)
Modified: branches/nexuiz-2.0/.patchsets
===================================================================
--- branches/nexuiz-2.0/.patchsets 2009-09-30 05:47:26 UTC (rev 7990)
+++ branches/nexuiz-2.0/.patchsets 2009-09-30 06:54:56 UTC (rev 7991)
@@ -1,2 +1,2 @@
master = svn://svn.icculus.org/nexuiz/trunk
-revisions_applied = 1-7945,7948-7948,7951-7986
+revisions_applied = 1-7945,7948-7948,7951-7990
Copied: branches/nexuiz-2.0/data/gfx/hud/sb_kh_bluearrow.tga (from rev 7990, trunk/data/gfx/hud/sb_kh_bluearrow.tga)
===================================================================
(Binary files differ)
Copied: branches/nexuiz-2.0/data/gfx/hud/sb_kh_pinkarrow.tga (from rev 7990, trunk/data/gfx/hud/sb_kh_pinkarrow.tga)
===================================================================
(Binary files differ)
Copied: branches/nexuiz-2.0/data/gfx/hud/sb_kh_redarrow.tga (from rev 7990, trunk/data/gfx/hud/sb_kh_redarrow.tga)
===================================================================
(Binary files differ)
Copied: branches/nexuiz-2.0/data/gfx/hud/sb_kh_yellowarrow.tga (from rev 7990, trunk/data/gfx/hud/sb_kh_yellowarrow.tga)
===================================================================
(Binary files differ)
Modified: branches/nexuiz-2.0/data/qcsrc/client/sbar.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/client/sbar.qc 2009-09-30 05:47:26 UTC (rev 7990)
+++ branches/nexuiz-2.0/data/qcsrc/client/sbar.qc 2009-09-30 06:54:56 UTC (rev 7991)
@@ -23,7 +23,9 @@
vector color;
float SCOREBOARD_OFFSET = 50;
+void CSQC_kh_hudreset();
void CSQC_kh_hud();
+void CSQC_ctf_hudreset();
void CSQC_ctf_hud();
void CSQC_nb_hud();
void MapVote_Draw();
@@ -2423,6 +2425,8 @@
}
else
Sbar_FinaleOverlay();
+
+ goto reset;
}
else if (sb_showscores_force || getstati(STAT_HEALTH) <= 0 || intermission == 1)
{
@@ -2432,6 +2436,8 @@
Sbar_DrawScoreboard();
Sbar_Score();
Sbar_Timer();
+
+ goto reset;
}
else
{
@@ -2632,15 +2638,30 @@
else if(gametype == GAME_NEXBALL)
CSQC_nb_hud();
}
+ return;
+
+:reset
+ // draw gametype specific icons
+ if(gametype == GAME_KEYHUNT)
+ CSQC_kh_hudreset();
+ else if(gametype == GAME_CTF)
+ CSQC_ctf_hudreset();
}
// CTF HUD
float redflag_prevframe, blueflag_prevframe; // status during previous frame
-float redflag_prevstatus, blueflag_prevstatus; // previous status, not = 0
+float redflag_prevstatus, blueflag_prevstatus; // last remembered status
float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
+
+void CSQC_ctf_hudreset(void)
+{
+ redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
+}
+
void CSQC_ctf_hud(void)
{
vector bottomleft, redflag_pos, blueflag_pos, sz;
+ float f; // every function should have that
bottomleft_x = 0;
bottomleft_y = vid_conheight;
bottomleft_z = 0;
@@ -2653,55 +2674,87 @@
redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
- if (redflag != redflag_prevframe) {
+ // when status CHANGES, set old status into prevstatus and current status into status
+ if (redflag != redflag_prevframe)
+ {
redflag_statuschange_time = time;
- if (redflag)
- redflag_prevstatus = redflag;
+ redflag_prevstatus = redflag_prevframe;
+ redflag_prevframe = redflag;
}
- redflag_prevframe = redflag;
- if (blueflag != blueflag_prevframe) {
+ if (blueflag != blueflag_prevframe)
+ {
blueflag_statuschange_time = time;
- if (blueflag)
- blueflag_prevstatus = blueflag;
+ blueflag_prevstatus = blueflag_prevframe;
+ blueflag_prevframe = blueflag;
}
- blueflag_prevframe = blueflag;
redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
+ float BLINK_FACTOR = 0.15;
+ float BLINK_BASE = 0.85;
+ // note:
+ // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
+ // thus
+ // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
+ // ensure RMS == 1
+ float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
+
string red_icon, red_icon_prevstatus;
+ float red_alpha, red_alpha_prevstatus;
+ red_alpha = red_alpha_prevstatus = 1;
switch(redflag) {
case 1: red_icon = "gfx/hud/sb_flag_red_taken"; break;
case 2: red_icon = "gfx/hud/sb_flag_red_lost"; break;
- case 3: red_icon = "gfx/hud/sb_flag_red_carrying"; break;
+ case 3: red_icon = "gfx/hud/sb_flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
default:
if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
- red_icon = "gfx/hud/sb_flag_red_shielded"; break;
- } switch(redflag_prevstatus) {
+ red_icon = "gfx/hud/sb_flag_red_shielded";
+ else
+ red_icon = string_null;
+ break;
+ }
+ switch(redflag_prevstatus) {
case 1: red_icon_prevstatus = "gfx/hud/sb_flag_red_taken"; break;
case 2: red_icon_prevstatus = "gfx/hud/sb_flag_red_lost"; break;
- case 3: red_icon_prevstatus = "gfx/hud/sb_flag_red_carrying"; break;
+ case 3: red_icon_prevstatus = "gfx/hud/sb_flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
default:
- if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
- red_icon_prevstatus = "gfx/hud/sb_flag_red_shielded"; break;
+ if(redflag == 3)
+ red_icon_prevstatus = "gfx/hud/sb_flag_red_carrying"; // make it more visible
+ else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
+ red_icon_prevstatus = "gfx/hud/sb_flag_red_shielded";
+ else
+ red_icon_prevstatus = string_null;
+ break;
}
string blue_icon, blue_icon_prevstatus;
+ float blue_alpha, blue_alpha_prevstatus;
+ blue_alpha = blue_alpha_prevstatus = 1;
switch(blueflag) {
case 1: blue_icon = "gfx/hud/sb_flag_blue_taken"; break;
case 2: blue_icon = "gfx/hud/sb_flag_blue_lost"; break;
- case 3: blue_icon = "gfx/hud/sb_flag_blue_carrying"; break;
+ case 3: blue_icon = "gfx/hud/sb_flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
default:
if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
- blue_icon = "gfx/hud/sb_flag_blue_shielded"; break;
- } switch(blueflag_prevstatus) {
+ blue_icon = "gfx/hud/sb_flag_blue_shielded";
+ else
+ blue_icon = string_null;
+ break;
+ }
+ switch(blueflag_prevstatus) {
case 1: blue_icon_prevstatus = "gfx/hud/sb_flag_blue_taken"; break;
case 2: blue_icon_prevstatus = "gfx/hud/sb_flag_blue_lost"; break;
- case 3: blue_icon_prevstatus = "gfx/hud/sb_flag_blue_carrying"; break;
+ case 3: blue_icon_prevstatus = "gfx/hud/sb_flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
default:
- if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
- blue_icon_prevstatus = "gfx/hud/sb_flag_blue_shielded"; break;
+ if(blueflag == 3)
+ blue_icon_prevstatus = "gfx/hud/sb_flag_blue_carrying"; // make it more visible
+ else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
+ blue_icon_prevstatus = "gfx/hud/sb_flag_blue_shielded";
+ else
+ blue_icon_prevstatus = string_null;
+ break;
}
if (myteam == COLOR_TEAM1) { // always draw own flag on left
@@ -2714,87 +2767,130 @@
sz = '52 52 0';
- // draw the icons
- if (redflag_statuschange_elapsedtime > 1 && red_icon) // red flag status has not changed during the previous second
- drawpic(redflag_pos, red_icon, sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- else { // red flag status HAS changed during the previous second
- if (redflag == 0 && red_icon_prevstatus) // in this case, the status was lost so we have to use the value in prevstatus to determine which icon to fade out
- drawpic_expanding(redflag_pos, red_icon_prevstatus, sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL,
- bound(0, redflag_statuschange_elapsedtime*2, 1));
- else if (red_icon)
- drawpic_expanding_two(redflag_pos, red_icon, sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL,
- bound(0, redflag_statuschange_elapsedtime*2, 1));
- }
-
- if (blueflag_statuschange_elapsedtime > 1 && blue_icon) // blue flag status has not changed during the previous second
- drawpic(blueflag_pos, blue_icon, sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- else { // blue flag status HAS changed during the previous second
- if (blueflag == 0 && blue_icon_prevstatus) // in this case, the status was lost so we have to use the value in prevstatus to determine which icon to fade out
- drawpic_expanding(blueflag_pos, blue_icon_prevstatus, sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL,
- bound(0, blueflag_statuschange_elapsedtime*2, 1));
- else if (blue_icon)
- drawpic_expanding_two(blueflag_pos, blue_icon, sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL,
- bound(0, blueflag_statuschange_elapsedtime*2, 1));
- }
+ f = bound(0, redflag_statuschange_elapsedtime*2, 1);
+ if(red_icon_prevstatus && f < 1)
+ drawpic_expanding(redflag_pos, red_icon_prevstatus, sz, '1 1 1', sbar_alpha_fg * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
+ if(red_icon)
+ drawpic(redflag_pos, red_icon, sz, '1 1 1', sbar_alpha_fg * red_alpha * f, DRAWFLAG_NORMAL);
+
+ f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
+ if(blue_icon_prevstatus && f < 1)
+ drawpic_expanding(blueflag_pos, blue_icon_prevstatus, sz, '1 1 1', sbar_alpha_fg * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
+ if(blue_icon)
+ drawpic(blueflag_pos, blue_icon, sz, '1 1 1', sbar_alpha_fg * blue_alpha * f, DRAWFLAG_NORMAL);
}
// Keyhunt HUD
+float kh_runheretime;
+
+void CSQC_kh_hudreset(void)
+{
+ kh_runheretime = 0;
+}
+
void CSQC_kh_hud(void)
{
- float kh_keys, kh_keys_status, kh_teams_set;
- vector red_pos, blue_pos, yellow_pos, pink_pos, kh_size;
+ float kh_keys;
+ float keyteam;
+ float a, aa;
+ vector p, pa, kh_size, kh_asize;
vector bottomleft;
bottomleft_x = 0;
bottomleft_y = vid_conheight;
bottomleft_z = 0;
- red_pos_x = 6;
- red_pos_y = vid_conheight - 35 - 6;
- red_pos_z = 0;
+ p_x = 6;
+ p_y = vid_conheight - 34 - 3;
+ p_z = 0;
- blue_pos_x = 6 + (24 * 1);
- blue_pos_y = vid_conheight - 35 - 6;
- blue_pos_z = 0;
-
- yellow_pos_x = 6 + (24 * 2);
- yellow_pos_y = vid_conheight - 35 - 6;
- yellow_pos_z = 0;
-
- pink_pos_x = 6 + (24 * 3);
- pink_pos_y = vid_conheight - 35 - 6;
- pink_pos_z = 0;
-
kh_keys = getstati(STAT_KH_KEYS);
- kh_keys_status = kh_keys / 256;
- kh_teams_set = cvar("_teams_available"); // set in keyhunt.qc
- kh_size = '22 35 0';
+ kh_size = '19 34 0';
+ kh_asize = '19 10 0';
+ pa = p + '0 -10 0';
- if (kh_keys_status & 1) // red
- drawpic (red_pos, "gfx/hud/sb_kh_red", kh_size, '1 1 1', 0.3, DRAWFLAG_NORMAL); // show 30% alpha key
- if (kh_keys & 1)
- drawpic (red_pos, "gfx/hud/sb_kh_red", kh_size, '1 1 1', 1.0, DRAWFLAG_NORMAL); // show solid key 100% alpha
+ float i, key;
- if (kh_keys_status & 2) // blue
- drawpic (blue_pos, "gfx/hud/sb_kh_blue", kh_size, '1 1 1', 0.3, DRAWFLAG_NORMAL);
- if (kh_keys & 2)
- drawpic (blue_pos, "gfx/hud/sb_kh_blue", kh_size, '1 1 1', 1.0, DRAWFLAG_NORMAL);
+ float keycount;
+ keycount = 0;
+ for(i = 0; i < 4; ++i)
+ {
+ key = floor(kh_keys / pow(32, i)) & 31;
+ keyteam = key - 1;
+ if(keyteam == 30 && keycount <= 4)
+ keycount += 4;
+ if(keyteam == myteam || keyteam == -1 || keyteam == 30)
+ keycount += 1;
+ }
+ // this yields 8 exactly if "RUN HERE" shows
- if (kh_teams_set & 4) // yellow
+ if(keycount == 8)
{
- if (kh_keys_status & 4)
- drawpic (yellow_pos, "gfx/hud/sb_kh_yellow", kh_size, '1 1 1', 0.3, DRAWFLAG_NORMAL);
- if (kh_keys & 4)
- drawpic (yellow_pos, "gfx/hud/sb_kh_yellow", kh_size, '1 1 1', 1.0, DRAWFLAG_NORMAL);
+ if(!kh_runheretime)
+ kh_runheretime = time;
+ pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
}
+ else
+ kh_runheretime = 0;
- if (kh_teams_set & 8) // pink
+ for(i = 0; i < 4; ++i)
{
- if (kh_keys_status & 8)
- drawpic (pink_pos, "gfx/hud/sb_kh_pink", kh_size, '1 1 1', 0.3, DRAWFLAG_NORMAL);
- if (kh_keys & 8)
- drawpic (pink_pos, "gfx/hud/sb_kh_pink", kh_size, '1 1 1', 1.0, DRAWFLAG_NORMAL);
+ key = floor(kh_keys / pow(32, i)) & 31;
+ keyteam = key - 1;
+ switch(keyteam)
+ {
+ case 30: // my key
+ keyteam = myteam;
+ a = 1;
+ aa = 1;
+ break;
+ case -1: // no key
+ a = 0;
+ aa = 0;
+ break;
+ default: // owned or dropped
+ a = 0.2;
+ aa = 0.5;
+ break;
+ }
+ if(a > 0)
+ {
+ switch(keyteam)
+ {
+ case COLOR_TEAM1:
+ drawpic (pa, "gfx/hud/sb_kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
+ break;
+ case COLOR_TEAM2:
+ drawpic (pa, "gfx/hud/sb_kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
+ break;
+ case COLOR_TEAM3:
+ drawpic (pa, "gfx/hud/sb_kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
+ break;
+ case COLOR_TEAM4:
+ drawpic (pa, "gfx/hud/sb_kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
+ break;
+ default:
+ break;
+ }
+ switch(i)
+ {
+ case 0:
+ drawpic (p, "gfx/hud/sb_kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
+ break;
+ case 1:
+ drawpic (p, "gfx/hud/sb_kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
+ break;
+ case 2:
+ drawpic (p, "gfx/hud/sb_kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
+ break;
+ case 3:
+ drawpic (p, "gfx/hud/sb_kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
+ break;
+ }
+ }
+ p_x += 24;
+ pa_x += 24;
}
}
Modified: branches/nexuiz-2.0/data/qcsrc/server/cl_client.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/cl_client.qc 2009-09-30 05:47:26 UTC (rev 7990)
+++ branches/nexuiz-2.0/data/qcsrc/server/cl_client.qc 2009-09-30 06:54:56 UTC (rev 7991)
@@ -2006,6 +2006,7 @@
======================
*/
void SpectateCopy(entity spectatee) {
+ self.kh_state = spectatee.kh_state;
self.armortype = spectatee.armortype;
self.armorvalue = spectatee.armorvalue;
self.ammo_cells = spectatee.ammo_cells;
@@ -2543,7 +2544,6 @@
minstagib_ammocheck();
ctf_setstatus();
- kh_setstatus();
nexball_setstatus();
self.dmg_team = max(0, self.dmg_team - cvar("g_teamdamage_resetspeed") * frametime);
Modified: branches/nexuiz-2.0/data/qcsrc/server/keyhunt.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/keyhunt.qc 2009-09-30 05:47:26 UTC (rev 7990)
+++ branches/nexuiz-2.0/data/qcsrc/server/keyhunt.qc 2009-09-30 06:54:56 UTC (rev 7991)
@@ -25,8 +25,10 @@
float kh_no_radar_circles;
// kh_state
-// bits 0-7: player's key status
-// bits 8-15: general key status
+// bits 0- 4: team of key 1, or 0 for no such key, or 30 for dropped, or 31 for self
+// bits 5- 9: team of key 2, or 0 for no such key, or 30 for dropped, or 31 for self
+// bits 10-14: team of key 3, or 0 for no such key, or 30 for dropped, or 31 for self
+// bits 15-19: team of key 4, or 0 for no such key, or 30 for dropped, or 31 for self
.float kh_state;
.float siren_time; // time delay the siren
//.float stuff_time; // time delay to stuffcmd a cvar
@@ -192,23 +194,6 @@
void kh_Key_Detach(entity key) // runs every time a key is dropped or lost. Runs several times times when all the keys are captured
{
- float i;
- i = test[key.owner.playerid];
- if(key.netname == "^1red key")
- i -= 1;
- if(key.netname == "^4blue key")
- i -= 2;
- if(key.netname == "^3yellow key")
- i -= 4;
- if(key.netname == "^6pink key")
- i -= 8;
- test[key.owner.playerid] = i;
-
- kh_show_temp();
- if(key.owner)
- key.owner.kh_state = (key.owner.kh_state | 255) - 255 + test[key.owner.playerid];
- //key.owner.kh_state += test[key.owner.playerid];
-
#ifdef KH_PLAYER_USE_ATTACHMENT
entity first;
first = key.owner.kh_next;
@@ -323,9 +308,7 @@
}
// moved that here, also update if there's no player
- kh_show_temp();
- if(key.owner)
- key.owner.kh_state = (key.owner.kh_state | 255) - 255 + test[key.owner.playerid];
+ kh_update_state();
key.pusher = world;
@@ -375,10 +358,11 @@
kh_Key_Remove(self);
}
-void kh_Key_Spawn(entity initial_owner, float angle) // runs every time a new flag is created, ie after all the keys have been collected
+void kh_Key_Spawn(entity initial_owner, float angle, float i) // runs every time a new flag is created, ie after all the keys have been collected
{
entity key;
key = spawn();
+ key.count = i;
key.classname = STR_ITEM_KH_KEY;
key.touch = kh_Key_Touch;
key.think = kh_Key_Think;
@@ -456,6 +440,8 @@
}
remove(key);
+
+ kh_update_state();
}
// -1 when no team completely owns all keys yet
@@ -548,16 +534,7 @@
if(intermission_running)
return;
- /*
- if(time > self.stuff_time)
- {
- FOR_EACH_PLAYER(player)
- player.kh_state = test[0]*256 + (player.kh_state&255);
- self.stuff_time = time + 1; // repeat in 1 second
- }
- */
-
#ifdef KH_KEY_ATTACHMENT_DEBUG
if(self.kh_prev == self.owner)
{
@@ -880,28 +857,13 @@
if(random() * players <= 1)
my_player = player;
}
- kh_Key_Spawn(my_player, 360 * i / kh_teams);
- //kh_Key_Spawn(my_player, 360 * i / kh_teams);
- //kh_Key_Spawn(my_player, 360 * i / kh_teams);
+ kh_Key_Spawn(my_player, 360 * i / kh_teams, i);
}
kh_tracking_enabled = FALSE;
kh_Controller_SetThink(cvar("g_balance_keyhunt_delay_tracking"), "Scanning frequency range...", kh_EnableTrackingDevice);
}
-void kh_setstatus() // runs all the time
-{
- if(kh_teams)
- {
- float kh_KEY;
- kh_KEY = (IT_RED_FLAG_TAKEN | IT_RED_FLAG_LOST | IT_BLUE_FLAG_TAKEN | IT_BLUE_FLAG_LOST); // the one impossible combination
- if(self.kh_next)
- self.items = self.items | kh_KEY;
- else
- self.items = self.items - (self.items & kh_KEY);
- }
-}
-
void kh_EnableTrackingDevice() // runs after each round
{
entity player;
@@ -1014,23 +976,32 @@
kh_controller = world;
}
-/**
- * kh_show_temp originally by victim.
- * changed it to use the kh_state stat var
- * Updates the general key stat bits for each player
- */
-void kh_show_temp()
+void kh_update_state()
{
entity player;
- float i, j;
+ entity key;
+ float s;
+ float f;
- j = 0; // reset/blank j
- for(i=1; i<17; ++i) // replace 17 with cvar("maxplayers"); !!!!!!!!!
- j += test[i];
+ s = 0;
+ FOR_EACH_KH_KEY(key)
+ {
+ if(key.owner)
+ f = key.team;
+ else
+ f = 30;
+ s |= pow(32, key.count) * f;
+ }
- test[0] = j;
+ FOR_EACH_CLIENT(player)
+ {
+ player.kh_state = s;
+ }
- j *= 256;
- FOR_EACH_PLAYER(player)
- player.kh_state = j + (player.kh_state & 255); // update the general key bits
+ FOR_EACH_KH_KEY(key)
+ {
+ if(key.owner)
+ key.owner.kh_state |= pow(32, key.count) * 31;
+ }
+ //print(ftos((nextent(world)).kh_state), "\n");
}
Modified: branches/nexuiz-2.0/data/qcsrc/server/keyhunt.qh
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/keyhunt.qh 2009-09-30 05:47:26 UTC (rev 7990)
+++ branches/nexuiz-2.0/data/qcsrc/server/keyhunt.qh 2009-09-30 06:54:56 UTC (rev 7991)
@@ -1,3 +1,4 @@
+.float kh_state;
float kh_teams;
float kh_tracking_enabled;
.entity kh_next, kh_prev;
@@ -6,7 +7,7 @@
void kh_Key_Attach(entity key);
void kh_Key_Detach(entity key);
void kh_Key_AssignTo(entity key, entity player);
-void kh_Key_Spawn(entity initial_owner, float angle);
+void kh_Key_Spawn(entity initial_owner, float angle, float idx);
void kh_Key_Remove(entity key);
void kh_Key_Collect(entity key, entity player);
void kh_Key_DropAll(entity player, float suicide);
@@ -21,11 +22,10 @@
void kh_finalize();
float kh_KeyCarrier_waypointsprite_visible_for_player(entity e);
float kh_Key_waypointsprite_visible_for_player(entity e);
-void kh_setstatus();
float kh_HandleFrags(entity attacker, entity targ, float f);
float kh_Key_AllOwnedByWhichTeam();
-void kh_show_temp(); // added by victim
+void kh_update_state();
#define STR_ITEM_KH_KEY "item_kh_key"
typedef void(void) kh_Think_t;
More information about the nexuiz-commits
mailing list