Merge branch 'master' into Mario/despawn_effects
authorMario <zacjardine@y7mail.com>
Fri, 14 Nov 2014 08:37:11 +0000 (19:37 +1100)
committerMario <zacjardine@y7mail.com>
Fri, 14 Nov 2014 08:37:11 +0000 (19:37 +1100)
gamemodes.cfg
qcsrc/client/csqc_constants.qc
qcsrc/server/autocvars.qh
qcsrc/server/mutators/gamemode_tdm.qc [new file with mode: 0644]
qcsrc/server/mutators/mutators.qh
qcsrc/server/mutators/mutators_include.qc
qcsrc/server/teamplay.qc

index 4e14689..ec140d3 100644 (file)
@@ -322,6 +322,8 @@ set g_dm 1 "Deathmatch: killing any other player is one frag, player with most f
 set g_tdm_teams 2 "how many teams are in team deathmatch (set by mapinfo)"
 set g_tdm_team_spawns 0 "when 1, players spawn from the team spawnpoints of the map, if any"
 seta g_tdm_teams_override 0    "how many teams are in team deathmatch"
+set g_tdm_point_limit -1 "TDM point limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
+set g_tdm_point_leadlimit -1 "TDM point lead limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
 
 
 // ============
index 3889603..4d96647 100644 (file)
@@ -41,29 +41,6 @@ const float          VF_CL_VIEWANGLES_X                              = 34;   //(float)
 const float            VF_CL_VIEWANGLES_Y                              = 35;   //(float)
 const float            VF_CL_VIEWANGLES_Z                              = 36;   //(float)
 
-// Server Autosent Stat Constants
-const float            STAT_HEALTH                                             = 0;
-const float            STAT_WEAPONMODEL                                = 2;
-const float            STAT_AMMO                                               = 3;
-const float            STAT_ARMOR                                              = 4;
-const float            STAT_WEAPONFRAME                                = 5;
-const float            STAT_SHELLS                                             = 6;
-const float            STAT_NAILS                                              = 7;
-const float            STAT_ROCKETS                                    = 8;
-const float            STAT_CELLS                                              = 9;
-const float            STAT_ACTIVEWEAPON                               = 10;
-const float            STAT_TOTALSECRETS                               = 11;
-const float            STAT_TOTALMONSTERS                              = 12;
-const float            STAT_SECRETS                                    = 13;
-const float            STAT_MONSTERS                                   = 14;
-const float            STAT_ITEMS                                              = 15;
-const float            STAT_VIEWHEIGHT                                 = 16;
-const float            STAT_MOVEVARS_TICRATE           = 240;
-const float            STAT_MOVEVARS_TIMESCALE         = 241;
-const float            STAT_FRAGLIMIT                                  = 235;
-const float            STAT_TIMELIMIT                                  = 236;
-const float     STAT_MOVEVARS_GRAVITY           = 242;
-
 // Quake-style Point Contents
 const float            CONTENT_EMPTY                                   = -1;
 const float            CONTENT_SOLID                                   = -2;
index 22ab631..92ff358 100644 (file)
@@ -480,6 +480,8 @@ float autocvar_g_spawn_useallspawns;
 float autocvar_g_spawnpoints_auto_move_out_of_solid;
 #define autocvar_g_spawnshieldtime cvar("g_spawnshieldtime")
 float autocvar_g_tdm_team_spawns;
+float autocvar_g_tdm_point_limit;
+float autocvar_g_tdm_point_leadlimit;
 float autocvar_g_tdm_teams;
 float autocvar_g_tdm_teams_override;
 float autocvar_g_teamdamage_resetspeed;
diff --git a/qcsrc/server/mutators/gamemode_tdm.qc b/qcsrc/server/mutators/gamemode_tdm.qc
new file mode 100644 (file)
index 0000000..59f0927
--- /dev/null
@@ -0,0 +1,79 @@
+/*QUAKED spawnfunc_tdm_team (0 .5 .8) (-16 -16 -24) (16 16 32)
+Team declaration for TDM gameplay, this allows you to decide what team names and control point models are used in your map.
+Note: If you use spawnfunc_tdm_team entities you must define at least 2!  However, unlike domination, you don't need to make a blank one too.
+Keys:
+"netname" Name of the team (for example Red, Blue, Green, Yellow, Life, Death, Offense, Defense, etc)...
+"cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */
+void spawnfunc_tdm_team()
+{
+       if(!g_tdm) { remove(self); return; }
+
+       self.classname = "tdm_team";
+       self.team = self.cnt + 1;
+}
+
+// code from here on is just to support maps that don't have team entities
+void tdm_SpawnTeam (string teamname, float teamcolor)
+{
+       entity oldself;
+       oldself = self;
+       self = spawn();
+       self.classname = "tdm_team";
+       self.netname = teamname;
+       self.cnt = teamcolor;
+
+       spawnfunc_tdm_team();
+
+       self = oldself;
+}
+
+void tdm_DelayedInit()
+{
+       // if no teams are found, spawn defaults
+       if(find(world, classname, "tdm_team") == world)
+       {
+               print("No ""tdm_team"" entities found on this map, creating them anyway.\n");
+
+               float numteams = min(4, autocvar_g_tdm_teams_override);
+
+               if(numteams < 2) { numteams = autocvar_g_tdm_teams; }
+               numteams = bound(2, numteams, 4);
+
+               float i;
+               for(i = 1; i <= numteams; ++i)
+                       tdm_SpawnTeam(Team_ColorName(Team_NumberToTeam(i)), Team_NumberToTeam(i) - 1);
+       }
+}
+
+MUTATOR_HOOKFUNCTION(tdm_GetTeamCount)
+{
+       ret_string = "tdm_team";
+       return TRUE;
+}
+
+MUTATOR_DEFINITION(gamemode_tdm)
+{
+       MUTATOR_HOOK(GetTeamCount, tdm_GetTeamCount, CBC_ORDER_ANY);
+
+       MUTATOR_ONADD
+       {
+               if(time > 1) // game loads at time 1
+                       error("This is a game type and it cannot be added at runtime.");
+               InitializeEntity(world, tdm_DelayedInit, INITPRIO_GAMETYPE);
+       }
+
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               // we actually cannot roll back tdm_Initialize here
+               // BUT: we don't need to! If this gets called, adding always
+               // succeeds.
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               print("This is a game type and it cannot be removed at runtime.");
+               return -1;
+       }
+
+       return 0;
+}
index a28a459..eff44c2 100644 (file)
@@ -11,6 +11,7 @@ MUTATOR_DECLARATION(gamemode_lms);
 MUTATOR_DECLARATION(gamemode_invasion);
 MUTATOR_DECLARATION(gamemode_cts);
 MUTATOR_DECLARATION(gamemode_race);
+MUTATOR_DECLARATION(gamemode_tdm);
 
 MUTATOR_DECLARATION(mutator_dodging);
 MUTATOR_DECLARATION(mutator_invincibleprojectiles);
index 92bef2d..c1932db 100644 (file)
@@ -12,6 +12,7 @@
 #include "gamemode_invasion.qc"
 #include "gamemode_race.qc"
 #include "gamemode_cts.qc"
+#include "gamemode_tdm.qc"
 
 #include "mutator_invincibleproj.qc"
 #include "mutator_new_toys.qc"
index 0dd7fd4..d7d833a 100644 (file)
@@ -13,7 +13,6 @@ void TeamchangeFrags(entity e)
        PlayerScore_Clear(e);
 }
 
-void tdm_init();
 void entcs_init();
 
 void LogTeamchange(float player_id, float team_number, float type)
@@ -83,7 +82,10 @@ void InitGameplayMode()
        if(g_tdm)
        {
                ActivateTeamplay();
-               tdm_init();
+               fraglimit_override = autocvar_g_tdm_point_limit;
+               leadlimit_override = autocvar_g_tdm_point_leadlimit;
+               MUTATOR_ADD(gamemode_tdm);
+
                if(autocvar_g_tdm_team_spawns)
                        have_team_spawns = -1; // request team spawns
        }
@@ -1000,44 +1002,3 @@ void ShufflePlayerOutOfTeam (float source_team)
                Damage(selected, selected, selected, 100000, DEATH_AUTOTEAMCHANGE, selected.origin, '0 0 0');
        centerprint(selected, strcat("You have been moved into a different team to improve team balance\nYou are now on: ", Team_ColoredFullName(selected.team)));
 }
-
-// code from here on is just to support maps that don't have team entities
-void tdm_spawnteam (string teamname, float teamcolor)
-{
-       entity e;
-       e = spawn();
-       e.classname = "tdm_team";
-       e.netname = teamname;
-       e.cnt = teamcolor;
-       e.team = e.cnt + 1;
-}
-
-// spawn some default teams if the map is not set up for tdm
-void tdm_spawnteams()
-{
-       float numteams;
-
-       numteams = autocvar_g_tdm_teams_override;
-       if(numteams < 2)
-               numteams = autocvar_g_tdm_teams;
-       numteams = bound(2, numteams, 4);
-
-       tdm_spawnteam("Red", NUM_TEAM_1-1);
-       tdm_spawnteam("Blue", NUM_TEAM_2-1);
-       if(numteams >= 3)
-               tdm_spawnteam("Yellow", NUM_TEAM_3-1);
-       if(numteams >= 4)
-               tdm_spawnteam("Pink", NUM_TEAM_4-1);
-}
-
-void tdm_delayedinit()
-{
-       // if no teams are found, spawn defaults
-       if (find(world, classname, "tdm_team") == world)
-               tdm_spawnteams();
-}
-
-void tdm_init()
-{
-       InitializeEntity(world, tdm_delayedinit, INITPRIO_GAMETYPE);
-}