]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_ctf.qc
lib: move csqcmodellib and warpzonelib
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_ctf.qc
index 988534e2b3800fec4d1023fd834c42f9d0799578..eff581154286530b94f44a5c2e794046911a6535 100644 (file)
@@ -1,13 +1,13 @@
 #include "gamemode_ctf.qh"
-#include "../_all.qh"
 
 #include "gamemode.qh"
 
 #ifdef SVQC
 #include "../../common/vehicles/all.qh"
+#include "../teamplay.qh"
 #endif
 
-#include "../../warpzonelib/common.qh"
+#include "../../lib/warpzone/common.qh"
 
 void ctf_FakeTimeLimit(entity e, float t)
 {
@@ -1091,7 +1091,6 @@ void set_flag_string(entity flag, .string field, string value, string teamname)
 void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag entity on the map as a spawnfunc
 {SELFPARAM();
        // declarations
-       string teamname = Static_Team_ColorName_Lower(teamnumber);
        setself(flag); // for later usage with droptofloor()
 
        // main setup
@@ -1124,6 +1123,7 @@ void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag e
        flag.nextthink = time + FLAG_THINKRATE;
        flag.ctf_status = FLAG_BASE;
 
+       string teamname = Static_Team_ColorName_Lower(teamnumber);
        // appearence
        if(!flag.scale)                         { flag.scale = FLAG_SCALE; }
        if(flag.skin == 0)                      { flag.skin = cvar(sprintf("g_ctf_flag_%s_skin", teamname)); }
@@ -1133,10 +1133,10 @@ void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag e
        set_flag_string(flag, capeffect,        "%s_cap",               teamname);
 
        // sounds
-       flag.snd_flag_taken = SND(CTF_TAKEN(teamname));
-       flag.snd_flag_returned = SND(CTF_RETURNED(teamname));
-       flag.snd_flag_capture = SND(CTF_CAPTURE(teamname));
-       flag.snd_flag_dropped = SND(CTF_DROPPED(teamname));
+       flag.snd_flag_taken = SND(CTF_TAKEN(teamnumber));
+       flag.snd_flag_returned = SND(CTF_RETURNED(teamnumber));
+       flag.snd_flag_capture = SND(CTF_CAPTURE(teamnumber));
+       flag.snd_flag_dropped = SND(CTF_DROPPED(teamnumber));
        if (flag.snd_flag_respawn == "") flag.snd_flag_respawn = SND(CTF_RESPAWN); // if there is ever a team-based sound for this, update the code to match.
        precache_sound(flag.snd_flag_respawn);
        if (flag.snd_flag_touch == "") flag.snd_flag_touch = SND(CTF_TOUCH); // again has no team-based sound
@@ -2247,8 +2247,8 @@ Keys:
 "noise3" sound played when flag is lost in the field and respawns itself...
 "noise4" sound played when flag is dropped by a player...
 "noise5" sound played when flag touches the ground... */
-void spawnfunc_item_flag_team1()
-{SELFPARAM();
+spawnfunc(item_flag_team1)
+{
        if(!g_ctf) { remove(self); return; }
 
        ctf_FlagSetup(NUM_TEAM_1, self);
@@ -2265,8 +2265,8 @@ Keys:
 "noise3" sound played when flag is lost in the field and respawns itself...
 "noise4" sound played when flag is dropped by a player...
 "noise5" sound played when flag touches the ground... */
-void spawnfunc_item_flag_team2()
-{SELFPARAM();
+spawnfunc(item_flag_team2)
+{
        if(!g_ctf) { remove(self); return; }
 
        ctf_FlagSetup(NUM_TEAM_2, self);
@@ -2283,8 +2283,8 @@ Keys:
 "noise3" sound played when flag is lost in the field and respawns itself...
 "noise4" sound played when flag is dropped by a player...
 "noise5" sound played when flag touches the ground... */
-void spawnfunc_item_flag_team3()
-{SELFPARAM();
+spawnfunc(item_flag_team3)
+{
        if(!g_ctf) { remove(self); return; }
 
        ctf_FlagSetup(NUM_TEAM_3, self);
@@ -2301,8 +2301,8 @@ Keys:
 "noise3" sound played when flag is lost in the field and respawns itself...
 "noise4" sound played when flag is dropped by a player...
 "noise5" sound played when flag touches the ground... */
-void spawnfunc_item_flag_team4()
-{SELFPARAM();
+spawnfunc(item_flag_team4)
+{
        if(!g_ctf) { remove(self); return; }
 
        ctf_FlagSetup(NUM_TEAM_4, self);
@@ -2319,8 +2319,8 @@ Keys:
 "noise3" sound played when flag is lost in the field and respawns itself...
 "noise4" sound played when flag is dropped by a player...
 "noise5" sound played when flag touches the ground... */
-void spawnfunc_item_flag_neutral()
-{SELFPARAM();
+spawnfunc(item_flag_neutral)
+{
        if(!g_ctf) { remove(self); return; }
        if(!cvar("g_ctf_oneflag")) { remove(self); return; }
 
@@ -2333,8 +2333,8 @@ Note: If you use spawnfunc_ctf_team entities you must define at least 2!  Howeve
 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_ctf_team()
-{SELFPARAM();
+spawnfunc(ctf_team)
+{
        if(!g_ctf) { remove(self); return; }
 
        self.classname = "ctf_team";
@@ -2342,15 +2342,17 @@ void spawnfunc_ctf_team()
 }
 
 // compatibility for quake maps
-void spawnfunc_team_CTF_redflag()    { spawnfunc_item_flag_team1();    }
-void spawnfunc_team_CTF_blueflag()   { spawnfunc_item_flag_team2();    }
-void spawnfunc_team_CTF_redplayer()  { spawnfunc_info_player_team1();  }
-void spawnfunc_team_CTF_blueplayer() { spawnfunc_info_player_team2();  }
-void spawnfunc_team_CTF_redspawn()   { spawnfunc_info_player_team1();  }
-void spawnfunc_team_CTF_bluespawn()  { spawnfunc_info_player_team2();  }
+spawnfunc(team_CTF_redflag)    { spawnfunc_item_flag_team1(this);    }
+spawnfunc(team_CTF_blueflag)   { spawnfunc_item_flag_team2(this);    }
+spawnfunc(info_player_team1);
+spawnfunc(team_CTF_redplayer)  { spawnfunc_info_player_team1(this);  }
+spawnfunc(team_CTF_redspawn)   { spawnfunc_info_player_team1(this);  }
+spawnfunc(info_player_team2);
+spawnfunc(team_CTF_blueplayer) { spawnfunc_info_player_team2(this);  }
+spawnfunc(team_CTF_bluespawn)  { spawnfunc_info_player_team2(this);  }
 
-void team_CTF_neutralflag()                     { spawnfunc_item_flag_neutral();  }
-void team_neutralobelisk()                      { spawnfunc_item_flag_neutral();  }
+void team_CTF_neutralflag()                     { SELFPARAM(); spawnfunc_item_flag_neutral(self);  }
+void team_neutralobelisk()                      { SELFPARAM(); spawnfunc_item_flag_neutral(self);  }
 
 
 // ==============
@@ -2374,15 +2376,12 @@ void ctf_ScoreRules(int teams)
 
 // code from here on is just to support maps that don't have flag and team entities
 void ctf_SpawnTeam (string teamname, int teamcolor)
-{SELFPARAM();
-       setself(spawn());
-       self.classname = "ctf_team";
-       self.netname = teamname;
-       self.cnt = teamcolor;
-
-       spawnfunc_ctf_team();
-
-       setself(this);
+{
+       entity this = new(ctf_team);
+       this.netname = teamname;
+       this.cnt = teamcolor;
+       this.spawnfunc_checked = true;
+       WITH(entity, self, this, spawnfunc_ctf_team(this));
 }
 
 void ctf_DelayedInit() // Do this check with a delay so we can wait for teams to be set up.