]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/items/item/ammo.qh
Remove some unnecessary item bits, increase maximum items to 32 now that the item...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items / item / ammo.qh
index f240578b3295f7f7f50978245c123e01f61d3dfa..22d2826fe7db98fe59b9c2a9e0c981ba02d17db1 100644 (file)
 #pragma once
 
 #include "pickup.qh"
+#include <common/items/all.qh>
+#ifdef SVQC
+    #include <common/t_items.qh>
+    #include <server/resources.qh>
+#endif
+
+#if 1
+.int ammo_none;
+.int ammo_shells;
+.int ammo_nails;
+.int ammo_rockets;
+.int ammo_cells;
+#ifdef SVQC
+const .int ammo_plasma = _STAT(PLASMA);
+const .int ammo_fuel = _STAT(FUEL);
+#else
+.int ammo_plasma;
+.int ammo_fuel;
+#endif
+#endif
+
+#ifdef GAMEQC
+.int spawnflags;
+#endif
+
+#ifdef SVQC
+PROPERTY(float, g_pickup_ammo_anyway);
+#endif
+
 CLASS(Ammo, Pickup)
 #ifdef SVQC
     ATTRIB(Ammo, m_pickupevalfunc, float(entity player, entity item), ammo_pickupevalfunc);
     ATTRIB(Ammo, m_respawntime, float(), GET(g_pickup_respawntime_ammo));
     ATTRIB(Ammo, m_respawntimejitter, float(), GET(g_pickup_respawntimejitter_ammo));
+    ATTRIB(Ammo, m_pickupanyway, float(), GET(g_pickup_ammo_anyway));
 #endif
 ENDCLASS(Ammo)
 
-#ifdef SVQC
-    #include <common/t_items.qh>
-#endif
 
 #ifdef GAMEQC
 MODEL(Bullets_ITEM, Item_Model("a_bullets.mdl"));
 #endif
 
-REGISTER_ITEM(Bullets, Ammo) {
+#ifdef SVQC
+PROPERTY(int, g_pickup_nails);
+void ammo_bullets_init(Pickup this, entity item)
+{
+    if(!GetResource(item, RES_BULLETS))
+        SetResourceExplicit(item, RES_BULLETS, g_pickup_nails);
+}
+#endif
+
+CLASS(Bullets, Ammo)
+ENDCLASS(Bullets)
+
+REGISTER_ITEM(Bullets, Bullets) {
+    this.m_canonical_spawnfunc = "item_bullets";
 #ifdef GAMEQC
+       this.spawnflags = ITEM_FLAG_NORMAL | ITEM_FLAG_RESOURCE;
     this.m_model    =   MDL_Bullets_ITEM;
 #endif
-    this.m_name     =   "bullets";
+    this.netname    =   "bullets";
+    this.m_name     =   _("bullets");
     this.m_icon     =   "ammo_bullets";
 #ifdef SVQC
     this.m_botvalue =   1500;
-    this.m_itemid   =   IT_NAILS;
+    this.m_itemid   =   IT_RESOURCE;
+    this.m_iteminit =   ammo_bullets_init;
 #endif
 }
 
+SPAWNFUNC_ITEM(item_bullets, ITEM_Bullets)
+
 #ifdef GAMEQC
 MODEL(Cells_ITEM, Item_Model("a_cells.md3"));
 #endif
 
+#ifdef SVQC
+PROPERTY(int, g_pickup_cells);
+void ammo_cells_init(Pickup this, entity item)
+{
+    if(!GetResource(item, RES_CELLS))
+        SetResourceExplicit(item, RES_CELLS, g_pickup_cells);
+}
+#endif
 REGISTER_ITEM(Cells, Ammo) {
+    this.m_canonical_spawnfunc = "item_cells";
 #ifdef GAMEQC
+       this.spawnflags = ITEM_FLAG_NORMAL | ITEM_FLAG_RESOURCE;
     this.m_model    =   MDL_Cells_ITEM;
 #endif
-    this.m_name     =   "cells";
+    this.netname    =   "cells";
+    this.m_name     =   _("cells");
     this.m_icon     =   "ammo_cells";
 #ifdef SVQC
     this.m_botvalue =   1500;
-    this.m_itemid   =   IT_CELLS;
+    this.m_itemid   =   IT_RESOURCE;
+    this.m_iteminit =   ammo_cells_init;
 #endif
 }
 
+SPAWNFUNC_ITEM(item_cells, ITEM_Cells)
+
 #ifdef GAMEQC
 MODEL(Plasma_ITEM, Item_Model("a_cells.md3"));
 #endif
 
+#ifdef SVQC
+PROPERTY(int, g_pickup_plasma);
+void ammo_plasma_init(Pickup this, entity item)
+{
+    if(!GetResource(item, RES_PLASMA))
+        SetResourceExplicit(item, RES_PLASMA, g_pickup_plasma);
+}
+#endif
 REGISTER_ITEM(Plasma, Ammo) {
+    this.m_canonical_spawnfunc = "item_plasma";
 #ifdef GAMEQC
+       this.spawnflags = ITEM_FLAG_NORMAL | ITEM_FLAG_RESOURCE;
     this.m_model    =   MDL_Plasma_ITEM;
 #endif
-    this.m_name     =   "plasma";
+    this.netname    =   "plasma";
+    this.m_name     =   _("plasma");
     this.m_icon     =   "ammo_plasma";
 #ifdef SVQC
     this.m_botvalue =   1500;
-    this.m_itemid   =   IT_PLASMA;
+    this.m_itemid   =   IT_RESOURCE;
+    this.m_iteminit =   ammo_plasma_init;
 #endif
 }
 
+SPAWNFUNC_ITEM(item_plasma, ITEM_Plasma)
+
 #ifdef GAMEQC
 MODEL(Rockets_ITEM, Item_Model("a_rockets.md3"));
 #endif
 
+#ifdef SVQC
+PROPERTY(int, g_pickup_rockets);
+void ammo_rockets_init(Pickup this, entity item)
+{
+    if(!GetResource(item, RES_ROCKETS))
+        SetResourceExplicit(item, RES_ROCKETS, g_pickup_rockets);
+}
+#endif
 REGISTER_ITEM(Rockets, Ammo) {
+    this.m_canonical_spawnfunc = "item_rockets";
 #ifdef GAMEQC
+       this.spawnflags = ITEM_FLAG_NORMAL | ITEM_FLAG_RESOURCE;
     this.m_model    =   MDL_Rockets_ITEM;
 #endif
-    this.m_name     =   "rockets";
+    this.netname    =   "rockets";
+    this.m_name     =   _("rockets");
     this.m_icon     =   "ammo_rockets";
 #ifdef SVQC
     this.m_botvalue =   1500;
-    this.m_itemid   =   IT_ROCKETS;
+    this.m_itemid   =   IT_RESOURCE;
+    this.m_iteminit =   ammo_rockets_init;
 #endif
 }
 
+SPAWNFUNC_ITEM(item_rockets, ITEM_Rockets)
+
 #ifdef GAMEQC
 MODEL(Shells_ITEM, Item_Model("a_shells.md3"));
 #endif
 
-REGISTER_ITEM(Shells, Ammo) {
+#ifdef SVQC
+PROPERTY(int, g_pickup_shells);
+void ammo_shells_init(Pickup this, entity item)
+{
+    if(!GetResource(item, RES_SHELLS))
+        SetResourceExplicit(item, RES_SHELLS, g_pickup_shells);
+}
+#endif
+
+CLASS(Shells, Ammo)
+ENDCLASS(Shells)
+
+REGISTER_ITEM(Shells, Shells) {
+    this.m_canonical_spawnfunc = "item_shells";
 #ifdef GAMEQC
+       this.spawnflags = ITEM_FLAG_NORMAL | ITEM_FLAG_RESOURCE;
     this.m_model    =   MDL_Shells_ITEM;
 #endif
-    this.m_name     =   "shells";
+    this.netname    =   "shells";
+    this.m_name     =   _("shells");
     this.m_icon     =   "ammo_shells";
 #ifdef SVQC
     this.m_botvalue =   1000;
-    this.m_itemid   =   IT_SHELLS;
+    this.m_itemid   =   IT_RESOURCE;
+    this.m_iteminit =   ammo_shells_init;
 #endif
 }
+
+SPAWNFUNC_ITEM(item_shells, ITEM_Shells)