4 /// \brief Source file that contains implementation of the functions related to
6 /// \copyright GNU GPLv2 or any later version.
8 #include <common/mutators/mutator/instagib/sv_instagib.qh>
10 .bool m_isloot; ///< Holds whether item is loot.
12 entity Item_Create(string class_name, vector position)
14 entity item = spawn();
15 item.classname = class_name;
16 item.spawnfunc_checked = true;
17 Item_Initialize(item, class_name);
22 setorigin(item, position);
26 void Item_Initialize(entity item, string class_name)
30 case "item_health_small":
32 spawnfunc_item_health_small(item);
35 case "item_health_medium":
37 spawnfunc_item_health_medium(item);
40 case "item_health_big":
41 case "item_health_large":
43 spawnfunc_item_health_big(item);
46 case "item_health_mega":
48 spawnfunc_item_health_mega(item);
51 case "item_armor_small":
53 spawnfunc_item_armor_small(item);
56 case "item_armor_medium":
58 spawnfunc_item_armor_medium(item);
61 case "item_armor_big":
62 case "item_armor_large":
64 spawnfunc_item_armor_big(item);
67 case "item_armor_mega":
69 spawnfunc_item_armor_mega(item);
74 spawnfunc_item_shells(item);
79 spawnfunc_item_bullets(item);
84 spawnfunc_item_rockets(item);
89 spawnfunc_item_cells(item);
94 spawnfunc_item_plasma(item);
99 spawnfunc_item_fuel(item);
102 case "weapon_blaster":
105 spawnfunc_weapon_blaster(item);
108 case "weapon_shotgun":
110 spawnfunc_weapon_shotgun(item);
113 case "weapon_machinegun":
116 spawnfunc_weapon_machinegun(item);
119 case "weapon_mortar":
120 case "weapon_grenadelauncher":
122 spawnfunc_weapon_mortar(item);
125 case "weapon_electro":
127 spawnfunc_weapon_electro(item);
130 case "weapon_crylink":
132 spawnfunc_weapon_crylink(item);
135 case "weapon_vortex":
138 spawnfunc_weapon_vortex(item);
143 spawnfunc_weapon_hagar(item);
146 case "weapon_devastator":
147 case "weapon_rocketlauncher":
149 spawnfunc_weapon_devastator(item);
152 case "weapon_shockwave":
154 spawnfunc_weapon_shockwave(item);
159 spawnfunc_weapon_arc(item);
164 spawnfunc_weapon_hook(item);
169 spawnfunc_weapon_tuba(item);
174 spawnfunc_weapon_porto(item);
177 case "weapon_fireball":
179 spawnfunc_weapon_fireball(item);
182 case "weapon_minelayer":
184 spawnfunc_weapon_minelayer(item);
189 spawnfunc_weapon_hlac(item);
193 case "weapon_campingrifle":
194 case "weapon_sniperrifle":
196 spawnfunc_weapon_rifle(item);
199 case "weapon_seeker":
201 spawnfunc_weapon_seeker(item);
204 case "weapon_vaporizer":
205 case "weapon_minstanex":
207 spawnfunc_weapon_vaporizer(item);
210 case "item_strength":
212 spawnfunc_item_strength(item);
215 case "item_invincible":
217 spawnfunc_item_invincible(item);
220 case "item_fuel_regen":
222 spawnfunc_item_fuel_regen(item);
227 spawnfunc_item_jetpack(item);
230 case "item_vaporizer_cells":
232 spawnfunc_item_vaporizer_cells(item);
235 case "item_invisibility":
237 instagib_invisibility(item);
240 case "item_extralife":
242 instagib_extralife(item);
247 instagib_speed(item);
251 error("Item_Initialize: Invalid classname ", class_name);
254 entity Item_CreateLoot(string class_name, vector position, vector vel,
257 entity item = spawn();
258 if (!Item_InitializeLoot(item, class_name, position, vel, time_to_live))
265 bool Item_InitializeLoot(entity item, string class_name, vector position,
266 vector vel, float time_to_live)
268 item.classname = class_name;
269 Item_SetLoot(item, true);
271 item.pickup_anyway = true;
272 item.spawnfunc_checked = true;
273 Item_Initialize(item, class_name);
279 setorigin(item, position);
281 SUB_SetFade(item, time + time_to_live, 1);
285 bool Item_IsLoot(entity item)
287 return item.m_isloot || (item.classname == "droppedweapon");
290 void Item_SetLoot(entity item, bool loot)
292 item.m_isloot = loot;
295 spawnfunc(item_health_small)
297 StartItem(this, ITEM_HealthSmall);
300 spawnfunc(item_health_medium)
302 StartItem(this, ITEM_HealthMedium);
305 spawnfunc(item_health_big)
307 StartItem(this, ITEM_HealthBig);
310 spawnfunc(item_health_mega)
312 StartItem(this, ITEM_HealthMega);
315 spawnfunc(item_armor_small)
317 StartItem(this, ITEM_ArmorSmall);
320 spawnfunc(item_armor_medium)
322 StartItem(this, ITEM_ArmorMedium);
325 spawnfunc(item_armor_big)
327 StartItem(this, ITEM_ArmorBig);
330 spawnfunc(item_armor_mega)
332 StartItem(this, ITEM_ArmorMega);
335 spawnfunc(item_shells)
337 if (!weaponswapping && autocvar_sv_q3acompat_machineshotgunswap &&
338 (this.classname != "droppedweapon"))
340 weaponswapping = true;
341 spawnfunc_item_bullets(this);
342 weaponswapping = false;
345 StartItem(this, ITEM_Shells);
348 spawnfunc(item_bullets)
350 if (!weaponswapping && autocvar_sv_q3acompat_machineshotgunswap &&
351 (this.classname != "droppedweapon"))
353 weaponswapping = true;
354 spawnfunc_item_shells(this);
355 weaponswapping = false;
358 StartItem(this, ITEM_Bullets);
361 spawnfunc(item_rockets)
363 StartItem(this, ITEM_Rockets);
366 spawnfunc(item_cells)
368 StartItem(this, ITEM_Cells);
371 spawnfunc(item_plasma)
373 StartItem(this, ITEM_Plasma);
378 StartItem(this, ITEM_JetpackFuel);
381 spawnfunc(item_strength)
383 StartItem(this, ITEM_Strength);
386 spawnfunc(item_invincible)
388 StartItem(this, ITEM_Shield);
391 spawnfunc(item_fuel_regen)
393 if (start_items & ITEM_JetpackRegen.m_itemid)
395 spawnfunc_item_fuel(this);
398 StartItem(this, ITEM_JetpackRegen);
401 spawnfunc(item_jetpack)
403 if(start_items & ITEM_Jetpack.m_itemid)
405 spawnfunc_item_fuel(this);
408 StartItem(this, ITEM_Jetpack);
411 // Compatibility spawn functions
413 spawnfunc(item_armor1) { spawnfunc_item_armor_small(this); } // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
414 spawnfunc(item_armor25) { spawnfunc_item_armor_mega(this); }
415 spawnfunc(item_armor_large) { spawnfunc_item_armor_mega(this); }
416 spawnfunc(item_health1) { spawnfunc_item_health_small(this); }
417 spawnfunc(item_health25) { spawnfunc_item_health_medium(this); }
418 spawnfunc(item_health_large) { spawnfunc_item_health_big(this); }
419 spawnfunc(item_health100) { spawnfunc_item_health_mega(this); }