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>
9 #include <common/mutators/mutator/overkill/hmg.qh>
10 #include <common/mutators/mutator/overkill/rpc.qh>
12 .bool m_isloot; ///< Holds whether item is loot.
14 entity Item_Create(string class_name, vector position)
16 entity item = spawn();
17 item.classname = class_name;
18 item.spawnfunc_checked = true;
19 Item_Initialize(item, class_name);
24 setorigin(item, position);
28 void Item_Initialize(entity item, string class_name)
32 case "item_health_small":
34 spawnfunc_item_health_small(item);
37 case "item_health_medium":
39 spawnfunc_item_health_medium(item);
42 case "item_health_big":
43 case "item_health_large":
45 spawnfunc_item_health_big(item);
48 case "item_health_mega":
50 spawnfunc_item_health_mega(item);
53 case "item_armor_small":
55 spawnfunc_item_armor_small(item);
58 case "item_armor_medium":
60 spawnfunc_item_armor_medium(item);
63 case "item_armor_big":
64 case "item_armor_large":
66 spawnfunc_item_armor_big(item);
69 case "item_armor_mega":
71 spawnfunc_item_armor_mega(item);
76 spawnfunc_item_shells(item);
81 spawnfunc_item_bullets(item);
86 spawnfunc_item_rockets(item);
91 spawnfunc_item_cells(item);
96 spawnfunc_item_plasma(item);
101 spawnfunc_item_fuel(item);
104 case "weapon_blaster":
107 spawnfunc_weapon_blaster(item);
110 case "weapon_shotgun":
112 spawnfunc_weapon_shotgun(item);
115 case "weapon_machinegun":
118 spawnfunc_weapon_machinegun(item);
121 case "weapon_mortar":
122 case "weapon_grenadelauncher":
124 spawnfunc_weapon_mortar(item);
127 case "weapon_electro":
129 spawnfunc_weapon_electro(item);
132 case "weapon_crylink":
134 spawnfunc_weapon_crylink(item);
137 case "weapon_vortex":
140 spawnfunc_weapon_vortex(item);
145 spawnfunc_weapon_hagar(item);
148 case "weapon_devastator":
149 case "weapon_rocketlauncher":
151 spawnfunc_weapon_devastator(item);
154 case "weapon_shockwave":
156 spawnfunc_weapon_shockwave(item);
161 spawnfunc_weapon_arc(item);
166 spawnfunc_weapon_hook(item);
171 spawnfunc_weapon_tuba(item);
176 spawnfunc_weapon_porto(item);
179 case "weapon_fireball":
181 spawnfunc_weapon_fireball(item);
184 case "weapon_minelayer":
186 spawnfunc_weapon_minelayer(item);
191 spawnfunc_weapon_hlac(item);
195 case "weapon_campingrifle":
196 case "weapon_sniperrifle":
198 spawnfunc_weapon_rifle(item);
201 case "weapon_seeker":
203 spawnfunc_weapon_seeker(item);
206 case "weapon_vaporizer":
207 case "weapon_minstanex":
209 spawnfunc_weapon_vaporizer(item);
214 spawnfunc_weapon_hmg(item);
219 spawnfunc_weapon_rpc(item);
222 case "item_strength":
224 spawnfunc_item_strength(item);
227 case "item_invincible":
229 spawnfunc_item_invincible(item);
232 case "item_fuel_regen":
234 spawnfunc_item_fuel_regen(item);
239 spawnfunc_item_jetpack(item);
242 case "item_vaporizer_cells":
244 spawnfunc_item_vaporizer_cells(item);
247 case "item_invisibility":
249 instagib_invisibility(item);
252 case "item_extralife":
254 instagib_extralife(item);
259 instagib_speed(item);
263 error("Item_Initialize: Invalid classname ", class_name);
266 entity Item_CreateLoot(string class_name, vector position, vector vel,
269 entity item = spawn();
270 if (!Item_InitializeLoot(item, class_name, position, vel, time_to_live))
277 bool Item_InitializeLoot(entity item, string class_name, vector position,
278 vector vel, float time_to_live)
280 item.classname = class_name;
281 Item_SetLoot(item, true);
283 item.pickup_anyway = true;
284 item.spawnfunc_checked = true;
285 Item_Initialize(item, class_name);
291 setorigin(item, position);
293 SUB_SetFade(item, time + time_to_live, 1);
297 bool Item_IsLoot(entity item)
299 return item.m_isloot || (item.classname == "droppedweapon");
302 void Item_SetLoot(entity item, bool loot)
304 item.m_isloot = loot;
307 spawnfunc(item_health_small)
309 StartItem(this, ITEM_HealthSmall);
312 spawnfunc(item_health_medium)
314 StartItem(this, ITEM_HealthMedium);
317 spawnfunc(item_health_big)
319 StartItem(this, ITEM_HealthBig);
322 spawnfunc(item_health_mega)
324 StartItem(this, ITEM_HealthMega);
327 spawnfunc(item_armor_small)
329 StartItem(this, ITEM_ArmorSmall);
332 spawnfunc(item_armor_medium)
334 StartItem(this, ITEM_ArmorMedium);
337 spawnfunc(item_armor_big)
339 StartItem(this, ITEM_ArmorBig);
342 spawnfunc(item_armor_mega)
344 StartItem(this, ITEM_ArmorMega);
347 spawnfunc(item_shells)
349 if (!weaponswapping && autocvar_sv_q3acompat_machineshotgunswap &&
350 (this.classname != "droppedweapon"))
352 weaponswapping = true;
353 spawnfunc_item_bullets(this);
354 weaponswapping = false;
357 StartItem(this, ITEM_Shells);
360 spawnfunc(item_bullets)
362 if (!weaponswapping && autocvar_sv_q3acompat_machineshotgunswap &&
363 (this.classname != "droppedweapon"))
365 weaponswapping = true;
366 spawnfunc_item_shells(this);
367 weaponswapping = false;
370 StartItem(this, ITEM_Bullets);
373 spawnfunc(item_rockets)
375 StartItem(this, ITEM_Rockets);
378 spawnfunc(item_cells)
380 StartItem(this, ITEM_Cells);
383 spawnfunc(item_plasma)
385 StartItem(this, ITEM_Plasma);
390 StartItem(this, ITEM_JetpackFuel);
393 spawnfunc(item_strength)
395 StartItem(this, ITEM_Strength);
398 spawnfunc(item_invincible)
400 StartItem(this, ITEM_Shield);
403 spawnfunc(item_fuel_regen)
405 if (start_items & ITEM_JetpackRegen.m_itemid)
407 spawnfunc_item_fuel(this);
410 StartItem(this, ITEM_JetpackRegen);
413 spawnfunc(item_jetpack)
415 if(start_items & ITEM_Jetpack.m_itemid)
417 spawnfunc_item_fuel(this);
420 StartItem(this, ITEM_Jetpack);
423 // Compatibility spawn functions
425 spawnfunc(item_armor1)
427 this.classname = "item_armor_small";
428 spawnfunc_item_armor_small(this); // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
431 spawnfunc(item_armor25)
433 this.classname = "item_armor_mega";
434 spawnfunc_item_armor_mega(this);
437 spawnfunc(item_armor_large)
439 this.classname = "item_armor_mega";
440 spawnfunc_item_armor_mega(this);
443 spawnfunc(item_health1)
445 this.classname = "item_health_small";
446 spawnfunc_item_health_small(this);
449 spawnfunc(item_health25)
451 this.classname = "item_health_medium";
452 spawnfunc_item_health_medium(this);
455 spawnfunc(item_health_large)
457 this.classname = "item_health_big";
458 spawnfunc_item_health_big(this);
461 spawnfunc(item_health100)
463 this.classname = "item_health_mega";
464 spawnfunc_item_health_mega(this);