]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/weapons/accuracy.qh
Transifex autosync
[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 REPLICATE_INIT(bool, cvar_cl_accuracy_data_share);
24 REPLICATE_INIT(bool, cvar_cl_accuracy_data_receive);
25
26 .entity accuracy;
27 .float accuracy_frags[REGISTRY_MAX(Weapons)];
28
29 .float accuracy_hit[REGISTRY_MAX(Weapons)];
30 .float accuracy_fired[REGISTRY_MAX(Weapons)];
31 .float accuracy_cnt_hit[REGISTRY_MAX(Weapons)];
32 .float accuracy_cnt_fired[REGISTRY_MAX(Weapons)];
33
34
35 // init/free
36 void accuracy_init(entity e);
37 void accuracy_free(entity e);
38
39 void accuracy_reset(entity e);
40
41 // force a resend of a player's accuracy stats
42 void accuracy_resend(entity e);
43
44 // update accuracy stats
45 void accuracy_add(entity e, Weapon w, float fired, float hit);
46
47 // helper
48 bool accuracy_isgooddamage(entity attacker, entity targ);
49 bool accuracy_canbegooddamage(entity attacker);