]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_tdm.qc
Spawnfunc whitelist
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_tdm.qc
index de172873e29255af8f14c0c8ae972758519f5c60..451e4a55c32536d35ac84ec33b1b0add8dde0bec 100644 (file)
@@ -1,12 +1,16 @@
+#include "../_all.qh"
+
+#include "gamemode.qh"
+
 /*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()
+spawnfunc(tdm_team)
 {
-       if(!g_tdm) { remove(self); return; }
+       if(!g_tdm || !self.cnt) { remove(self); return; }
 
        self.classname = "tdm_team";
        self.team = self.cnt + 1;
@@ -15,16 +19,11 @@ void spawnfunc_tdm_team()
 // 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;
+       entity this = new(tdm_team);
+       this.netname = teamname;
+       this.cnt = teamcolor;
+       this.spawnfunc_checked = true;
+       WITH(entity, self, this, spawnfunc_tdm_team(this));
 }
 
 void tdm_DelayedInit()
@@ -32,9 +31,9 @@ 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");
+               LOG_INFO("No ""tdm_team"" entities found on this map, creating them anyway.\n");
 
-               float numteams = min(4, autocvar_g_tdm_teams_override);
+               int numteams = min(4, autocvar_g_tdm_teams_override);
 
                if(numteams < 2) { numteams = autocvar_g_tdm_teams; }
                numteams = bound(2, numteams, 4);
@@ -51,9 +50,16 @@ MUTATOR_HOOKFUNCTION(tdm_GetTeamCount)
        return true;
 }
 
+MUTATOR_HOOKFUNCTION(tdm_CountFrags)
+{
+       // announce remaining frags
+       return true;
+}
+
 MUTATOR_DEFINITION(gamemode_tdm)
 {
        MUTATOR_HOOK(GetTeamCount, tdm_GetTeamCount, CBC_ORDER_ANY);
+       MUTATOR_HOOK(Scores_CountFragsRemaining, tdm_CountFrags, CBC_ORDER_ANY);
 
        MUTATOR_ONADD
        {
@@ -71,7 +77,7 @@ MUTATOR_DEFINITION(gamemode_tdm)
 
        MUTATOR_ONREMOVE
        {
-               print("This is a game type and it cannot be removed at runtime.");
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
                return -1;
        }