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)
30 FOREACH(Weapons, it.m_canonical_spawnfunc == class_name,
32 weapon_defaultspawnfunc(item, it);
35 FOREACH(Items, it.m_canonical_spawnfunc == class_name,
40 LOG_FATALF("Item_Initialize: Invalid classname: %s", class_name);
43 entity Item_CreateLoot(string class_name, vector position, vector vel,
46 entity item = spawn();
47 if (!Item_InitializeLoot(item, class_name, position, vel, time_to_live))
54 bool Item_InitializeLoot(entity item, string class_name, vector position,
55 vector vel, float time_to_live)
57 item.classname = class_name;
58 Item_SetLoot(item, true);
60 item.pickup_anyway = true;
61 item.spawnfunc_checked = true;
62 Item_Initialize(item, class_name);
68 setorigin(item, position);
70 SUB_SetFade(item, time + time_to_live, 1);
74 bool Item_IsLoot(entity item)
76 return item.m_isloot || (item.classname == "droppedweapon");
79 void Item_SetLoot(entity item, bool loot)
84 // Compatibility spawn functions
86 // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
87 SPAWNFUNC_ITEM(item_armor1, ITEM_ArmorSmall)
89 SPAWNFUNC_ITEM(item_armor25, ITEM_ArmorMega)
91 SPAWNFUNC_ITEM(item_armor_large, ITEM_ArmorMega)
93 SPAWNFUNC_ITEM(item_health1, ITEM_HealthSmall)
95 SPAWNFUNC_ITEM(item_health25, ITEM_HealthMedium)
97 SPAWNFUNC_ITEM(item_health_large, ITEM_HealthBig)
99 SPAWNFUNC_ITEM(item_health100, ITEM_HealthMega)
101 SPAWNFUNC_ITEM(item_quad, ITEM_Strength)