#define CENTERPRINT_MAX_LINES 10
float cpm_index;
string centerprint_messages[CENTERPRINT_MAX_LINES];
+float centerprint_msgID[CENTERPRINT_MAX_LINES];
float centerprint_width[CENTERPRINT_MAX_LINES];
float centerprint_time[CENTERPRINT_MAX_LINES];
float centerprint_expire;
float centerprint_num;
-float centerprint_offset_hint;
vector centerprint_fontsize;
+string strip_CPID(string s)
+{
+ return substring(s, strstrofs(s, " ", 0) + 1, strlen(s));
+}
+float get_CPID(string s)
+{
+ if(substring(s, 0, 1) != "#")
+ return 0;
+ return stof(substring(s, 1, strstrofs(s, " ", 0)));
+}
void centerprint(string strMessage)
{
float i, j, n, hcount;
if(strMessage == "")
return;
- // strip trailing newlines
- j = strlen(strMessage) - 1;
- while(substring(strMessage, j, 1) == "\n" && j >= 0)
- j = j - 1;
- strMessage = substring(strMessage, 0, j + 1);
-
- if(strMessage == "")
- return;
-
- // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
- j = 0;
- while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
- j = j + 1;
- strMessage = substring(strMessage, j, strlen(strMessage) - j);
- centerprint_offset_hint = j;
-
- if(strMessage == "")
- return;
+ float new_id = get_CPID(strMessage);
for (i=0, j=cpm_index; i<CENTERPRINT_MAX_LINES; ++i, ++j)
{
if (j == CENTERPRINT_MAX_LINES)
j = 0;
+ if (new_id && new_id == centerprint_msgID[j])
+ {
+ if(centerprint_messages[j])
+ strunzone(centerprint_messages[j]);
+ centerprint_messages[j] == strzone(strip_CPID(strMessage));
+ centerprint_time[j] = time;
+ return;
+ }
if(centerprint_messages[j] == strMessage)
{
centerprint_time[j] = time;
+ centerprint_msgID[j] = new_id;
return;
}
}
cpm_index = CENTERPRINT_MAX_LINES - 1;
if(centerprint_messages[cpm_index])
strunzone(centerprint_messages[cpm_index]);
- centerprint_messages[cpm_index] = strzone(strMessage);
+ if (new_id)
+ centerprint_messages[cpm_index] = strzone(strip_CPID(strMessage));
+ else
+ centerprint_messages[cpm_index] = strzone(strMessage);
+ centerprint_msgID[cpm_index] = new_id;
centerprint_time[cpm_index] = time;
countdown_rounded = floor(0.5 + countdown);
if(countdown <= 0) {
if (!spectatee_status) //do cprint only for players
- centerprint(_("^1Begin!"));
+ centerprint(strcat(CPID_GAME_STARTING, _("^1Begin!")));
sound(world, CHAN_AUTO, strcat("announcer/", autocvar_cl_announcer, "/begin.wav"), VOL_BASEVOICE, ATTN_NONE);
//reset maptime announcers now as well
}
else {
if (!spectatee_status) //do cprint only for players
- centerprint(sprintf(_("^1Game starts in %d seconds"), countdown_rounded));
+ centerprint(strcat(CPID_GAME_STARTING, sprintf(_("^1Game starts in %d seconds"), countdown_rounded)));
if(countdown_rounded <= 3 && countdown_rounded >= 1) {
sound(world, CHAN_AUTO, strcat("announcer/", autocvar_cl_announcer, "/", ftos(countdown_rounded), ".wav"), VOL_BASEVOICE, ATTN_NONE);
float MAX_SHOT_DISTANCE = 32768;
+//centerprint ID list
+#define CPID_TEAMCHANGE "#1 "
+#define CPID_KILL "#2 "
+#define CPID_MINSTA_FINDAMMO "#3 "
+#define CPID_NIX_WPNCHANGE "#4 "
+#define CPID_DISCONNECT_IDLING "#5 "
+#define CPID_ROUND_STARTING "#6 "
+#define CPID_GAME_STARTING "#7 "
+#define CPID_TIMEOUT_COUNTDOWN "#8 "
+
// CSQC centerprint/notify message types
float MSG_SUICIDE = 0;
float MSG_KILL = 1;
allowed_to_spawn = 1;
if(champion && g_arena)
msg = strcat("The Champion is ", champion_name, "^7\n");
- //centerprint(self, strcat(msg, "The Champion is ", champion.netname, "^7\n"));
if(f != roundStartTime_prev) {
- msg = strcat(msg, "Round will start in ", ftos(f),"\n");
- //centerprint(self, strcat("Round will start in ", ftos(f),"\n"));
+ msg = strcat(CPID_ROUND_STARTING, msg, "Round will start in ", ftos(f),"\n");
roundStartTime_prev = f;
if(f == 5)
Announce("prepareforbattle");
if(self.owner.killindicator_teamchange)
{
if(self.owner.killindicator_teamchange == -1)
- centerprint(self.owner, strcat("Changing team in ", ftos(self.cnt), " seconds"));
+ centerprint(self.owner, strcat(CPID_TEAMCHANGE, "Changing team in ", ftos(self.cnt), " seconds"));
else if(self.owner.killindicator_teamchange == -2)
- centerprint(self.owner, strcat("Spectating in ", ftos(self.cnt), " seconds"));
+ centerprint(self.owner, strcat(CPID_TEAMCHANGE, "Spectating in ", ftos(self.cnt), " seconds"));
else
- centerprint(self.owner, strcat("Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds"));
+ centerprint(self.owner, strcat(CPID_TEAMCHANGE, "Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds"));
}
else
- centerprint(self.owner, strcat("^1Suicide in ", ftos(self.cnt), " seconds"));
+ centerprint(self.owner, strcat(CPID_KILL, "^1Suicide in ", ftos(self.cnt), " seconds"));
}
self.nextthink = time + 1;
self.cnt -= 1;
else {
retStr = strcat("Timeout begins in ", ftos(remainingLeadTime), " seconds!\n");
}
- return retStr;
+ return strcat(CPID_TIMEOUT_COUNTDOWN, retStr);
}
else if (timeoutStatus == 2) {
if (addOneSecond) {
retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime + 1), " seconds!\n");
//don't show messages like "Timeout ends in 0 seconds"...
if ((remainingTimeoutTime + 1) > 0)
- return retStr;
+ return strcat(CPID_TIMEOUT_COUNTDOWN, retStr);
else
- return "";
+ return strcat(CPID_TIMEOUT_COUNTDOWN, "");
}
else {
retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime), " seconds!\n");
//don't show messages like "Timeout ends in 0 seconds"...
- if (remainingTimeoutTime > 0)
- return retStr;
+ if ((remainingTimeoutTime) > 0)
+ return strcat(CPID_TIMEOUT_COUNTDOWN, retStr);
else
- return "";
+ return strcat(CPID_TIMEOUT_COUNTDOWN, "");
}
}
else return "";
{
if(timeleft != self.idlekick_lasttimeleft)
{
- centerprint_atprio(self, CENTERPRIO_IDLEKICK, strcat("^3Stop idling!\n^3Disconnecting in ", ftos(timeleft), "..."));
+ centerprint_atprio(self, CENTERPRIO_IDLEKICK, strcat(CPID_DISCONNECT_IDLING, "^3Stop idling!\n^3Disconnecting in ", ftos(timeleft), "..."));
AnnounceTo(self, strcat(ftos(timeleft), ""));
}
}
if(dt >= 1 && dt <= 5)
self.nix_lastinfotime = -42;
else
- centerprint(self, strcat("\n\n^2Active weapon: ^3", W_Name(nix_weapon)));
+ centerprint(self, strcat(CPID_NIX_WPNCHANGE, "\n\n^2Active weapon: ^3", W_Name(nix_weapon)));
}
if(self.nix_lastinfotime != dt)
{
self.nix_lastinfotime = dt; // initial value 0 should count as "not seen"
if(dt >= 1 && dt <= 5)
- centerprint(self, strcat("^3", ftos(dt), "^2 seconds until weapon change...\n\nNext weapon: ^3", W_Name(nix_nextweapon), "\n"));
+ centerprint(self, strcat(CPID_NIX_WPNCHANGE, "^3", ftos(dt), "^2 seconds until weapon change...\n\nNext weapon: ^3", W_Name(nix_nextweapon), "\n"));
}
if(!(self.items & IT_UNLIMITED_WEAPON_AMMO) && time > self.nix_nextincr)
{
if (self.health == 5)
{
- centerprint(self, "you're dead now...\n");
+ centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "you're dead now...\n"));
Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
AnnounceTo(self, "terminated");
}
else if (self.health == 10)
{
- centerprint(self, "^11^7 second left to find some ammo\n");
+ centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^11^7 second left to find some ammo\n"));
Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
AnnounceTo(self, "1");
}
else if (self.health == 20)
{
- centerprint(self, "^12^7 seconds left to find some ammo\n");
+ centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^12^7 seconds left to find some ammo\n"));
Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
AnnounceTo(self, "2");
}
else if (self.health == 30)
{
- centerprint(self, "^13^7 seconds left to find some ammo\n");
+ centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^13^7 seconds left to find some ammo\n"));
Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
AnnounceTo(self, "3");
}
else if (self.health == 40)
{
- centerprint(self, "^14^7 seconds left to find some ammo\n");
+ centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^14^7 seconds left to find some ammo\n"));
Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
AnnounceTo(self, "4");
}
else if (self.health == 50)
{
- centerprint(self, "^15^7 seconds left to find some ammo\n");
+ centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^15^7 seconds left to find some ammo\n"));
Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
AnnounceTo(self, "5");
}
else if (self.health == 60)
{
- centerprint(self, "^36^7 seconds left to find some ammo\n");
+ centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^36^7 seconds left to find some ammo\n"));
Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
AnnounceTo(self, "6");
}
else if (self.health == 70)
{
- centerprint(self, "^37^7 seconds left to find some ammo\n");
+ centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^37^7 seconds left to find some ammo\n"));
Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
AnnounceTo(self, "7");
}
else if (self.health == 80)
{
- centerprint(self, "^38^7 seconds left to find some ammo\n");
+ centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^38^7 seconds left to find some ammo\n"));
Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
AnnounceTo(self, "8");
}
else if (self.health == 90)
{
- centerprint(self, "^39^7 seconds left to find some ammo\n");
+ centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^39^7 seconds left to find some ammo\n"));
Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
AnnounceTo(self, "9");
}
else if (self.health == 100)
{
- centerprint(self, "get some ammo or\nyou'll be dead in ^310^7 seconds...");
+ centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "get some ammo or\nyou'll be dead in ^310^7 seconds..."));
Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
if not(self.flags & FL_GODMODE)
AnnounceTo(self, "10");