]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/items/item.qh
Merge branch 'master' into Mario/csqc_muzzleflash
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items / item.qh
1 #pragma once
2
3 #ifdef GAMEQC
4 #include <common/models/all.qh>
5 #include <common/sounds/all.qh>
6 #include <common/sounds/all.inc>
7 #include <common/stats.qh>
8 #endif
9
10 #ifdef SVQC
11 #include <server/items.qh>
12 #endif
13
14 const int IT_UNLIMITED_AMMO                     =  BIT(0); // when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup.
15 const int IT_UNLIMITED_SUPERWEAPONS             =  BIT(1); // when this bit is set, superweapons don't expire. Checkpoints can give this powerup.
16
17 const int IT_JETPACK                            =  BIT(2); // actual item
18 const int IT_USING_JETPACK                      =  BIT(3); // confirmation that button is pressed
19 const int IT_FUEL_REGEN                         =  BIT(4); // fuel regeneration trigger
20
21 const int IT_RESOURCE                           =  BIT(5); // bitflag to mark this item as a resource (unused)
22
23 const int IT_KEY1                                               = BIT(6);
24 const int IT_KEY2                                               = BIT(7);
25
26 const int IT_CTF_SHIELDED                       = BIT(8); // set for the flag shield
27
28 // special colorblend meaning in engine
29 const int IT_INVISIBILITY                               = BIT(9);
30 const int IT_INVINCIBLE                                 = BIT(10);
31 const int IT_SUPERWEAPON                                = BIT(11); // suit
32 const int IT_STRENGTH                                   = BIT(12);
33
34 // item masks
35 const int IT_PICKUPMASK                 = IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS | IT_JETPACK | IT_FUEL_REGEN; // strength and invincible are handled separately
36
37 #ifdef SVQC
38 .float strength_finished; // NOTE: this field is used only by map entities, it does not directly apply the strength stat
39 .float invincible_finished; // ditto
40
41 #define spawnfunc_body(item) \
42         if (!Item_IsDefinitionAllowed(item)) \
43         { \
44                 startitem_failed = true; \
45                 delete(this); \
46                 return; \
47         } \
48         StartItem(this, item)
49
50 #define SPAWNFUNC_ITEM(name, item) \
51         spawnfunc(name) \
52         { \
53                 spawnfunc_body(item); \
54         }
55
56 #define SPAWNFUNC_ITEM_COND(name, cond, item1, item2) \
57         spawnfunc(name) \
58         { \
59                 entity item = (cond) ? item1 : item2; \
60                 spawnfunc_body(item); \
61         }
62
63 #else
64
65 #define SPAWNFUNC_ITEM(name, item)
66
67 #endif
68
69 enum
70 {
71         ITEM_FLAG_NORMAL = BIT(0), ///< Item is usable during normal gameplay.
72         ITEM_FLAG_MUTATORBLOCKED = BIT(1),
73         ITEM_FLAG_RESOURCE = BIT(2) ///< Item is is a resource, not a held item.
74 };
75
76 #define ITEM_HANDLE(signal, ...) __Item_Send_##signal(__VA_ARGS__)
77 CLASS(GameItem, Object)
78     ATTRIB(GameItem, m_id, int, 0);
79     /** the canonical spawnfunc name */
80     ATTRIB(GameItem, m_canonical_spawnfunc, string);
81     METHOD(GameItem, m_spawnfunc_hookreplace, GameItem(GameItem this, entity e)) { return this; }
82     ATTRIB(GameItem, m_name, string);
83     ATTRIB(GameItem, m_icon, string);
84     ATTRIB(GameItem, m_color, vector, '1 1 1');
85     ATTRIB(GameItem, m_waypoint, string);
86     ATTRIB(GameItem, m_waypointblink, int, 1);
87 #ifdef GAMEQC
88     ATTRIB(GameItem, m_glow, bool, false);
89     ATTRIB(GameItem, m_respawnsound, Sound, SND_ITEMRESPAWN);
90 #endif
91     METHOD(GameItem, display, void(GameItem this, void(string name, string icon) returns))
92     {
93         TC(GameItem, this);
94         returns(this.m_name, this.m_icon ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon) : string_null);
95     }
96     METHOD(GameItem, show, void(GameItem this))
97     {
98         TC(GameItem, this);
99         LOG_INFO("A game item");
100     }
101     void ITEM_HANDLE(Show, GameItem this) { this.show(this); }
102 ENDCLASS(GameItem)