From: z411 Date: Mon, 19 Oct 2020 21:45:15 +0000 (-0300) Subject: Sending attackertext to spectators as well X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ec8e73197be88de7e2e85f3965ea47a217a9c637;p=xonotic%2Fxonotic-data.pk3dir.git Sending attackertext to spectators as well --- diff --git a/qcsrc/common/mutators/mutator/attackertext/sv_attackertext.qc b/qcsrc/common/mutators/mutator/attackertext/sv_attackertext.qc index 59b0865d6..2a2556d7c 100644 --- a/qcsrc/common/mutators/mutator/attackertext/sv_attackertext.qc +++ b/qcsrc/common/mutators/mutator/attackertext/sv_attackertext.qc @@ -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); }); }