]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/items/item.qh
Update default video settings
[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/spawning.qh>
12 #endif
13
14 #ifdef GAMEQC
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.
17
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
21
22 const int IT_RESOURCE                           =  BIT(5); // bitflag to mark this item as a resource (unused)
23
24 const int IT_KEY1                                               = BIT(6);
25 const int IT_KEY2                                               = BIT(7);
26
27 const int IT_BUFF                                               = BIT(8); // unused bit for buff items
28
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);
36
37 // item masks
38 const int IT_PICKUPMASK                 = IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS | IT_JETPACK | IT_FUEL_REGEN; // strength and invincible are handled separately
39
40 // item networking
41 const int ISF_REMOVEFX          = BIT(0); // technically unnecessary (after the kludge in Item_Think() is reverted), but cheaper and cleaner than using ITS_AVAILABLE
42 const int ISF_LOCATION          = BIT(1);
43 const int ISF_SIZE2             = 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);
49
50 REGISTER_NET_LINKED(ENT_CLIENT_ITEM)
51
52 // item status
53 .int ItemStatus;
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);
61 const int ITS_EXPIRING          = BIT(7);
62
63 // enough to notice it's about to despawn and circle jump to grab it
64 const float IT_DESPAWNFX_TIME = 1.5;
65
66 // 2hz probably enough to correct a desync caused by serious lag
67 // FIXME but updating faster applies the kludge in Item_Think() sooner so it's less noticeable
68 const float IT_UPDATE_INTERVAL = 0.0625;
69
70 // item bboxes for sv_legacy_bbox_expand 0
71 // Small, Default and Large (large maxs are used with default mins)
72 const vector ITEM_S_MINS = '-24 -24 0';
73 const vector ITEM_S_MAXS = '24 24 48';
74 const vector ITEM_D_MINS = '-30 -30 0'; // 0.8.6 set '-16 -16 0' then DP subtracted '15 15 1' but NetRadiant used '-30 -30 0'
75 const vector ITEM_D_MAXS = '30 30 48';  // 0.8.6 set '16 16 48' then DP added '15 15 1' but NetRadiant used '30 30 32'
76 const vector ITEM_L_MAXS = '30 30 70';  // 0.8.6 set '16 16 80' for powerups, '16 16 70' for megas, '16 16 60' for buffs
77
78 .float fade_start;
79 .float fade_end;
80
81 .string mdl;
82 #endif
83
84 #ifdef SVQC
85 .float strength_finished; // NOTE: this field is used only by map entities, it does not directly apply the strength stat
86 .float invincible_finished; // ditto
87 .float buffs_finished; // ditts
88
89 #define SPAWNFUNC_BODY(item) \
90         if (item && Item_IsDefinitionAllowed(item)) \
91                 StartItem(this, item); \
92         else \
93         { \
94                 startitem_failed = true; \
95                 delete(this); \
96         }
97
98 #define SPAWNFUNC_ITEM(name, item) \
99         spawnfunc(name) \
100         { \
101                 SPAWNFUNC_BODY(item) \
102         }
103
104 #define SPAWNFUNC_ITEM_COND(name, cond, item1, item2) \
105         SPAWNFUNC_ITEM(name, (cond ? item1 : item2))
106
107 #else
108
109 #define SPAWNFUNC_ITEM(name, item)
110
111 #endif
112
113 enum
114 {
115         ITEM_FLAG_NORMAL = BIT(0), ///< Item is usable during normal gameplay.
116         ITEM_FLAG_MUTATORBLOCKED = BIT(1),
117         ITEM_FLAG_RESOURCE = BIT(2) ///< Item is is a resource, not a held item.
118 };
119
120 #define ITEM_HANDLE(signal, ...) __Item_Send_##signal(__VA_ARGS__)
121 CLASS(GameItem, Object)
122     ATTRIB(GameItem, m_id, int, 0);
123     /** the canonical spawnfunc name */
124     ATTRIB(GameItem, m_canonical_spawnfunc, string);
125     METHOD(GameItem, m_spawnfunc_hookreplace, GameItem(GameItem this, entity e)) { return this; }
126     ATTRIB(GameItem, m_name, string);
127     ATTRIB(GameItem, m_icon, string);
128     ATTRIB(GameItem, m_color, vector, '1 1 1');
129     ATTRIB(GameItem, m_waypoint, string);
130     ATTRIB(GameItem, m_waypointblink, int, 1);
131 #ifdef GAMEQC
132     ATTRIB(GameItem, m_glow, bool, false);
133     ATTRIB(GameItem, m_respawnsound, Sound, SND_ITEMRESPAWN);
134 #endif
135     METHOD(GameItem, display, void(GameItem this, void(string name, string icon) returns))
136     {
137         TC(GameItem, this);
138         returns(this.m_name, this.m_icon ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon) : string_null);
139     }
140     METHOD(GameItem, show, void(GameItem this))
141     {
142         TC(GameItem, this);
143         LOG_INFO("A game item");
144     }
145     void ITEM_HANDLE(Show, GameItem this) { this.show(this); }
146 ENDCLASS(GameItem)