-.entity accuracy;
.float accuracy_hit[WEP_MAXCOUNT];
.float accuracy_fired[WEP_MAXCOUNT];
-FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(accuracy_hit);
-FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(accuracy_fired);
+.float accuracy_cnt_hit[WEP_MAXCOUNT];
+.float accuracy_cnt_fired[WEP_MAXCOUNT];
float accuracy_byte(float n, float d)
{
- print(sprintf("accuracy: %d / %d\n", n, d));
+ //print(sprintf("accuracy: %d / %d\n", n, d));
if(n <= 0)
return 0;
if(n > d)
}
// update accuracy stats
-void accuracy_set(entity e, float w, float fired, float hit)
-{
- entity a;
- float b;
- a = e.accuracy;
- if(!a)
- return;
- w -= WEP_FIRST;
- b = accuracy_byte(a.(accuracy_hit[w]), a.(accuracy_fired[w]));
- a.(accuracy_hit[w]) = hit;
- a.(accuracy_fired[w]) = fired;
- if(b == accuracy_byte(hit, fired))
- return;
- w = pow(2, w);
- a.SendFlags |= w;
- FOR_EACH_CLIENT(a)
- if(a.classname == "spectator")
- if(a.enemy == e)
- a.SendFlags |= w;
-}
+.float hit_time;
+.float fired_time;
void accuracy_add(entity e, float w, float fired, float hit)
{
entity a;
float b;
+ if(IS_INDEPENDENT_PLAYER(e))
+ return;
a = e.accuracy;
if(!a || !(hit || fired))
return;
a.(accuracy_hit[w]) += hit;
if(fired)
a.(accuracy_fired[w]) += fired;
+
+ if(hit && a.hit_time != time) // only run this once per frame
+ {
+ a.(accuracy_cnt_hit[w]) += 1;
+ a.hit_time = time;
+ }
+
+ if(fired && a.fired_time != time) // only run this once per frame
+ {
+ a.(accuracy_cnt_fired[w]) += 1;
+ a.fired_time = time;
+ }
+
if(b == accuracy_byte(a.(accuracy_hit[w]), a.(accuracy_fired[w])))
return;
w = pow(2, w);