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