]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/buffs/buffs.qh
Cleanup common mutators: remove IMPLEMENTATION macro
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / buffs / buffs.qh
1 #pragma once
2
3 #include <common/teams.qh>
4 #include <common/util.qh>
5
6 REGISTER_WAYPOINT(Buff, _("Buff"), '1 0.5 0', 1);
7 REGISTER_RADARICON(Buff, 1);
8
9 REGISTRY(Buffs, BITS(5))
10 #define Buffs_from(i) _Buffs_from(i, BUFF_Null)
11 REGISTER_REGISTRY(Buffs)
12 REGISTRY_CHECK(Buffs)
13
14 #define REGISTER_BUFF(id) \
15     REGISTER(Buffs, BUFF_##id, m_id, NEW(Buff))
16
17 #include <common/items/item/pickup.qh>
18 CLASS(Buff, Pickup)
19         /** bit index */
20         ATTRIB(Buff, m_itemid, int, 0);
21         ATTRIB(Buff, m_name, string, "buff");
22         ATTRIB(Buff, m_color, vector, '1 1 1');
23         ATTRIB(Buff, m_prettyName, string, "Buff");
24         ATTRIB(Buff, m_skin, int, 0);
25         ATTRIB(Buff, m_sprite, string, "");
26         METHOD(Buff, display, void(entity this, void(string name, string icon) returns)) {
27                 returns(this.m_prettyName, sprintf("/gfx/hud/%s/buff_%s", cvar_string("menu_skin"), this.m_name));
28         }
29 #ifdef SVQC
30         METHOD(Buff, m_time, float(Buff this))
31         { return cvar(strcat("g_buffs_", this.netname, "_time")); }
32 #endif
33 ENDCLASS(Buff)
34
35 STATIC_INIT(REGISTER_BUFFS) {
36     FOREACH(Buffs, true, {
37         it.netname = it.m_name; \
38         it.m_itemid = BIT(it.m_id - 1); \
39         it.m_sprite = strzone(strcat("buff-", it.m_name)); \
40     });
41 }
42
43 #ifdef SVQC
44         // .int buffs = _STAT(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                 this.buffs = b.m_itemid; \
49                 this.team = t; \
50                 buff_Init(this); \
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(this, 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"