]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/weapons/accuracy.qh
81d2b1763bfe4c8e9f82b408cf61be22c60ee314
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / accuracy.qh
1 #pragma once
2
3 #include <common/weapons/_all.qh>
4 #include <common/stats.qh>
5
6 /**
7  * Weapon Accuracy stats
8  *
9  * These stats are sent to all the clients to be displayed on the scoreboard
10  * and also to Xonstats.
11  *
12  * Note that weapon damage is counted differently from player damage:
13  *  - it isn't limited by target's health in case you kill them
14  *  - it ignores handicap, shield, strength and similar powerups / buffs
15  *  - it doesn't count more than a single full hit if you hit multiple targets
16  *    with a single shot in order to never assign more than 100% accuracy per hit
17  *  - obviously damage caused by fall, lava, trigger_hurt and telefrags isn't
18  *    counted as weapon damage in any way
19  */
20
21 float autocvar_sv_accuracy_data_share = 1;
22
23 .bool cvar_cl_accuracy_data_share;
24 REPLICATE(cvar_cl_accuracy_data_share, bool, "cl_accuracy_data_share");
25 .bool cvar_cl_accuracy_data_receive;
26 REPLICATE(cvar_cl_accuracy_data_receive, bool, "cl_accuracy_data_receive");
27
28 .entity accuracy;
29 .float accuracy_frags[REGISTRY_MAX(Weapons)];
30
31 .float accuracy_hit[REGISTRY_MAX(Weapons)];
32 .float accuracy_fired[REGISTRY_MAX(Weapons)];
33 .float accuracy_cnt_hit[REGISTRY_MAX(Weapons)];
34 .float accuracy_cnt_fired[REGISTRY_MAX(Weapons)];
35
36
37 // init/free
38 void accuracy_init(entity e);
39 void accuracy_free(entity e);
40
41 void accuracy_reset(entity e);
42
43 // force a resend of a player's accuracy stats
44 void accuracy_resend(entity e);
45
46 // update accuracy stats
47 void accuracy_add(entity e, Weapon w, float fired, float hit);
48
49 // helper
50 bool accuracy_isgooddamage(entity attacker, entity targ);
51 bool accuracy_canbegooddamage(entity attacker);