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
24string count_ammo(int num, entity res);
25
34
35
36// NOTE: ammo resource registration order should match ammo (as item) registration order
37// see REGISTER_RESOURCE calls order
38
39// ammo type #1: shells
40#ifdef GAMEQC
41MODEL(Shells_ITEM, Item_Model("a_shells.md3"));
42#endif
43
44#ifdef SVQC
48{
49 if(!GetResource(item, RES_SHELLS))
51}
52#endif
53
55/* spawnfunc */ ATTRIB(Shells, m_canonical_spawnfunc, string, "item_shells");
56#ifdef GAMEQC
58/* model */ ATTRIB(Shells, m_model, Model, MDL_Shells_ITEM);
59#endif
60/* refname */ ATTRIB(Shells, netname, string, "shells");
61/* itemname */ ATTRIB(Shells, m_name, string, _("Shells"));
62/* icon */ ATTRIB(Shells, m_icon, string, "ammo_shells");
63/* color */ ATTRIB(Shells, m_color, vector, '0.604 0.647 0.671');
64#ifdef SVQC
65/* botvalue */ ATTRIB(Shells, m_botvalue, int, 1000);
66/* itemid */ ATTRIB(Shells, m_itemid, int, IT_RESOURCE);
67/* iteminit */ ATTRIB(Shells, m_iteminit, void(Pickup this, entity item), ammo_shells_init);
68#endif
71
72SPAWNFUNC_ITEM(item_shells, ITEM_Shells)
73
74
75// ammo type #2: bullets
76#ifdef GAMEQC
77MODEL(Bullets_ITEM, Item_Model("a_bullets.mdl"));
78#endif
79
80#ifdef SVQC
84{
85 if(!GetResource(item, RES_BULLETS))
87}
88#endif
89
91/* spawnfunc */ ATTRIB(Bullets, m_canonical_spawnfunc, string, "item_bullets");
92#ifdef GAMEQC
94/* model */ ATTRIB(Bullets, m_model, Model, MDL_Bullets_ITEM);
95#endif
96/* refname */ ATTRIB(Bullets, netname, string, "bullets");
97/* itemname */ ATTRIB(Bullets, m_name, string, _("Bullets"));
98/* icon */ ATTRIB(Bullets, m_icon, string, "ammo_bullets");
99/* color */ ATTRIB(Bullets, m_color, vector, '0.678 0.941 0.522');
100#ifdef SVQC
101/* botvalue */ ATTRIB(Bullets, m_botvalue, int, 1500);
102/* itemid */ ATTRIB(Bullets, m_itemid, int, IT_RESOURCE);
103/* iteminit */ ATTRIB(Bullets, m_iteminit, void(Pickup this, entity item), ammo_bullets_init);
104#endif
107
108SPAWNFUNC_ITEM(item_bullets, ITEM_Bullets)
109
110
111// ammo type #3: rockets
112#ifdef GAMEQC
113MODEL(Rockets_ITEM, Item_Model("a_rockets.md3"));
114#endif
115
116#ifdef SVQC
120{
121 if(!GetResource(item, RES_ROCKETS))
123}
124#endif
125
127/* spawnfunc */ ATTRIB(Rockets, m_canonical_spawnfunc, string, "item_rockets");
128#ifdef GAMEQC
130/* model */ ATTRIB(Rockets, m_model, Model, MDL_Rockets_ITEM);
131#endif
132/* refname */ ATTRIB(Rockets, netname, string, "rockets");
133/* itename */ ATTRIB(Rockets, m_name, string, _("Rockets"));
134/* icon */ ATTRIB(Rockets, m_icon, string, "ammo_rockets");
135/* color */ ATTRIB(Rockets, m_color, vector, '0.918 0.686 0.525');
136#ifdef SVQC
137/* botvalue */ ATTRIB(Rockets, m_botvalue, int, 1500);
138/* itemid */ ATTRIB(Rockets, m_itemid, int, IT_RESOURCE);
139/* iteminit */ ATTRIB(Rockets, m_iteminit, void(Pickup this, entity item), ammo_rockets_init);
140#endif
143
144SPAWNFUNC_ITEM(item_rockets, ITEM_Rockets)
145
146
147// ammo type #4: cells
148#ifdef GAMEQC
149MODEL(Cells_ITEM, Item_Model("a_cells.md3"));
150#endif
151
152#ifdef SVQC
156{
157 if(!GetResource(item, RES_CELLS))
159}
160#endif
161
163/* spawnfunc */ ATTRIB(Cells, m_canonical_spawnfunc, string, "item_cells");
164#ifdef GAMEQC
166/* model */ ATTRIB(Cells, m_model, Model, MDL_Cells_ITEM);
167#endif
168/* refname */ ATTRIB(Cells, netname, string, "cells");
169/* itemname */ ATTRIB(Cells, m_name, string, _("Cells"));
170/* icon */ ATTRIB(Cells, m_icon, string, "ammo_cells");
171/* color */ ATTRIB(Cells, m_color, vector, '0.545 0.882 0.969');
172#ifdef SVQC
173/* botvalue */ ATTRIB(Cells, m_botvalue, int, 1500);
174/* itemid */ ATTRIB(Cells, m_itemid, int, IT_RESOURCE);
175/* iteminit */ ATTRIB(Cells, m_iteminit, void(Pickup this, entity item), ammo_cells_init);
176#endif
179
180SPAWNFUNC_ITEM(item_cells, ITEM_Cells)
181
182
183// ammo type #5: fuel
184#ifdef GAMEQC
185MODEL(Fuel_ITEM, Item_Model("g_fuel.md3"));
186#endif
187
188#ifdef SVQC
192{
193 if(!GetResource(item, RES_FUEL))
195}
196#endif
197
199/* spawnfunc */ ATTRIB(Fuel, m_canonical_spawnfunc, string, "item_fuel");
200#ifdef GAMEQC
202/* model */ ATTRIB(Fuel, m_model, Model, MDL_Fuel_ITEM);
203#endif
204/* refname */ ATTRIB(Fuel, netname, string, "fuel");
205/* itemname */ ATTRIB(Fuel, m_name, string, _("Fuel"));
206/* icon */ ATTRIB(Fuel, m_icon, string, "ammo_fuel");
207/* color */ ATTRIB(Fuel, m_color, vector, '0.984 0.878 0.506');
208#ifdef SVQC
209/* botvlaue */ ATTRIB(Fuel, m_botvalue, int, 2000);
210/* itemid */ ATTRIB(Fuel, m_itemid, int, IT_RESOURCE);
211/* iteminit */ ATTRIB(Fuel, m_iteminit, void(Pickup this, entity item), ammo_fuel_init);
212#endif
215
216SPAWNFUNC_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.
Definition ammo.qh:26
float m_respawntimejitter
Definition ammo.qh:30
bool m_pickupanyway
Definition ammo.qh:31
float m_respawntime
Definition ammo.qh:29
string m_canonical_spawnfunc
Definition ammo.qh:91
int m_botvalue
Definition ammo.qh:101
string m_icon
Definition ammo.qh:98
Model m_model
Definition ammo.qh:94
int spawnflags
Definition ammo.qh:93
int m_itemid
Definition ammo.qh:102
string netname
Definition ammo.qh:96
vector m_color
Definition ammo.qh:99
string m_name
Definition ammo.qh:97
Definition ammo.qh:162
string netname
Definition ammo.qh:168
int spawnflags
Definition ammo.qh:165
Model m_model
Definition ammo.qh:166
vector m_color
Definition ammo.qh:171
int m_itemid
Definition ammo.qh:174
int m_botvalue
Definition ammo.qh:173
string m_canonical_spawnfunc
Definition ammo.qh:163
string m_name
Definition ammo.qh:169
string m_icon
Definition ammo.qh:170
Definition ammo.qh:198
vector m_color
Definition ammo.qh:207
string m_canonical_spawnfunc
Definition ammo.qh:199
string m_icon
Definition ammo.qh:206
int m_botvalue
Definition ammo.qh:209
string netname
Definition ammo.qh:204
int m_itemid
Definition ammo.qh:210
Model m_model
Definition ammo.qh:202
string m_name
Definition ammo.qh:205
int spawnflags
Definition ammo.qh:201
Definition model.qh:3
ATTRIB(Pickup, m_model, Model)
string netname
Definition ammo.qh:132
int m_itemid
Definition ammo.qh:138
string m_icon
Definition ammo.qh:134
int m_botvalue
Definition ammo.qh:137
string m_name
Definition ammo.qh:133
Model m_model
Definition ammo.qh:130
int spawnflags
Definition ammo.qh:129
string m_canonical_spawnfunc
Definition ammo.qh:127
vector m_color
Definition ammo.qh:135
Definition ammo.qh:54
Model m_model
Definition ammo.qh:58
string m_name
Definition ammo.qh:61
int m_itemid
Definition ammo.qh:66
vector m_color
Definition ammo.qh:63
int m_botvalue
Definition ammo.qh:65
string netname
Definition ammo.qh:60
string m_icon
Definition ammo.qh:62
int spawnflags
Definition ammo.qh:57
string m_canonical_spawnfunc
Definition ammo.qh:55
int autocvar_g_pickup_rockets_max
Definition ammo.qh:118
int autocvar_g_pickup_nails
Definition ammo.qh:81
bool autocvar_g_pickup_ammo_anyway
Definition ammo.qh:19
void ammo_fuel_init(Pickup this, entity item)
Definition ammo.qh:191
int spawnflags
Definition ammo.qh:15
int autocvar_g_pickup_fuel_max
Definition ammo.qh:190
int autocvar_g_pickup_shells_max
Definition ammo.qh:46
void ammo_bullets_init(Pickup this, entity item)
Definition ammo.qh:83
int autocvar_g_pickup_cells_max
Definition ammo.qh:154
int autocvar_g_pickup_rockets
Definition ammo.qh:117
void ammo_cells_init(Pickup this, entity item)
Definition ammo.qh:155
int autocvar_g_pickup_nails_max
Definition ammo.qh:82
void ammo_rockets_init(Pickup this, entity item)
Definition ammo.qh:119
void ammo_shells_init(Pickup this, entity item)
Definition ammo.qh:47
string count_ammo(int num, entity res)
Definition ammo.qc:5
int autocvar_g_pickup_fuel
Definition ammo.qh:189
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:45
int autocvar_g_pickup_cells
Definition ammo.qh:153
#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
SetResourceExplicit(ent, RES_ARMOR, ReadByte() *DEC_FACTOR)) ENTCS_PROP(NAME
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:120
#define CLASS(...)
Definition oo.qh:149
#define ENDCLASS(cname)
Definition oo.qh:286
#define ATTRIB(...)
Definition oo.qh:152
vector
Definition self.qh:96
float ammo_pickupevalfunc(entity player, entity item)
Definition items.qc:909
Header file that describes the resource system.