X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fweapons%2Faccuracy.qc;h=2d553ba1685b1a62bb6f6dade746acd9042c72b2;hb=e51ce3d45d2852ca793118fc73da9c25f789101f;hp=bee961bc080d0aecd64ccc284e02a0d49be4517b;hpb=38ad97a27a38fe7e497d1cccefca9a8d26de7862;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/weapons/accuracy.qc b/qcsrc/server/weapons/accuracy.qc index bee961bc0..2d553ba16 100644 --- a/qcsrc/server/weapons/accuracy.qc +++ b/qcsrc/server/weapons/accuracy.qc @@ -1,6 +1,6 @@ #include "accuracy.qh" -#include "../mutators/_mod.qh" +#include #include #include #include @@ -23,7 +23,7 @@ bool accuracy_send(entity this, entity to, int sf) a = CS(a).accuracy; if (to != a.owner) - if (!autocvar_sv_accuracy_data_share && !a.owner.cvar_cl_accuracy_data_share) + if (!autocvar_sv_accuracy_data_share && !CS(a.owner).cvar_cl_accuracy_data_share) sf = 0; // note: zero sendflags can never be sent... so we can use that to say that we send no accuracy! WriteInt24_t(MSG_ENTITY, sf); @@ -67,14 +67,15 @@ void accuracy_add(entity this, int w, int fired, int hit) entity a = CS(this).accuracy; if (!a) return; if (!hit && !fired) return; + if (w == WEP_Null.m_id) return; w -= WEP_FIRST; int b = accuracy_byte(a.accuracy_hit[w], a.accuracy_fired[w]); if (hit) a.accuracy_hit [w] += hit; if (fired) a.accuracy_fired[w] += fired; - if (hit && a.hit_time != time) { // only run this once per frame + if (hit && STAT(HIT_TIME, a) != time) { // only run this once per frame a.accuracy_cnt_hit[w] += 1; - a.hit_time = time; + STAT(HIT_TIME, a) = time; } if (fired && a.fired_time != time) { // only run this once per frame @@ -85,7 +86,7 @@ void accuracy_add(entity this, int w, int fired, int hit) if (b == accuracy_byte(a.accuracy_hit[w], a.accuracy_fired[w])) return; // no change int sf = 1 << (w % 24); a.SendFlags |= sf; - FOREACH_CLIENT(IS_SPEC(it) && it.enemy == this, LAMBDA(CS(it).accuracy.SendFlags |= sf)); + FOREACH_CLIENT(IS_SPEC(it) && it.enemy == this, { CS(it).accuracy.SendFlags |= sf; }); } bool accuracy_isgooddamage(entity attacker, entity targ) @@ -93,8 +94,11 @@ bool accuracy_isgooddamage(entity attacker, entity targ) int mutator_check = MUTATOR_CALLHOOK(AccuracyTargetValid, attacker, targ); if (warmup_stage) return false; - if (IS_DEAD(targ)) return false; - if (STAT(FROZEN, targ)) return false; + + // damage to dead/frozen players is good only if it happens in the frame they get killed / frozen + // so that stats for weapons that shoot multiple projectiles per shot are properly counted + if (IS_DEAD(targ) && time > targ.death_time) return false; + if (STAT(FROZEN, targ) && time > targ.freeze_time) return false; if (SAME_TEAM(attacker, targ)) return false; if (mutator_check == MUT_ACCADD_INVALID) return true;