Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
item.qh
Go to the documentation of this file.
1#pragma once
2
3#ifdef GAMEQC
7#include <common/stats.qh>
8#endif
9
10#ifdef SVQC
12#endif
13
14#ifndef SVQC
15#include <common/util.qh> // for icon_path_from_HUDskin
16#endif
17
18#ifdef MENUQC
19#include <menu/draw.qh>
20#endif
21
22#ifdef GAMEQC
23const int IT_UNLIMITED_AMMO = BIT(0); // when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup.
24const int IT_UNLIMITED_SUPERWEAPONS = BIT(1); // when this bit is set, superweapons don't expire. Checkpoints can give this powerup.
25
26const int IT_JETPACK = BIT(2); // actual item
27const int IT_USING_JETPACK = BIT(3); // confirmation that button is pressed
28const int IT_FUEL_REGEN = BIT(4); // fuel regeneration trigger
29
30const int IT_RESOURCE = BIT(5); // bitflag to mark this item as a resource (unused)
31
32const int IT_KEY1 = BIT(6);
33const int IT_KEY2 = BIT(7);
34
35const int IT_BUFF = BIT(8); // unused bit for buff items
36
37// special colorblend meaning in engine
38// legacy bitflags for powerups
39const int IT_INVISIBILITY = BIT(9);
40const int IT_INVINCIBLE = BIT(10);
41const int IT_SUPERWEAPON = BIT(11); // suit
42const int IT_STRENGTH = BIT(12);
43const int IT_SPEED = BIT(13);
44
45// item masks
46const int IT_PICKUPMASK = IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS | IT_JETPACK | IT_FUEL_REGEN; // strength and invincible are handled separately
47
48// item networking
49const int ISF_REMOVEFX = BIT(0); // technically unnecessary (after the kludge in Item_Think() is reverted), but cheaper and cleaner than using ITS_AVAILABLE
50const int ISF_LOCATION = BIT(1);
51const int ISF_SIZE2 = BIT(2);
52const int ISF_STATUS = BIT(3);
53const int ISF_COLORMAP = BIT(4);
54const int ISF_DROP = BIT(5);
55const int ISF_ANGLES = BIT(6);
56const int ISF_SIZE = BIT(7);
57
58REGISTER_NET_LINKED(ENT_CLIENT_ITEM)
59
60// item status
62const int ITS_STAYWEP = BIT(0);
63const int ITS_ANIMATE1 = BIT(1);
64const int ITS_ANIMATE2 = BIT(2);
65const int ITS_AVAILABLE = BIT(3);
66const int ITS_ALLOWFB = BIT(4);
67const int ITS_ALLOWSI = BIT(5);
68const int ITS_GLOW = BIT(6);
69const int ITS_EXPIRING = BIT(7);
70
71// enough to notice it's about to despawn and circle jump to grab it
72const float IT_DESPAWNFX_TIME = 1.5;
73
74// 2hz probably enough to correct a desync caused by serious lag
75// FIXME but updating faster applies the kludge in Item_Think() sooner so it's less noticeable
76const float IT_UPDATE_INTERVAL = 0.0625;
77
78// item bboxes for sv_legacy_bbox_expand 0
79// Small, Default and Large (large maxs are used with default mins)
80const vector ITEM_S_MINS = '-24 -24 0';
81const vector ITEM_S_MAXS = '24 24 48';
82const 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'
83const 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'
84const 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
85
87.float fade_end;
88
89.string mdl;
90#endif
91
92#ifdef SVQC
93.float strength_finished; // NOTE: this field is used only by map entities, it does not directly apply the strength stat
94.float invincible_finished; // ditto
95.float buffs_finished; // ditts
96
97#define SPAWNFUNC_BODY(item) \
98 if (item && Item_IsDefinitionAllowed(item)) \
99 StartItem(this, item); \
100 else \
101 { \
102 startitem_failed = true; \
103 delete(this); \
104 }
105
106#define SPAWNFUNC_ITEM(name, item) \
107 spawnfunc(name) \
108 { \
109 SPAWNFUNC_BODY((item)) \
110 }
111
112#else
113
114#define SPAWNFUNC_ITEM(name, item)
115
116#endif
117
118enum
119{
123};
124
125#define ITEM_HANDLE(signal, ...) __Item_Send_##signal(__VA_ARGS__)
129 ATTRIB(GameItem, m_canonical_spawnfunc, string);
132 ATTRIB(GameItem, m_icon, string);
134 ATTRIB(GameItem, m_waypoint, string);
136#ifdef GAMEQC
137 ATTRIB(GameItem, m_glow, bool, false);
138 ATTRIB(GameItem, m_respawnsound, Sound, SND_ITEMRESPAWN);
139#endif
140#ifdef MENUQC
142 {
143 TC(GameItem, this);
144 return SUPER(GameItem).describe(this);
145 }
146#endif
147#ifndef SVQC
148 METHOD(GameItem, display, void(GameItem this, void(string name, string icon) returns))
149 {
150 TC(GameItem, this);
151 returns(this.m_name, icon_path_from_HUDskin(this.m_icon));
152 }
153#endif
155 {
156 TC(GameItem, this);
157 LOG_INFO("A game item");
158 }
159 void ITEM_HANDLE(Show, GameItem this) { this.show(this); }
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
Sound m_respawnsound
Definition item.qh:138
int m_waypointblink
Definition item.qh:135
ATTRIB(GameItem, m_canonical_spawnfunc, string)
the canonical spawnfunc name
int m_id
Definition item.qh:127
ATTRIB(GameItem, m_name, string)
vector m_color
Definition item.qh:133
ATTRIB(GameItem, m_icon, string)
void ITEM_HANDLE(Show, GameItem this)
Definition item.qh:159
virtual void describe()
Definition item.qh:141
bool m_glow
Definition item.qh:137
virtual void m_spawnfunc_hookreplace()
Definition item.qh:130
ATTRIB(GameItem, m_waypoint, string)
virtual void show()
Definition item.qh:154
float fade_start
Definition item.qh:86
float fade_end
Definition item.qh:87
const int ITS_STAYWEP
Definition item.qh:62
float strength_finished
Definition item.qh:93
const int ISF_COLORMAP
Definition item.qh:53
const int ITS_ALLOWSI
Definition item.qh:67
const int IT_USING_JETPACK
Definition item.qh:27
const int IT_INVINCIBLE
Definition item.qh:40
const int IT_STRENGTH
Definition item.qh:42
const int ITS_EXPIRING
Definition item.qh:69
const int ITS_ALLOWFB
Definition item.qh:66
const int ITS_GLOW
Definition item.qh:68
const int IT_JETPACK
Definition item.qh:26
const int IT_BUFF
Definition item.qh:35
const float IT_UPDATE_INTERVAL
Definition item.qh:76
const int IT_PICKUPMASK
Definition item.qh:46
const int IT_SUPERWEAPON
Definition item.qh:41
string mdl
Definition item.qh:89
float buffs_finished
Definition item.qh:95
const int IT_SPEED
Definition item.qh:43
const int IT_FUEL_REGEN
Definition item.qh:28
const int IT_UNLIMITED_AMMO
Definition item.qh:23
const int ITS_AVAILABLE
Definition item.qh:65
const int ISF_SIZE2
Definition item.qh:51
const vector ITEM_S_MAXS
Definition item.qh:81
const int IT_UNLIMITED_SUPERWEAPONS
Definition item.qh:24
const vector ITEM_D_MAXS
Definition item.qh:83
const vector ITEM_S_MINS
Definition item.qh:80
int ItemStatus
Definition item.qh:61
const int IT_RESOURCE
Definition item.qh:30
const vector ITEM_L_MAXS
Definition item.qh:84
float invincible_finished
Definition item.qh:94
const int ITS_ANIMATE1
Definition item.qh:63
const int ISF_STATUS
Definition item.qh:52
const vector ITEM_D_MINS
Definition item.qh:82
@ ITEM_FLAG_MUTATORBLOCKED
Definition item.qh:121
@ ITEM_FLAG_RESOURCE
Item is is a resource, not a held item.
Definition item.qh:122
@ ITEM_FLAG_NORMAL
Item is usable during normal gameplay.
Definition item.qh:120
const int ISF_REMOVEFX
Definition item.qh:49
const int ISF_ANGLES
Definition item.qh:55
const float IT_DESPAWNFX_TIME
Definition item.qh:72
const int ITS_ANIMATE2
Definition item.qh:64
const int ISF_SIZE
Definition item.qh:56
const int ISF_LOCATION
Definition item.qh:50
const int ISF_DROP
Definition item.qh:54
string m_name
Definition scores.qh:142
Header file that describes the functions related to game items.
#define TC(T, sym)
Definition _all.inc:82
#define REGISTER_NET_LINKED(id)
Definition net.qh:55
#define LOG_INFO(...)
Definition log.qh:65
string name
Definition menu.qh:30
#define SUPER(cname)
Definition oo.qh:231
#define CLASS(...)
Definition oo.qh:145
#define ENDCLASS(cname)
Definition oo.qh:281
#define METHOD(cname, name, prototype)
Definition oo.qh:269
#define ATTRIB(...)
Definition oo.qh:148
vector
Definition self.qh:92
entity this
Definition self.qh:72
#define IT_KEY1
Definition sys-pre.qh:20
#define IT_INVISIBILITY
Definition sys-pre.qh:23
#define IT_KEY2
Definition sys-pre.qh:21