]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/items/item/pickup.qh
Merge branch 'master' into Mario/overkill
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items / item / pickup.qh
index 1bd644a7c3e5f81a8f55fe4fab524c373b5a2a69..26771e68d09e2ef325bdf23cc8ec272ce275e51c 100644 (file)
@@ -1,49 +1,60 @@
-#ifndef PICKUP_H
-#define PICKUP_H
-#include "../item.qh"
-CLASS(Pickup, GameItem)
-    METHOD(Pickup, respondTo, bool(entity, int))
-    ATTRIB(Pickup, m_model, string, string_null)
-    ATTRIB(Pickup, m_sound, string, string_null)
-    ATTRIB(Pickup, m_name, string, string_null)
-    ATTRIB(Pickup, m_itemid, int, 0)
-#ifdef SVQC
-    ATTRIB(Pickup, m_botvalue, int, 0)
-    ATTRIB(Pickup, m_itemflags, int, 0)
-    ATTRIB(Pickup, m_pickupevalfunc, float(entity player, entity item), generic_pickupevalfunc)
-    ATTRIB(Pickup, m_respawntime, float(), func_null)
-    ATTRIB(Pickup, m_respawntimejitter, float(), func_null)
-#endif
-ENDCLASS(Pickup)
+#pragma once
 
 #ifdef SVQC
-// For g_pickup_respawntime
-#include "../../../server/defs.qh"
-// Getters to dynamically retrieve the values of g_pickup_respawntime* as they aren't autocvars
-GETTER(float, g_pickup_respawntime_weapon)
-GETTER(float, g_pickup_respawntime_superweapon)
-GETTER(float, g_pickup_respawntime_ammo)
-GETTER(float, g_pickup_respawntime_short)
-GETTER(float, g_pickup_respawntime_medium)
-GETTER(float, g_pickup_respawntime_long)
-GETTER(float, g_pickup_respawntime_powerup)
-GETTER(float, g_pickup_respawntimejitter_weapon)
-GETTER(float, g_pickup_respawntimejitter_superweapon)
-GETTER(float, g_pickup_respawntimejitter_ammo)
-GETTER(float, g_pickup_respawntimejitter_short)
-GETTER(float, g_pickup_respawntimejitter_medium)
-GETTER(float, g_pickup_respawntimejitter_long)
-GETTER(float, g_pickup_respawntimejitter_powerup)
+PROPERTY(float, g_pickup_respawntime_weapon)
+PROPERTY(float, g_pickup_respawntime_superweapon)
+PROPERTY(float, g_pickup_respawntime_ammo)
+PROPERTY(float, g_pickup_respawntime_short)
+PROPERTY(float, g_pickup_respawntime_medium)
+PROPERTY(float, g_pickup_respawntime_long)
+PROPERTY(float, g_pickup_respawntime_powerup)
+PROPERTY(float, g_pickup_respawntimejitter_weapon)
+PROPERTY(float, g_pickup_respawntimejitter_superweapon)
+PROPERTY(float, g_pickup_respawntimejitter_ammo)
+PROPERTY(float, g_pickup_respawntimejitter_short)
+PROPERTY(float, g_pickup_respawntimejitter_medium)
+PROPERTY(float, g_pickup_respawntimejitter_long)
+PROPERTY(float, g_pickup_respawntimejitter_powerup)
 #endif
 
-bool Pickup_respondTo(entity this, int request)
-{
-    switch (request) {
-        default: return false;
-        case ITEM_SIGNAL(Default):
-            print(strcat(this.m_name, " responding\n"));
-            return true;
-    }
-}
+#include <common/items/inventory.qh>
+#include <common/items/item.qh>
+#include <common/t_items.qh>
 
+CLASS(Pickup, GameItem)
+#ifdef GAMEQC
+    ATTRIB(Pickup, m_model, Model);
+    ATTRIB(Pickup, m_sound, Sound, SND_ITEMPICKUP);
 #endif
+    ATTRIB(Pickup, m_name, string);
+    METHOD(Pickup, show, void(Pickup this))
+    {
+        TC(Pickup, this);
+        LOG_INFOF("%s: %s\n", etos(this), this.m_name);
+    }
+    ATTRIB(Pickup, m_itemid, int, 0);
+#ifdef SVQC
+    ATTRIB(Pickup, m_mins, vector, '-16 -16 0');
+    ATTRIB(Pickup, m_maxs, vector, '16 16 32');
+    ATTRIB(Pickup, m_botvalue, int, 0);
+    ATTRIB(Pickup, m_itemflags, int, 0);
+    float generic_pickupevalfunc(entity player, entity item);
+    ATTRIB(Pickup, m_pickupevalfunc, float(entity player, entity item), generic_pickupevalfunc);
+    ATTRIB(Pickup, m_respawntime, float());
+    ATTRIB(Pickup, m_respawntimejitter, float());
+    ATTRIB(Pickup, m_pickupanyway, float());
+    float Item_GiveTo(entity item, entity player);
+    METHOD(Pickup, giveTo, bool(Pickup this, entity item, entity player))
+    {
+        TC(Pickup, this);
+        bool b = Item_GiveTo(item, player);
+        if (b) {
+            LOG_DEBUGF("entity %i picked up %s", player, this.m_name);
+            player.inventory.inv_items[this.m_id]++;
+            Inventory_update(player);
+        }
+        return b;
+    }
+    bool ITEM_HANDLE(Pickup, Pickup this, entity item, entity player);
+#endif
+ENDCLASS(Pickup)