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