4 /// \brief Source file that contains implementation of the functions related to
6 /// \copyright GNU GPLv2 or any later version.
9 #include <common/weapons/all.qh>
11 .bool m_isloot; ///< Holds whether item is loot.
12 /// \brief Holds whether strength, shield or superweapon timers expire while
13 /// this item is on the ground.
16 entity Item_Create(string class_name, vector position)
18 entity item = spawn();
19 item.classname = class_name;
20 item.spawnfunc_checked = true;
21 Item_Initialize(item, class_name);
26 setorigin(item, position);
30 void Item_Initialize(entity item, string class_name)
32 FOREACH(Weapons, it.m_canonical_spawnfunc == class_name,
34 weapon_defaultspawnfunc(item, it);
37 FOREACH(Items, it.m_canonical_spawnfunc == class_name,
42 LOG_FATALF("Item_Initialize: Invalid classname: %s", class_name);
45 entity Item_CreateLoot(string class_name, vector position, vector vel,
48 entity item = spawn();
49 if (!Item_InitializeLoot(item, class_name, position, vel, time_to_live))
56 bool Item_InitializeLoot(entity item, string class_name, vector position,
57 vector vel, float time_to_live)
59 item.classname = class_name;
60 Item_SetLoot(item, true);
62 item.pickup_anyway = true;
63 item.spawnfunc_checked = true;
64 Item_Initialize(item, class_name);
70 setorigin(item, position);
72 SUB_SetFade(item, time + time_to_live, 1);
76 bool Item_IsLoot(entity item)
78 return item.m_isloot || (item.classname == "droppedweapon");
81 void Item_SetLoot(entity item, bool loot)
86 bool Item_IsExpiring(entity item)
88 return item.m_isexpiring;
91 void Item_SetExpiring(entity item, bool expiring)
93 item.m_isexpiring = expiring;
96 // Compatibility spawn functions
98 // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
99 SPAWNFUNC_ITEM(item_armor1, ITEM_ArmorSmall)
101 SPAWNFUNC_ITEM(item_armor25, ITEM_ArmorMega)
103 SPAWNFUNC_ITEM(item_armor_large, ITEM_ArmorMega)
105 SPAWNFUNC_ITEM(item_health1, ITEM_HealthSmall)
107 SPAWNFUNC_ITEM(item_health25, ITEM_HealthMedium)
109 SPAWNFUNC_ITEM(item_health_large, ITEM_HealthBig)
111 SPAWNFUNC_ITEM(item_health100, ITEM_HealthMega)
113 SPAWNFUNC_ITEM(item_quad, ITEM_Strength)