From 887735d407c08816212f7309dc442fe14c60bb69 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 13 Aug 2013 15:10:02 +1000 Subject: [PATCH] Attempt to fix reverse mode --- qcsrc/server/mutators/gamemode_ctf.qc | 57 +++++++++++---------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/qcsrc/server/mutators/gamemode_ctf.qc b/qcsrc/server/mutators/gamemode_ctf.qc index 78772fce5..6db09965f 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qc +++ b/qcsrc/server/mutators/gamemode_ctf.qc @@ -131,6 +131,12 @@ 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; +} + // ======================= // CaptureShield Functions @@ -194,7 +200,7 @@ void ctf_CaptureShield_Update(entity player, float wanted_status) float ctf_CaptureShield_Customize() { if(!other.ctf_captureshielded) { return FALSE; } - if(!IsDifferentTeam(self, other)) { return FALSE; } + if(!ctf_IsDifferentTeam(self, other)) { return FALSE; } return TRUE; } @@ -202,7 +208,7 @@ float ctf_CaptureShield_Customize() void ctf_CaptureShield_Touch() { if(!other.ctf_captureshielded) { return; } - if(!IsDifferentTeam(self, other)) { return; } + if(!ctf_IsDifferentTeam(self, other)) { return; } vector mymid = (self.absmin + self.absmax) * 0.5; vector othermid = (other.absmin + other.absmax) * 0.5; @@ -307,7 +313,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(!ctf_IsDifferentTeam(tmp_player, sender)) Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, APP_TEAM_ENT_4(flag, CENTER_CTF_PASS_OTHER_), sender.netname, player.netname); } @@ -419,12 +425,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(IsDifferentTeam(player, flag)) { return; } + if(ctf_IsDifferentTeam(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, 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, ATTN_NONE); switch(capturetype) { @@ -530,7 +536,7 @@ void ctf_Handle_Pickup(entity flag, entity player, float pickuptype) 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) && !IsDifferentTeam(flag, tmp_player)) + else if(ctf_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); @@ -856,16 +862,16 @@ void ctf_FlagTouch() { case FLAG_BASE: { - if(!IsDifferentTeam(toucher, self) && (toucher.flagcarried) && IsDifferentTeam(toucher.flagcarried, self)) + if(!ctf_IsDifferentTeam(toucher, self) && (toucher.flagcarried) && IsDifferentTeam(toucher.flagcarried, self)) ctf_Handle_Capture(self, toucher, CAPTURE_NORMAL); // toucher just captured the enemies flag to his base - else if(IsDifferentTeam(toucher, self) && (!toucher.flagcarried) && (!toucher.ctf_captureshielded) && (time > toucher.next_take_time)) + else if(ctf_IsDifferentTeam(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(!IsDifferentTeam(toucher, self)) + if(!ctf_IsDifferentTeam(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 @@ -882,7 +888,7 @@ void ctf_FlagTouch() { if((IS_PLAYER(toucher)) && (toucher.deadflag == DEAD_NO) && (toucher != self.pass_sender)) { - if(IsDifferentTeam(toucher, self.pass_sender)) + if(ctf_IsDifferentTeam(toucher, self.pass_sender)) ctf_Handle_Return(self, toucher); else ctf_Handle_Retrieve(self, toucher); @@ -977,32 +983,15 @@ void ctf_DelayedFlagSetup(void) // called after a flag is placed on a map by ctf void ctf_FlagSetup(float teamnumber, entity flag) // called when spawning a flag entity on the map as a spawnfunc { // declarations - //teamnumber = fabs(teamnumber - bound(0, autocvar_g_ctf_reverse, 1)); // if we were originally 1, this will become 0. If we were originally 0, this will become 1. self = flag; // for later usage with droptofloor() - switch(teamnumber) - { - case 0: // blue - teamnumber = ((autocvar_g_ctf_reverse) ? NUM_TEAM_1 : NUM_TEAM_2); - break; - case 1: // red - teamnumber = ((autocvar_g_ctf_reverse) ? NUM_TEAM_2 : NUM_TEAM_1); - break; - case 2: // yellow - teamnumber = ((autocvar_g_ctf_reverse) ? NUM_TEAM_4 : NUM_TEAM_3); - break; - case 3: // pink - teamnumber = ((autocvar_g_ctf_reverse) ? NUM_TEAM_3 : NUM_TEAM_4); - break; - } - // main setup flag.ctf_worldflagnext = ctf_worldflaglist; // link flag into ctf_worldflaglist ctf_worldflaglist = flag; setattachment(flag, world, ""); - flag.netname = strcat(strtoupper(Static_Team_ColorName(teamnumber)), "^7 flag"); + flag.netname = strcat(Static_Team_ColorName_Upper(teamnumber), "^7 flag"); flag.team = teamnumber; flag.classname = "item_flag_team"; flag.target = "###item###"; // wut? @@ -1836,7 +1825,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) && IsDifferentTeam(frag_target, frag_attacker)) // if the target is a flagcarrier + else if(frag_target.flagcarried && (frag_target.deadflag == DEAD_NO) && ctf_IsDifferentTeam(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) @@ -1912,7 +1901,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 && !ctf_IsDifferentTeam(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) @@ -2171,7 +2160,7 @@ void spawnfunc_item_flag_team1() { if(!g_ctf) { remove(self); return; } - ctf_FlagSetup(1, self); // 1 = red + ctf_FlagSetup(NUM_TEAM_1, self); } /*QUAKED spawnfunc_item_flag_team2 (0 0.5 0.8) (-48 -48 -37) (48 48 37) @@ -2189,7 +2178,7 @@ void spawnfunc_item_flag_team2() { if(!g_ctf) { remove(self); return; } - ctf_FlagSetup(0, self); // the 0 is misleading, but -- 0 = blue. + ctf_FlagSetup(NUM_TEAM_2, self); } /*QUAKED spawnfunc_item_flag_team3 (0 0.5 0.8) (-48 -48 -37) (48 48 37) @@ -2207,7 +2196,7 @@ void spawnfunc_item_flag_team3() { if(!g_ctf) { remove(self); return; } - ctf_FlagSetup(2, self); // 2 = yellow? + ctf_FlagSetup(NUM_TEAM_3, self); } /*QUAKED spawnfunc_item_flag_team4 (0 0.5 0.8) (-48 -48 -37) (48 48 37) @@ -2225,7 +2214,7 @@ void spawnfunc_item_flag_team4() { if(!g_ctf) { remove(self); return; } - ctf_FlagSetup(3, self); // 3 = pink? + ctf_FlagSetup(NUM_TEAM_4, self); } /*QUAKED spawnfunc_ctf_team (0 .5 .8) (-16 -16 -24) (16 16 32) -- 2.39.2