From: terencehill Date: Sun, 12 Jun 2011 22:25:37 +0000 (+0200) Subject: Other improvements to the multiple centerprints system X-Git-Tag: xonotic-v0.5.0~213 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=94e06a728c24bc94f5a05cc8233fc0d920b980f2;p=xonotic%2Fxonotic-data.pk3dir.git Other improvements to the multiple centerprints system Server now uses Send_CSQC_Centerprint_Generic instead of centerprint_builtin to send messages, so that it's possible to send more parameters (id, duration and countdown_num) without adding them to the msg (like the id before). If duration is not set, then the default duration will be used, that is hud_panel_centerprint_time. In the countdown case, the server can send only the first msg of a series with the same id and the client can continue the countdown by its own; the next countdown messages can be sent by the server anyway, for example to change the countdown msg or for whatever reason. Countdown can be stopped by the server at any time by sending an empty msg (always same id). The centerprint function in the client now is a wrapper for centerprint_generic, which actually handles the new parameters and add the msgs to the list. Changes on minstagib_ammocheck are neccessary to correctly stop the out of ammo countdown. Still other work to do anyway... --- diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 0cc156391..796b300c6 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -1318,6 +1318,16 @@ void Net_Notify() { { HUD_Centerprint(ReadString(), ReadString(), ReadShort(), ReadByte()); } + else if(type == CSQC_CENTERPRINT_GENERIC) + { + // id string time countdown_num + float id; + id = ReadByte(); + if (id == 0) + centerprint_generic(id, ReadString(), 0, 0); + else + centerprint_generic(id, ReadString(), ReadByte(), ReadByte()); + } } void Net_WeaponComplain() { diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 6c4fe426d..a5b8f080a 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -4339,45 +4339,41 @@ float cpm_index; string centerprint_messages[CENTERPRINT_MAX_MSGS]; float centerprint_msgID[CENTERPRINT_MAX_MSGS]; float centerprint_time[CENTERPRINT_MAX_MSGS]; +float centerprint_expire_time[CENTERPRINT_MAX_MSGS]; +float centerprint_countdown_num[CENTERPRINT_MAX_MSGS]; -string msg_without_CPID(string s) -{ - return substring(s, strstrofs(s, " ", 0) + 1, strlen(s)); -} -float get_CPID(string s) -{ - if(substring(s, 0, 1) != "\r") - return 0; - return stof(substring(s, 1, strstrofs(s, " ", 0))); -} -void centerprint(string strMessage) +void centerprint_generic(float new_id, string strMessage, float duration, float countdown_num) { float i, j; - if(autocvar_hud_panel_centerprint_time <= 0) + if(strMessage == "" && new_id == 0) return; - if(strMessage == "") - return; - - float new_id = get_CPID(strMessage); + if(duration == 0) + duration = autocvar_hud_panel_centerprint_time; for (i=0, j=cpm_index; i= time) + if (new_id && new_id == centerprint_msgID[j]) // && centerprint_expire_time[j] >= time { if(centerprint_messages[j]) strunzone(centerprint_messages[j]); - centerprint_messages[j] = strzone(msg_without_CPID(strMessage)); - centerprint_time[j] = time; + centerprint_messages[j] = strzone(strMessage); + + centerprint_time[j] = duration; + centerprint_expire_time[j] = time + duration; + centerprint_countdown_num[j] = countdown_num; return; } if(centerprint_messages[j] == strMessage) { - centerprint_time[j] = time; centerprint_msgID[j] = new_id; + + centerprint_time[j] = duration; + centerprint_expire_time[j] = time + duration; + centerprint_countdown_num[j] = countdown_num; return; } } @@ -4387,12 +4383,16 @@ void centerprint(string strMessage) cpm_index = CENTERPRINT_MAX_MSGS - 1; if(centerprint_messages[cpm_index]) strunzone(centerprint_messages[cpm_index]); - if (new_id) - centerprint_messages[cpm_index] = strzone(msg_without_CPID(strMessage)); - else - centerprint_messages[cpm_index] = strzone(strMessage); + centerprint_messages[cpm_index] = strzone(strMessage); centerprint_msgID[cpm_index] = new_id; - centerprint_time[cpm_index] = time; + centerprint_time[cpm_index] = duration; + centerprint_expire_time[cpm_index] = time + duration; + centerprint_countdown_num[cpm_index] = countdown_num; +} + +void centerprint(string strMessage) +{ + centerprint_generic(0, strMessage, autocvar_hud_panel_centerprint_time, 0); } // CenterPrint (#16) @@ -4457,21 +4457,34 @@ void HUD_CenterPrint (void) { if (j == CENTERPRINT_MAX_MSGS) j = 0; - if (centerprint_time[j] + autocvar_hud_panel_centerprint_time < time) - continue; - else if (centerprint_time[j] + autocvar_hud_panel_centerprint_time - fade > time) + if (centerprint_expire_time[j] < time) + { + if (centerprint_countdown_num[j]) + { + centerprint_countdown_num[j] = centerprint_countdown_num[j] - 1; + if (centerprint_countdown_num[j] == 0) + continue; + centerprint_expire_time[j] = centerprint_expire_time[j] + centerprint_time[j]; + } + else + continue; + } + if (centerprint_expire_time[j] - fade > time) { a = 1 * alpha_factor; sz = 1; } - else if (centerprint_time[j] + autocvar_hud_panel_centerprint_time > time) + else if (centerprint_expire_time[j] > time) { - a = (centerprint_time[j] + autocvar_hud_panel_centerprint_time - time) / fade * alpha_factor; + a = (centerprint_expire_time[j] - time) / fade * alpha_factor; sz = 0.8 + a * (1 - 0.8); } drawfontscale = sz * '1 1 0'; - n = tokenizebyseparator(centerprint_messages[j], "\n"); + if (centerprint_countdown_num[j]) + n = tokenizebyseparator(sprintf(centerprint_messages[j], centerprint_countdown_num[j]), "\n"); + else + n = tokenizebyseparator(centerprint_messages[j], "\n"); if (autocvar_hud_panel_centerprint_flip) { // check if the message can be entirely shown @@ -4514,12 +4527,12 @@ void HUD_CenterPrint (void) if (autocvar_hud_panel_centerprint_flip) { pos_y = next_msg_pos_y; - if (a < 1) + if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages pos_y += 1.5 * fontsize_y * (1 - a*a); } else { - if (a < 1) + if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages pos_y -= 1.5 * fontsize_y * (1 - a*a); } drawfontscale = '1 1 0'; diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index af849e18c..689722a1f 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -144,6 +144,7 @@ float camera_roll; vector camera_direction; void centerprint(string strMessage); +void centerprint_generic(float new_id, string strMessage, float duration, float countdown_num); #define ALPHA_MIN_VISIBLE 0.003 diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc index e47734cb3..0ecb2b89a 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/miscfunctions.qc @@ -20,7 +20,7 @@ void restartAnnouncer_Think() { countdown_rounded = floor(0.5 + countdown); if(countdown <= 0) { if (!spectatee_status) //do cprint only for players - centerprint(strcat(CPID_GAME_STARTING, _("^1Begin!"))); + centerprint_generic(CPID_GAME_STARTING, _("^1Begin!"), 1, 0); sound(world, CHAN_AUTO, strcat("announcer/", autocvar_cl_announcer, "/begin.wav"), VOL_BASEVOICE, ATTN_NONE); //reset maptime announcers now as well @@ -31,7 +31,7 @@ void restartAnnouncer_Think() { } else { if (!spectatee_status) //do cprint only for players - centerprint(strcat(CPID_GAME_STARTING, sprintf(_("^1Game starts in %d seconds"), countdown_rounded))); + centerprint_generic(CPID_GAME_STARTING, _("^1Game starts in %d seconds"), 1, 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); diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 31dcf71a9..ffabf0eb8 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -82,6 +82,7 @@ const float RANKINGS_CNT = 15; const float CSQC_KILLNOTIFY = 0; const float CSQC_CENTERPRINT = 1; +const float CSQC_CENTERPRINT_GENERIC = 2; const float ENT_CLIENT = 0; const float ENT_CLIENT_DEAD = 1; @@ -581,15 +582,15 @@ float WATERLEVEL_SUBMERGED = 3; float MAX_SHOT_DISTANCE = 32768; //centerprint ID list -#define CPID_TEAMCHANGE "\r1 " -#define CPID_KILL "\r2 " -#define CPID_MINSTA_FINDAMMO "\r3 " -#define CPID_NIX_WPNCHANGE "\r4 " -#define CPID_DISCONNECT_IDLING "\r5 " -#define CPID_ROUND_STARTING "\r6 " -#define CPID_GAME_STARTING "\r7 " -#define CPID_TIMEOUT_COUNTDOWN "\r8 " -#define CPID_MOTD "\r9 " +float CPID_TEAMCHANGE = 1; +float CPID_KILL = 2; +float CPID_MINSTA_FINDAMMO = 3; +float CPID_NIX_WPNCHANGE = 4; +float CPID_DISCONNECT_IDLING = 5; +float CPID_ROUND_STARTING = 6; +float CPID_GAME_STARTING = 7; +float CPID_TIMEOUT_COUNTDOWN = 8; +float CPID_MOTD = 9; // CSQC centerprint/notify message types float MSG_SUICIDE = 0; diff --git a/qcsrc/server/arena.qc b/qcsrc/server/arena.qc index 9ff080e97..04b392c94 100644 --- a/qcsrc/server/arena.qc +++ b/qcsrc/server/arena.qc @@ -229,10 +229,13 @@ void Arena_Warmup() if (g_ca) allowed_to_spawn = 1; if(champion && g_arena) + { msg = strcat("The Champion is ", champion_name, "^7\n"); + FOR_EACH_PLAYER(e) + centerprint(e, msg); // TODO: send this msg only once + } if(f != roundStartTime_prev) { - msg = strcat(CPID_ROUND_STARTING, msg, "Round will start in ", ftos(f),"\n"); roundStartTime_prev = f; if(f == 5) Announce("prepareforbattle"); @@ -243,8 +246,8 @@ void Arena_Warmup() else if(f == 1) Announce("1"); - FOR_EACH_PLAYER(e) - centerprint(e, msg); + FOR_EACH_PLAYER(e) + Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "Round will start in %d\n", 1, f); // TODO: send this msg only once } if (g_arena) { @@ -261,7 +264,7 @@ void Arena_Warmup() { roundStartTime_prev = f; Announce("begin"); - centerprint(self, strcat(CPID_ROUND_STARTING, "^1Begin!\n")); + Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "^1Begin!\n", 1, 0); if(g_ca) { ca_players = 0; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 6a0b0239e..3c61ba435 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -614,6 +614,9 @@ void PutObserverInServer (void) DropAllRunes(self); MUTATOR_CALLHOOK(MakePlayerObserver); + if (g_minstagib) + minstagib_stop_countdown(); + Portal_ClearAll(self); if(self.alivetime) @@ -1299,17 +1302,18 @@ void KillIndicator_Think() { if(self.cnt <= 10) AnnounceTo(self.owner, strcat(ftos(self.cnt), "")); + // TODO: Send_CSQC_Centerprint_Generic only once if(self.owner.killindicator_teamchange) { if(self.owner.killindicator_teamchange == -1) - centerprint(self.owner, strcat(CPID_TEAMCHANGE, "Changing team in ", ftos(self.cnt), " seconds")); + Send_CSQC_Centerprint_Generic(self.owner, CPID_TEAMCHANGE, "Changing team in %d seconds", 1, self.cnt); else if(self.owner.killindicator_teamchange == -2) - centerprint(self.owner, strcat(CPID_TEAMCHANGE, "Spectating in ", ftos(self.cnt), " seconds")); + Send_CSQC_Centerprint_Generic(self.owner, CPID_TEAMCHANGE, "Spectating in %d seconds", 1, self.cnt); else - centerprint(self.owner, strcat(CPID_TEAMCHANGE, "Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds")); + Send_CSQC_Centerprint_Generic(self.owner, CPID_TEAMCHANGE, strcat("Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in %d seconds"), 1, self.cnt); } else - centerprint(self.owner, strcat(CPID_KILL, "^1Suicide in ", ftos(self.cnt), " seconds")); + Send_CSQC_Centerprint_Generic(self.owner, CPID_KILL, "^1Suicide in %d seconds", 1, self.cnt); } self.nextthink = time + 1; self.cnt -= 1; @@ -1658,8 +1662,6 @@ void ClientConnect (void) bprint("\n"); - self.welcomemessage_time = 0; - stuffcmd(self, strcat(clientstuff, "\n")); stuffcmd(self, strcat("exec maps/", mapname, ".cfg\n")); stuffcmd(self, "cl_particles_reloadeffects\n"); @@ -1773,6 +1775,9 @@ void ClientConnect (void) set_dom_state(self); CheatInitClient(); + + // FIXME: .BUTTON_INFO in PrintWelcomeMessage must be checked at every frame, not just here + PrintWelcomeMessage(self); } /* @@ -1986,24 +1991,24 @@ string getTimeoutText(float addOneSecond) { else { retStr = strcat("Timeout begins in ", ftos(remainingLeadTime), " seconds!\n"); } - return strcat(CPID_TIMEOUT_COUNTDOWN, retStr); + return 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 strcat(CPID_TIMEOUT_COUNTDOWN, retStr); + return retStr; else - return strcat(CPID_TIMEOUT_COUNTDOWN, ""); + return ""; } else { retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime), " seconds!\n"); //don't show messages like "Timeout ends in 0 seconds"... if ((remainingTimeoutTime) > 0) - return strcat(CPID_TIMEOUT_COUNTDOWN, retStr); + return retStr; else - return strcat(CPID_TIMEOUT_COUNTDOWN, ""); + return ""; } } else return ""; @@ -2443,7 +2448,7 @@ void LeaveSpectatorMode() bprint ("^4", self.netname, "^4 is playing now\n"); if(!autocvar_g_campaign) - centerprint(self, CPID_MOTD); // clear MOTD + Send_CSQC_Centerprint_Generic(self, CPID_MOTD, "", 1, 0); // clear MOTD return; } else { @@ -2528,7 +2533,6 @@ void ObserverThink() } } } - PrintWelcomeMessage(self); } void SpectatorThink() @@ -2568,7 +2572,6 @@ void SpectatorThink() } } - PrintWelcomeMessage(self); self.flags |= FL_CLIENT | FL_NOTARGET; } @@ -2664,8 +2667,6 @@ void PlayerPreThink (void) CheckRules_Player(); - PrintWelcomeMessage(self); - if (intermission_running) { IntermissionThink (); // otherwise a button could be missed between @@ -2876,12 +2877,12 @@ void PlayerPreThink (void) if(autocvar_g_balance_nex_charge_rot_rate && self.nex_charge > autocvar_g_balance_nex_charge_limit && self.nex_charge_rottime < time) self.nex_charge = bound(autocvar_g_balance_nex_charge_limit, self.nex_charge - autocvar_g_balance_nex_charge_rot_rate * frametime / W_TICSPERFRAME, 1); - if(frametime) - player_anim(); - if (g_minstagib) minstagib_ammocheck(); + if(frametime) + player_anim(); + if(g_ctf) ctf_setstatus(); @@ -3020,13 +3021,14 @@ void PlayerPostThink (void) { if(timeleft != self.idlekick_lasttimeleft) { - centerprint_atprio(self, CENTERPRIO_IDLEKICK, strcat(CPID_DISCONNECT_IDLING, "^3Stop idling!\n^3Disconnecting in ", ftos(timeleft), "...")); + // TODO: send this msg only once + Send_CSQC_Centerprint_Generic(self, CPID_DISCONNECT_IDLING, "^3Stop idling!\n^3Disconnecting in %d seconds...", 1, timeleft); AnnounceTo(self, strcat(ftos(timeleft), "")); } } else { - centerprint_expire(self, CENTERPRIO_IDLEKICK); + Send_CSQC_Centerprint_Generic(self, CPID_DISCONNECT_IDLING, "", 1, timeleft); } self.idlekick_lasttimeleft = timeleft; } diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 043686bd8..072dfed8a 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -231,7 +231,7 @@ void weapon_defaultspawnfunc(float wpn); string w_deathtypestring; -void(entity client, string s) centerprint_builtin = #73; +// void(entity client, string s) centerprint_builtin = #73; .vector dest1, dest2; float gameover; diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 12a15f4f4..1175494a7 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -103,13 +103,15 @@ void fteqcc_testbugs() void timeoutHandler_Think() { local string timeStr; local entity plr; + // NOTE: the below Send_CSQC_Centerprint_Generic send msgs with countdown_num + // parameter set as 0, even if the msgs are part of a countdown if (timeoutStatus == 1) { if (remainingLeadTime > 0) { //centerprint the information to every player timeStr = getTimeoutText(0); FOR_EACH_REALCLIENT(plr) { if(plr.classname == "player") { - centerprint_atprio(plr, CENTERPRIO_SPAM, timeStr); + Send_CSQC_Centerprint_Generic(plr, CPID_TIMEOUT_COUNTDOWN, timeStr, 1, 0); } } remainingLeadTime -= 1; @@ -136,7 +138,7 @@ void timeoutHandler_Think() { timeStr = getTimeoutText(0); FOR_EACH_REALCLIENT(plr) { if(plr.classname == "player") { - centerprint_atprio(plr, CENTERPRIO_SPAM, timeStr); + Send_CSQC_Centerprint_Generic(plr, CPID_TIMEOUT_COUNTDOWN, timeStr, 1, 0); } } if(remainingTimeoutTime == autocvar_sv_timeout_resumetime) { //play a warning sound when only seconds are left @@ -156,7 +158,7 @@ void timeoutHandler_Think() { //get rid of the countdown message FOR_EACH_REALCLIENT(plr) { if(plr.classname == "player") { - centerprint_atprio(plr, CENTERPRIO_SPAM, ""); + Send_CSQC_Centerprint_Generic(plr, CPID_TIMEOUT_COUNTDOWN, "", 1, 0); } } remove(self); @@ -167,7 +169,7 @@ void timeoutHandler_Think() { else if (timeoutStatus == 0) { //if a player called the resumegame command (which set timeoutStatus to 0 already) FOR_EACH_REALCLIENT(plr) { if(plr.classname == "player") { - centerprint_atprio(plr, CENTERPRIO_SPAM, ""); + Send_CSQC_Centerprint_Generic(plr, CPID_TIMEOUT_COUNTDOWN, "", 1, 0); } } remove(self); diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 33fcebe10..4fc3b9c5c 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -728,6 +728,7 @@ float NumberToTeamNumber(float number) #define CENTERPRIO_ADMIN 99 .float centerprint_priority; .float centerprint_expires; +void Send_CSQC_Centerprint_Generic(entity e, float id, string s1, float duration, float countdown_num); void centerprint_atprio(entity e, float prio, string s) { if (intermission_running) @@ -742,7 +743,8 @@ void centerprint_atprio(entity e, float prio, string s) e.centerprint_expires = time + (e.cvar_hud_panel_centerprint_time * TIMEOUT_SLOWMO_VALUE); else e.centerprint_expires = time + e.cvar_hud_panel_centerprint_time; - centerprint_builtin(e, s); + // centerprint_builtin(e, s); + Send_CSQC_Centerprint_Generic(e, 0, s, 0, 0); } } void centerprint_expire(entity e, float prio) @@ -750,7 +752,8 @@ void centerprint_expire(entity e, float prio) if (prio == e.centerprint_priority) { e.centerprint_priority = 0; - centerprint_builtin(e, ""); + // centerprint_builtin(e, ""); + Send_CSQC_Centerprint_Generic(e, 0, "", 0, 0); } } void centerprint(entity e, string s) @@ -1689,6 +1692,26 @@ void precache() #define WRITESPECTATABLE_MSG_ONE(statement) WRITESPECTATABLE_MSG_ONE_VARNAME(oldmsg_entity, statement) #define WRITESPECTATABLE(msg,statement) if(msg == MSG_ONE) { WRITESPECTATABLE_MSG_ONE(statement); } else statement float WRITESPECTATABLE_workaround = 0 + +void Send_CSQC_Centerprint_Generic(entity e, float id, string s1, float duration, float countdown_num) +{ + if (clienttype(e) == CLIENTTYPE_REAL) + { + msg_entity = e; + WRITESPECTATABLE_MSG_ONE({ + WriteByte(MSG_ONE, SVC_TEMPENTITY); + WriteByte(MSG_ONE, TE_CSQC_NOTIFY); + WriteByte(MSG_ONE, CSQC_CENTERPRINT_GENERIC); + WriteByte(MSG_ONE, id); + WriteString(MSG_ONE, s1); + if (id != 0) + { + WriteByte(MSG_ONE, duration); + WriteByte(MSG_ONE, countdown_num); + } + }); + } +} // WARNING: this kills the trace globals #define EXACTTRIGGER_TOUCH if(WarpZoneLib_ExactTrigger_Touch()) return #define EXACTTRIGGER_INIT WarpZoneLib_ExactTrigger_Init() diff --git a/qcsrc/server/mutators/mutator_nix.qc b/qcsrc/server/mutators/mutator_nix.qc index b306b653c..bed98afba 100644 --- a/qcsrc/server/mutators/mutator_nix.qc +++ b/qcsrc/server/mutators/mutator_nix.qc @@ -98,13 +98,13 @@ void NIX_GiveCurrentWeapon() if(dt >= 1 && dt <= 5) self.nix_lastinfotime = -42; else - centerprint(self, strcat(CPID_NIX_WPNCHANGE, "\n\n^2Active weapon: ^3", W_Name(nix_weapon))); + Send_CSQC_Centerprint_Generic(self, CPID_NIX_WPNCHANGE, strcat("^2Active weapon: ^3", W_Name(nix_weapon)), 2, dt); } 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(CPID_NIX_WPNCHANGE, "^3", ftos(dt), "^2 seconds until weapon change...\n\nNext weapon: ^3", W_Name(nix_nextweapon), "\n")); + Send_CSQC_Centerprint_Generic(self, CPID_NIX_WPNCHANGE, strcat("^3%d^2 seconds until weapon change...\n\nNext weapon: ^3", W_Name(nix_nextweapon), "\n"), 1, dt); // TODO: send this msg only once } if(!(self.items & IT_UNLIMITED_WEAPON_AMMO) && time > self.nix_nextincr) diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 0eea40b15..d6e232286 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -283,7 +283,6 @@ float Item_GiveTo(entity item, entity player) { pickedup = TRUE; // play some cool sounds ;) - centerprint(player, CPID_MINSTA_FINDAMMO); //clear countdown if (clienttype(player) == CLIENTTYPE_REAL) { if(player.health <= 5) diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index 0acd63080..6ef71b98a 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -455,8 +455,6 @@ void PrintWelcomeMessage(entity pl) { string s, modifications, motd; - if(self.cvar_hud_panel_centerprint_time == 0) return; - if(autocvar_g_campaign) { if(self.classname == "player" && !self.BUTTON_INFO) @@ -468,11 +466,6 @@ void PrintWelcomeMessage(entity pl) return; } - if( !(timeoutStatus >= 1) ) { //really print the WelcomeMessage to the player every frame when timeout-seconds are shown or the game is restarted, to make sure that the shown number is accurate - if(self.welcomemessage_time > time) return; - self.welcomemessage_time = time + max(0.5, self.cvar_hud_panel_centerprint_time * 0.6); - } - if(autocvar_g_campaign) { centerprint(pl, campaign_message); @@ -495,7 +488,7 @@ void PrintWelcomeMessage(entity pl) return; goto normal; } - return centerprint_atprio(self, CENTERPRIO_SPAM, specString); + return centerprint_atprio(self, CENTERPRIO_SPAM, specString); // TODO: convert to Send_CSQC_Centerprint_Generic(self, CPID_TIMEOUT_COUNTDOWN, ... } :normal @@ -535,7 +528,7 @@ void PrintWelcomeMessage(entity pl) local string versionmessage; versionmessage = GetClientVersionMessage(); - s = strcat(CPID_MOTD, "This is Xonotic ", autocvar_g_xonoticversion, "\n", versionmessage); + s = strcat("This is Xonotic ", autocvar_g_xonoticversion, "\n", versionmessage); s = strcat(s, "^8\n\nmatch type is ^1", gamemode_name, "^8\n"); if(modifications != "") @@ -567,7 +560,7 @@ void PrintWelcomeMessage(entity pl) } s = strcat(s, "\n"); - centerprint(pl, s); + Send_CSQC_Centerprint_Generic(pl, CPID_MOTD, s, autocvar_welcome_message_time, 0); } diff --git a/qcsrc/server/w_minstanex.qc b/qcsrc/server/w_minstanex.qc index 920d03f71..95225be3a 100644 --- a/qcsrc/server/w_minstanex.qc +++ b/qcsrc/server/w_minstanex.qc @@ -88,77 +88,80 @@ void W_MinstaNex_Attack (void) .float minstagib_nextthink; -void minstagib_ammocheck (void) +.float minstagib_needammo; +void minstagib_stop_countdown(void) { - if (time < self.minstagib_nextthink || self.deadflag || gameover) + if (self.minstagib_needammo) + { + self.health = 100; + Send_CSQC_Centerprint_Generic(self, CPID_MINSTA_FINDAMMO, "", 1, 0); + } + self.minstagib_needammo = FALSE; +} +void minstagib_ammocheck(void) +{ + if (time < self.minstagib_nextthink) return; - if (self.ammo_cells <= 0) - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) + if (self.deadflag || gameover || self.ammo_cells > 0 || (self.items & IT_UNLIMITED_WEAPON_AMMO)) + minstagib_stop_countdown(); + else { + self.minstagib_needammo = TRUE; if (self.health == 5) { - 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, 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, 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, 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, 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, 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, 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, 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, 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, strcat(CPID_MINSTA_FINDAMMO, "^39^7 seconds left to find some ammo\n")); + Send_CSQC_Centerprint_Generic(self, CPID_MINSTA_FINDAMMO, "^1%d^7 second left to find some ammo", 1, 9); Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0'); AnnounceTo(self, "9"); } else if (self.health == 100) { - centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "get some ammo or\nyou'll be dead in ^310^7 seconds...")); + Send_CSQC_Centerprint_Generic(self, CPID_MINSTA_FINDAMMO, "get some ammo or\nyou'll be dead in ^3%d^7 seconds...", 1, 10); Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0'); if not(self.flags & FL_GODMODE) AnnounceTo(self, "10");