2 .float accuracy_hit[WEP_MAXCOUNT];
3 .float accuracy_fired[WEP_MAXCOUNT];
4 FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(accuracy_hit);
5 FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(accuracy_fired);
7 float accuracy_byte(float n, float d)
11 return 1.0 + rint(n * 254.0 / d);
14 float accuracy_send(entity to, float sf)
18 WriteByte(MSG_ENTITY, ENT_CLIENT_ACCURACY);
21 if(a.classname == "spectator")
26 if not(self.owner.cvar_cl_accuracy_data_share && autocvar_sv_accuracy_data_share)
28 // note: zero sendflags can never be sent... so we can use that to say that we send no accuracy!
29 WriteInt24_t(MSG_ENTITY, sf);
32 // note: we know that client and server agree about SendFlags...
33 for(w = 0, f = 1; w <= WEP_LAST - WEP_FIRST; ++w, f *= 2)
36 WriteByte(MSG_ENTITY, accuracy_byte(self.(accuracy_hit[w]), self.(accuracy_fired[w])));
42 void accuracy_init(entity e)
46 e.accuracy.classname = "accuracy";
47 e.accuracy.drawonlytoclient = e;
48 Net_LinkEntity(e.accuracy, FALSE, 0, accuracy_send);
51 void accuracy_free(entity e)
56 // force a resend of a player's accuracy stats
57 void accuracy_resend(entity e)
59 e.accuracy.SendFlags = 0xFFFFFF;
62 // update accuracy stats
63 void accuracy_set(entity e, float w, float hit, float fired)
71 b = accuracy_byte(a.(accuracy_hit[w]), a.(accuracy_fired[w]));
72 a.(accuracy_hit[w]) = hit;
73 a.(accuracy_fired[w]) = fired;
74 if(b == accuracy_byte(hit, fired))
79 if(a.classname == "spectator")
84 void accuracy_add(entity e, float w, float hit, float fired)
89 if(!a || !(hit || fired))
92 b = accuracy_byte(a.(accuracy_hit[w]), a.(accuracy_fired[w]));
94 a.(accuracy_hit[w]) += hit;
96 a.(accuracy_fired[w]) += fired;
97 if(b == accuracy_byte(a.(accuracy_hit[w]), a.(accuracy_fired[w])))
102 if(a.classname == "spectator")
107 float accuracy_isgooddamage(entity attacker, entity targ)
110 if(targ.flags & FL_CLIENT)
111 if(targ.deadflag == DEAD_NO)
112 if(IsDifferentTeam(attacker, targ))
117 float accuracy_canbegooddamage(entity attacker)