From: z411 Date: Tue, 10 Nov 2020 09:42:23 +0000 (-0300) Subject: Added Defense medal to CTF X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=74c83cda13a0d5dad9fafe6e4f3edca2f558ccba;p=xonotic%2Fxonotic-data.pk3dir.git Added Defense medal to CTF --- diff --git a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc index 937575752..b01771808 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc +++ b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc @@ -2246,10 +2246,25 @@ MUTATOR_HOOKFUNCTION(ctf, PlayerDies) 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) @@ -2258,6 +2273,7 @@ MUTATOR_HOOKFUNCTION(ctf, PlayerDies) ctf_Handle_Throw(frag_target, NULL, DROP_NORMAL); tmp_entity.ctf_dropper = NULL; } + } MUTATOR_HOOKFUNCTION(ctf, GiveFragsForKill) diff --git a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qh b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qh index 58954905c..24a47ac9e 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qh +++ b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qh @@ -177,3 +177,5 @@ void havocbot_role_ctf_setrole(entity bot, int role); // 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)