Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
ammo.qh
Go to the documentation of this file.
1#pragma once
2
3#include "pickup.qh"
4#include <common/items/all.qh>
6// NOTE: ammo doesn't need this powerups include, but it prevents #2994
7// TODO: this sort of problem could be fixed by moving away from registries
9#ifdef SVQC
11 #include <server/items/items.qh>
12#endif
13
14#ifdef GAMEQC
16#endif
17
18#ifdef SVQC
22#endif
23
32
33
34// NOTE: ammo resource registration order should match ammo (as item) registration order
35// see REGISTER_RESOURCE calls order
36
37// ammo type #1: shells
38#ifdef GAMEQC
39MODEL(Shells_ITEM, Item_Model("a_shells.md3"));
40#endif
41
42#ifdef SVQC
46{
47 if(!GetResource(item, RES_SHELLS))
49}
50#endif
51
53/* spawnfunc */ ATTRIB(Shells, m_canonical_spawnfunc, string, "item_shells");
54#ifdef GAMEQC
56/* model */ ATTRIB(Shells, m_model, Model, MDL_Shells_ITEM);
57#endif
58/* refname */ ATTRIB(Shells, netname, string, "shells");
59/* itemname */ ATTRIB(Shells, m_name, string, _("Shells"));
60/* icon */ ATTRIB(Shells, m_icon, string, "ammo_shells");
61/* color */ ATTRIB(Shells, m_color, vector, '0.604 0.647 0.671');
62#ifdef SVQC
63/* botvalue */ ATTRIB(Shells, m_botvalue, int, 1000);
64/* itemid */ ATTRIB(Shells, m_itemid, int, IT_RESOURCE);
65/* iteminit */ ATTRIB(Shells, m_iteminit, void(Pickup this, entity item), ammo_shells_init);
66#endif
69
70SPAWNFUNC_ITEM(item_shells, ITEM_Shells)
71
72
73// ammo type #2: bullets
74#ifdef GAMEQC
75MODEL(Bullets_ITEM, Item_Model("a_bullets.mdl"));
76#endif
77
78#ifdef SVQC
82{
83 if(!GetResource(item, RES_BULLETS))
85}
86#endif
87
89/* spawnfunc */ ATTRIB(Bullets, m_canonical_spawnfunc, string, "item_bullets");
90#ifdef GAMEQC
92/* model */ ATTRIB(Bullets, m_model, Model, MDL_Bullets_ITEM);
93#endif
94/* refname */ ATTRIB(Bullets, netname, string, "bullets");
95/* itemname */ ATTRIB(Bullets, m_name, string, _("Bullets"));
96/* icon */ ATTRIB(Bullets, m_icon, string, "ammo_bullets");
97/* color */ ATTRIB(Bullets, m_color, vector, '0.678 0.941 0.522');
98#ifdef SVQC
99/* botvalue */ ATTRIB(Bullets, m_botvalue, int, 1500);
100/* itemid */ ATTRIB(Bullets, m_itemid, int, IT_RESOURCE);
101/* iteminit */ ATTRIB(Bullets, m_iteminit, void(Pickup this, entity item), ammo_bullets_init);
102#endif
105
106SPAWNFUNC_ITEM(item_bullets, ITEM_Bullets)
107
108
109// ammo type #3: rockets
110#ifdef GAMEQC
111MODEL(Rockets_ITEM, Item_Model("a_rockets.md3"));
112#endif
113
114#ifdef SVQC
118{
119 if(!GetResource(item, RES_ROCKETS))
121}
122#endif
123
125/* spawnfunc */ ATTRIB(Rockets, m_canonical_spawnfunc, string, "item_rockets");
126#ifdef GAMEQC
128/* model */ ATTRIB(Rockets, m_model, Model, MDL_Rockets_ITEM);
129#endif
130/* refname */ ATTRIB(Rockets, netname, string, "rockets");
131/* itename */ ATTRIB(Rockets, m_name, string, _("Rockets"));
132/* icon */ ATTRIB(Rockets, m_icon, string, "ammo_rockets");
133/* color */ ATTRIB(Rockets, m_color, vector, '0.918 0.686 0.525');
134#ifdef SVQC
135/* botvalue */ ATTRIB(Rockets, m_botvalue, int, 1500);
136/* itemid */ ATTRIB(Rockets, m_itemid, int, IT_RESOURCE);
137/* iteminit */ ATTRIB(Rockets, m_iteminit, void(Pickup this, entity item), ammo_rockets_init);
138#endif
141
142SPAWNFUNC_ITEM(item_rockets, ITEM_Rockets)
143
144
145// ammo type #4: cells
146#ifdef GAMEQC
147MODEL(Cells_ITEM, Item_Model("a_cells.md3"));
148#endif
149
150#ifdef SVQC
154{
155 if(!GetResource(item, RES_CELLS))
157}
158#endif
159
161/* spawnfunc */ ATTRIB(Cells, m_canonical_spawnfunc, string, "item_cells");
162#ifdef GAMEQC
164/* model */ ATTRIB(Cells, m_model, Model, MDL_Cells_ITEM);
165#endif
166/* refname */ ATTRIB(Cells, netname, string, "cells");
167/* itemname */ ATTRIB(Cells, m_name, string, _("Cells"));
168/* icon */ ATTRIB(Cells, m_icon, string, "ammo_cells");
169/* color */ ATTRIB(Cells, m_color, vector, '0.545 0.882 0.969');
170#ifdef SVQC
171/* botvalue */ ATTRIB(Cells, m_botvalue, int, 1500);
172/* itemid */ ATTRIB(Cells, m_itemid, int, IT_RESOURCE);
173/* iteminit */ ATTRIB(Cells, m_iteminit, void(Pickup this, entity item), ammo_cells_init);
174#endif
177
178SPAWNFUNC_ITEM(item_cells, ITEM_Cells)
179
180
181// ammo type #5: fuel
182#ifdef GAMEQC
183MODEL(Fuel_ITEM, Item_Model("g_fuel.md3"));
184#endif
185
186#ifdef SVQC
190{
191 if(!GetResource(item, RES_FUEL))
193}
194#endif
195
197/* spawnfunc */ ATTRIB(Fuel, m_canonical_spawnfunc, string, "item_fuel");
198#ifdef GAMEQC
200/* model */ ATTRIB(Fuel, m_model, Model, MDL_Fuel_ITEM);
201#endif
202/* refname */ ATTRIB(Fuel, netname, string, "fuel");
203/* itemname */ ATTRIB(Fuel, m_name, string, _("Fuel"));
204/* icon */ ATTRIB(Fuel, m_icon, string, "ammo_fuel");
205/* color */ ATTRIB(Fuel, m_color, vector, '0.984 0.878 0.506');
206#ifdef SVQC
207/* botvlaue */ ATTRIB(Fuel, m_botvalue, int, 2000);
208/* itemid */ ATTRIB(Fuel, m_itemid, int, IT_RESOURCE);
209/* iteminit */ ATTRIB(Fuel, m_iteminit, void(Pickup this, entity item), ammo_fuel_init);
210#endif
213
214SPAWNFUNC_ITEM(item_fuel, ITEM_Fuel)
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
Definition ammo.qh:24
float m_respawntimejitter
Definition ammo.qh:28
bool m_pickupanyway
Definition ammo.qh:29
float m_respawntime
Definition ammo.qh:27
string m_canonical_spawnfunc
Definition ammo.qh:89
int m_botvalue
Definition ammo.qh:99
string m_icon
Definition ammo.qh:96
Model m_model
Definition ammo.qh:92
int spawnflags
Definition ammo.qh:91
int m_itemid
Definition ammo.qh:100
string netname
Definition ammo.qh:94
vector m_color
Definition ammo.qh:97
string m_name
Definition ammo.qh:95
Definition ammo.qh:160
string netname
Definition ammo.qh:166
int spawnflags
Definition ammo.qh:163
Model m_model
Definition ammo.qh:164
vector m_color
Definition ammo.qh:169
int m_itemid
Definition ammo.qh:172
int m_botvalue
Definition ammo.qh:171
string m_canonical_spawnfunc
Definition ammo.qh:161
string m_name
Definition ammo.qh:167
string m_icon
Definition ammo.qh:168
Definition ammo.qh:196
vector m_color
Definition ammo.qh:205
string m_canonical_spawnfunc
Definition ammo.qh:197
string m_icon
Definition ammo.qh:204
int m_botvalue
Definition ammo.qh:207
string netname
Definition ammo.qh:202
int m_itemid
Definition ammo.qh:208
Model m_model
Definition ammo.qh:200
string m_name
Definition ammo.qh:203
int spawnflags
Definition ammo.qh:199
Definition model.qh:3
ATTRIB(Pickup, m_model, Model)
string netname
Definition ammo.qh:130
int m_itemid
Definition ammo.qh:136
string m_icon
Definition ammo.qh:132
int m_botvalue
Definition ammo.qh:135
string m_name
Definition ammo.qh:131
Model m_model
Definition ammo.qh:128
int spawnflags
Definition ammo.qh:127
string m_canonical_spawnfunc
Definition ammo.qh:125
vector m_color
Definition ammo.qh:133
Definition ammo.qh:52
Model m_model
Definition ammo.qh:56
string m_name
Definition ammo.qh:59
int m_itemid
Definition ammo.qh:64
vector m_color
Definition ammo.qh:61
int m_botvalue
Definition ammo.qh:63
string netname
Definition ammo.qh:58
string m_icon
Definition ammo.qh:60
int spawnflags
Definition ammo.qh:55
string m_canonical_spawnfunc
Definition ammo.qh:53
int autocvar_g_pickup_rockets_max
Definition ammo.qh:116
int autocvar_g_pickup_nails
Definition ammo.qh:79
bool autocvar_g_pickup_ammo_anyway
Definition ammo.qh:19
void ammo_fuel_init(Pickup this, entity item)
Definition ammo.qh:189
int spawnflags
Definition ammo.qh:15
int autocvar_g_pickup_fuel_max
Definition ammo.qh:188
int autocvar_g_pickup_shells_max
Definition ammo.qh:44
void ammo_bullets_init(Pickup this, entity item)
Definition ammo.qh:81
int autocvar_g_pickup_cells_max
Definition ammo.qh:152
int autocvar_g_pickup_rockets
Definition ammo.qh:115
void ammo_cells_init(Pickup this, entity item)
Definition ammo.qh:153
int autocvar_g_pickup_nails_max
Definition ammo.qh:80
void ammo_rockets_init(Pickup this, entity item)
Definition ammo.qh:117
void ammo_shells_init(Pickup this, entity item)
Definition ammo.qh:45
int autocvar_g_pickup_fuel
Definition ammo.qh:187
float autocvar_g_pickup_respawntime_ammo
Definition ammo.qh:20
float autocvar_g_pickup_respawntimejitter_ammo
Definition ammo.qh:21
int autocvar_g_pickup_shells
Definition ammo.qh:43
int autocvar_g_pickup_cells
Definition ammo.qh:151
#define SPAWNFUNC_ITEM(name, item)
Definition item.qh:106
const int IT_RESOURCE
Definition item.qh:30
@ 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
string Item_Model(string item_mdl)
Definition all.qc:8
#define REGISTER_ITEM(id, inst)
Definition all.qh:13
#define MODEL(name, path)
Definition all.qh:8
#define NEW(cname,...)
Definition oo.qh:117
#define CLASS(...)
Definition oo.qh:145
#define ENDCLASS(cname)
Definition oo.qh:281
#define ATTRIB(...)
Definition oo.qh:148
vector
Definition self.qh:92
float ammo_pickupevalfunc(entity player, entity item)
Definition items.qc:908
Header file that describes the resource system.