else { return TRUE; }
}
+float ctf_IsDifferentTeam(entity a, entity b)
+{
+ float f = IsDifferentTeam(a, b);
+ return (autocvar_g_ctf_reverse) ? !f : f;
+}
+
// =======================
// CaptureShield Functions
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;
}
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;
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);
}
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)
{
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);
{
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
{
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);
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?
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)
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)
{
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)
{
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)
{
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)
{
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)