]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_ctf.qc
Merge branch 'master' into divVerent/4team_ctf
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_ctf.qc
index f6c43a91d1890f030ef1ea08e41a6309a42a0917..7d4339343507ba29b47b37bbc7cd75dd04196e66 100644 (file)
@@ -139,12 +139,16 @@ float ctf_IsDifferentTeam(entity a, entity b)
 
 float ctf_Stalemate_waypointsprite_visible_for_player(entity e)
 {
+       // personal waypoints
+       if(self.enemy)
+               if(self.enemy != e)
+                       return FALSE;
+                       
        // team waypoints
+       if(self.rule == SPRITERULE_DEFAULT)
        if(ctf_IsDifferentTeam(self.owner.flagcarried, self.owner))
        if(ctf_IsDifferentTeam(self.owner.flagcarried, e))
-       if(!IsDifferentTeam(self.owner, e))
-               return FALSE;
-       if not(IS_PLAYER(e))
+       if(!IsDifferentTeam(self.owner, e) || !IS_PLAYER(e))
                return FALSE;
 
        return TRUE;
@@ -271,7 +275,7 @@ void ctf_Handle_Drop(entity flag, entity player, float droptype)
        
        // messages and sounds
        Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_LOST_), player.netname);
-       sound(flag, CH_TRIGGER, flag.snd_flag_dropped, VOL_BASE, ATTN_NONE);
+       sound(flag, CH_TRIGGER, flag.snd_flag_dropped, VOL_BASE, ATTEN_NONE);
        ctf_EventLog("dropped", player.team, player);
 
        // scoring
@@ -317,7 +321,7 @@ void ctf_Handle_Retrieve(entity flag, entity player)
        flag.ctf_status = FLAG_CARRY;
 
        // messages and sounds
-       sound(player, CH_TRIGGER, flag.snd_flag_pass, VOL_BASE, ATTN_NORM);
+       sound(player, CH_TRIGGER, flag.snd_flag_pass, VOL_BASE, ATTEN_NORM);
        ctf_EventLog("receive", flag.team, player);
        
        FOR_EACH_REALPLAYER(tmp_player)
@@ -384,7 +388,7 @@ void ctf_Handle_Throw(entity player, entity receiver, float droptype)
                        flag.ctf_status = FLAG_PASSING;
                        
                        // other
-                       sound(player, CH_TRIGGER, flag.snd_flag_touch, VOL_BASE, ATTN_NORM);
+                       sound(player, CH_TRIGGER, flag.snd_flag_touch, VOL_BASE, ATTEN_NORM);
                        WarpZone_TrailParticles(world, particleeffectnum(flag.passeffect), player.origin, targ_origin);
                        ctf_EventLog("pass", flag.team, player);
                        break;
@@ -443,7 +447,7 @@ void ctf_Handle_Capture(entity flag, entity toucher, float capturetype)
        // messages and sounds
        Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT_4(enemy_flag, CENTER_CTF_CAPTURE_));
        ctf_CaptureRecord(enemy_flag, player);
-       sound(player, CH_TRIGGER, ((IsDifferentTeam(player, flag)) ? enemy_flag.snd_flag_capture : flag.snd_flag_capture), VOL_BASE, ATTN_NONE);
+       sound(player, CH_TRIGGER, ((IsDifferentTeam(player, flag)) ? enemy_flag.snd_flag_capture : flag.snd_flag_capture), VOL_BASE, ATTEN_NONE);
        
        switch(capturetype)
        {
@@ -485,7 +489,7 @@ void ctf_Handle_Return(entity flag, entity player)
        // messages and sounds
        Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT_4(flag, CENTER_CTF_RETURN_));
        Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_RETURN_), player.netname);
-       sound(player, CH_TRIGGER, flag.snd_flag_returned, VOL_BASE, ATTN_NONE);
+       sound(player, CH_TRIGGER, flag.snd_flag_returned, VOL_BASE, ATTEN_NONE);
        ctf_EventLog("return", flag.team, player);
 
        // scoring
@@ -533,7 +537,7 @@ void ctf_Handle_Pickup(entity flag, entity player, float pickuptype)
 
        // messages and sounds
        Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_PICKUP_), player.netname);
-       sound(player, CH_TRIGGER, flag.snd_flag_taken, VOL_BASE, ATTN_NONE);
+       sound(player, CH_TRIGGER, flag.snd_flag_taken, VOL_BASE, ATTEN_NONE);
 
        FOR_EACH_REALPLAYER(tmp_player)
        {
@@ -623,7 +627,7 @@ void ctf_CheckFlagReturn(entity flag, float returntype)
                                case RETURN_TIMEOUT:
                                        { Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_FLAGRETURN_TIMEOUT_)); break; }
                        }
-                       sound(flag, CH_TRIGGER, flag.snd_flag_respawn, VOL_BASE, ATTN_NONE);
+                       sound(flag, CH_TRIGGER, flag.snd_flag_respawn, VOL_BASE, ATTEN_NONE);
                        ctf_EventLog("returned", flag.team, world);
                        ctf_RespawnFlag(flag);
                }
@@ -648,20 +652,23 @@ void ctf_CheckStalemate(void)
                        tmp_entity.ctf_staleflagnext = ctf_staleflaglist; // link flag into staleflaglist
                        ctf_staleflaglist = tmp_entity;
                        
-                       if(tmp_entity.team == NUM_TEAM_1) { ++stale_red_flags; }
-                       if(tmp_entity.team == NUM_TEAM_2) { ++stale_blue_flags; }
-                       if(tmp_entity.team == NUM_TEAM_3) { ++stale_yellow_flags; }
-                       if(tmp_entity.team == NUM_TEAM_4) { ++stale_pink_flags; }
+                       switch(tmp_entity.team)
+                       {
+                               case NUM_TEAM_1: ++stale_red_flags; break;
+                               case NUM_TEAM_2: ++stale_blue_flags; break;
+                               case NUM_TEAM_3: ++stale_yellow_flags; break;
+                               case NUM_TEAM_4: ++stale_pink_flags; break;
+                       }
                }
        }
        
        stale_flags = (stale_red_flags > 0) + (stale_blue_flags > 0) + (stale_yellow_flags > 0) + (stale_pink_flags > 0);
        
-       if(stale_flags >= ctf_teams)
+       if(stale_flags == ctf_teams)
                ctf_stalemate = TRUE;
-       else if(stale_flags < ctf_teams && autocvar_g_ctf_stalemate_endcondition == 2)
+       else if(stale_flags == 0 && autocvar_g_ctf_stalemate_endcondition == 2)
                { ctf_stalemate = FALSE; wpforenemy_announced = FALSE; }
-       else if(stale_flags > 0 && autocvar_g_ctf_stalemate_endcondition == 1)
+       else if(stale_flags < ctf_teams && stale_flags > 0 && autocvar_g_ctf_stalemate_endcondition == 1)
                { ctf_stalemate = FALSE; wpforenemy_announced = FALSE; }
                
        // if sufficient stalemate, then set up the waypointsprite and announce the stalemate if necessary
@@ -807,6 +814,7 @@ void ctf_FlagThink()
                        }
                        if(!ctf_IsDifferentTeam(self, self.owner))
                        {
+                               // drop the flag if reverse status has changed
                                ctf_Handle_Throw(self.owner, world, DROP_THROW);
                        }
                        return;
@@ -871,7 +879,7 @@ void ctf_FlagTouch()
                if(time > self.wait) // if we haven't in a while, play a sound/effect
                {
                        pointparticles(particleeffectnum(self.toucheffect), self.origin, '0 0 0', 1);
-                       sound(self, CH_TRIGGER, self.snd_flag_touch, VOL_BASE, ATTN_NORM);
+                       sound(self, CH_TRIGGER, self.snd_flag_touch, VOL_BASE, ATTEN_NORM);
                        self.wait = time + FLAG_TOUCHRATE;
                }
                return;
@@ -1781,19 +1789,19 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerPreThink)
        float t = 0, t2 = 0, t3 = 0;
        
        // initially clear items so they can be set as necessary later.
-       self.items &~= (IT_RED_FLAG_CARRYING | IT_RED_FLAG_TAKEN | IT_RED_FLAG_LOST 
-                                 | IT_BLUE_FLAG_CARRYING | IT_BLUE_FLAG_TAKEN | IT_BLUE_FLAG_LOST
-                                 | IT_YELLOW_FLAG_CARRYING | IT_YELLOW_FLAG_TAKEN | IT_YELLOW_FLAG_LOST
-                                 | IT_PINK_FLAG_CARRYING | IT_PINK_FLAG_TAKEN | IT_PINK_FLAG_LOST
+       self.items &= ~(IT_RED_FLAG_CARRYING    | IT_RED_FLAG_TAKEN     | IT_RED_FLAG_LOST 
+                                 | IT_BLUE_FLAG_CARRYING       | IT_BLUE_FLAG_TAKEN    | IT_BLUE_FLAG_LOST
+                                 | IT_YELLOW_FLAG_CARRYING | IT_YELLOW_FLAG_TAKEN      | IT_YELLOW_FLAG_LOST
+                                 | IT_PINK_FLAG_CARRYING       | IT_PINK_FLAG_TAKEN    | IT_PINK_FLAG_LOST
                                  | IT_CTF_SHIELDED);
 
        // scan through all the flags and notify the client about them 
        for(flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext)
        {
-               if(flag.team == NUM_TEAM_1) { t = IT_RED_FLAG_CARRYING; t2 = IT_RED_FLAG_TAKEN; t3 = IT_RED_FLAG_LOST; }
-               if(flag.team == NUM_TEAM_2) { t = IT_BLUE_FLAG_CARRYING; t2 = IT_BLUE_FLAG_TAKEN; t3 = IT_BLUE_FLAG_LOST; }
-               if(flag.team == NUM_TEAM_3) { t = IT_YELLOW_FLAG_CARRYING; t2 = IT_YELLOW_FLAG_TAKEN; t3 = IT_YELLOW_FLAG_LOST; }
-               if(flag.team == NUM_TEAM_4) { t = IT_PINK_FLAG_CARRYING; t2 = IT_PINK_FLAG_TAKEN; t3 = IT_PINK_FLAG_LOST; }
+               if(flag.team == NUM_TEAM_1) { t = IT_RED_FLAG_CARRYING;         t2 = IT_RED_FLAG_TAKEN;         t3 = IT_RED_FLAG_LOST; }
+               if(flag.team == NUM_TEAM_2) { t = IT_BLUE_FLAG_CARRYING;        t2 = IT_BLUE_FLAG_TAKEN;        t3 = IT_BLUE_FLAG_LOST; }
+               if(flag.team == NUM_TEAM_3) { t = IT_YELLOW_FLAG_CARRYING;      t2 = IT_YELLOW_FLAG_TAKEN;      t3 = IT_YELLOW_FLAG_LOST; }
+               if(flag.team == NUM_TEAM_4) { t = IT_PINK_FLAG_CARRYING;        t2 = IT_PINK_FLAG_TAKEN;        t3 = IT_PINK_FLAG_LOST; }
        
                switch(flag.ctf_status)
                {
@@ -2321,7 +2329,6 @@ void ctf_DelayedInit() // Do this check with a delay so we can wait for teams to
                        ctf_SpawnTeam("Pink", NUM_TEAM_4 - 1);
        }
        
-       ret_float = ctf_teams;
        ctf_ScoreRules(ctf_teams);
 }