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/spawning.qh>
15 const int IT_UNLIMITED_AMMO = BIT(0); // when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup.
16 const int IT_UNLIMITED_SUPERWEAPONS = BIT(1); // when this bit is set, superweapons don't expire. Checkpoints can give this powerup.
18 const int IT_JETPACK = BIT(2); // actual item
19 const int IT_USING_JETPACK = BIT(3); // confirmation that button is pressed
20 const int IT_FUEL_REGEN = BIT(4); // fuel regeneration trigger
22 const int IT_RESOURCE = BIT(5); // bitflag to mark this item as a resource (unused)
24 const int IT_KEY1 = BIT(6);
25 const int IT_KEY2 = BIT(7);
27 const int IT_BUFF = BIT(8); // unused bit for buff items
29 // special colorblend meaning in engine
30 // legacy bitflags for powerups
31 const int IT_INVISIBILITY = BIT(9);
32 const int IT_INVINCIBLE = BIT(10);
33 const int IT_SUPERWEAPON = BIT(11); // suit
34 const int IT_STRENGTH = BIT(12);
35 const int IT_SPEED = BIT(13);
38 const int IT_PICKUPMASK = IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS | IT_JETPACK | IT_FUEL_REGEN; // strength and invincible are handled separately
41 const int ISF_SIZE2 = BIT(0);
42 const int ISF_LOCATION = BIT(1);
43 const int ISF_MODEL = BIT(2);
44 const int ISF_STATUS = BIT(3);
45 const int ISF_COLORMAP = BIT(4);
46 const int ISF_DROP = BIT(5);
47 const int ISF_ANGLES = BIT(6);
48 const int ISF_SIZE = BIT(7);
50 REGISTER_NET_LINKED(ENT_CLIENT_ITEM)
54 const int ITS_STAYWEP = BIT(0);
55 const int ITS_ANIMATE1 = BIT(1);
56 const int ITS_ANIMATE2 = BIT(2);
57 const int ITS_AVAILABLE = BIT(3);
58 const int ITS_ALLOWFB = BIT(4);
59 const int ITS_ALLOWSI = BIT(5);
60 const int ITS_GLOW = BIT(6);
62 // item bboxes for sv_legacy_bbox_expand 0
63 // Small, Default and Large (large maxs are used with default mins)
64 const vector ITEM_S_MINS = '-16 -16 0'; // smaller items now get the same "unexpanded" bbox that normal items
65 const vector ITEM_S_MAXS = '16 16 48'; // had during MoveOutOfSolid and DropToFloor (before expansion) in 0.8.5
66 const vector ITEM_D_MINS = '-30 -30 0'; // 0.8.5 set '-16 -16 0' then DP subtracted '15 15 1' but NetRadiant used '-30 -30 0'
67 const vector ITEM_D_MAXS = '30 30 48'; // 0.8.5 set '16 16 48' then DP added '15 15 1' but NetRadiant used '30 30 32'
68 const vector ITEM_L_MAXS = '30 30 70'; // 0.8.5 set '16 16 80' for powerups, '16 16 70' for megas, '16 16 60' for buffs
77 .float strength_finished; // NOTE: this field is used only by map entities, it does not directly apply the strength stat
78 .float invincible_finished; // ditto
79 .float buffs_finished; // ditts
81 #define SPAWNFUNC_BODY(item) \
82 if (item && Item_IsDefinitionAllowed(item)) \
83 StartItem(this, item); \
86 startitem_failed = true; \
90 #define SPAWNFUNC_ITEM(name, item) \
93 SPAWNFUNC_BODY(item) \
96 #define SPAWNFUNC_ITEM_COND(name, cond, item1, item2) \
97 SPAWNFUNC_ITEM(name, (cond ? item1 : item2))
101 #define SPAWNFUNC_ITEM(name, item)
107 ITEM_FLAG_NORMAL = BIT(0), ///< Item is usable during normal gameplay.
108 ITEM_FLAG_MUTATORBLOCKED = BIT(1),
109 ITEM_FLAG_RESOURCE = BIT(2) ///< Item is is a resource, not a held item.
112 #define ITEM_HANDLE(signal, ...) __Item_Send_##signal(__VA_ARGS__)
113 CLASS(GameItem, Object)
114 ATTRIB(GameItem, m_id, int, 0);
115 /** the canonical spawnfunc name */
116 ATTRIB(GameItem, m_canonical_spawnfunc, string);
117 METHOD(GameItem, m_spawnfunc_hookreplace, GameItem(GameItem this, entity e)) { return this; }
118 ATTRIB(GameItem, m_name, string);
119 ATTRIB(GameItem, m_icon, string);
120 ATTRIB(GameItem, m_color, vector, '1 1 1');
121 ATTRIB(GameItem, m_waypoint, string);
122 ATTRIB(GameItem, m_waypointblink, int, 1);
124 ATTRIB(GameItem, m_glow, bool, false);
125 ATTRIB(GameItem, m_respawnsound, Sound, SND_ITEMRESPAWN);
127 METHOD(GameItem, display, void(GameItem this, void(string name, string icon) returns))
130 returns(this.m_name, this.m_icon ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon) : string_null);
132 METHOD(GameItem, show, void(GameItem this))
135 LOG_INFO("A game item");
137 void ITEM_HANDLE(Show, GameItem this) { this.show(this); }