]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
allow forcing friend and enemy colors in teamplay
authorRudolf Polzer <divverent@alientrap.org>
Mon, 30 Apr 2012 15:24:59 +0000 (17:24 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Mon, 30 Apr 2012 15:24:59 +0000 (17:24 +0200)
It's done by the normal cvars. In teamplay, forcemyplayercolors defines friend color, and forceplayercolors forces enemy to own color from settings. This best matches DM.

Enemy color cannot be forced if there are more than 2 teams, obviously. Friend color still can, as long as the color does not match one of the enemy colors.

qcsrc/client/autocvars.qh
qcsrc/client/csqcmodel_hooks.qc

index 43dd0dd1834bd76fea1b760fefca9489d4c75f8a..01718c9429aef7a0204045ffe77a138fa6b022f0 100644 (file)
@@ -394,6 +394,7 @@ float autocvar_cl_forceplayercolors;
 string autocvar_cl_forcemyplayermodel;
 float autocvar_cl_forcemyplayerskin;
 float autocvar_cl_forcemyplayercolors;
+float autocvar__cl_color;
 float autocvar__cl_playerskin;
 string autocvar__cl_playermodel;
 float autocvar_cl_precacheplayermodels;
index 152ecbe82e998e398d35fcd0a8a1f0cbc37a811b..ac3a6952fa9232c70e5f89b619c57c30fa2a8425 100644 (file)
@@ -196,7 +196,58 @@ void CSQCPlayer_ForceModel_Apply(float islocalplayer)
        }
 
        // forceplayercolors too
-       if(!teamplay)
+       if(teamplay)
+       {
+               // own team's color is never forced
+               float forcecolor_friend = 0;
+               float forcecolor_enemy = 0;
+               float teams_count = 0;
+               float my_colors = 1024 + autocvar__cl_color;
+               entity tm;
+
+               for(tm = teams.sort_next; tm; tm = tm.sort_next)
+                       if(tm.team != COLOR_SPECTATOR)
+                               ++teams_count;
+
+               if(autocvar_cl_forcemyplayercolors)
+                       forcecolor_friend = 1024 + autocvar_cl_forcemyplayercolors;
+               if(autocvar_cl_forceplayercolors && teams_count == 2)
+                       forcecolor_enemy = 1024 + my_colors;
+
+               if(forcecolor_enemy && !forcecolor_friend)
+               {
+                       // only enemy color is forced?
+                       // verify it is not equal to the friend color
+                       if(forcecolor_enemy == 1024 + 17 * myteam)
+                               forcecolor_enemy = 0;
+               }
+
+               if(forcecolor_friend && !forcecolor_enemy)
+               {
+                       // only friend color is forced?
+                       // verify it is not equal to the enemy color
+                       for(tm = teams.sort_next; tm; tm = tm.sort_next)
+                               if(tm.team != myteam)
+                                       if(forcecolor_friend == 1024 + 17 * tm.team)
+                                               forcecolor_friend = 0;
+               }
+
+               float cm;
+               cm = self.forceplayermodels_savecolormap;
+               cm = (cm >= 1024) ? cm : (stof(getplayerkeyvalue(self.colormap - 1, "colors")) + 1024);
+
+               if(cm == 1024 + 17 * myteam)
+               {
+                       if(forcecolor_friend)
+                               self.colormap = forcecolor_friend;
+               }
+               else
+               {
+                       if(forcecolor_enemy)
+                               self.colormap = forcecolor_enemy;
+               }
+       }
+       else
        {
                if(autocvar_cl_forcemyplayercolors && islocalplayer)
                        self.colormap = 1024 + autocvar_cl_forcemyplayercolors;