]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Added Defense medal to CTF
authorz411 <z411@omaera.org>
Tue, 10 Nov 2020 09:42:23 +0000 (06:42 -0300)
committerz411 <z411@omaera.org>
Tue, 10 Nov 2020 09:42:23 +0000 (06:42 -0300)
qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc
qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qh

index 937575752af4f2c1547f11ac55c39e0060314505..b017718088704c9d0168aa402e6670a8838385cc 100644 (file)
@@ -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)
index 58954905c2106af96bccee9c7c201724e1f846f9..24a47ac9e79aaedabd6384e59f15e69506b98224 100644 (file)
@@ -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)