]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/ctf.qc
mutator_invincibleproj.qc: Add a mutator (like g_rocketflying) which allows projectil...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / ctf.qc
index b4356cab33e9ae546cdc2b35e9fd50f29521bce1..7b78958451dc79f6ae5d5ae80eac1d16343b858c 100644 (file)
@@ -66,12 +66,12 @@ void ctf_captureshield_update(entity p, float dir)
                {
                        if(should)
                        {
-                               centerprint_atprio(p, CENTERPRIO_SHIELDING, "^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_atprio(p, CENTERPRIO_SHIELDING, "^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_atprio(other, CENTERPRIO_SHIELDING, "^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()
@@ -125,15 +128,9 @@ void ctf_flag_spawnstuff()
        self.basewaypoint = self.nearestwaypoint;
 
        if(self.team == COLOR_TEAM1)
-       {
-               WaypointSprite_SpawnFixed("redbase", self.origin + '0 0 61', self, sprite);
-               WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_FLAG, colormapPaletteColor(COLOR_TEAM1 - 1, FALSE));
-       }
+               WaypointSprite_SpawnFixed("redbase", self.origin + '0 0 61', self, sprite, RADARICON_FLAG, colormapPaletteColor(COLOR_TEAM1 - 1, FALSE));
        else
-       {
-               WaypointSprite_SpawnFixed("bluebase", self.origin + '0 0 61', self, sprite);
-               WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_FLAG, colormapPaletteColor(COLOR_TEAM2 - 1, FALSE));
-       }
+               WaypointSprite_SpawnFixed("bluebase", self.origin + '0 0 61', self, sprite, RADARICON_FLAG, colormapPaletteColor(COLOR_TEAM2 - 1, FALSE));
 }
 
 float ctf_score_value(string parameter)
@@ -309,7 +306,7 @@ void DropFlag(entity e, entity penalty_receiver, entity attacker)
                backtrace("Flag carrier had no flag sprite?!?");
        }
        LogCTF("dropped", p.team, p);
-       sound (self, CHAN_TRIGGER, self.noise4, VOL_BASE, ATTN_NONE);
+       sound (p, CH_TRIGGER, self.noise4, VOL_BASE, ATTN_NONE);
 
        setattachment(e, world, "");
        e.damageforcescale = autocvar_g_balance_ctf_damageforcescale;
@@ -364,7 +361,7 @@ void FlagThink()
                {
                        bprint("The ", self.netname, " became impatient after ", ftos_decimals(flagcaptimerecord, 2), " seconds and returned itself\n");
 
-                       sound (self, CHAN_TRIGGER, self.noise3, VOL_BASE, ATTN_NONE);
+                       sound (self, CH_TRIGGER, self.noise3, VOL_BASE, ATTN_NONE);
                        self.owner.impulse = 141; // returning!
 
                        e = self;
@@ -391,7 +388,7 @@ void FlagThink()
                if (time > self.pain_finished)
                {
                        bprint("The ", self.netname, " has returned to base\n");
-                       sound (self, CHAN_TRIGGER, self.noise3, VOL_BASE, ATTN_NONE);
+                       sound (self, CH_TRIGGER, self.noise3, VOL_BASE, ATTN_NONE);
                        LogCTF("returned", self.team, world);
                        ReturnFlag(self);
                }
@@ -499,7 +496,7 @@ void FlagTouch()
                        }
                }
 
-               sound (other, CHAN_AUTO, self.noise2, VOL_BASE, ATTN_NONE);
+               sound (other, CH_TRIGGER, self.noise2, VOL_BASE, ATTN_NONE);
                WaypointSprite_DetachCarrier(other);
                if(self.speedrunning)
                        FakeTimeLimit(other, -1);
@@ -537,7 +534,7 @@ void FlagTouch()
                self.dropperid = other.playerid;
                PlayerScore_Add(other, SP_CTF_PICKUPS, 1);
                LogCTF("steal", self.team, other);
-               sound (other, CHAN_AUTO, self.noise, VOL_BASE, ATTN_NONE);
+               sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NONE);
 
                FOR_EACH_PLAYER(player)
                        if(player.team == self.team)
@@ -592,7 +589,7 @@ void FlagTouch()
                        }
                        PlayerScore_Add(other, SP_CTF_RETURNS, 1);
                        LogCTF("return", self.team, other);
-                       sound (other, CHAN_AUTO, self.noise1, VOL_BASE, ATTN_NONE);
+                       sound (other, CH_TRIGGER, self.noise1, VOL_BASE, ATTN_NONE);
                        ReturnFlag(self);
                }
                else if (!other.flagcarried && (other.playerid != self.dropperid || time > self.ctf_droptime + autocvar_g_balance_ctf_delay_collect))
@@ -624,7 +621,7 @@ void FlagTouch()
                        UpdateFrags(other, f);
                        PlayerScore_Add(other, SP_CTF_PICKUPS, 1);
                        LogCTF("pickup", self.team, other);
-                       sound (other, CHAN_AUTO, self.noise, VOL_BASE, ATTN_NONE);
+                       sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NONE);
 
                        FOR_EACH_PLAYER(player)
                                if(player.team == self.team)
@@ -771,6 +768,7 @@ Keys:
  (default ctf/respawn.wav)
 */
 
+void spawnfunc_item_flag_team2();
 void spawnfunc_item_flag_team1()
 {
        if (!g_ctf)
@@ -779,21 +777,22 @@ void spawnfunc_item_flag_team1()
                return;
        }
 
+       if (g_ctf_reverse)
+       {
+               float old_g_ctf_reverse = g_ctf_reverse;
+               g_ctf_reverse = 0; // avoid an endless loop
+               spawnfunc_item_flag_team2();
+               g_ctf_reverse = old_g_ctf_reverse;
+               return;
+       }
+
        // link flag into ctf_worldflaglist
        self.ctf_worldflagnext = ctf_worldflaglist;
        ctf_worldflaglist = self;
 
        self.classname = "item_flag_team";
-       if(g_ctf_reverse)
-       {
-               self.team = COLOR_TEAM2; // color 13 team (blue)
-               self.items = IT_KEY1; // silver key (bluish enough)
-       }
-       else
-       {
-               self.team = COLOR_TEAM1; // color 4 team (red)
-               self.items = IT_KEY2; // gold key (redish enough)
-       }
+       self.team = COLOR_TEAM1; // color 4 team (red)
+       self.items = IT_KEY2; // gold key (redish enough)
        self.netname = "^1RED^7 flag";
        self.target = "###item###";
        self.skin = autocvar_g_ctf_flag_red_skin;
@@ -877,21 +876,22 @@ void spawnfunc_item_flag_team2()
                return;
        }
 
+       if (g_ctf_reverse)
+       {
+               float old_g_ctf_reverse = g_ctf_reverse;
+               g_ctf_reverse = 0; // avoid an endless loop
+               spawnfunc_item_flag_team1();
+               g_ctf_reverse = old_g_ctf_reverse;
+               return;
+       }
+
        // link flag into ctf_worldflaglist
        self.ctf_worldflagnext = ctf_worldflaglist;
        ctf_worldflaglist = self;
 
        self.classname = "item_flag_team";
-       if(g_ctf_reverse)
-       {
-               self.team = COLOR_TEAM1; // color 4 team (red)
-               self.items = IT_KEY2; // gold key (redish enough)
-       }
-       else
-       {
-               self.team = COLOR_TEAM2; // color 13 team (blue)
-               self.items = IT_KEY1; // silver key (bluish enough)
-       }
+       self.team = COLOR_TEAM2; // color 13 team (blue)
+       self.items = IT_KEY1; // silver key (bluish enough)
        self.netname = "^4BLUE^7 flag";
        self.target = "###item###";
        self.skin = autocvar_g_ctf_flag_blue_skin;