]> de.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 29b428857441b4a787872136dc395d4747354c6f..510ba79f9bd6abb033f10e982a670230372dac2e 100644 (file)
@@ -22,34 +22,14 @@ void ctf_EventLog(string mode, float flagteam, entity actor) // use an alias for
 
 void ctf_CaptureRecord(entity flag, entity player)
 {
-       entity tmp_entity;
        float cap_record = ctf_captimerecord;
        float cap_time = (time - flag.ctf_pickuptime);
        string refername = db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"));
        
        // notify about shit
-       FOR_EACH_REALCLIENT(tmp_entity)
-       {
-               if(tmp_entity.CAPTURE_VERBOSE)
-               {
-                       if(!ctf_captimerecord) { Send_Notification(NOTIF_ONE_ONLY, tmp_entity, MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_CAPTURE_TIME_), player.netname, (cap_time * 100)); }
-                       else if(cap_time < cap_record) { Send_Notification(NOTIF_ONE_ONLY, tmp_entity, MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_CAPTURE_BROKEN_), player.netname, refername, (cap_time * 100), (cap_record * 100)); }
-                       else { Send_Notification(NOTIF_ONE_ONLY, tmp_entity, MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_CAPTURE_UNBROKEN_), player.netname, refername, (cap_time * 100), (cap_record * 100)); }
-               }
-               else { Send_Notification(NOTIF_ONE_ONLY, tmp_entity, MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_CAPTURE_), player.netname); }
-       }
-
-       // the previous notification broadcast is only sent to real clients, this will notify server log too
-       if(server_is_dedicated)
-       {
-               if(autocvar_notification_ctf_capture_verbose)
-               {
-                       if(!ctf_captimerecord) { Local_Notification(MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_CAPTURE_TIME_), player.netname, (cap_time * 100)); }
-                       else if(cap_time < cap_record) { Local_Notification(MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_CAPTURE_BROKEN_), player.netname, refername, (cap_time * 100), (cap_record * 100)); }
-                       else { Local_Notification(MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_CAPTURE_UNBROKEN_), player.netname, refername, (cap_time * 100), (cap_record * 100)); }
-               }
-               else { Local_Notification(MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_CAPTURE_), player.netname); }
-       }
+       if(!ctf_captimerecord) { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT_4(flag, CHOICE_CTF_CAPTURE_TIME_), player.netname, (cap_time * 100)); }
+       else if(cap_time < cap_record) { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT_4(flag, CHOICE_CTF_CAPTURE_BROKEN_), player.netname, refername, (cap_time * 100), (cap_record * 100)); }
+       else { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT_4(flag, CHOICE_CTF_CAPTURE_UNBROKEN_), player.netname, refername, (cap_time * 100), (cap_record * 100)); }
        
        // write that shit in the database
        if((!ctf_captimerecord) || (cap_time < cap_record))
@@ -131,12 +111,6 @@ float ctf_CheckPassDirection(vector head_center, vector passer_center, vector pa
        else { return TRUE; }
 }
 
-float ctf_IsDifferentTeam(entity a, entity b)
-{
-       float f = IsDifferentTeam(a, b);
-       return (autocvar_g_ctf_reverse) ? !f : f;
-}
-
 float ctf_Stalemate_customizeentityforclient()
 {
        // make spectators see what the player would see
@@ -145,7 +119,7 @@ float ctf_Stalemate_customizeentityforclient()
        wp_owner = self.owner;
        
        // team waypoints
-       if(!ctf_IsDifferentTeam(wp_owner.flagcarried, wp_owner))
+       if(CTF_SAMETEAM(wp_owner.flagcarried, wp_owner))
                return FALSE;
                
        if not(IS_PLAYER(e))
@@ -181,7 +155,7 @@ float ctf_CaptureShield_CheckStatus(entity p)
        players_total = players_worseeq = 0;
        FOR_EACH_PLAYER(e)
        {
-               if(IsDifferentTeam(e, p))
+               if(DIFF_TEAM(e, p))
                        continue;
                se = PlayerScore_Add(e, SP_CTF_CAPS, 0);
                se2 = PlayerScore_Add(e, SP_CTF_PICKUPS, 0);
@@ -217,7 +191,7 @@ void ctf_CaptureShield_Update(entity player, float wanted_status)
 float ctf_CaptureShield_Customize()
 {
        if(!other.ctf_captureshielded) { return FALSE; }
-       if(!ctf_IsDifferentTeam(self, other)) { return FALSE; }
+       if(SAME_TEAM(self, other)) { return FALSE; }
        
        return TRUE;
 }
@@ -225,7 +199,7 @@ float ctf_CaptureShield_Customize()
 void ctf_CaptureShield_Touch()
 {
        if(!other.ctf_captureshielded) { return; }
-       if(!ctf_IsDifferentTeam(self, other)) { return; }
+       if(SAME_TEAM(self, other)) { return; }
        
        vector mymid = (self.absmin + self.absmax) * 0.5;
        vector othermid = (other.absmin + other.absmax) * 0.5;
@@ -330,7 +304,7 @@ void ctf_Handle_Retrieve(entity flag, entity player)
                        Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, APP_TEAM_ENT_4(flag, CENTER_CTF_PASS_SENT_), player.netname);
                else if(tmp_player == player)
                        Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, APP_TEAM_ENT_4(flag, CENTER_CTF_PASS_RECEIVED_), sender.netname);
-               else if(!IsDifferentTeam(tmp_player, sender))
+               else if(SAME_TEAM(tmp_player, sender))
                        Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, APP_TEAM_ENT_4(flag, CENTER_CTF_PASS_OTHER_), sender.netname, player.netname);
        }
        
@@ -442,12 +416,12 @@ void ctf_Handle_Capture(entity flag, entity toucher, float capturetype)
        float old_time, new_time; 
        
        if not(player) { return; } // without someone to give the reward to, we can't possibly cap
-       if(ctf_IsDifferentTeam(player, flag)) { return; }
+       if(CTF_DIFFTEAM(player, flag)) { return; }
        
        // 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, ATTEN_NONE);
+       sound(player, CH_TRIGGER, ((CTF_DIFFTEAM(player, flag)) ? enemy_flag.snd_flag_capture : flag.snd_flag_capture), VOL_BASE, ATTEN_NONE);
        
        switch(capturetype)
        {
@@ -512,7 +486,6 @@ void ctf_Handle_Return(entity flag, entity player)
 void ctf_Handle_Pickup(entity flag, entity player, float pickuptype)
 {
        // declarations
-       entity tmp_player; // temporary entity which the FOR_EACH_PLAYER loop uses to scan players
        float pickup_dropped_score; // used to calculate dropped pickup score
        
        // attach the flag to the player
@@ -536,31 +509,14 @@ 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);
+       Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_PICKUP_), player.netname);  
+       Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT_4(flag, CENTER_CTF_PICKUP_));
+       if(ctf_stalemate) { Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_CTF_STALEMATE_CARRIER); }
+       
+       Send_Notification(NOTIF_TEAM_EXCEPT, player, MSG_CHOICE, APP_TEAM_ENT_4(flag, CHOICE_CTF_PICKUP_TEAM_), Team_ColorCode(player.team), player.netname);
+       Send_Notification(NOTIF_TEAM, flag, MSG_CHOICE, CHOICE_CTF_PICKUP_ENEMY, Team_ColorCode(player.team), player.netname);
+       
        sound(player, CH_TRIGGER, flag.snd_flag_taken, VOL_BASE, ATTEN_NONE);
-
-       FOR_EACH_REALPLAYER(tmp_player)
-       {
-               if(tmp_player == player)
-               {
-                       Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, APP_TEAM_ENT_4(flag, CENTER_CTF_PICKUP_));
-                       if(ctf_stalemate) { Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_CTF_STALEMATE_CARRIER); }
-               }
-               else if(!IsDifferentTeam(tmp_player, player) && tmp_player != player)
-               {
-                       if(tmp_player.PICKUP_TEAM_VERBOSE)
-                               Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, APP_TEAM_ENT_4(flag, CENTER_CTF_PICKUP_TEAM_VERBOSE_), Team_ColorCode(player.team), player.netname);
-                       else
-                               Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, APP_TEAM_ENT_4(flag, CENTER_CTF_PICKUP_TEAM_), Team_ColorCode(player.team));
-               }
-               else if(IsDifferentTeam(tmp_player, player) && !ctf_IsDifferentTeam(flag, tmp_player))
-               {
-                       if(tmp_player.PICKUP_ENEMY_VERBOSE)
-                               Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, CENTER_CTF_PICKUP_ENEMY_VERBOSE, Team_ColorCode(player.team), player.netname);
-                       else
-                               Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, CENTER_CTF_PICKUP_ENEMY, Team_ColorCode(player.team));
-               }
-       }
        
        // scoring
        PlayerScore_Add(player, SP_CTF_PICKUPS, 1);
@@ -812,7 +768,7 @@ void ctf_FlagThink()
                                        wpforenemy_nextthink = time + WPFE_THINKRATE; // waypoint for enemy think rate (to reduce unnecessary spam of this check)
                                }
                        }
-                       if(!ctf_IsDifferentTeam(self, self.owner))
+                       if(CTF_SAMETEAM(self, self.owner))
                        {
                                // drop the flag if reverse status has changed
                                ctf_Handle_Throw(self.owner, world, DROP_THROW);
@@ -890,16 +846,16 @@ void ctf_FlagTouch()
        {       
                case FLAG_BASE:
                {
-                       if(!ctf_IsDifferentTeam(toucher, self) && (toucher.flagcarried) && IsDifferentTeam(toucher.flagcarried, self))
+                       if(SAME_TEAM(toucher, self) && (toucher.flagcarried) && DIFF_TEAM(toucher.flagcarried, self))
                                ctf_Handle_Capture(self, toucher, CAPTURE_NORMAL); // toucher just captured the enemies flag to his base
-                       else if(ctf_IsDifferentTeam(toucher, self) && (!toucher.flagcarried) && (!toucher.ctf_captureshielded) && (time > toucher.next_take_time))
+                       else if(DIFF_TEAM(toucher, self) && (!toucher.flagcarried) && (!toucher.ctf_captureshielded) && (time > toucher.next_take_time))
                                ctf_Handle_Pickup(self, toucher, PICKUP_BASE); // toucher just stole the enemies flag
                        break;
                }
                
                case FLAG_DROPPED:
                {
-                       if(!ctf_IsDifferentTeam(toucher, self))
+                       if(SAME_TEAM(toucher, self))
                                ctf_Handle_Return(self, toucher); // toucher just returned his own flag
                        else if((!toucher.flagcarried) && ((toucher != self.ctf_dropper) || (time > self.ctf_droptime + autocvar_g_ctf_flag_collect_delay)))
                                ctf_Handle_Pickup(self, toucher, PICKUP_DROPPED); // toucher just picked up a dropped enemy flag
@@ -916,7 +872,7 @@ void ctf_FlagTouch()
                {
                        if((IS_PLAYER(toucher)) && (toucher.deadflag == DEAD_NO) && (toucher != self.pass_sender))
                        {
-                               if(IsDifferentTeam(toucher, self.pass_sender))
+                               if(DIFF_TEAM(toucher, self.pass_sender))
                                        ctf_Handle_Return(self, toucher);
                                else
                                        ctf_Handle_Retrieve(self, toucher);
@@ -1152,7 +1108,7 @@ entity havocbot_ctf_find_flag(entity bot)
        f = ctf_worldflaglist;
        while (f)
        {
-               if (!ctf_IsDifferentTeam(bot, f))
+               if (CTF_SAMETEAM(bot, f))
                        return f;
                f = f.ctf_worldflagnext;
        }
@@ -1165,7 +1121,7 @@ entity havocbot_ctf_find_enemy_flag(entity bot)
        f = ctf_worldflaglist;
        while (f)
        {
-               if (ctf_IsDifferentTeam(bot, f))
+               if (CTF_DIFFTEAM(bot, f))
                        return f;
                f = f.ctf_worldflagnext;
        }
@@ -1198,7 +1154,7 @@ void havocbot_goalrating_ctf_ourflag(float ratingscale)
        head = ctf_worldflaglist;
        while (head)
        {
-               if (!ctf_IsDifferentTeam(self, head))
+               if (CTF_SAMETEAM(self, head))
                        break;
                head = head.ctf_worldflagnext;
        }
@@ -1212,7 +1168,7 @@ void havocbot_goalrating_ctf_ourbase(float ratingscale)
        head = ctf_worldflaglist;
        while (head)
        {
-               if (!ctf_IsDifferentTeam(self, head))
+               if (CTF_SAMETEAM(self, head))
                        break;
                head = head.ctf_worldflagnext;
        }
@@ -1228,7 +1184,7 @@ void havocbot_goalrating_ctf_enemyflag(float ratingscale)
        head = ctf_worldflaglist;
        while (head)
        {
-               if (ctf_IsDifferentTeam(self, head))
+               if(CTF_DIFFTEAM(self, head))
                        break;
                head = head.ctf_worldflagnext;
        }
@@ -1846,7 +1802,7 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerDamage) // for changing damage and force values t
                        frag_force *= autocvar_g_ctf_flagcarrier_forcefactor;
                }
        }
-       else if(frag_target.flagcarried && (frag_target.deadflag == DEAD_NO) && ctf_IsDifferentTeam(frag_target, frag_attacker)) // if the target is a flagcarrier
+       else if(frag_target.flagcarried && (frag_target.deadflag == DEAD_NO) && DIFF_TEAM(frag_target, frag_attacker)) // if the target is a flagcarrier
        {
                if(autocvar_g_ctf_flagcarrier_auto_helpme_damage > ('1 0 0' * healtharmor_maxdamage(frag_target.health, frag_target.armorvalue, autocvar_g_balance_armor_blockpercent)))
                if(time > frag_target.wps_helpme_time + autocvar_g_ctf_flagcarrier_auto_helpme_time)
@@ -1922,7 +1878,7 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey)
                        while(head) // find the closest acceptable target to pass to
                        {
                                if(IS_PLAYER(head) && head.deadflag == DEAD_NO)
-                               if(head != player && !IsDifferentTeam(head, player))
+                               if(head != player && SAME_TEAM(head, player))
                                if(!head.speedrunning && !head.vehicle)
                                {
                                        // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc) 
@@ -2101,21 +2057,12 @@ MUTATOR_HOOKFUNCTION(ctf_BotRoles)
        return TRUE;
 }
 
-MUTATOR_HOOKFUNCTION(ctf_GetCvars)
-{
-       GetCvars_handleFloat(get_cvars_s, get_cvars_f, CAPTURE_VERBOSE, "notification_ctf_capture_verbose");
-       GetCvars_handleFloat(get_cvars_s, get_cvars_f, PICKUP_TEAM_VERBOSE, "notification_ctf_pickup_team_verbose");
-       GetCvars_handleFloat(get_cvars_s, get_cvars_f, PICKUP_ENEMY_VERBOSE, "notification_ctf_pickup_enemy_verbose");
-       return TRUE;
-}
-
 MUTATOR_HOOKFUNCTION(ctf_GetTeamCount)
 {
        ret_float = ctf_teams;
        return 0;
 }
 
-
 // ==========
 // Spawnfuncs
 // ==========
@@ -2351,7 +2298,6 @@ MUTATOR_DEFINITION(gamemode_ctf)
        MUTATOR_HOOK(VehicleExit, ctf_VehicleExit, CBC_ORDER_ANY);
        MUTATOR_HOOK(AbortSpeedrun, ctf_AbortSpeedrun, CBC_ORDER_ANY);
        MUTATOR_HOOK(HavocBot_ChooseRule, ctf_BotRoles, CBC_ORDER_ANY);
-       MUTATOR_HOOK(GetCvars, ctf_GetCvars, CBC_ORDER_ANY);
        MUTATOR_HOOK(GetTeamCount, ctf_GetTeamCount, CBC_ORDER_ANY);
        
        MUTATOR_ONADD