Xonotic
ammo.qh
Go to the documentation of this file.
1 #pragma once
2 
3 #include "pickup.qh"
4 #include <common/items/all.qh>
6 #ifdef SVQC
8  #include <server/items/items.qh>
9 #endif
10 
11 #ifdef GAMEQC
12 .int spawnflags;
13 #endif
14 
15 #ifdef SVQC
16 PROPERTY(float, g_pickup_ammo_anyway);
17 #endif
18 
20 #ifdef SVQC
21  ATTRIB(Ammo, m_pickupevalfunc, float(entity player, entity item), ammo_pickupevalfunc);
22  ATTRIB(Ammo, m_respawntime, float(), GET(g_pickup_respawntime_ammo));
23  ATTRIB(Ammo, m_respawntimejitter, float(), GET(g_pickup_respawntimejitter_ammo));
24  ATTRIB(Ammo, m_pickupanyway, float(), GET(g_pickup_ammo_anyway));
25 #endif
27 
28 
29 #ifdef GAMEQC
30 MODEL(Bullets_ITEM, Item_Model("a_bullets.mdl"));
31 #endif
32 
33 #ifdef SVQC
34 PROPERTY(int, g_pickup_nails);
35 void ammo_bullets_init(Pickup this, entity item)
36 {
37  if(!GetResource(item, RES_BULLETS))
38  SetResourceExplicit(item, RES_BULLETS, g_pickup_nails);
39 }
40 #endif
41 
44 
46  this.m_canonical_spawnfunc = "item_bullets";
47 #ifdef GAMEQC
49  this.m_model = MDL_Bullets_ITEM;
50 #endif
51  this.netname = "bullets";
52  this.m_name = _("bullets");
53  this.m_icon = "ammo_bullets";
54 #ifdef SVQC
55  this.m_botvalue = 1500;
56  this.m_itemid = IT_RESOURCE;
57  this.m_iteminit = ammo_bullets_init;
58 #endif
59 }
60 
61 SPAWNFUNC_ITEM(item_bullets, ITEM_Bullets)
62 
63 #ifdef GAMEQC
64 MODEL(Cells_ITEM, Item_Model("a_cells.md3"));
65 #endif
66 
67 #ifdef SVQC
68 PROPERTY(int, g_pickup_cells);
69 void ammo_cells_init(Pickup this, entity item)
70 {
71  if(!GetResource(item, RES_CELLS))
72  SetResourceExplicit(item, RES_CELLS, g_pickup_cells);
73 }
74 #endif
76  this.m_canonical_spawnfunc = "item_cells";
77 #ifdef GAMEQC
79  this.m_model = MDL_Cells_ITEM;
80 #endif
81  this.netname = "cells";
82  this.m_name = _("cells");
83  this.m_icon = "ammo_cells";
84 #ifdef SVQC
85  this.m_botvalue = 1500;
86  this.m_itemid = IT_RESOURCE;
87  this.m_iteminit = ammo_cells_init;
88 #endif
89 }
90 
91 SPAWNFUNC_ITEM(item_cells, ITEM_Cells)
92 
93 #ifdef GAMEQC
94 MODEL(Plasma_ITEM, Item_Model("a_cells.md3"));
95 #endif
96 
97 #ifdef SVQC
98 PROPERTY(int, g_pickup_plasma);
99 void ammo_plasma_init(Pickup this, entity item)
100 {
101  if(!GetResource(item, RES_PLASMA))
102  SetResourceExplicit(item, RES_PLASMA, g_pickup_plasma);
103 }
104 #endif
105 REGISTER_ITEM(Plasma, Ammo) {
106  this.m_canonical_spawnfunc = "item_plasma";
107 #ifdef GAMEQC
109  this.m_model = MDL_Plasma_ITEM;
110 #endif
111  this.netname = "plasma";
112  this.m_name = _("plasma");
113  this.m_icon = "ammo_plasma";
114 #ifdef SVQC
115  this.m_botvalue = 1500;
116  this.m_itemid = IT_RESOURCE;
117  this.m_iteminit = ammo_plasma_init;
118 #endif
119 }
120 
121 SPAWNFUNC_ITEM(item_plasma, ITEM_Plasma)
122 
123 #ifdef GAMEQC
124 MODEL(Rockets_ITEM, Item_Model("a_rockets.md3"));
125 #endif
126 
127 #ifdef SVQC
128 PROPERTY(int, g_pickup_rockets);
129 void ammo_rockets_init(Pickup this, entity item)
130 {
131  if(!GetResource(item, RES_ROCKETS))
132  SetResourceExplicit(item, RES_ROCKETS, g_pickup_rockets);
133 }
134 #endif
135 REGISTER_ITEM(Rockets, Ammo) {
136  this.m_canonical_spawnfunc = "item_rockets";
137 #ifdef GAMEQC
139  this.m_model = MDL_Rockets_ITEM;
140 #endif
141  this.netname = "rockets";
142  this.m_name = _("rockets");
143  this.m_icon = "ammo_rockets";
144 #ifdef SVQC
145  this.m_botvalue = 1500;
146  this.m_itemid = IT_RESOURCE;
147  this.m_iteminit = ammo_rockets_init;
148 #endif
149 }
150 
151 SPAWNFUNC_ITEM(item_rockets, ITEM_Rockets)
152 
153 #ifdef GAMEQC
154 MODEL(Shells_ITEM, Item_Model("a_shells.md3"));
155 #endif
156 
157 #ifdef SVQC
158 PROPERTY(int, g_pickup_shells);
159 void ammo_shells_init(Pickup this, entity item)
160 {
161  if(!GetResource(item, RES_SHELLS))
162  SetResourceExplicit(item, RES_SHELLS, g_pickup_shells);
163 }
164 #endif
165 
168 
170  this.m_canonical_spawnfunc = "item_shells";
171 #ifdef GAMEQC
173  this.m_model = MDL_Shells_ITEM;
174 #endif
175  this.netname = "shells";
176  this.m_name = _("shells");
177  this.m_icon = "ammo_shells";
178 #ifdef SVQC
179  this.m_botvalue = 1000;
180  this.m_itemid = IT_RESOURCE;
181  this.m_iteminit = ammo_shells_init;
182 #endif
183 }
184 
185 SPAWNFUNC_ITEM(item_shells, ITEM_Shells)
Item is usable during normal gameplay.
Definition: item.qh:98
Definition: ammo.qh:19
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
Definition: cl_resources.qc:15
CLASS(Object) Object
Definition: oo.qh:318
SPAWNFUNC_ITEM(item_armor_green, ITEM_ArmorMedium) .float wait
Header file that describes the resource system.
entity() spawn
string netname
Definition: powerups.qc:20
float ammo_pickupevalfunc(entity player, entity item)
Definition: items.qc:821
int m_itemid
Definition: jetpack.qh:11
Definition: pickup.qh:22
float spawnflags
Definition: progsdefs.qc:191
#define ATTRIB(...)
Definition: oo.qh:136
Definition: ammo.qh:42
Item is is a resource, not a held item.
Definition: item.qh:100
#define GET(name)
Definition: misc.qh:34
#define MODEL(name, path)
Definition: all.qh:8
REGISTER_ITEM(Bullets, Bullets)
Definition: ammo.qh:45
#define PROPERTY(type, name)
Definition: misc.qh:36
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
Definition: ammo.qh:166
#define ENDCLASS(cname)
Definition: oo.qh:269
string Item_Model(string item_mdl)
Definition: all.qc:8
string m_name
Definition: scores.qh:135