]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/accuracy.qc
mutator_invincibleproj.qc: Add a mutator (like g_rocketflying) which allows projectil...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / accuracy.qc
index bc638d61464b96a91575ce9d2b515ae63ffd2aac..de6b52752b95b358503e9fdd1a846377bd4f6bc6 100644 (file)
@@ -1,12 +1,7 @@
-.entity accuracy;
 .float accuracy_hit[WEP_MAXCOUNT];
 .float accuracy_fired[WEP_MAXCOUNT];
 .float accuracy_cnt_hit[WEP_MAXCOUNT];
 .float accuracy_cnt_fired[WEP_MAXCOUNT];
-FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(accuracy_hit);
-FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(accuracy_fired);
-FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(accuracy_cnt_hit);
-FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(accuracy_cnt_fired);
 
 float accuracy_byte(float n, float d)
 {
@@ -81,7 +76,7 @@ void accuracy_set(entity e, float w, float fired, float hit)
 
     if(hit)
         a.(accuracy_cnt_hit[w]) = 1;
-       a.(accuracy_cnt_fired[w]) = 1;
+    a.(accuracy_cnt_fired[w]) = 1;
 
        if(b == accuracy_byte(hit, fired))
                return;
@@ -93,6 +88,9 @@ void accuracy_set(entity e, float w, float fired, float hit)
                                a.SendFlags |= w;
 }
 
+.float hit_time;
+.float fired_time;
+
 void accuracy_add(entity e, float w, float fired, float hit)
 {
        entity a;
@@ -107,9 +105,17 @@ void accuracy_add(entity e, float w, float fired, float hit)
        if(fired)
                a.(accuracy_fired[w]) += fired;
 
-    if(hit)
+    if(hit && a.hit_time != time) // only run this once per frame
+    {
         a.(accuracy_cnt_hit[w]) += 1;
-       a.(accuracy_cnt_fired[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;