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