]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/weapons/accuracy.qh
Merge branch 'master' into LegendaryGuard/cyber
[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 .entity roundaccuracy;
30 .float accuracy_frags[REGISTRY_MAX(Weapons)];
31
32 .float accuracy_hit[REGISTRY_MAX(Weapons)];
33 .float accuracy_fired[REGISTRY_MAX(Weapons)];
34 .float accuracy_cnt_hit[REGISTRY_MAX(Weapons)];
35 .float accuracy_cnt_fired[REGISTRY_MAX(Weapons)];
36
37
38 // init/free
39 void accuracy_init(entity e);
40 void accuracy_free(entity e);
41
42 void accuracy_reset(entity e);
43
44 // force a resend of a player's accuracy stats
45 void accuracy_resend(entity e);
46
47 // update accuracy stats
48 void accuracy_add(entity e, Weapon w, float fired, float hit);
49 void roundaccuracy_clear(entity this);
50
51 // helper
52 bool accuracy_isgooddamage(entity attacker, entity targ);
53 bool accuracy_canbegooddamage(entity attacker);