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>
10 .bool m_isloot; ///< Holds whether item is loot.
12 void Item_Initialize(entity item, string class_name)
16 case "item_health_small":
18 StartItem(item, ITEM_HealthSmall);
21 case "item_health_medium":
23 StartItem(item, ITEM_HealthMedium);
26 case "item_health_big":
27 case "item_health_large":
29 StartItem(item, ITEM_HealthBig);
32 case "item_health_mega":
34 StartItem(item, ITEM_HealthMega);
37 case "item_armor_small":
39 StartItem(item, ITEM_ArmorSmall);
42 case "item_armor_medium":
44 StartItem(item, ITEM_ArmorMedium);
47 case "item_armor_big":
48 case "item_armor_large":
50 StartItem(item, ITEM_ArmorBig);
53 case "item_armor_mega":
55 StartItem(item, ITEM_ArmorMega);
60 StartItem(item, ITEM_Shells);
65 StartItem(item, ITEM_Bullets);
70 StartItem(item, ITEM_Rockets);
75 StartItem(item, ITEM_Cells);
80 StartItem(item, ITEM_Plasma);
85 StartItem(item, ITEM_JetpackFuel);
88 case "weapon_blaster":
91 weapon_defaultspawnfunc(item, WEP_BLASTER);
94 case "weapon_shotgun":
96 weapon_defaultspawnfunc(item, WEP_SHOTGUN);
99 case "weapon_machinegun":
102 weapon_defaultspawnfunc(item, WEP_MACHINEGUN);
105 case "weapon_mortar":
106 case "weapon_grenadelauncher":
108 weapon_defaultspawnfunc(item, WEP_MORTAR);
111 case "weapon_electro":
113 weapon_defaultspawnfunc(item, WEP_ELECTRO);
116 case "weapon_crylink":
118 weapon_defaultspawnfunc(item, WEP_CRYLINK);
121 case "weapon_vortex":
124 weapon_defaultspawnfunc(item, WEP_VORTEX);
129 weapon_defaultspawnfunc(item, WEP_HAGAR);
132 case "weapon_devastator":
133 case "weapon_rocketlauncher":
135 weapon_defaultspawnfunc(item, WEP_DEVASTATOR);
138 case "weapon_shockwave":
140 weapon_defaultspawnfunc(item, WEP_SHOCKWAVE);
145 weapon_defaultspawnfunc(item, WEP_ARC);
150 weapon_defaultspawnfunc(item, WEP_HOOK);
155 weapon_defaultspawnfunc(item, WEP_TUBA);
160 weapon_defaultspawnfunc(item, WEP_PORTO);
163 case "weapon_fireball":
165 weapon_defaultspawnfunc(item, WEP_FIREBALL);
168 case "weapon_minelayer":
170 weapon_defaultspawnfunc(item, WEP_MINE_LAYER);
175 weapon_defaultspawnfunc(item, WEP_HLAC);
179 case "weapon_campingrifle":
180 case "weapon_sniperrifle":
182 weapon_defaultspawnfunc(item, WEP_RIFLE);
185 case "weapon_seeker":
187 weapon_defaultspawnfunc(item, WEP_SEEKER);
190 case "weapon_vaporizer":
191 case "weapon_minstanex":
193 weapon_defaultspawnfunc(item, WEP_VAPORIZER);
196 case "item_strength":
198 StartItem(item, ITEM_Strength);
201 case "item_invincible":
203 StartItem(item, ITEM_Shield);
206 case "item_fuel_regen":
208 StartItem(item, ITEM_JetpackRegen);
213 StartItem(item, ITEM_Jetpack);
217 error("Item_Initialize: Invalid classname");
220 entity Item_CreateLoot(string class_name, vector position, vector vel,
223 entity item = spawn();
224 if (!Item_InitializeLoot(item, class_name, position, vel, time_to_live))
231 bool Item_InitializeLoot(entity item, string class_name, vector position,
232 vector vel, float time_to_live)
234 item.classname = class_name;
235 Item_SetLoot(item, true);
237 item.pickup_anyway = true;
238 item.spawnfunc_checked = true;
239 Item_Initialize(item, class_name);
245 setorigin(item, position);
247 SUB_SetFade(item, time + time_to_live, 1);
251 bool Item_IsLoot(entity item)
253 return item.m_isloot || (item.classname == "droppedweapon");
256 void Item_SetLoot(entity item, bool loot)
258 item.m_isloot = loot;