]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/items/item.qh
Merge branch 'martin-t/warns' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items / item.qh
index 7a12b305006754776fd9ff90af756c916032d594..b7fc933e8b5dbaf35dde8a37fca1762c51a4e08a 100644 (file)
@@ -1,60 +1,93 @@
-#ifndef GAMEITEM_H
-#define GAMEITEM_H
-
-const int IT_UNLIMITED_WEAPON_AMMO             =       1; // when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup.
-const int IT_UNLIMITED_SUPERWEAPONS            =       2; // when this bit is set, superweapons don't expire. Checkpoints can give this powerup.
-const int IT_CTF_SHIELDED                      =       4; // set for the flag shield
-const int IT_USING_JETPACK                     =       8; // confirmation that button is pressed
-const int IT_JETPACK                           =      16; // actual item
-const int IT_FUEL_REGEN                        =      32; // fuel regeneration trigger
-// where is 64... ?
-const int IT_FUEL                                      =     128;
-// -Wdouble-declaration
-#define IT_SHELLS                                        256
-// -Wdouble-declaration
-#define IT_NAILS                                         512
-// -Wdouble-declaration
-#define IT_ROCKETS                                      1024
-// -Wdouble-declaration
-#define IT_CELLS                                        2048
-const int IT_SUPERWEAPON                               =    4096;
-const int IT_STRENGTH                                  =    8192;
-const int IT_INVINCIBLE                                =   16384;
-const int IT_HEALTH                                    =   32768;
-const int IT_PLASMA                                    =   65536;
-
-// shared value space (union):
-       // for items:
-       // -Wdouble-declaration
-       #define IT_KEY1                                                 131072
-       // -Wdouble-declaration
-       #define IT_KEY2                                                 262144
-// end
-
-const int IT_5HP                               =  524288;
-const int IT_25HP                              = 1048576;
-const int IT_ARMOR_SHARD                       = 2097152;
-const int IT_ARMOR                             = 4194304;
+#pragma once
+
+#ifdef GAMEQC
+#include <common/models/all.qh>
+#include <common/sounds/all.qh>
+#include <common/sounds/all.inc>
+#include <common/stats.qh>
+#endif
+
+const int IT_UNLIMITED_WEAPON_AMMO             =  BIT(0); // when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup.
+const int IT_UNLIMITED_SUPERWEAPONS            =  BIT(1); // when this bit is set, superweapons don't expire. Checkpoints can give this powerup.
+
+const int IT_JETPACK                           =  BIT(2); // actual item
+const int IT_USING_JETPACK                     =  BIT(3); // confirmation that button is pressed
+const int IT_FUEL_REGEN                        =  BIT(4); // fuel regeneration trigger
+
+const int IT_FUEL                                      =  BIT(5);
+const int IT_SHELLS                     =  BIT(6);
+const int IT_NAILS                      =  BIT(7);
+const int IT_ROCKETS                    =  BIT(8);
+const int IT_CELLS                      =  BIT(9);
+const int IT_PLASMA                                    = BIT(10);
+
+const int IT_5HP                               = BIT(11);
+const int IT_25HP                              = BIT(12);
+const int IT_HEALTH                                    = BIT(13);
+
+const int IT_ARMOR_SHARD                       = BIT(14);
+const int IT_ARMOR                             = BIT(15);
+
+const int IT_KEY1                                              = BIT(16);
+const int IT_KEY2                                              = BIT(17);
+
+const int IT_CTF_SHIELDED                      = BIT(18); // set for the flag shield
+
+// special colorblend meaning in engine
+const int IT_INVISIBILITY                              = BIT(19);
+const int IT_INVINCIBLE                                = BIT(20);
+const int IT_SUPERWEAPON                               = BIT(21); // suit
+const int IT_STRENGTH                                  = BIT(22);
 
 // item masks
-const int IT_AMMO                              =    3968; // IT_FUEL | IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS | IT_PLASMA;
-const int IT_PICKUPMASK                        =      51; // IT_FUEL_REGEN | IT_JETPACK | IT_UNLIMITED_AMMO; // strength and invincible are handled separately
-const int IT_UNLIMITED_AMMO                    =       3; // IT_UNLIMITED_SUPERWEAPONS | IT_UNLIMITED_WEAPON_AMMO;
+const int IT_UNLIMITED_AMMO                    = IT_UNLIMITED_WEAPON_AMMO | IT_UNLIMITED_SUPERWEAPONS;
+const int IT_PICKUPMASK                        = IT_UNLIMITED_AMMO | IT_JETPACK | IT_FUEL_REGEN; // strength and invincible are handled separately
+
+#ifdef SVQC
+.float  strength_finished = _STAT(STRENGTH_FINISHED);
+.float  invincible_finished = _STAT(INVINCIBLE_FINISHED);
+
+#define SPAWNFUNC_ITEM(name, item) \
+    spawnfunc(name) { StartItem(this, item); }
+
+#else
+
+#define SPAWNFUNC_ITEM(name, item)
+
+#endif
+
+enum
+{
+       ITEM_FLAG_NORMAL = BIT(0), ///< Item is usable during normal gameplay.
+       ITEM_FLAG_INSTAGIB = BIT(1), ///< Item is usable in instagib.
+       ITEM_FLAG_OVERKILL = BIT(2), ///< Item is usable in overkill.
+       ITEM_FLAG_MUTATORBLOCKED = BIT(3)
+};
 
 #define ITEM_HANDLE(signal, ...) __Item_Send_##signal(__VA_ARGS__)
-/** If you register a new item, make sure to add it to all.inc */
 CLASS(GameItem, Object)
-    ATTRIB(GameItem, m_id, int, 0)
-    ATTRIB(GameItem, m_name, string, string_null)
-    ATTRIB(GameItem, m_icon, string, string_null)
-    ATTRIB(GameItem, m_color, vector, '1 1 1')
-    ATTRIB(GameItem, m_waypoint, string, string_null)
-    ATTRIB(GameItem, m_waypointblink, int, 1)
-    METHOD(GameItem, display, void(entity this, void(string name, string icon) returns)) {
+    ATTRIB(GameItem, m_id, int, 0);
+    /** the canonical spawnfunc name */
+    ATTRIB(GameItem, m_canonical_spawnfunc, string);
+    METHOD(GameItem, m_spawnfunc_hookreplace, GameItem(GameItem this, entity e)) { return this; }
+    ATTRIB(GameItem, m_name, string);
+    ATTRIB(GameItem, m_icon, string);
+    ATTRIB(GameItem, m_color, vector, '1 1 1');
+    ATTRIB(GameItem, m_waypoint, string);
+    ATTRIB(GameItem, m_waypointblink, int, 1);
+#ifdef GAMEQC
+    ATTRIB(GameItem, m_glow, bool, false);
+    ATTRIB(GameItem, m_respawnsound, Sound, SND_ITEMRESPAWN);
+#endif
+    METHOD(GameItem, display, void(GameItem this, void(string name, string icon) returns))
+    {
+        TC(GameItem, this);
         returns(this.m_name, this.m_icon ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon) : string_null);
     }
-    METHOD(GameItem, show, void(entity this)) { LOG_INFO("A game item\n"); }
-    void ITEM_HANDLE(Show, entity this) { this.show(this); }
+    METHOD(GameItem, show, void(GameItem this))
+    {
+        TC(GameItem, this);
+        LOG_INFO("A game item");
+    }
+    void ITEM_HANDLE(Show, GameItem this) { this.show(this); }
 ENDCLASS(GameItem)
-
-#endif