From 25891bda14996c2ae58fcc0a8061b3cbb0850baa Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 1 Jul 2011 13:11:09 +0200 Subject: [PATCH] Do not spam multiple msgs at once touching the flag when it's shielded --- qcsrc/common/constants.qh | 2 +- qcsrc/server/ctf.qc | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index ffb0d0faa..42262ac3d 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -614,7 +614,7 @@ float MAX_SHOT_DISTANCE = 32768; //centerprint ID list float CPID_TEAMCHANGE = 1; - +float CPID_CTF_CAPTURESHIELD = 2; float CPID_MINSTA_FINDAMMO = 3; float CPID_NIX_WPNCHANGE = 4; float CPID_DISCONNECT_IDLING = 5; diff --git a/qcsrc/server/ctf.qc b/qcsrc/server/ctf.qc index df44f5d2e..8370ef704 100644 --- a/qcsrc/server/ctf.qc +++ b/qcsrc/server/ctf.qc @@ -66,12 +66,12 @@ void ctf_captureshield_update(entity p, float dir) { if(should) { - centerprint(p, "^3You are now ^4shielded^3 from the flag\n^3for ^1too many unsuccessful attempts^3 to capture.\n\n^3Make some defensive scores before trying again."); + Send_CSQC_Centerprint_Generic(other, CPID_CTF_CAPTURESHIELD, "^3You are ^4shielded^3 from the flag\n^3for ^1too many unsuccessful attempts^3 to capture.\n\n^3Get some defensive scores before trying again.", 5, 0); // TODO csqc notifier for this } else { - centerprint(p, "^3You are now free.\n\n^3Feel free to ^1try to capture^3 the flag again\n^3if you think you will succeed."); + Send_CSQC_Centerprint_Generic(p, CPID_CTF_CAPTURESHIELD, "^3You are now free.\n\n^3Feel free to ^1try to capture^3 the flag again\n^3if you think you will succeed.", 5, 0); // TODO csqc notifier for this } p.ctf_captureshielded = should; @@ -88,6 +88,7 @@ float ctf_captureshield_customize() return TRUE; } +.float ctf_captureshield_touch_msgtime; void ctf_captureshield_touch() { if not(other.ctf_captureshielded) @@ -99,7 +100,9 @@ void ctf_captureshield_touch() mymid = (self.absmin + self.absmax) * 0.5; othermid = (other.absmin + other.absmax) * 0.5; Damage(other, self, self, 0, DEATH_HURTTRIGGER, mymid, normalize(othermid - mymid) * captureshield_force); - centerprint(other, "^3You are ^4shielded^3 from the flag\n^3for ^1too many unsuccessful attempts^3 to capture.\n\n^3Get some defensive scores before trying again."); + if (time - other.ctf_captureshield_touch_msgtime > 2) + Send_CSQC_Centerprint_Generic(other, CPID_CTF_CAPTURESHIELD, "^3You are ^4shielded^3 from the flag\n^3for ^1too many unsuccessful attempts^3 to capture.\n\n^3Get some defensive scores before trying again.", 5, 0); + other.ctf_captureshield_touch_msgtime = time; } void ctf_flag_spawnstuff() -- 2.39.2