4 #include <common/models/all.qh>
5 #include <common/sounds/all.qh>
6 #include <common/sounds/all.inc>
7 #include <common/stats.qh>
11 #include <server/items.qh>
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.
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
21 const int IT_RESOURCE = BIT(5); // bitflag to mark this item as a resource (unused)
23 const int IT_KEY1 = BIT(6);
24 const int IT_KEY2 = BIT(7);
26 const int IT_CTF_SHIELDED = BIT(8); // set for the flag shield
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);
35 const int IT_PICKUPMASK = IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS | IT_JETPACK | IT_FUEL_REGEN; // strength and invincible are handled separately
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
41 #define spawnfunc_body(item) \
42 if (!Item_IsDefinitionAllowed(item)) \
44 startitem_failed = true; \
50 #define SPAWNFUNC_ITEM(name, item) \
53 spawnfunc_body(item); \
56 #define SPAWNFUNC_ITEM_COND(name, cond, item1, item2) \
59 entity item = (cond) ? item1 : item2; \
60 spawnfunc_body(item); \
65 #define SPAWNFUNC_ITEM(name, item)
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.
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);
88 ATTRIB(GameItem, m_glow, bool, false);
89 ATTRIB(GameItem, m_respawnsound, Sound, SND_ITEMRESPAWN);
91 METHOD(GameItem, display, void(GameItem this, void(string name, string icon) returns))
94 returns(this.m_name, this.m_icon ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon) : string_null);
96 METHOD(GameItem, show, void(GameItem this))
99 LOG_INFO("A game item");
101 void ITEM_HANDLE(Show, GameItem this) { this.show(this); }