]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/accuracy.qh
Merge branch 'terencehill/weapon_model_fixes' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / accuracy.qh
index 03f002f6a9fd59d8576de2050ab60c0dc2aa96d0..d5d9f97d9fc469783ae5ff49bb799e02ff2f2941 100644 (file)
@@ -1,29 +1,49 @@
-#ifndef ACCURACY_H
-#define ACCURACY_H
-
-.float cvar_cl_accuracy_data_share;
-.float cvar_cl_accuracy_data_receive;
+#pragma once
+
+#include <common/weapons/_all.qh>
+#include <common/stats.qh>
+
+/**
+ * Weapon Accuracy stats
+ *
+ * These stats are sent to all the clients to be displayed on the scoreboard
+ * and also to Xonstats.
+ *
+ * Note that weapon damage is counted differently from player damage:
+ *  - it isn't limited by target's health in case you kill them
+ *  - it ignores handicap, shield, strength and similar powerups / buffs
+ *  - it doesn't count more than a single full hit if you hit multiple targets
+ *    with a single shot in order to never assign more than 100% accuracy per hit
+ *  - obviously damage caused by fall, lava, trigger_hurt and telefrags isn't
+ *    counted as weapon damage in any way
+ */
+
+float autocvar_sv_accuracy_data_share = 1;
+
+REPLICATE_INIT(bool, cvar_cl_accuracy_data_share);
+REPLICATE_INIT(bool, cvar_cl_accuracy_data_receive);
 
 .entity accuracy;
-.float accuracy_frags[WEP_MAXCOUNT];
+.float accuracy_frags[REGISTRY_MAX(Weapons)];
 
-.float accuracy_hit[WEP_MAXCOUNT];
-.float accuracy_fired[WEP_MAXCOUNT];
-.float accuracy_cnt_hit[WEP_MAXCOUNT];
-.float accuracy_cnt_fired[WEP_MAXCOUNT];
+.float accuracy_hit[REGISTRY_MAX(Weapons)];
+.float accuracy_fired[REGISTRY_MAX(Weapons)];
+.float accuracy_cnt_hit[REGISTRY_MAX(Weapons)];
+.float accuracy_cnt_fired[REGISTRY_MAX(Weapons)];
 
 
 // init/free
 void accuracy_init(entity e);
 void accuracy_free(entity e);
 
+void accuracy_reset(entity e);
+
 // force a resend of a player's accuracy stats
 void accuracy_resend(entity e);
 
 // update accuracy stats
-void accuracy_add(entity e, float w, float fired, float hit);
+void accuracy_add(entity e, Weapon w, float fired, float hit);
 
 // helper
-float accuracy_isgooddamage(entity attacker, entity targ);
-float accuracy_canbegooddamage(entity attacker);
-#endif
+bool accuracy_isgooddamage(entity attacker, entity targ);
+bool accuracy_canbegooddamage(entity attacker);