]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move the superspec followfc command into the CTF mutator file
authorMario <mario@smbclan.net>
Wed, 14 Oct 2015 12:47:22 +0000 (22:47 +1000)
committerMario <mario@smbclan.net>
Wed, 14 Oct 2015 12:47:22 +0000 (22:47 +1000)
qcsrc/common/monsters/sv_monsters.qc
qcsrc/server/mutators/gamemode_ctf.qc
qcsrc/server/mutators/mutator_superspec.qc

index 1155c6427108eb51320c3c382e3789d3e2b52683..bf74dcea0aa532126dfa72b66dd2f19f5a7cccbf 100644 (file)
@@ -571,7 +571,6 @@ vector Monster_Move_Target(entity targ)
                        || (self.enemy.takedamage == DAMAGE_NO)
                        || (vlen(self.origin - targ_origin) > self.target_range)
                        || ((trace_fraction < 1) && (trace_ent != self.enemy)))
-                       //|| (time > self.ctf_droptime + autocvar_g_ctf_pass_timelimit)) // TODO: chase timelimit?
                {
                        self.enemy = world;
                        self.pass_distance = 0;
index b813ed87f1c3f0ab42b698211cf846c58c3711a5..2814a4e4e3dd1137d36fb8789b7022dfe784aff5 100644 (file)
@@ -2328,6 +2328,51 @@ MUTATOR_HOOKFUNCTION(ctf, GetRecords)
        return false;
 }
 
+bool superspec_Spectate(entity _player); // TODO
+void superspec_msg(string _center_title, string _con_title, entity _to, string _msg, float _spamlevel); // TODO
+MUTATOR_HOOKFUNCTION(ctf, SV_ParseClientCommand)
+{
+       if(IS_PLAYER(self) || MUTATOR_RETURNVALUE || !cvar("g_superspectate")) { return false; }
+
+       if(cmd_name == "followfc")
+       {
+               if(!g_ctf)
+                       return true;
+
+               entity _player;
+               int _team = 0;
+               bool found = false;
+
+               if(cmd_argc == 2)
+               {
+                       switch(argv(1))
+                       {
+                               case "red": _team = NUM_TEAM_1; break;
+                               case "blue": _team = NUM_TEAM_2; break;
+                               case "yellow": if(ctf_teams >= 3) _team = NUM_TEAM_3; break;
+                               case "pink": if(ctf_teams >= 4) _team = NUM_TEAM_4; break;
+                       }
+               }
+
+               FOR_EACH_PLAYER(_player)
+               {
+                       if(_player.flagcarried && (_player.team == _team || _team == 0))
+                       {
+                               found = true;
+                               if(_team == 0 && IS_SPEC(self) && self.enemy == _player)
+                                       continue; // already spectating a fc, try to find the other fc
+                               return superspec_Spectate(_player);
+                       }
+               }
+
+               if(!found)
+                       superspec_msg("", "", self, "No active flag carrier\n", 1);
+               return true;
+       }
+
+       return false;
+}
+
 
 // ==========
 // Spawnfuncs
index f5b3d36fbcd2865d4c22de0aaf36fd3e2e2b4716..8f1060371e4da93608e10da4dc5b53a4e1abae25 100644 (file)
@@ -24,7 +24,7 @@ const float SSF_ITEMMSG = 4;
 
 .string superspec_itemfilter; //"classname1 classname2 ..."
 
-float _spectate(entity _player)
+bool superspec_Spectate(entity _player)
 {SELFPARAM();
        if(Spectate(_player) == 1)
                self.classname = "spectator";
@@ -115,7 +115,7 @@ MUTATOR_HOOKFUNCTION(superspec, ItemTouch)
                                        superspec_msg("", "", self, sprintf("Player %s^7 just picked up ^3%s\n^8(%s^8)\n", other.netname, _item.netname, _item.classname), 1);
                                if((self.autospec_flags & ASF_SSIM) && self.enemy != other)
                                {
-                                       _spectate(other);
+                                       superspec_Spectate(other);
 
                                        setself(this);
                                        return MUT_ITEMTOUCH_CONTINUE;
@@ -141,7 +141,7 @@ MUTATOR_HOOKFUNCTION(superspec, ItemTouch)
                                        if(self.autospec_flags & ASF_SHOWWHAT)
                                                superspec_msg("", "", self, sprintf("^7Following %s^7 due to picking up %s\n", other.netname, _item.netname), 2);
 
-                                       _spectate(other);
+                                       superspec_Spectate(other);
                                }
                        }
                }
@@ -349,7 +349,7 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
                FOR_EACH_PLAYER(_player)
                {
                        if(_player.strength_finished > time || _player.invincible_finished > time)
-                               return _spectate(_player);
+                               return superspec_Spectate(_player);
                }
 
                superspec_msg("", "", self, "No active powerup\n", 1);
@@ -362,7 +362,7 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
                FOR_EACH_PLAYER(_player)
                {
                        if(_player.strength_finished > time)
-                               return _spectate(_player);
+                               return superspec_Spectate(_player);
                }
 
                superspec_msg("", "", self, "No active Strength\n", 1);
@@ -375,49 +375,13 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
                FOR_EACH_PLAYER(_player)
                {
                        if(_player.invincible_finished > time)
-                               return _spectate(_player);
+                               return superspec_Spectate(_player);
                }
 
                superspec_msg("", "", self, "No active Shield\n", 1);
                return true;
        }
 
-       if(cmd_name == "followfc")
-       {
-               if(!g_ctf)
-                       return true;
-
-               entity _player;
-               int _team = 0;
-               bool found = false;
-
-               if(cmd_argc == 2)
-               {
-                       switch(argv(1))
-                       {
-                               case "red": _team = NUM_TEAM_1; break;
-                               case "blue": _team = NUM_TEAM_2; break;
-                               case "yellow": if(ctf_teams >= 3) _team = NUM_TEAM_3; break;
-                               case "pink": if(ctf_teams >= 4) _team = NUM_TEAM_4; break;
-                       }
-               }
-
-               FOR_EACH_PLAYER(_player)
-               {
-                       if(_player.flagcarried && (_player.team == _team || _team == 0))
-                       {
-                               found = true;
-                               if(_team == 0 && IS_SPEC(self) && self.enemy == _player)
-                                       continue; // already spectating a fc, try to find the other fc
-                               return _spectate(_player);
-                       }
-               }
-
-               if(!found)
-                       superspec_msg("", "", self, "No active flag carrier\n", 1);
-               return true;
-       }
-
        return false;
 #undef OPTIONINFO
 }
@@ -501,7 +465,7 @@ MUTATOR_HOOKFUNCTION(superspec, PlayerDies)
                        if(self.autospec_flags & ASF_SHOWWHAT)
                                superspec_msg("", "", self, sprintf("^7Following %s^7 due to followkiller\n", frag_attacker.netname), 2);
 
-                       _spectate(frag_attacker);
+                       superspec_Spectate(frag_attacker);
                }
        }