]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/items.qc
Update the weapon ammo notification to point people to the developers
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / items.qc
index 23124730fab631094b82938f07048d7d79d52886..b21df78e3f247cb53b809446f95a555c25c86bcb 100644 (file)
@@ -5,22 +5,55 @@
 /// game items.
 /// \copyright GNU GPLv2 or any later version.
 
-#include "g_subs.qh"
+#include <server/mutators/_mod.qh>
 #include <common/weapons/all.qh>
+#include <common/mapobjects/subs.qh>
 
 .bool m_isloot; ///< Holds whether item is loot.
+/// \brief Holds whether strength, shield or superweapon timers expire while
+/// this item is on the ground.
+.bool m_isexpiring;
 
-entity Item_Create(string class_name, vector position)
+entity Item_FindDefinition(string class_name)
+{
+       FOREACH(Items, it.m_canonical_spawnfunc == class_name,
+       {
+               return it;
+       });
+       FOREACH(Weapons, it.m_canonical_spawnfunc == class_name,
+       {
+               return it.m_pickup;
+       });
+       return NULL;
+}
+
+bool Item_IsAllowed(string class_name)
+{
+       entity definition = Item_FindDefinition(class_name);
+       if (definition == NULL)
+       {
+               return false;
+       }
+       return Item_IsDefinitionAllowed(definition);
+}
+
+bool Item_IsDefinitionAllowed(entity definition)
+{
+       return !MUTATOR_CALLHOOK(FilterItemDefinition, definition);
+}
+
+entity Item_Create(string class_name, vector position, bool no_align)
 {
        entity item = spawn();
        item.classname = class_name;
        item.spawnfunc_checked = true;
+       setorigin(item, position);
+       item.noalign = no_align;
        Item_Initialize(item, class_name);
        if (wasfreed(item))
        {
                return NULL;
        }
-       setorigin(item, position);
        return item;
 }
 
@@ -56,6 +89,7 @@ bool Item_InitializeLoot(entity item, string class_name, vector position,
        item.classname = class_name;
        Item_SetLoot(item, true);
        item.noalign = true;
+       setorigin(item, position);
        item.pickup_anyway = true;
        item.spawnfunc_checked = true;
        Item_Initialize(item, class_name);
@@ -64,7 +98,6 @@ bool Item_InitializeLoot(entity item, string class_name, vector position,
                return false;
        }
        item.gravity = 1;
-       setorigin(item, position);
        item.velocity = vel;
        SUB_SetFade(item, time + time_to_live, 1);
        return true;
@@ -72,7 +105,7 @@ bool Item_InitializeLoot(entity item, string class_name, vector position,
 
 bool Item_IsLoot(entity item)
 {
-       return item.m_isloot || (item.classname == "droppedweapon");
+       return item.m_isloot;
 }
 
 void Item_SetLoot(entity item, bool loot)
@@ -80,6 +113,21 @@ void Item_SetLoot(entity item, bool loot)
        item.m_isloot = loot;
 }
 
+bool Item_ShouldKeepPosition(entity item)
+{
+       return item.noalign || (item.spawnflags & 1);
+}
+
+bool Item_IsExpiring(entity item)
+{
+       return item.m_isexpiring;
+}
+
+void Item_SetExpiring(entity item, bool expiring)
+{
+       item.m_isexpiring = expiring;
+}
+
 // Compatibility spawn functions
 
 // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard