]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
g_ca_spectate_enemies 0 will forbid dead ca players from spectating enemy players...
authoratheros <nexather@gmail.com>
Tue, 30 Aug 2011 13:35:13 +0000 (15:35 +0200)
committeratheros <nexather@gmail.com>
Tue, 30 Aug 2011 13:35:13 +0000 (15:35 +0200)
defaultXonotic.cfg
qcsrc/server/autocvars.qh
qcsrc/server/cl_client.qc

index e9d5b285bd05c74d083b9128b7d7b04d95d844e1..e7d0ed257f6f43aba2d2057390cbe90fe6105a4a 100644 (file)
@@ -808,6 +808,7 @@ set g_arena_powerups 0      "enables powerups (superhealth, strength and shield), whi
 set g_ca 0 "Clan Arena: Played in rounds, once you're dead you're out! The team with survivors wins the round."
 set g_ca_point_limit 10 "point limit 10 is standard for clan arena"
 set g_ca_point_leadlimit 0
+set g_ca_spectate_enemies 1 "Allow spectating enemy player by dead player during clan arena games."
 set g_ca_warmup 10 "how long the players will have time to run around the map before the round starts"
 
 // onslaught
index ff99823330df8ac13212d5d79facd93fc7b3f5a3..492f017832d9f20d363fe706487d7c64fa793033 100644 (file)
@@ -712,6 +712,7 @@ float autocvar_g_ca_damage2score_multiplier;
 float autocvar_g_ca_point_leadlimit;
 float autocvar_g_ca_point_limit;
 float autocvar_g_ca_round_timelimit;
+float autocvar_g_ca_spectate_enemies;
 float autocvar_g_ca_warmup;
 float autocvar_g_campaign;
 float autocvar_g_campaign_forceteam;
index f3d34bb47531dcef705aa032d86a40fb8fae9db2..a146e183c113b98edca54b11200798fe198c08b7 100644 (file)
@@ -2359,38 +2359,66 @@ float SpectateUpdate() {
        return 1;
 }
 
-float SpectateNext() {
-       other = find(self.enemy, classname, "player");
 
-       if (!other)
+// Returns next available player to spectate if g_ca_spectate_enemies == 0
+entity CA_SpectateNext(entity start) {
+       if (start.team == self.team) {
+               return start;
+       }
+       
+       other = start;
+       // continue from current player
+       while(other && other.team != self.team) {
+               other = find(other, classname, "player");
+       }
+       
+       if (!other) {
+               // restart from begining
                other = find(other, classname, "player");
+               while(other && other.team != self.team) {
+                       other = find(other, classname, "player");
+               }
+       }
+       
+       return other;
+}
 
+float SpectateNext() {
+       other = find(self.enemy, classname, "player");
+       if (g_ca && !autocvar_g_ca_spectate_enemies && self.caplayer) {
+               // CA and ca players when spectating enemies is forbidden
+               other = CA_SpectateNext(other);
+       } else {
+               // other modes and ca spectators or spectating enemies is allowed
+               if (!other)
+                       other = find(other, classname, "player");
+       }
+       
        if (other)
                self.enemy = other;
-
+       
        if(self.enemy.classname == "player") {
-           if(self.enemy.vehicle)
-           {      
-            msg_entity = self;
-            WriteByte(MSG_ONE, SVC_SETVIEWPORT);
-            WriteEntity(MSG_ONE, self.enemy);
-            //stuffcmd(self, "set viewsize $tmpviewsize \n");
-            self.movetype = MOVETYPE_NONE;
-            accuracy_resend(self);
-           }
-           else 
-           {           
-            msg_entity = self;
-            WriteByte(MSG_ONE, SVC_SETVIEW);
-            WriteEntity(MSG_ONE, self.enemy);
-            //stuffcmd(self, "set viewsize $tmpviewsize \n");
-            self.movetype = MOVETYPE_NONE;
-            accuracy_resend(self);
-
-            if(!SpectateUpdate())
-                PutObserverInServer();
-        }
-        return 1;
+               if(self.enemy.vehicle)
+               {          
+                       msg_entity = self;
+                       WriteByte(MSG_ONE, SVC_SETVIEWPORT);
+                       WriteEntity(MSG_ONE, self.enemy);
+                       //stuffcmd(self, "set viewsize $tmpviewsize \n");
+                       self.movetype = MOVETYPE_NONE;
+                       accuracy_resend(self);
+               }
+               else
+               {
+                       msg_entity = self;
+                       WriteByte(MSG_ONE, SVC_SETVIEW);
+                       WriteEntity(MSG_ONE, self.enemy);
+                       //stuffcmd(self, "set viewsize $tmpviewsize \n");
+                       self.movetype = MOVETYPE_NONE;
+                       accuracy_resend(self);
+                       if(!SpectateUpdate())
+                               PutObserverInServer();
+               }
+               return 1;
        } else {
                return 0;
        }