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.
13 entity Item_Create(string class_name, vector position)
15 entity item = spawn();
16 item.classname = class_name;
17 item.spawnfunc_checked = true;
18 Item_Initialize(item, class_name);
23 setorigin(item, position);
27 void Item_Initialize(entity item, string class_name)
29 FOREACH(Weapons, it.m_canonical_spawnfunc == class_name,
31 weapon_defaultspawnfunc(item, it);
34 FOREACH(Items, it.m_canonical_spawnfunc == class_name,
39 LOG_FATALF("Item_Initialize: Invalid classname: %s", class_name);
42 entity Item_CreateLoot(string class_name, vector position, vector vel,
45 entity item = spawn();
46 if (!Item_InitializeLoot(item, class_name, position, vel, time_to_live))
53 bool Item_InitializeLoot(entity item, string class_name, vector position,
54 vector vel, float time_to_live)
56 item.classname = class_name;
57 Item_SetLoot(item, true);
59 item.pickup_anyway = true;
60 item.spawnfunc_checked = true;
61 Item_Initialize(item, class_name);
67 setorigin(item, position);
69 SUB_SetFade(item, time + time_to_live, 1);
73 bool Item_IsLoot(entity item)
75 return item.m_isloot || (item.classname == "droppedweapon");
78 void Item_SetLoot(entity item, bool loot)
83 // Compatibility spawn functions
85 // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
86 SPAWNFUNC_ITEM(item_armor1, ITEM_ArmorSmall)
88 SPAWNFUNC_ITEM(item_armor25, ITEM_ArmorMega)
90 SPAWNFUNC_ITEM(item_armor_large, ITEM_ArmorMega)
92 SPAWNFUNC_ITEM(item_health1, ITEM_HealthSmall)
94 SPAWNFUNC_ITEM(item_health25, ITEM_HealthMedium)
96 SPAWNFUNC_ITEM(item_health_large, ITEM_HealthBig)
98 SPAWNFUNC_ITEM(item_health100, ITEM_HealthMega)
100 SPAWNFUNC_ITEM(item_quad, ITEM_Strength)