From: Mario Date: Wed, 14 Oct 2015 12:47:22 +0000 (+1000) Subject: Move the superspec followfc command into the CTF mutator file X-Git-Tag: xonotic-v0.8.2~1801^2~34 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=332a0883b072c2e610b5fdca61902e893df075e1;p=xonotic%2Fxonotic-data.pk3dir.git Move the superspec followfc command into the CTF mutator file --- diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 1155c6427..bf74dcea0 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -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; diff --git a/qcsrc/server/mutators/gamemode_ctf.qc b/qcsrc/server/mutators/gamemode_ctf.qc index b813ed87f..2814a4e4e 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qc +++ b/qcsrc/server/mutators/gamemode_ctf.qc @@ -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 diff --git a/qcsrc/server/mutators/mutator_superspec.qc b/qcsrc/server/mutators/mutator_superspec.qc index f5b3d36fb..8f1060371 100644 --- a/qcsrc/server/mutators/mutator_superspec.qc +++ b/qcsrc/server/mutators/mutator_superspec.qc @@ -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); } }