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 void Item_Initialize(entity item, string class_name)
17 case "item_health_small":
19 spawnfunc_item_health_small(item);
22 case "item_health_medium":
24 spawnfunc_item_health_medium(item);
27 case "item_health_big":
28 case "item_health_large":
30 spawnfunc_item_health_big(item);
33 case "item_health_mega":
35 spawnfunc_item_health_mega(item);
38 case "item_armor_small":
40 spawnfunc_item_armor_small(item);
43 case "item_armor_medium":
45 spawnfunc_item_armor_medium(item);
48 case "item_armor_big":
49 case "item_armor_large":
51 spawnfunc_item_armor_big(item);
54 case "item_armor_mega":
56 spawnfunc_item_armor_mega(item);
61 spawnfunc_item_shells(item);
66 spawnfunc_item_bullets(item);
71 spawnfunc_item_rockets(item);
76 spawnfunc_item_cells(item);
81 spawnfunc_item_plasma(item);
86 spawnfunc_item_fuel(item);
89 case "weapon_blaster":
92 spawnfunc_weapon_blaster(item);
95 case "weapon_shotgun":
97 spawnfunc_weapon_shotgun(item);
100 case "weapon_machinegun":
103 spawnfunc_weapon_machinegun(item);
106 case "weapon_mortar":
107 case "weapon_grenadelauncher":
109 spawnfunc_weapon_mortar(item);
112 case "weapon_electro":
114 spawnfunc_weapon_electro(item);
117 case "weapon_crylink":
119 spawnfunc_weapon_crylink(item);
122 case "weapon_vortex":
125 spawnfunc_weapon_vortex(item);
130 spawnfunc_weapon_hagar(item);
133 case "weapon_devastator":
134 case "weapon_rocketlauncher":
136 spawnfunc_weapon_devastator(item);
139 case "weapon_shockwave":
141 spawnfunc_weapon_shockwave(item);
146 spawnfunc_weapon_arc(item);
151 spawnfunc_weapon_hook(item);
156 spawnfunc_weapon_tuba(item);
161 spawnfunc_weapon_porto(item);
164 case "weapon_fireball":
166 spawnfunc_weapon_fireball(item);
169 case "weapon_minelayer":
171 spawnfunc_weapon_minelayer(item);
176 spawnfunc_weapon_hlac(item);
180 case "weapon_campingrifle":
181 case "weapon_sniperrifle":
183 spawnfunc_weapon_rifle(item);
186 case "weapon_seeker":
188 spawnfunc_weapon_seeker(item);
191 case "weapon_vaporizer":
192 case "weapon_minstanex":
194 spawnfunc_weapon_vaporizer(item);
197 case "item_strength":
199 spawnfunc_item_strength(item);
202 case "item_invincible":
204 spawnfunc_item_invincible(item);
207 case "item_fuel_regen":
209 spawnfunc_item_fuel_regen(item);
214 spawnfunc_item_jetpack(item);
217 case "item_vaporizer_cells":
219 spawnfunc_item_vaporizer_cells(item);
222 case "item_invisibility":
224 instagib_invisibility(item);
227 case "item_extralife":
229 instagib_extralife(item);
234 instagib_speed(item);
238 error("Item_Initialize: Invalid classname ", class_name);
241 entity Item_CreateLoot(string class_name, vector position, vector vel,
244 entity item = spawn();
245 if (!Item_InitializeLoot(item, class_name, position, vel, time_to_live))
252 bool Item_InitializeLoot(entity item, string class_name, vector position,
253 vector vel, float time_to_live)
255 item.classname = class_name;
256 Item_SetLoot(item, true);
258 item.pickup_anyway = true;
259 item.spawnfunc_checked = true;
260 Item_Initialize(item, class_name);
266 setorigin(item, position);
268 SUB_SetFade(item, time + time_to_live, 1);
272 bool Item_IsLoot(entity item)
274 return item.m_isloot || (item.classname == "droppedweapon");
277 void Item_SetLoot(entity item, bool loot)
279 item.m_isloot = loot;
282 spawnfunc(item_health_small)
284 StartItem(this, ITEM_HealthSmall);
287 spawnfunc(item_health_medium)
289 StartItem(this, ITEM_HealthMedium);
292 spawnfunc(item_health_big)
294 StartItem(this, ITEM_HealthBig);
297 spawnfunc(item_health_mega)
299 StartItem(this, ITEM_HealthMega);
302 spawnfunc(item_armor_small)
304 StartItem(this, ITEM_ArmorSmall);
307 spawnfunc(item_armor_medium)
309 StartItem(this, ITEM_ArmorMedium);
312 spawnfunc(item_armor_big)
314 StartItem(this, ITEM_ArmorBig);
317 spawnfunc(item_armor_mega)
319 StartItem(this, ITEM_ArmorMega);
322 spawnfunc(item_shells)
324 if (!weaponswapping && autocvar_sv_q3acompat_machineshotgunswap &&
325 (this.classname != "droppedweapon"))
327 weaponswapping = true;
328 spawnfunc_item_bullets(this);
329 weaponswapping = false;
332 StartItem(this, ITEM_Shells);
335 spawnfunc(item_bullets)
337 if (!weaponswapping && autocvar_sv_q3acompat_machineshotgunswap &&
338 (this.classname != "droppedweapon"))
340 weaponswapping = true;
341 spawnfunc_item_shells(this);
342 weaponswapping = false;
345 StartItem(this, ITEM_Bullets);
348 spawnfunc(item_rockets)
350 StartItem(this, ITEM_Rockets);
353 spawnfunc(item_cells)
355 StartItem(this, ITEM_Cells);
358 spawnfunc(item_plasma)
360 StartItem(this, ITEM_Plasma);
365 StartItem(this, ITEM_JetpackFuel);
368 spawnfunc(item_strength)
370 StartItem(this, ITEM_Strength);
373 spawnfunc(item_invincible)
375 StartItem(this, ITEM_Shield);
378 spawnfunc(item_fuel_regen)
380 if (start_items & ITEM_JetpackRegen.m_itemid)
382 spawnfunc_item_fuel(this);
385 StartItem(this, ITEM_JetpackRegen);
388 spawnfunc(item_jetpack)
390 if(start_items & ITEM_Jetpack.m_itemid)
392 spawnfunc_item_fuel(this);
395 StartItem(this, ITEM_Jetpack);
398 // Compatibility spawn functions
400 spawnfunc(item_armor1) { spawnfunc_item_armor_small(this); } // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
401 spawnfunc(item_armor25) { spawnfunc_item_armor_mega(this); }
402 spawnfunc(item_armor_large) { spawnfunc_item_armor_mega(this); }
403 spawnfunc(item_health1) { spawnfunc_item_health_small(this); }
404 spawnfunc(item_health25) { spawnfunc_item_health_medium(this); }
405 spawnfunc(item_health_large) { spawnfunc_item_health_big(this); }
406 spawnfunc(item_health100) { spawnfunc_item_health_mega(this); }
410 this.classname = "item_strength";
411 spawnfunc_item_strength(this);