game-source/ctf/qwsrc/status.qc

365 lines
9.4 KiB
C++
Raw Normal View History

/*
2003-03-03 19:17:04 +00:00
status.qc
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
.float laststattime; // time of last status update
.float motd_count;
.float statstate; // is the status bar on?
float PLAYERSTATTIME = 1.75;
2003-03-03 19:17:04 +00:00
void ()
MOTD =
{
if (self.motd_count < 4) {
self.motd_count = self.motd_count + 1;
if (self.classname == "spectator") {
2003-03-03 19:17:04 +00:00
centerprint (self, "Welcome!\nRunning ThreeWave CTF 4.21\n\n"
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>!\n");
return;
}
if (gamestart) {
2003-03-03 19:17:04 +00:00
centerprint (self, "Welcome!\nRunning ThreeWave CTF 4.21\n\n"
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>!\n\nChoose an exit...\n"); //red
return;
}
if (self.steam == TEAM_COLOR1)
2003-03-03 19:17:04 +00:00
centerprint (self, "Welcome!\nRunning ThreeWave CTF 4.21\n\n"
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>!\n\nYou are <20><><EFBFBD> team\n"); //red
else
2003-03-03 19:17:04 +00:00
centerprint (self, "Welcome!\nRunning Threewave CTF 4.21\n\n"
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>!\n\nYou are <20><><EFBFBD><EFBFBD> team"); //blue
return;
}
2003-03-03 19:17:04 +00:00
sprint (self, PRINT_HIGH, "Impulse 70 to turn off status bar\n");
sprint (self, PRINT_HIGH, "Impulse 71 through 81 to set status bar "
"resolution\n");
sprint (self, PRINT_HIGH, "71:200 72:240 73:300 74:350 75:384 76:400 "
"77:480 78:600 79:768 81:1024\n");
self.motd_count = 0;
};
2003-03-03 19:17:04 +00:00
void ()
MOTD_ChooseTeam =
{
if (self.motd_count < 6) {
self.motd_count = self.motd_count + 1;
2003-03-03 19:17:04 +00:00
centerprint (self, "Welcome!\nRunning ThreeWave CTF 4.2\n\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "
"<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>!\n\nPress 1 for <20><><EFBFBD> team\nPress 2 for <20><><EFBFBD><EFBFBD> "
"team\nOr Press Jump for automatic team\n");
return;
}
self.motd_count = 0;
};
2003-03-03 19:17:04 +00:00
void ()
TeamCaptureCheckUpdate =
{
2003-03-03 19:17:04 +00:00
local entity p;
if (gamestart)
return; // handled by vote exit
if (lastteamscrtime > time)
return;
lastteamscrtime = time + TEAMSCRTIME;
// count up teamscr
teamscr1 = teamscr2 = 0;
2003-03-03 19:17:04 +00:00
p = find (world, classname, "player");
while (p != world) {
if (p.steam == TEAM_COLOR1)
teamscr1 = teamscr1 + p.frags;
else if (p.steam == TEAM_COLOR2)
teamscr2 = teamscr2 + p.frags;
2003-03-03 19:17:04 +00:00
p = find (p, classname, "player");
}
};
2003-03-03 19:17:04 +00:00
void ()
TeamCaptureResetUpdate =
{
lastteamscrtime = 0;
TeamCaptureCheckUpdate();
};
2003-03-03 19:17:04 +00:00
void ()
TeamEndScore =
{
2003-03-03 19:17:04 +00:00
local string s;
if (gamestart)
return;
lastteamscrtime = 0;
TeamCaptureCheckUpdate();
if (teamscr1 > teamscr2) {
2003-03-03 19:17:04 +00:00
bprint (PRINT_HIGH, "<EFBFBD><EFBFBD><EFBFBD> team won the level with ");
s = ftos (teamscr1);
bprint (PRINT_HIGH, s);
bprint (PRINT_HIGH, " points!\n");
bprint (PRINT_HIGH, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> team lost with ");
s = ftos (teamscr2);
bprint (PRINT_HIGH, s);
bprint (PRINT_HIGH, " points.\n");
} else if (teamscr1 < teamscr2) {
2003-03-03 19:17:04 +00:00
bprint (PRINT_HIGH, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> team won the level with ");
s = ftos (teamscr2);
bprint (PRINT_HIGH, s);
bprint (PRINT_HIGH, " points!\n");
bprint (PRINT_HIGH, "<EFBFBD><EFBFBD><EFBFBD> team lost with ");
s = ftos (teamscr1);
bprint (PRINT_HIGH, s);
bprint (PRINT_HIGH, " points.\n");
} else {
2003-03-03 19:17:04 +00:00
bprint (PRINT_HIGH, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> and <20><><EFBFBD> team tied level with ");
s = ftos (teamscr1);
bprint (PRINT_HIGH, s);
bprint (PRINT_HIGH, " points!\n");
}
};
2003-03-03 19:17:04 +00:00
string (entity who)
TeamSetStatRes =
{
2003-03-03 19:17:04 +00:00
switch (who.statstate) {
default: // > 7 = 768+
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
2003-03-03 19:17:04 +00:00
case 7: // 600
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
2003-03-03 19:17:04 +00:00
case 6: // 480
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
2003-03-03 19:17:04 +00:00
case 5: // 400:
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
2003-03-03 19:17:04 +00:00
case 4: // 384
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
2003-03-03 19:17:04 +00:00
case 3: // 350
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
2003-03-03 19:17:04 +00:00
case 2: // 300
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
2003-03-03 19:17:04 +00:00
case 1: // 240:
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
2003-03-03 19:17:04 +00:00
case 0: // 200
return "\n\n\n\n\n\n\n\n\n\n\n\n";
}
};
2003-03-03 19:17:04 +00:00
string (entity who)
TeamSetStatRes2 =
{
2003-03-03 19:17:04 +00:00
switch (who.statstate) {
default: // >7 = 768+
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
2003-03-03 19:17:04 +00:00
case 7: // 600
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
2003-03-03 19:17:04 +00:00
case 6: // 480
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
2003-03-03 19:17:04 +00:00
case 5: // 400
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
2003-03-03 19:17:04 +00:00
case 4: // 384
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
2003-03-03 19:17:04 +00:00
case 3: // 350
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
2003-03-03 19:17:04 +00:00
case 2: // 300
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
2003-03-03 19:17:04 +00:00
case 1: // 240
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
2003-03-03 19:17:04 +00:00
case 0: // 200
return "\n\n\n\n\n\n\n\n\n\n\n";
}
};
2003-03-03 19:17:04 +00:00
void ()
TeamCapturePlayerUpdate =
{
2003-03-03 19:17:04 +00:00
local entity e;
local string n, t, s1, s2, s3, res;
if (self.laststattime > time)
return;
2003-03-03 19:17:04 +00:00
TeamCaptureCheckUpdate ();
self.laststattime = time + PLAYERSTATTIME;
if (self.motd_count) {
2003-03-03 19:17:04 +00:00
MOTD ();
return;
}
if (self.statstate < 0)
return;
res = TeamSetStatRes(self);
if (gamestart) {
if (vote_leader == world)
2003-03-03 19:17:04 +00:00
centerprint2 (self, res, " Choose an exit...");
else {
2003-03-03 19:17:04 +00:00
res = TeamSetStatRes2 (vote_leader);
n = ftos (voteexit_time - time);
centerprint5 (self, res, vote_leader.message,
" leads\n", n, " seconds until exit");
}
return;
}
//.1234567890123456789012345678901234567
// Res.R.B. Capture The Flag
// Res.R.B. BLUE 999
if (self.player_flag & ITEM_RUNE1_FLAG)
s1 = "Resist <20>";
else if (self.player_flag & ITEM_RUNE2_FLAG)
s1 = "Strength<EFBFBD>";
else if (self.player_flag & ITEM_RUNE3_FLAG)
s1 = "Haste <20>";
else if (self.player_flag & ITEM_RUNE4_FLAG)
s1 = "Regen <20>";
else
s1 = " <20>";
2003-03-03 19:17:04 +00:00
e = find (world, classname, "item_flag_team1");
if (e.cnt == FLAG_AT_BASE)
s2 = " <20>";
else if (e.cnt == FLAG_CARRIED)
s2 = "R<EFBFBD>";
else
s2 = "Ò…";
2003-03-03 19:17:04 +00:00
e = find (world, classname, "item_flag_team2");
if (e.cnt == FLAG_AT_BASE)
s3 = " <20>";
else if (e.cnt == FLAG_CARRIED)
s3 = "B<EFBFBD>";
else
s3 = "Â…";
2003-08-27 23:43:13 +00:00
if (teamscr1 == 0 && teamscr2 == 0) {
2003-03-03 19:17:04 +00:00
// CTFBOT
centerprint5 (self, res, s1, s2, s3, " Capture The Flag");
return;
}
2003-03-03 19:17:04 +00:00
if (time < (last_flag_capture + 6)) {
if (last_capture_team == TEAM_COLOR1) {
if (teamscr1 > teamscr2) {
t = "Red Capture! RED ";
n = ftos(teamscr1 - teamscr2);
} else if (teamscr1 < teamscr2) {
t = "Red Capture! BLUE ";
n = ftos(teamscr2 - teamscr1);
} else {
t = "Red Capture! TIED ";
n = "";
}
2003-03-03 19:17:04 +00:00
} else {
if (teamscr1 > teamscr2) {
t = "Blue Capture! RED ";
n = ftos(teamscr1 - teamscr2);
} else if (teamscr1 < teamscr2) {
t = "Blue Capture! BLUE ";
n = ftos(teamscr2 - teamscr1);
} else {
t = "Blue Capture! TIED ";
n = "";
}
}
2003-03-03 19:17:04 +00:00
} else {
if (teamscr1 > teamscr2) {
t = " RED ";
n = ftos(teamscr1 - teamscr2);
} else if (teamscr1 < teamscr2) {
t = " BLUE ";
n = ftos(teamscr2 - teamscr1);
} else {
t = " TIED ";
n = "";
}
}
centerprint7(self, res, s1, s2, s3, " ", t, n); //
};
2003-03-03 19:17:04 +00:00
void (entity who, string s)
TeamPlayerUpdate =
{
local string n, res;
TeamCaptureCheckUpdate();
who.laststattime = time + PLAYERSTATTIME;
if (who.statstate < 0) {
centerprint(who, s);
return;
}
res = TeamSetStatRes2(who);
if (teamscr1 == 0 && teamscr2 == 0) {
centerprint3(who, res, s, "\n Capture The Flag");
} else if (teamscr1 > teamscr2) {
n = ftos(teamscr1 - teamscr2);
centerprint4(who, res, s, "\n RED ", n);
} else if (teamscr1 < teamscr2) {
n = ftos(teamscr2 - teamscr1);
centerprint4(who, res, s, "\n BLUE ", n);
} else
centerprint3(who, res, s, "\n TIED");
};
2003-03-03 19:17:04 +00:00
void (entity who, string s1, string s2)
TeamPlayerUpdate2 =
{
2003-03-03 19:17:04 +00:00
local string res, n;
2003-03-03 19:17:04 +00:00
TeamCaptureCheckUpdate ();
who.laststattime = time + PLAYERSTATTIME;
if (who.statstate < 0) {
2003-03-03 19:17:04 +00:00
centerprint2 (who, s1, s2);
return;
}
2003-03-03 19:17:04 +00:00
res = TeamSetStatRes2 (who);
if (teamscr1 == 0 && teamscr2 == 0) {
2003-03-03 19:17:04 +00:00
centerprint4 (who, res, s1, s2,
"\n Capture The Flag");
return;
} else if (teamscr1 > teamscr2) {
n = ftos(teamscr1 - teamscr2);
2003-03-03 19:17:04 +00:00
centerprint5 (who, res, s1, s2,
"\n RED ", n);
} else if (teamscr1 < teamscr2) {
n = ftos(teamscr2 - teamscr1);
2003-03-03 19:17:04 +00:00
centerprint5 (who, res, s1, s2,
"\n BLUE ", n);
} else {
2003-03-03 19:17:04 +00:00
centerprint4 (who, res, s1, s2,
"\n TIED");
return;
}
};