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