]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/domination.qc
Merge remote-tracking branch 'origin/master' into samual/spawn_weapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / domination.qc
index b58c0f074fd052ba8824c007d89293247d5ea686..9e56023cb500ebb5425d08321fbff54d55d4a7e8 100644 (file)
@@ -34,7 +34,6 @@ float pps_yellow;
 float pps_pink;
 void set_dom_state(entity e)
 {
-       // BIG ugly hack to make stat sending work
        e.dom_total_pps = total_pps;
        e.dom_pps_red = pps_red;
        e.dom_pps_blue = pps_blue;
@@ -61,8 +60,8 @@ void() dom_spawnteams;
 
 void dompoint_captured ()
 {
-       local entity head;
-       local float old_delay, old_team, real_team;
+       entity head;
+       float old_delay, old_team, real_team;
 
        // now that the delay has expired, switch to the latest team to lay claim to this point
        head = self.owner;
@@ -109,9 +108,9 @@ void dompoint_captured ()
 
        if (head.noise != "")
                if(self.enemy)
-                       sound(self.enemy, CHAN_AUTO, head.noise, VOL_BASE, ATTN_NORM);
+                       sound(self.enemy, CH_TRIGGER, head.noise, VOL_BASE, ATTN_NORM);
                else
-                       sound(self, CHAN_TRIGGER, head.noise, VOL_BASE, ATTN_NORM);
+                       sound(self, CH_TRIGGER, head.noise, VOL_BASE, ATTN_NORM);
        if (head.noise1 != "")
                play2all(head.noise1);
 
@@ -130,50 +129,49 @@ void dompoint_captured ()
        self.delay = old_delay;
        self.team = old_team;
 
-       switch(self.team)
-       {
-               // "fix" pps when slightly under 0 because of approximation errors
-               case COLOR_TEAM1:
-                       pps_red -= (points/wait_time);
-                       if (pps_red < 0) pps_red = 0;
-                       break;
-               case COLOR_TEAM2:
-                       pps_blue -= (points/wait_time);
-                       if (pps_blue < 0) pps_blue = 0;
-                       break;
-               case COLOR_TEAM3:
-                       pps_yellow -= (points/wait_time);
-                       if (pps_yellow < 0) pps_yellow = 0;
-                       break;
-               case COLOR_TEAM4:
-                       pps_pink -= (points/wait_time);
-                       if (pps_pink < 0) pps_pink = 0;
-       }
-
        switch(self.goalentity.team)
        {
-               // "fix" pps when slightly over total_pps because of approximation errors
                case COLOR_TEAM1:
-                       pps_red += (points/wait_time);
-                       if (pps_red > total_pps) pps_red = total_pps;
                        WaypointSprite_UpdateSprites(self.sprite, "dom-red", "", "");
                        break;
                case COLOR_TEAM2:
-                       pps_blue += (points/wait_time);
-                       if (pps_blue > total_pps) pps_blue = total_pps;
                        WaypointSprite_UpdateSprites(self.sprite, "dom-blue", "", "");
                        break;
                case COLOR_TEAM3:
-                       pps_yellow += (points/wait_time);
-                       if (pps_yellow > total_pps) pps_yellow = total_pps;
                        WaypointSprite_UpdateSprites(self.sprite, "dom-yellow", "", "");
                        break;
                case COLOR_TEAM4:
-                       pps_pink += (points/wait_time);
-                       if (pps_pink > total_pps) pps_pink = total_pps;
                        WaypointSprite_UpdateSprites(self.sprite, "dom-pink", "", "");
        }
 
+       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; )
+       {
+               if (autocvar_g_domination_point_amt)
+                       points = autocvar_g_domination_point_amt;
+               else
+                       points = head.frags;
+               if (autocvar_g_domination_point_rate)
+                       wait_time = autocvar_g_domination_point_rate;
+               else
+                       wait_time = head.wait;
+               switch(head.goalentity.team)
+               {
+                       case COLOR_TEAM1:
+                               pps_red += points/wait_time;
+                               break;
+                       case COLOR_TEAM2:
+                               pps_blue += points/wait_time;
+                               break;
+                       case COLOR_TEAM3:
+                               pps_yellow += points/wait_time;
+                               break;
+                       case COLOR_TEAM4:
+                               pps_pink += points/wait_time;
+               }
+               total_pps += points/wait_time;
+       }
+
        WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_DOMPOINT, colormapPaletteColor(self.goalentity.team - 1, 0));
        WaypointSprite_Ping(self.sprite);
 
@@ -181,7 +179,7 @@ void dompoint_captured ()
 
        FOR_EACH_REALCLIENT(head)
                set_dom_state(head);
-};
+}
 
 void AnimateDomPoint()
 {
@@ -198,7 +196,7 @@ void AnimateDomPoint()
 
 void dompointthink()
 {
-       local float fragamt;
+       float fragamt;
 
        self.nextthink = time + 0.1;
 
@@ -241,7 +239,7 @@ void dompointthink()
 
 void dompointtouch()
 {
-       local entity head;
+       entity head;
        if (other.classname != "player")
                return;
        if (other.health < 1)
@@ -289,7 +287,7 @@ void dompointtouch()
        self.enemy = other; // individual player scoring
        self.enemy_playerid = other.playerid;
        dompoint_captured();
-};
+}
 
 /*QUAKED spawnfunc_dom_team (0 .5 .8) (-32 -32 -24) (32 32 32)
 Team declaration for Domination gameplay, this allows you to decide what team
@@ -338,11 +336,11 @@ void spawnfunc_dom_team()
        // this would have to be changed if used in quakeworld
        if(self.cnt)
                self.team = self.cnt + 1; // WHY are these different anyway?
-};
+}
 
 void dom_controlpoint_setup()
 {
-       local entity head;
+       entity head;
        // find the spawnfunc_dom_team representing unclaimed points
        head = find(world, classname, "dom_team");
        while(head && head.netname != "")
@@ -366,12 +364,12 @@ void dom_controlpoint_setup()
                self.wait = 5;
 
        float points, waittime;
-       if (autocvar_g_domination_point_rate)
-               points = autocvar_g_domination_point_rate;
+       if (autocvar_g_domination_point_amt)
+               points = autocvar_g_domination_point_amt;
        else
                points = self.frags;
-       if (autocvar_g_domination_point_amt)
-               waittime = autocvar_g_domination_point_amt;
+       if (autocvar_g_domination_point_rate)
+               waittime = autocvar_g_domination_point_rate;
        else
                waittime = self.wait;
 
@@ -392,9 +390,8 @@ void dom_controlpoint_setup()
        droptofloor();
 
        waypoint_spawnforitem(self);
-       WaypointSprite_SpawnFixed("dom-neut", self.origin + '0 0 32', self, sprite);
-       WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_DOMPOINT, '0 1 1');
-};
+       WaypointSprite_SpawnFixed("dom-neut", self.origin + '0 0 32', self, sprite, RADARICON_DOMPOINT, '0 1 1');
+}
 
 
 
@@ -610,12 +607,12 @@ void spawnfunc_dom_controlpoint()
        self.effects = self.effects | EF_LOWPRECISION;
        if (autocvar_g_domination_point_fullbright)
                self.effects |= EF_FULLBRIGHT;
-};
+}
 
 // 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)
 {
-       local entity oldself;
+       entity oldself;
        oldself = self;
        self = spawn();
        self.classname = "dom_team";
@@ -638,11 +635,11 @@ void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float p
 
        //eprint(self);
        self = oldself;
-};
+}
 
 void dom_spawnpoint(vector org)
 {
-       local entity oldself;
+       entity oldself;
        oldself = self;
        self = spawn();
        self.classname = "dom_controlpoint";
@@ -651,7 +648,7 @@ void dom_spawnpoint(vector org)
        setorigin(self, org);
        spawnfunc_dom_controlpoint();
        self = oldself;
-};
+}
 
 // spawn some default teams if the map is not set up for domination
 void dom_spawnteams()
@@ -669,11 +666,11 @@ void dom_spawnteams()
        if(numteams > 3)
                dom_spawnteam("Pink", COLOR_TEAM4-1, "models/domination/dom_pink.md3", 0, "domination/claim.wav", "", "Pink team has captured a control point");
        dom_spawnteam("", 0, "models/domination/dom_unclaimed.md3", 0, "", "", "");
-};
+}
 
 void dom_delayedinit()
 {
-       local entity head;
+       entity head;
 
        // if no teams are found, spawn defaults, if custom teams are set, use them
        if (find(world, classname, "dom_team") == world || autocvar_g_domination_teams_override >= 2)
@@ -694,7 +691,7 @@ void dom_delayedinit()
        }
 
        ScoreRules_dom();
-};
+}
 
 void dom_init()
 {
@@ -714,5 +711,5 @@ void dom_init()
        addstat(STAT_DOM_PPS_BLUE, AS_FLOAT, dom_pps_blue);
        if(c3 >= 0) addstat(STAT_DOM_PPS_YELLOW, AS_FLOAT, dom_pps_yellow);
        if(c4 >= 0) addstat(STAT_DOM_PPS_PINK, AS_FLOAT, dom_pps_pink);
-};
+}