]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/buffs/all.qh
Merge branch 'master' into Mario/hagar_notfixed
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / buffs / all.qh
1 #ifndef BUFFS_ALL_H
2 #define BUFFS_ALL_H
3
4 #include <common/teams.qh>
5 #include <common/util.qh>
6
7 REGISTER_WAYPOINT(Buff, _("Buff"), '1 0.5 0', 1);
8 REGISTER_RADARICON(Buff, 1);
9
10 REGISTRY(Buffs, BITS(5))
11 #define Buffs_from(i) _Buffs_from(i, BUFF_Null)
12 REGISTER_REGISTRY(Buffs)
13 REGISTRY_CHECK(Buffs)
14
15 #define REGISTER_BUFF(id) \
16     REGISTER(Buffs, BUFF_##id, m_id, NEW(Buff))
17
18 #include <common/items/item/pickup.qh>
19 CLASS(Buff, Pickup)
20         /** bit index */
21         ATTRIB(Buff, m_itemid, int, 0)
22         ATTRIB(Buff, m_name, string, "buff")
23         ATTRIB(Buff, m_color, vector, '1 1 1')
24         ATTRIB(Buff, m_prettyName, string, "Buff")
25         ATTRIB(Buff, m_skin, int, 0)
26         ATTRIB(Buff, m_sprite, string, "")
27         METHOD(Buff, display, void(entity this, void(string name, string icon) returns)) {
28                 returns(this.m_prettyName, sprintf("/gfx/hud/%s/buff_%s", cvar_string("menu_skin"), this.m_name));
29         }
30 #ifdef SVQC
31         METHOD(Buff, m_time, float(Buff this))
32         { return cvar(strcat("g_buffs_", this.netname, "_time")); }
33 #endif
34 ENDCLASS(Buff)
35
36 STATIC_INIT(REGISTER_BUFFS) {
37     FOREACH(Buffs, true, {
38         it.netname = it.m_name; \
39         it.m_itemid = BIT(it.m_id - 1); \
40         it.m_sprite = strzone(strcat("buff-", it.m_name)); \
41     });
42 }
43
44 #ifdef SVQC
45         // .int buffs = _STAT(BUFFS);
46         void buff_Init(entity ent);
47         void buff_Init_Compat(entity ent, entity replacement);
48         #define BUFF_SPAWNFUNC(e, b, t) spawnfunc(item_buff_##e) { \
49                 self.buffs = b.m_itemid; \
50                 self.team = t; \
51                 buff_Init(self); \
52         }
53         #define BUFF_SPAWNFUNCS(e, b)                       \
54                         BUFF_SPAWNFUNC(e,           b,  0)          \
55                         BUFF_SPAWNFUNC(e##_team1,   b,  NUM_TEAM_1) \
56                         BUFF_SPAWNFUNC(e##_team2,   b,  NUM_TEAM_2) \
57                         BUFF_SPAWNFUNC(e##_team3,   b,  NUM_TEAM_3) \
58                         BUFF_SPAWNFUNC(e##_team4,   b,  NUM_TEAM_4)
59         #define BUFF_SPAWNFUNC_Q3TA_COMPAT(o, r) spawnfunc(item_##o) { buff_Init_Compat(self, r); }
60 #else
61         #define BUFF_SPAWNFUNC(e, b, t)
62         #define BUFF_SPAWNFUNCS(e, b)
63         #define BUFF_SPAWNFUNC_Q3TA_COMPAT(o, r)
64 #endif
65
66 REGISTER_BUFF(Null);
67 BUFF_SPAWNFUNCS(random, BUFF_Null)
68
69 #include "all.inc"
70
71 #endif