]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/buffs/all.qh
Merge branch 'terencehill/fuelregen_powerup' into 'master'
[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     REGISTER_INIT_POST(BUFF_##id) { \
18         this.netname = this.m_name; \
19         this.m_itemid = BIT(this.m_id - 1); \
20         this.m_sprite = strzone(strcat("buff-", this.m_name)); \
21     } \
22     REGISTER_INIT(BUFF_##id)
23
24 #include <common/items/item/pickup.qh>
25 CLASS(Buff, Pickup)
26         /** bit index */
27         ATTRIB(Buff, m_itemid, int, 0)
28         ATTRIB(Buff, m_name, string, "buff")
29         ATTRIB(Buff, m_color, vector, '1 1 1')
30         ATTRIB(Buff, m_prettyName, string, "Buff")
31         ATTRIB(Buff, m_skin, int, 0)
32         ATTRIB(Buff, m_sprite, string, "")
33         METHOD(Buff, display, void(entity this, void(string name, string icon) returns)) {
34                 returns(this.m_prettyName, sprintf("/gfx/hud/%s/buff_%s", cvar_string("menu_skin"), this.m_name));
35         }
36 #ifdef SVQC
37         METHOD(Buff, m_time, float(Buff this))
38         { return cvar(strcat("g_buffs_", this.netname, "_time")); }
39 #endif
40 ENDCLASS(Buff)
41
42 #ifdef SVQC
43         // .int buffs = _STAT(BUFFS);
44         void buff_Init(entity ent);
45         void buff_Init_Compat(entity ent, entity replacement);
46         #define BUFF_SPAWNFUNC(e, b, t) spawnfunc(item_buff_##e) { \
47                 self.buffs = b.m_itemid; \
48                 self.team = t; \
49                 buff_Init(self); \
50         }
51         #define BUFF_SPAWNFUNCS(e, b)                       \
52                         BUFF_SPAWNFUNC(e,           b,  0)          \
53                         BUFF_SPAWNFUNC(e##_team1,   b,  NUM_TEAM_1) \
54                         BUFF_SPAWNFUNC(e##_team2,   b,  NUM_TEAM_2) \
55                         BUFF_SPAWNFUNC(e##_team3,   b,  NUM_TEAM_3) \
56                         BUFF_SPAWNFUNC(e##_team4,   b,  NUM_TEAM_4)
57         #define BUFF_SPAWNFUNC_Q3TA_COMPAT(o, r) spawnfunc(item_##o) { buff_Init_Compat(self, r); }
58 #else
59         #define BUFF_SPAWNFUNC(e, b, t)
60         #define BUFF_SPAWNFUNCS(e, b)
61         #define BUFF_SPAWNFUNC_Q3TA_COMPAT(o, r)
62 #endif
63
64 REGISTER_BUFF(Null);
65 BUFF_SPAWNFUNCS(random, BUFF_Null)
66
67 #include "all.inc"
68
69 #endif