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)
9 //print(sprintf("accuracy: %d / %d\n", n, d));
14 return 1 + rint(n * 100.0 / d);
17 float accuracy_send(entity to, float sf)
21 WriteByte(MSG_ENTITY, ENT_CLIENT_ACCURACY);
24 if(a.classname == "spectator")
29 if not(self.owner.cvar_cl_accuracy_data_share && autocvar_sv_accuracy_data_share)
31 // note: zero sendflags can never be sent... so we can use that to say that we send no accuracy!
32 WriteInt24_t(MSG_ENTITY, sf);
35 // note: we know that client and server agree about SendFlags...
36 for(w = 0, f = 1; w <= WEP_LAST - WEP_FIRST; ++w, f *= 2)
39 WriteByte(MSG_ENTITY, accuracy_byte(self.(accuracy_hit[w]), self.(accuracy_fired[w])));
45 void accuracy_init(entity e)
49 e.accuracy.classname = "accuracy";
50 e.accuracy.drawonlytoclient = e;
51 Net_LinkEntity(e.accuracy, FALSE, 0, accuracy_send);
54 void accuracy_free(entity e)
59 // force a resend of a player's accuracy stats
60 void accuracy_resend(entity e)
62 e.accuracy.SendFlags = 0xFFFFFF;
65 // update accuracy stats
66 void accuracy_set(entity e, float w, float fired, float hit)
74 b = accuracy_byte(a.(accuracy_hit[w]), a.(accuracy_fired[w]));
75 a.(accuracy_hit[w]) = hit;
76 a.(accuracy_fired[w]) = fired;
77 if(b == accuracy_byte(hit, fired))
82 if(a.classname == "spectator")
87 void accuracy_add(entity e, float w, float fired, float hit)
92 if(!a || !(hit || fired))
95 b = accuracy_byte(a.(accuracy_hit[w]), a.(accuracy_fired[w]));
97 a.(accuracy_hit[w]) += hit;
99 a.(accuracy_fired[w]) += fired;
100 if(b == accuracy_byte(a.(accuracy_hit[w]), a.(accuracy_fired[w])))
105 if(a.classname == "spectator")
110 float accuracy_isgooddamage(entity attacker, entity targ)
113 if(targ.flags & FL_CLIENT)
114 if(targ.deadflag == DEAD_NO)
115 if(IsDifferentTeam(attacker, targ))
120 float accuracy_canbegooddamage(entity attacker)