2 .float accuracy_hit[WEP_MAXCOUNT];
3 .float accuracy_fired[WEP_MAXCOUNT];
5 void accuracy_send(entity to, float sf)
8 WriteByte(MSG_ENTITY, ENT_CLIENT_ACCURACY);
10 if not(self.owner.cvar_cl_accuracy_data_share && autocvar_sv_accuracy_data_share)
12 // note: zero sendflags can never be sent... so we can use that to say that we send no accuracy!
13 WriteInt24_t(MSG_ENTITY, sf);
16 // note: we know that client and server agree about SendFlags...
17 for(w = 0, f = 1; w <= WEP_LAST - WEP_FIRST; ++w, f *= 2)
21 if(self.(accuracy_fired[w]))
22 WriteByte(MSG_ENTITY, 0);
24 WriteByte(MSG_ENTITY, 1 + bound(0, (254.0 * self.(accuracy_hit[w])) / self.(accuracy_fired[w]), 254));
31 void accuracy_init(entity e)
35 e.accuracy.classname = "accuracy";
36 e.accuracy.SendEntity = accuracy_send;
39 void accuracy_free(entity e)
44 // force a resend of a player's accuracy stats
45 void accuracy_resend(entity e)
47 e.accuracy.SendFlags = 0xFFFFFF;
50 // update accuracy stats
51 void accuracy_set(entity e, float w, float hit, float fired)
55 e.(accuracy_hit[w]) = hit;
56 e.(accuracy_fired[w]) = fired;
57 e.SendFlags |= pow(2, w);
60 void accuracy_add(entity e, float w, float hit, float fired)
64 e.(accuracy_hit[w]) += hit;
65 e.(accuracy_fired[w]) += fired;
66 e.SendFlags |= pow(2, w);