]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/buffs/all.qh
GlobalSound: fix `cl_forceplayermodels 1` using default voices when observing
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / buffs / all.qh
1 #ifndef BUFFS_ALL_H
2 #define BUFFS_ALL_H
3 // Welcome to the stuff behind the scenes
4 // Below, you will find the list of buffs
5 // Add new buffs here!
6 // Note: Buffs also need spawnfuncs, which are set below
7
8 #include "../teams.qh"
9 #include "../util.qh"
10
11 REGISTRY(Buffs, BITS(4))
12 #define Buffs_from(i) _Buffs_from(i, BUFF_Null)
13 REGISTER_REGISTRY(RegisterBuffs)
14 REGISTRY_CHECK(Buffs)
15
16 #define REGISTER_BUFF(id) \
17     REGISTER(RegisterBuffs, BUFF, Buffs, id, m_id, NEW(Buff)); \
18     REGISTER_INIT_POST(BUFF, id) { \
19         this.netname = this.m_name; \
20         this.m_itemid = BIT(this.m_id - 1); \
21         this.m_sprite = strzone(strcat("buff-", this.m_name)); \
22     } \
23     REGISTER_INIT(BUFF, id)
24
25 #include "../items/item/pickup.qh"
26 CLASS(Buff, Pickup)
27         /** bit index */
28         ATTRIB(Buff, m_itemid, int, 0)
29         ATTRIB(Buff, m_name, string, "buff")
30         ATTRIB(Buff, m_color, vector, '1 1 1')
31         ATTRIB(Buff, m_prettyName, string, "Buff")
32         ATTRIB(Buff, m_skin, int, 0)
33         ATTRIB(Buff, m_sprite, string, "")
34         METHOD(Buff, display, void(entity this, void(string name, string icon) returns)) {
35                 returns(this.m_prettyName, sprintf("/gfx/hud/%s/buff_%s", cvar_string("menu_skin"), this.m_name));
36         }
37 #ifdef SVQC
38         METHOD(Buff, m_time, float(entity));
39         float Buff_m_time(entity this) { return cvar(strcat("g_buffs_", this.netname, "_time")); }
40 #endif
41 ENDCLASS(Buff)
42
43 #ifdef SVQC
44         .int buffs;
45         void buff_Init(entity ent);
46         void buff_Init_Compat(entity ent, entity replacement);
47         #define BUFF_SPAWNFUNC(e, b, t) spawnfunc(item_buff_##e) { \
48                 self.buffs = b.m_itemid; \
49                 self.team = t; \
50                 buff_Init(self); \
51         }
52         #define BUFF_SPAWNFUNCS(e, b)                       \
53                         BUFF_SPAWNFUNC(e,           b,  0)          \
54                         BUFF_SPAWNFUNC(e##_team1,   b,  NUM_TEAM_1) \
55                         BUFF_SPAWNFUNC(e##_team2,   b,  NUM_TEAM_2) \
56                         BUFF_SPAWNFUNC(e##_team3,   b,  NUM_TEAM_3) \
57                         BUFF_SPAWNFUNC(e##_team4,   b,  NUM_TEAM_4)
58         #define BUFF_SPAWNFUNC_Q3TA_COMPAT(o, r) spawnfunc(item_##o) { buff_Init_Compat(self, r); }
59 #else
60         #define BUFF_SPAWNFUNC(e, b, t)
61         #define BUFF_SPAWNFUNCS(e, b)
62         #define BUFF_SPAWNFUNC_Q3TA_COMPAT(o, r)
63 #endif
64
65 REGISTER_BUFF(Null);
66 BUFF_SPAWNFUNCS(random, BUFF_Null)
67
68 #include "all.inc"
69
70 #endif