]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Sending attackertext to spectators as well
authorz411 <z411@omaera.org>
Mon, 19 Oct 2020 21:45:15 +0000 (18:45 -0300)
committerz411 <z411@omaera.org>
Mon, 19 Oct 2020 21:45:15 +0000 (18:45 -0300)
qcsrc/common/mutators/mutator/attackertext/sv_attackertext.qc

index 59b0865d6fd2893e06faeb1513f42fa28b909ab9..2a2556d7c5bf2a3fc003b98b2c468b3e930a79fe 100644 (file)
@@ -7,19 +7,28 @@ REGISTER_MUTATOR(attackertext, true);
 #define SV_ATTACKERTEXT_DISABLED()        (autocvar_sv_attackertext <= 0)
 #define SV_ATTACKERTEXT_ENABLED()         (autocvar_sv_attackertext >= 1)
 
+void attackertext_Send(entity to, entity attacker, int sf)
+{
+       if(IS_REAL_CLIENT(to)) {
+               msg_entity = to;
+               WriteHeader(MSG_ONE, attackertext);
+               WriteByte(MSG_ONE, etof(attacker));
+               WriteByte(MSG_ONE, sf);
+       }
+}
+
 MUTATOR_HOOKFUNCTION(attackertext, PlayerDamaged) {
     if (SV_ATTACKERTEXT_DISABLED()) return;
        
     entity attacker = M_ARGV(0, entity);
-    entity hit = M_ARGV(1, entity); if (hit == attacker) return;
+    entity hit = M_ARGV(1, entity);
        
-       if (!IS_REAL_CLIENT(hit) || !IS_PLAYER(attacker)) return;
+       if (hit == attacker) return;
+       if (!IS_PLAYER(attacker)) return;
        
-       int flags = 0;
-       if (SAME_TEAM(hit, attacker)) flags |= ATFLAG_SAMETEAM;
+       int sf = 0;
+       if (SAME_TEAM(hit, attacker)) sf |= ATFLAG_SAMETEAM;
        
-       msg_entity = hit;
-       WriteHeader(MSG_ONE, attackertext);
-       WriteByte(MSG_ONE, etof(attacker));
-       WriteByte(MSG_ONE, flags);
+       attackertext_Send(hit, attacker, sf);
+       FOREACH_CLIENT(IS_SPEC(it) && it.(enemy) == hit, { attackertext_Send(it, attacker, sf); });
 }