Models: rename registry globals
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / buffs.qh
1 #ifndef BUFFS_H
2 #define BUFFS_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 void RegisterBuffs();
12 const int BUFFS_MAX = 16;
13 entity BUFFS[BUFFS_MAX], BUFFS_first, BUFFS_last;
14 int BUFFS_COUNT;
15 #define REGISTER_BUFF(id) \
16     REGISTER(RegisterBuffs, BUFF, BUFFS, BUFFS_COUNT, 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 REGISTER_REGISTRY(RegisterBuffs)
24
25 #include "items/item/pickup.qh"
26 CLASS(Buff, Pickup)
27         /** bit index */
28         ATTRIB(Buff, m_itemid, int, 0)
29         ATTRIB(Buff, m_name, string, "buff")
30         ATTRIB(Buff, m_color, vector, '1 1 1')
31         ATTRIB(Buff, m_prettyName, string, "Buff")
32         ATTRIB(Buff, m_skin, int, 0)
33         ATTRIB(Buff, m_sprite, string, "")
34         METHOD(Buff, display, void(entity this, void(string name, string icon) returns)) {
35                 returns(this.m_prettyName, sprintf("/gfx/hud/%s/buff_%s", cvar_string("menu_skin"), this.m_name));
36         }
37 #ifdef SVQC
38         METHOD(Buff, m_time, float(entity));
39         float Buff_m_time(entity this) { return cvar(strcat("g_buffs_", this.netname, "_time")); }
40 #endif
41 ENDCLASS(Buff)
42
43 REGISTER_BUFF(Null);
44
45 REGISTER_BUFF(AMMO) {
46         this.m_prettyName = _("Ammo");
47         this.m_name = "ammo";
48         this.m_skin = 3;
49         this.m_color = '0.76 1 0.1';
50 }
51
52 REGISTER_BUFF(RESISTANCE) {
53         this.m_prettyName = _("Resistance");
54         this.m_name = "resistance";
55         this.m_skin = 0;
56         this.m_color = '0.36 1 0.07';
57 }
58
59 REGISTER_BUFF(SPEED) {
60         this.m_prettyName = _("Speed");
61         this.m_name = "speed";
62         this.m_skin = 9;
63         this.m_color = '0.1 1 0.84';
64 }
65
66 REGISTER_BUFF(MEDIC) {
67         this.m_prettyName = _("Medic");
68         this.m_name = "medic";
69         this.m_skin = 1;
70         this.m_color = '1 0.12 0';
71 }
72
73 REGISTER_BUFF(BASH) {
74         this.m_prettyName = _("Bash");
75         this.m_name = "bash";
76         this.m_skin = 5;
77         this.m_color = '1 0.39 0';
78 }
79
80 REGISTER_BUFF(VAMPIRE) {
81         this.m_prettyName = _("Vampire");
82         this.m_name = "vampire";
83         this.m_skin = 2;
84         this.m_color = '1 0 0.24';
85 }
86
87 REGISTER_BUFF(DISABILITY) {
88         this.m_prettyName = _("Disability");
89         this.m_name = "disability";
90         this.m_skin = 7;
91         this.m_color = '0.94 0.3 1';
92 }
93
94 REGISTER_BUFF(VENGEANCE) {
95         this.m_prettyName = _("Vengeance");
96         this.m_name = "vengeance";
97         this.m_skin = 15;
98         this.m_color = '1 0.23 0.61';
99 }
100
101 REGISTER_BUFF(JUMP) {
102         this.m_prettyName = _("Jump");
103         this.m_name = "jump";
104         this.m_skin = 10;
105         this.m_color = '0.24 0.78 1';
106 }
107
108 REGISTER_BUFF(FLIGHT) {
109         this.m_prettyName = _("Flight");
110         this.m_name = "flight";
111         this.m_skin = 11;
112         this.m_color = '0.33 0.56 1';
113 }
114
115 REGISTER_BUFF(INVISIBLE) {
116         this.m_prettyName = _("Invisible");
117         this.m_name = "invisible";
118         this.m_skin = 12;
119         this.m_color = '0.5 0.5 1';
120 }
121
122 REGISTER_BUFF(INFERNO) {
123         this.m_prettyName = _("Inferno");
124         this.m_name = "inferno";
125         this.m_skin = 16;
126         this.m_color = '1 0.62 0';
127 }
128
129 REGISTER_BUFF(SWAPPER) {
130         this.m_prettyName = _("Swapper");
131         this.m_name = "swapper";
132         this.m_skin = 17;
133         this.m_color = '0.63 0.36 1';
134 }
135
136 REGISTER_BUFF(MAGNET) {
137         this.m_prettyName = _("Magnet");
138         this.m_name = "magnet";
139         this.m_skin = 18;
140         this.m_color = '1 0.95 0.18';
141 }
142
143 #ifdef SVQC
144 .int buffs;
145 void buff_Init(entity ent);
146 void buff_Init_Compat(entity ent, entity replacement);
147
148 #define BUFF_SPAWNFUNC(e, b, t) spawnfunc(item_buff_##e) { \
149         self.buffs = b.m_itemid; \
150         self.team = t; \
151         buff_Init(self); \
152 }
153 #define BUFF_SPAWNFUNCS(e, b)                       \
154                 BUFF_SPAWNFUNC(e,           b,  0)          \
155                 BUFF_SPAWNFUNC(e##_team1,   b,  NUM_TEAM_1) \
156                 BUFF_SPAWNFUNC(e##_team2,   b,  NUM_TEAM_2) \
157                 BUFF_SPAWNFUNC(e##_team3,   b,  NUM_TEAM_3) \
158                 BUFF_SPAWNFUNC(e##_team4,   b,  NUM_TEAM_4)
159 #define BUFF_SPAWNFUNC_Q3TA_COMPAT(o, r) spawnfunc(item_##o) { buff_Init_Compat(self, r); }
160
161 BUFF_SPAWNFUNCS(resistance,             BUFF_RESISTANCE)
162 BUFF_SPAWNFUNCS(ammo,                   BUFF_AMMO)
163 BUFF_SPAWNFUNCS(speed,                  BUFF_SPEED)
164 BUFF_SPAWNFUNCS(medic,                  BUFF_MEDIC)
165 BUFF_SPAWNFUNCS(bash,                   BUFF_BASH)
166 BUFF_SPAWNFUNCS(vampire,                BUFF_VAMPIRE)
167 BUFF_SPAWNFUNCS(disability,             BUFF_DISABILITY)
168 BUFF_SPAWNFUNCS(vengeance,              BUFF_VENGEANCE)
169 BUFF_SPAWNFUNCS(jump,                   BUFF_JUMP)
170 BUFF_SPAWNFUNCS(flight,                 BUFF_FLIGHT)
171 BUFF_SPAWNFUNCS(invisible,              BUFF_INVISIBLE)
172 BUFF_SPAWNFUNCS(inferno,                BUFF_INFERNO)
173 BUFF_SPAWNFUNCS(swapper,                BUFF_SWAPPER)
174 BUFF_SPAWNFUNCS(magnet,                 BUFF_MAGNET)
175 BUFF_SPAWNFUNCS(random,                 BUFF_Null)
176
177 BUFF_SPAWNFUNC_Q3TA_COMPAT(doubler,    BUFF_MEDIC)
178 BUFF_SPAWNFUNC_Q3TA_COMPAT(resistance, BUFF_RESISTANCE)
179 BUFF_SPAWNFUNC_Q3TA_COMPAT(scout,      BUFF_SPEED)
180 BUFF_SPAWNFUNC_Q3TA_COMPAT(ammoregen,  BUFF_AMMO)
181
182 // actually Q3
183 BUFF_SPAWNFUNC_Q3TA_COMPAT(haste,       BUFF_SPEED)
184 BUFF_SPAWNFUNC_Q3TA_COMPAT(invis,       BUFF_INVISIBLE)
185 BUFF_SPAWNFUNC_Q3TA_COMPAT(medic,       BUFF_MEDIC)
186
187 #undef BUFF_SPAWNFUNC
188 #undef BUFF_SPAWNFUNC_Q3TA_COMPAT
189 #undef BUFF_SPAWNFUNCS
190 #endif
191
192 #endif