4 /// \brief Source file that contains implementation of the functions related to
6 /// \copyright GNU GPLv2 or any later version.
8 #include <common/t_items.qh>
9 #include <common/mutators/mutator/instagib/sv_instagib.qh>
11 .bool m_isloot; ///< Holds whether item is loot.
13 entity Item_Create(string class_name, vector position)
15 entity item = spawn();
16 item.classname = class_name;
17 item.spawnfunc_checked = true;
18 Item_Initialize(item, class_name);
23 setorigin(item, position);
27 void Item_Initialize(entity item, string class_name)
31 case "item_health_small":
33 spawnfunc_item_health_small(item);
36 case "item_health_medium":
38 spawnfunc_item_health_medium(item);
41 case "item_health_big":
42 case "item_health_large":
44 spawnfunc_item_health_big(item);
47 case "item_health_mega":
49 spawnfunc_item_health_mega(item);
52 case "item_armor_small":
54 spawnfunc_item_armor_small(item);
57 case "item_armor_medium":
59 spawnfunc_item_armor_medium(item);
62 case "item_armor_big":
63 case "item_armor_large":
65 spawnfunc_item_armor_big(item);
68 case "item_armor_mega":
70 spawnfunc_item_armor_mega(item);
75 spawnfunc_item_shells(item);
80 spawnfunc_item_bullets(item);
85 spawnfunc_item_rockets(item);
90 spawnfunc_item_cells(item);
95 spawnfunc_item_plasma(item);
100 spawnfunc_item_fuel(item);
103 case "weapon_blaster":
106 spawnfunc_weapon_blaster(item);
109 case "weapon_shotgun":
111 spawnfunc_weapon_shotgun(item);
114 case "weapon_machinegun":
117 spawnfunc_weapon_machinegun(item);
120 case "weapon_mortar":
121 case "weapon_grenadelauncher":
123 spawnfunc_weapon_mortar(item);
126 case "weapon_electro":
128 spawnfunc_weapon_electro(item);
131 case "weapon_crylink":
133 spawnfunc_weapon_crylink(item);
136 case "weapon_vortex":
139 spawnfunc_weapon_vortex(item);
144 spawnfunc_weapon_hagar(item);
147 case "weapon_devastator":
148 case "weapon_rocketlauncher":
150 spawnfunc_weapon_devastator(item);
153 case "weapon_shockwave":
155 spawnfunc_weapon_shockwave(item);
160 spawnfunc_weapon_arc(item);
165 spawnfunc_weapon_hook(item);
170 spawnfunc_weapon_tuba(item);
175 spawnfunc_weapon_porto(item);
178 case "weapon_fireball":
180 spawnfunc_weapon_fireball(item);
183 case "weapon_minelayer":
185 spawnfunc_weapon_minelayer(item);
190 spawnfunc_weapon_hlac(item);
194 case "weapon_campingrifle":
195 case "weapon_sniperrifle":
197 spawnfunc_weapon_rifle(item);
200 case "weapon_seeker":
202 spawnfunc_weapon_seeker(item);
205 case "weapon_vaporizer":
206 case "weapon_minstanex":
208 spawnfunc_weapon_vaporizer(item);
211 case "item_strength":
213 spawnfunc_item_strength(item);
216 case "item_invincible":
218 spawnfunc_item_invincible(item);
221 case "item_fuel_regen":
223 spawnfunc_item_fuel_regen(item);
228 spawnfunc_item_jetpack(item);
231 case "item_vaporizer_cells":
233 spawnfunc_item_vaporizer_cells(item);
236 case "item_invisibility":
238 instagib_invisibility(item);
241 case "item_extralife":
243 instagib_extralife(item);
248 instagib_speed(item);
252 error("Item_Initialize: Invalid classname ", class_name);
255 entity Item_CreateLoot(string class_name, vector position, vector vel,
258 entity item = spawn();
259 if (!Item_InitializeLoot(item, class_name, position, vel, time_to_live))
266 bool Item_InitializeLoot(entity item, string class_name, vector position,
267 vector vel, float time_to_live)
269 item.classname = class_name;
270 Item_SetLoot(item, true);
272 item.pickup_anyway = true;
273 item.spawnfunc_checked = true;
274 Item_Initialize(item, class_name);
280 setorigin(item, position);
282 SUB_SetFade(item, time + time_to_live, 1);
286 bool Item_IsLoot(entity item)
288 return item.m_isloot || (item.classname == "droppedweapon");
291 void Item_SetLoot(entity item, bool loot)
293 item.m_isloot = loot;
296 spawnfunc(item_health_small)
298 StartItem(this, ITEM_HealthSmall);
301 spawnfunc(item_health_medium)
303 StartItem(this, ITEM_HealthMedium);
306 spawnfunc(item_health_big)
308 StartItem(this, ITEM_HealthBig);
311 spawnfunc(item_health_mega)
313 StartItem(this, ITEM_HealthMega);
316 spawnfunc(item_armor_small)
318 StartItem(this, ITEM_ArmorSmall);
321 spawnfunc(item_armor_medium)
323 StartItem(this, ITEM_ArmorMedium);
326 spawnfunc(item_armor_big)
328 StartItem(this, ITEM_ArmorBig);
331 spawnfunc(item_armor_mega)
333 StartItem(this, ITEM_ArmorMega);
336 spawnfunc(item_shells)
338 if (!weaponswapping && autocvar_sv_q3acompat_machineshotgunswap &&
339 (this.classname != "droppedweapon"))
341 weaponswapping = true;
342 spawnfunc_item_bullets(this);
343 weaponswapping = false;
346 StartItem(this, ITEM_Shells);
349 spawnfunc(item_bullets)
351 if (!weaponswapping && autocvar_sv_q3acompat_machineshotgunswap &&
352 (this.classname != "droppedweapon"))
354 weaponswapping = true;
355 spawnfunc_item_shells(this);
356 weaponswapping = false;
359 StartItem(this, ITEM_Bullets);
362 spawnfunc(item_rockets)
364 StartItem(this, ITEM_Rockets);
367 spawnfunc(item_cells)
369 StartItem(this, ITEM_Cells);
372 spawnfunc(item_plasma)
374 StartItem(this, ITEM_Plasma);
379 StartItem(this, ITEM_JetpackFuel);
382 spawnfunc(item_strength)
384 StartItem(this, ITEM_Strength);
387 spawnfunc(item_invincible)
389 StartItem(this, ITEM_Shield);
392 spawnfunc(item_fuel_regen)
394 if (start_items & ITEM_JetpackRegen.m_itemid)
396 spawnfunc_item_fuel(this);
399 StartItem(this, ITEM_JetpackRegen);
402 spawnfunc(item_jetpack)
404 if(start_items & ITEM_Jetpack.m_itemid)
406 spawnfunc_item_fuel(this);
409 StartItem(this, ITEM_Jetpack);
412 // Compatibility spawn functions
414 spawnfunc(item_armor1) { spawnfunc_item_armor_small(this); } // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
415 spawnfunc(item_armor25) { spawnfunc_item_armor_mega(this); }
416 spawnfunc(item_armor_large) { spawnfunc_item_armor_mega(this); }
417 spawnfunc(item_health1) { spawnfunc_item_health_small(this); }
418 spawnfunc(item_health25) { spawnfunc_item_health_medium(this); }
419 spawnfunc(item_health_large) { spawnfunc_item_health_big(this); }
420 spawnfunc(item_health100) { spawnfunc_item_health_mega(this); }
424 this.classname = "item_strength";
425 spawnfunc_item_strength(this);