entity frag_attacker = M_ARGV(1, entity);
entity frag_target = M_ARGV(2, entity);
- if((frag_attacker != frag_target) && (IS_PLAYER(frag_attacker)) && (frag_target.flagcarried))
- {
- GameRules_scoring_add_team(frag_attacker, SCORE, ((SAME_TEAM(frag_attacker, frag_target)) ? -autocvar_g_ctf_score_kill : autocvar_g_ctf_score_kill));
- GameRules_scoring_add(frag_attacker, CTF_FCKILLS, 1);
+ if((frag_attacker != frag_target) && (IS_PLAYER(frag_attacker)))
+ {
+ if(frag_target.flagcarried) {
+ // Killing an enemy flag carrier
+ GameRules_scoring_add_team(frag_attacker, SCORE, ((SAME_TEAM(frag_attacker, frag_target)) ? -autocvar_g_ctf_score_kill : autocvar_g_ctf_score_kill));
+ GameRules_scoring_add(frag_attacker, CTF_FCKILLS, 1);
+ Give_Medal(frag_attacker, DEFENSE);
+ } else {
+ entity tmp_entity;
+ for(tmp_entity = ctf_worldflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_worldflagnext)
+ if(tmp_entity.ctf_status == FLAG_BASE && CTF_SAMETEAM(tmp_entity, frag_attacker))
+ {
+ if(CTF_IS_NEAR(frag_target, tmp_entity, '1 1 1' * 1500))
+ {
+ Give_Medal(frag_attacker, DEFENSE);
+ }
+ break;
+ }
+ }
}
if(frag_target.flagcarried)
ctf_Handle_Throw(frag_target, NULL, DROP_NORMAL);
tmp_entity.ctf_dropper = NULL;
}
+
}
MUTATOR_HOOKFUNCTION(ctf, GiveFragsForKill)
// team checking
#define CTF_SAMETEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? DIFF_TEAM(a,b) : SAME_TEAM(a,b))
#define CTF_DIFFTEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? SAME_TEAM(a,b) : DIFF_TEAM(a,b))
+#define CTF_IS_NEAR(player, it, extra_size) \
+ boxesoverlap(player.absmin - extra_size, player.absmax + extra_size, it.absmin, it.absmax)