]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_domination.qc
Merge branch 'master' into TimePath/effectinfo
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_domination.qc
index c365eddd300a9cb4a32fddc34c9760d8abe50e23..66f4c8da316fafdfda252ca9ec48203d9d5baf33 100644 (file)
@@ -21,10 +21,9 @@ void set_dom_state(entity e)
 }
 
 void dompoint_captured ()
-{
+{SELFPARAM();
        entity head;
        float old_delay, old_team, real_team;
-       string msg = "dom-neut";
 
        // now that the delay has expired, switch to the latest team to lay claim to this point
        head = self.owner;
@@ -62,9 +61,9 @@ void dompoint_captured ()
 
        if (head.noise != "")
                if(self.enemy)
-                       sound(self.enemy, CH_TRIGGER, head.noise, VOL_BASE, ATTEN_NORM);
+                       _sound(self.enemy, CH_TRIGGER, head.noise, VOL_BASE, ATTEN_NORM);
                else
-                       sound(self, CH_TRIGGER, head.noise, VOL_BASE, ATTEN_NORM);
+                       _sound(self, CH_TRIGGER, head.noise, VOL_BASE, ATTEN_NORM);
        if (head.noise1 != "")
                play2all(head.noise1);
 
@@ -80,15 +79,16 @@ void dompoint_captured ()
        self.delay = old_delay;
        self.team = old_team;
 
+       entity msg = WP_DomNeut;
        switch(self.team)
        {
-               case NUM_TEAM_1: msg = "dom-red"; break;
-               case NUM_TEAM_2: msg = "dom-blue"; break;
-               case NUM_TEAM_3: msg = "dom-yellow"; break;
-               case NUM_TEAM_4: msg = "dom-pink"; break;
+               case NUM_TEAM_1: msg = WP_DomRed; break;
+               case NUM_TEAM_2: msg = WP_DomBlue; break;
+               case NUM_TEAM_3: msg = WP_DomYellow; break;
+               case NUM_TEAM_4: msg = WP_DomPink; break;
        }
 
-       WaypointSprite_UpdateSprites(self.sprite, msg, "", "");
+       WaypointSprite_UpdateSprites(self.sprite, msg, WP_Null, WP_Null);
 
        total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0;
        for(head = world; (head = find(head, classname, "dom_controlpoint")) != world; )
@@ -129,7 +129,7 @@ void dompoint_captured ()
 }
 
 void AnimateDomPoint()
-{
+{SELFPARAM();
        if(self.pain_finished > time)
                return;
        self.pain_finished = time + self.t_width;
@@ -142,7 +142,7 @@ void AnimateDomPoint()
 }
 
 void dompointthink()
-{
+{SELFPARAM();
        float fragamt;
 
        self.nextthink = time + 0.1;
@@ -186,7 +186,7 @@ void dompointthink()
 }
 
 void dompointtouch()
-{
+{SELFPARAM();
        entity head;
        if (!IS_PLAYER(other))
                return;
@@ -226,7 +226,7 @@ void dompointtouch()
        if(head == world)
                return;
 
-       WaypointSprite_UpdateSprites(self.sprite, "dom-neut", "", "");
+       WaypointSprite_UpdateSprites(self.sprite, WP_DomNeut, WP_Null, WP_Null);
        WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_DOMPOINT, '0 1 1');
        WaypointSprite_Ping(self.sprite);
 
@@ -241,7 +241,7 @@ void dompointtouch()
 }
 
 void dom_controlpoint_setup()
-{
+{SELFPARAM();
        entity head;
        // find the spawnfunc_dom_team representing unclaimed points
        head = find(world, classname, "dom_team");
@@ -252,7 +252,7 @@ void dom_controlpoint_setup()
 
        // copy important properties from spawnfunc_dom_team entity
        self.goalentity = head;
-       setmodel(self, head.mdl); // precision already set
+       _setmodel(self, head.mdl); // precision already set
        self.skin = head.skin;
 
        self.cnt = -1;
@@ -292,7 +292,7 @@ void dom_controlpoint_setup()
        droptofloor();
 
        waypoint_spawnforitem(self);
-       WaypointSprite_SpawnFixed("dom-neut", self.origin + '0 0 32', self, sprite, RADARICON_DOMPOINT, '0 1 1');
+       WaypointSprite_SpawnFixed(WP_DomNeut, self.origin + '0 0 32', self, sprite, RADARICON_DOMPOINT);
 }
 
 float total_controlpoints, redowned, blueowned, yellowowned, pinkowned;
@@ -385,7 +385,7 @@ void Domination_RoundStart()
 
 //go to best items, or control points you don't own
 void havocbot_role_dom()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
                return;
 
@@ -408,10 +408,12 @@ MUTATOR_HOOKFUNCTION(dom_GetTeamCount)
 }
 
 MUTATOR_HOOKFUNCTION(dom_ResetMap)
-{
+{SELFPARAM();
        total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0;
-       FOR_EACH_PLAYER(self)
+       entity e;
+       FOR_EACH_PLAYER(e)
        {
+               setself(e);
                PutClientInServer();
                self.player_blocked = 1;
                if(IS_REAL_CLIENT(self))
@@ -421,7 +423,7 @@ MUTATOR_HOOKFUNCTION(dom_ResetMap)
 }
 
 MUTATOR_HOOKFUNCTION(dom_PlayerSpawn)
-{
+{SELFPARAM();
        if(domination_roundbased)
        if(!round_handler_IsRoundStarted())
                self.player_blocked = 1;
@@ -431,13 +433,13 @@ MUTATOR_HOOKFUNCTION(dom_PlayerSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(dom_ClientConnect)
-{
+{SELFPARAM();
        set_dom_state(self);
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(dom_BotRoles)
-{
+{SELFPARAM();
        self.havocbot_role = havocbot_role_dom;
        return true;
 }
@@ -446,7 +448,7 @@ MUTATOR_HOOKFUNCTION(dom_BotRoles)
 Control point for Domination gameplay.
 */
 void spawnfunc_dom_controlpoint()
-{
+{SELFPARAM();
        if(!g_domination)
        {
                remove(self);
@@ -491,7 +493,7 @@ Keys:
 */
 
 void spawnfunc_dom_team()
-{
+{SELFPARAM();
        if(!g_domination || autocvar_g_domination_teams_override >= 2)
        {
                remove(self);
@@ -503,7 +505,7 @@ void spawnfunc_dom_team()
        if (self.noise1 != "")
                precache_sound(self.noise1);
        self.classname = "dom_team";
-       setmodel(self, self.model); // precision not needed
+       _setmodel(self, self.model); // precision not needed
        self.mdl = self.model;
        self.dmg = self.modelindex;
        self.model = "";
@@ -541,10 +543,8 @@ void ScoreRules_dom(float teams)
 
 // code from here on is just to support maps that don't have control point and team entities
 void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float pointskin, string capsound, string capnarration, string capmessage)
-{
-       entity oldself;
-       oldself = self;
-       self = spawn();
+{SELFPARAM();
+       setself(spawn());
        self.classname = "dom_team";
        self.netname = teamname;
        self.cnt = teamcolor;
@@ -555,7 +555,7 @@ void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float p
        self.message = capmessage;
 
        // this code is identical to spawnfunc_dom_team
-       setmodel(self, self.model); // precision not needed
+       _setmodel(self, self.model); // precision not needed
        self.mdl = self.model;
        self.dmg = self.modelindex;
        self.model = "";
@@ -564,31 +564,29 @@ void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float p
        self.team = self.cnt + 1;
 
        //eprint(self);
-       self = oldself;
+       setself(this);
 }
 
 void dom_spawnpoint(vector org)
-{
-       entity oldself;
-       oldself = self;
-       self = spawn();
+{SELFPARAM();
+       setself(spawn());
        self.classname = "dom_controlpoint";
        self.think = spawnfunc_dom_controlpoint;
        self.nextthink = time;
        setorigin(self, org);
        spawnfunc_dom_controlpoint();
-       self = oldself;
+       setself(this);
 }
 
 // spawn some default teams if the map is not set up for domination
 void dom_spawnteams(float teams)
 {
-       dom_spawnteam("Red", NUM_TEAM_1-1, "models/domination/dom_red.md3", 0, "domination/claim.wav", "", "Red team has captured a control point");
-       dom_spawnteam("Blue", NUM_TEAM_2-1, "models/domination/dom_blue.md3", 0, "domination/claim.wav", "", "Blue team has captured a control point");
+       dom_spawnteam("Red", NUM_TEAM_1-1, "models/domination/dom_red.md3", 0, SND(DOM_CLAIM), "", "Red team has captured a control point");
+       dom_spawnteam("Blue", NUM_TEAM_2-1, "models/domination/dom_blue.md3", 0, SND(DOM_CLAIM), "", "Blue team has captured a control point");
        if(teams >= 3)
-               dom_spawnteam("Yellow", NUM_TEAM_3-1, "models/domination/dom_yellow.md3", 0, "domination/claim.wav", "", "Yellow team has captured a control point");
+               dom_spawnteam("Yellow", NUM_TEAM_3-1, "models/domination/dom_yellow.md3", 0, SND(DOM_CLAIM), "", "Yellow team has captured a control point");
        if(teams >= 4)
-               dom_spawnteam("Pink", NUM_TEAM_4-1, "models/domination/dom_pink.md3", 0, "domination/claim.wav", "", "Pink team has captured a control point");
+               dom_spawnteam("Pink", NUM_TEAM_4-1, "models/domination/dom_pink.md3", 0, SND(DOM_CLAIM), "", "Pink team has captured a control point");
        dom_spawnteam("", 0, "models/domination/dom_unclaimed.md3", 0, "", "", "");
 }
 
@@ -597,7 +595,7 @@ void dom_DelayedInit() // Do this check with a delay so we can wait for teams to
        // if no teams are found, spawn defaults
        if(find(world, classname, "dom_team") == world || autocvar_g_domination_teams_override >= 2)
        {
-               print("No ""dom_team"" entities found on this map, creating them anyway.\n");
+               LOG_INFO("No ""dom_team"" entities found on this map, creating them anyway.\n");
                domination_teams = bound(2, ((autocvar_g_domination_teams_override < 2) ? autocvar_g_domination_default_teams : autocvar_g_domination_teams_override), 4);
                dom_spawnteams(domination_teams);
        }
@@ -624,13 +622,6 @@ void dom_DelayedInit() // Do this check with a delay so we can wait for teams to
 
 void dom_Initialize()
 {
-       precache_model("models/domination/dom_red.md3");
-       precache_model("models/domination/dom_blue.md3");
-       precache_model("models/domination/dom_yellow.md3");
-       precache_model("models/domination/dom_pink.md3");
-       precache_model("models/domination/dom_unclaimed.md3");
-       precache_sound("domination/claim.wav");
-
        InitializeEntity(world, dom_DelayedInit, INITPRIO_GAMETYPE);
 }
 
@@ -652,7 +643,7 @@ MUTATOR_DEFINITION(gamemode_domination)
 
        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;
        }