const string STATIC_NAME_TEAM_3 = "Yellow";
const string STATIC_NAME_TEAM_4 = "Pink";
-#define APP_TEAM_NUM_2(num,prefix) ((num == NUM_TEAM_1) ? prefix##RED : prefix##BLUE)
-#define APP_TEAM_NUM_4(num,prefix) ((num == NUM_TEAM_1) ? prefix##RED : ((num == NUM_TEAM_2) ? prefix##BLUE : ((num == NUM_TEAM_3) ? prefix##YELLOW : prefix##PINK)))
-#define APP_TEAM_ENT_2(ent,prefix) ((ent.team == NUM_TEAM_1) ? prefix##RED : prefix##BLUE)
-#define APP_TEAM_ENT_4(ent,prefix) ((ent.team == NUM_TEAM_1) ? prefix##RED : ((ent.team == NUM_TEAM_2) ? prefix##BLUE : ((ent.team == NUM_TEAM_3) ? prefix##YELLOW : prefix##PINK)))
-
#ifdef CSQC
float teamplay;
float myteam;
// replace these flags in a string with the strings provided
#define TCR(input,teamcolor,teamtext) strreplace("^TC", teamcolor, strreplace("^TT", teamtext, input))
+
+// safe team comparisons
+#define SAME_TEAM(a,b) (teamplay ? ((a.team == b.team) ? 1 : 0) : ((a == b) ? 1 : 0))
+#define DIFF_TEAM(a,b) (teamplay ? ((a.team != b.team) ? 1 : 0) : ((a != b) ? 1 : 0))
+
+// used for notification system multi-team identifiers
+#define APP_TEAM_NUM_2(num,prefix) ((num == NUM_TEAM_1) ? prefix##RED : prefix##BLUE)
+#define APP_TEAM_NUM_4(num,prefix) ((num == NUM_TEAM_1) ? prefix##RED : ((num == NUM_TEAM_2) ? prefix##BLUE : ((num == NUM_TEAM_3) ? prefix##YELLOW : prefix##PINK)))
+#define APP_TEAM_ENT_2(ent,prefix) ((ent.team == NUM_TEAM_1) ? prefix##RED : prefix##BLUE)
+#define APP_TEAM_ENT_4(ent,prefix) ((ent.team == NUM_TEAM_1) ? prefix##RED : ((ent.team == NUM_TEAM_2) ? prefix##BLUE : ((ent.team == NUM_TEAM_3) ? prefix##YELLOW : prefix##PINK)))
if(!warmup_stage)
if(IS_CLIENT(targ))
if(targ.deadflag == DEAD_NO)
- if(IsDifferentTeam(attacker, targ))
+ if(DIFF_TEAM(attacker, targ))
return TRUE;
return FALSE;
}
RandomSelection_Init();
FOR_EACH_PLAYER(e)
if(e.deadflag == DEAD_NO)
- if(IsDifferentTeam(e, self))
+ if(DIFF_TEAM(e, self))
RandomSelection_Add(e, 0, string_null, 1, 1);
if(RandomSelection_chosen_ent)
e = RandomSelection_chosen_ent;
drag = TRUE;
break;
case 2: // owner and team mates can grab
- if(!IsDifferentTeam(trace_ent.owner, self) || !IsDifferentTeam(trace_ent.realowner, self) || trace_ent.team == self.team)
+ if(SAME_TEAM(trace_ent.owner, self) || SAME_TEAM(trace_ent.realowner, self) || trace_ent.team == self.team)
drag = TRUE;
break;
case 3: // anyone can grab
if(vbot || IS_REAL_CLIENT(self))
if(abot || IS_REAL_CLIENT(attacker))
if(attacker && self != attacker)
- if(IsDifferentTeam(self, attacker))
+ if(DIFF_TEAM(self, attacker))
{
if(DEATH_ISSPECIAL(deathtype))
awep = attacker.weapon;
.float istypefrag;
.float taunt_soundtime;
-
-float IsDifferentTeam(entity a, entity b)
-{
- if(teamplay)
- {
- if(a.team == b.team)
- return 0;
- }
- else
- {
- if(a == b)
- return 0;
- }
- return 1;
-}
-
float IsFlying(entity a)
{
if(a.flags & FL_ONGROUND)
// ======
else if(IS_PLAYER(attacker))
{
- if(!IsDifferentTeam(attacker, targ))
+ if(SAME_TEAM(attacker, targ))
{
LogDeath("tk", deathtype, attacker, targ);
GiveFrags(attacker, targ, -1, deathtype);
if(DEATH_ISWEAPON(deathtype, WEP_HOOK) || DEATH_ISWEAPON(deathtype, WEP_TUBA))
{
if(IS_PLAYER(targ))
- if not(IsDifferentTeam(targ, attacker))
+ if(SAME_TEAM(targ, attacker))
{
self = oldself;
return;
damage = 0;
force = '0 0 0';
}
- else if(!IsDifferentTeam(attacker, targ))
+ else if(SAME_TEAM(attacker, targ))
{
if(autocvar_teamplay_mode == 1)
damage = 0;
if(IS_PLAYER(victim) || victim.turrcaps_flags & TFL_TURRCAPS_ISTURRET)
{
- if(IsDifferentTeam(victim, attacker))
+ if(DIFF_TEAM(victim, attacker))
{
if(damage > 0)
{
{
if(IS_PLAYER(frag_target))
if(frag_target.deadflag == DEAD_NO)
- if(frag_target == frag_attacker || !IsDifferentTeam(frag_target, frag_attacker) || frag_deathtype == DEATH_FALL)
+ if(frag_target == frag_attacker || SAME_TEAM(frag_target, frag_attacker) || frag_deathtype == DEATH_FALL)
frag_damage = 0;
frag_mirrordamage = 0;
players_total = players_worseeq = 0;
FOR_EACH_PLAYER(e)
{
- if(IsDifferentTeam(e, p))
+ if(DIFF_TEAM(e, p))
continue;
se = PlayerScore_Add(e, SP_SCORE, 0);
if(se <= s)
float ctf_CaptureShield_Customize()
{
if(!other.ctf_captureshielded) { return FALSE; }
- if(!IsDifferentTeam(self, other)) { return FALSE; }
+ if(SAME_TEAM(self, other)) { return FALSE; }
return TRUE;
}
void ctf_CaptureShield_Touch()
{
if(!other.ctf_captureshielded) { return; }
- if(!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;
Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, APP_TEAM_ENT_2(flag, CENTER_CTF_PASS_SENT_), player.netname);
else if(tmp_player == player)
Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, APP_TEAM_ENT_2(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_2(flag, CENTER_CTF_PASS_OTHER_), sender.netname, player.netname);
}
{
case FLAG_BASE:
{
- if(!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(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(!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
{
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);
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) && 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)
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)
MUTATOR_HOOKFUNCTION(minstagib_PlayerDamage)
{
- if(autocvar_g_friendlyfire == 0 && !IsDifferentTeam(frag_target, frag_attacker) && IS_PLAYER(frag_target) && IS_PLAYER(frag_attacker))
+ if(autocvar_g_friendlyfire == 0 && SAME_TEAM(frag_target, frag_attacker) && IS_PLAYER(frag_target) && IS_PLAYER(frag_attacker))
frag_damage = 0;
if(IS_PLAYER(frag_target))
// if you have the invisibility powerup, sprites ALWAYS are restricted to your team
// but only apply this to real players, not to spectators
if((self.owner.flags & FL_CLIENT) && (self.owner.items & IT_STRENGTH) && (e == other))
- if(IsDifferentTeam(self.owner, e))
+ if(DIFF_TEAM(self.owner, e))
return TRUE;
return FALSE;
{
if((head.takedamage != DAMAGE_NO) && (head.deadflag == DEAD_NO))
{
- if(IsDifferentTeam(head, projectile.realowner))
- ++hit_enemy;
- else
+ if(SAME_TEAM(head, projectile.realowner))
++hit_friendly;
+ else
+ ++hit_enemy;
}
head = head.chain;
{
if(other.takedamage == DAMAGE_AIM)
if(IS_PLAYER(other))
- if(IsDifferentTeam(self.realowner, other))
+ if(DIFF_TEAM(self.realowner, other))
if(other.deadflag == DEAD_NO)
if(IsFlying(other))
Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
// 2. bfg effect
// NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
for(e = findradius(self.origin, autocvar_g_balance_fireball_primary_bfgradius); e; e = e.chain)
- if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || IsDifferentTeam(e, self))
+ if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
{
// can we see fireball?
traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
RandomSelection_Init();
for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
- if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || IsDifferentTeam(e, self))
+ if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
{
p = e.origin;
p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
{
if(other.takedamage == DAMAGE_AIM)
if(IS_PLAYER(other))
- if(IsDifferentTeam(self.realowner, other))
+ if(DIFF_TEAM(self.realowner, other))
if(other.deadflag == DEAD_NO)
if(IsFlying(other))
Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT);
{
if(other.takedamage == DAMAGE_AIM)
if(IS_PLAYER(other))
- if(IsDifferentTeam(self.realowner, other))
+ if(DIFF_TEAM(self.realowner, other))
if(other.deadflag == DEAD_NO)
if(IsFlying(other))
Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT);
{
if(other.takedamage == DAMAGE_AIM)
if(IS_PLAYER(other))
- if(IsDifferentTeam(self.realowner, other))
+ if(DIFF_TEAM(self.realowner, other))
if(other.deadflag == DEAD_NO)
if(IsFlying(other))
Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT);
head = findradius(self.origin, autocvar_g_balance_minelayer_radius);
while(head)
{
- if(head == self.realowner || !IsDifferentTeam(head, self.realowner))
+ if(head == self.realowner || SAME_TEAM(head, self.realowner))
return;
head = head.chain;
}
while(head)
{
if(IS_PLAYER(head) && head.deadflag == DEAD_NO)
- if(head != self.realowner && IsDifferentTeam(head, self.realowner)) // don't trigger for team mates
+ if(head != self.realowner && DIFF_TEAM(head, self.realowner)) // don't trigger for team mates
if(!self.mine_time)
{
spamsound (self, CH_SHOTS, "weapons/mine_trigger.wav", VOL_BASE, ATTEN_NORM);
if(other.takedamage == DAMAGE_AIM)
if(IS_PLAYER(other))
- if(IsDifferentTeam(self.realowner, other))
+ if(DIFF_TEAM(self.realowner, other))
if(other.deadflag == DEAD_NO)
if(IsFlying(other))
Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT);