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, bool no_align)
18 entity item = spawn();
19 item.classname = class_name;
20 item.spawnfunc_checked = true;
21 setorigin(item, position);
22 item.noalign = no_align;
23 Item_Initialize(item, class_name);
31 void Item_Initialize(entity item, string class_name)
33 FOREACH(Weapons, it.m_canonical_spawnfunc == class_name,
35 weapon_defaultspawnfunc(item, it);
38 FOREACH(Items, it.m_canonical_spawnfunc == class_name,
43 LOG_FATALF("Item_Initialize: Invalid classname: %s", class_name);
46 entity Item_CreateLoot(string class_name, vector position, vector vel,
49 entity item = spawn();
50 if (!Item_InitializeLoot(item, class_name, position, vel, time_to_live))
57 bool Item_InitializeLoot(entity item, string class_name, vector position,
58 vector vel, float time_to_live)
60 item.classname = class_name;
61 Item_SetLoot(item, true);
63 setorigin(item, position);
64 item.pickup_anyway = true;
65 item.spawnfunc_checked = true;
66 Item_Initialize(item, class_name);
73 SUB_SetFade(item, time + time_to_live, 1);
77 bool Item_IsLoot(entity item)
82 void Item_SetLoot(entity item, bool loot)
87 bool Item_ShouldKeepPosition(entity item)
89 return item.noalign || (item.spawnflags & 1);
92 bool Item_IsExpiring(entity item)
94 return item.m_isexpiring;
97 void Item_SetExpiring(entity item, bool expiring)
99 item.m_isexpiring = expiring;
102 // Compatibility spawn functions
104 // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
105 SPAWNFUNC_ITEM(item_armor1, ITEM_ArmorSmall)
107 SPAWNFUNC_ITEM(item_armor25, ITEM_ArmorMega)
109 SPAWNFUNC_ITEM(item_armor_large, ITEM_ArmorMega)
111 SPAWNFUNC_ITEM(item_health1, ITEM_HealthSmall)
113 SPAWNFUNC_ITEM(item_health25, ITEM_HealthMedium)
115 SPAWNFUNC_ITEM(item_health_large, ITEM_HealthBig)
117 SPAWNFUNC_ITEM(item_health100, ITEM_HealthMega)
119 SPAWNFUNC_ITEM(item_quad, ITEM_Strength)