]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use the new item system for ammo
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 10 May 2015 11:12:47 +0000 (21:12 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 10 May 2015 11:12:47 +0000 (21:12 +1000)
qcsrc/common/items/all.qc
qcsrc/common/items/item.qh
qcsrc/common/items/item/ammo.qc
qcsrc/common/items/item/ammo.qh
qcsrc/server/t_items.qc
qcsrc/server/t_items.qh

index 1700ae9fbe4e71013dca7b89de60fad0bb481804..460f77fcbffd9127e567c679f83d31141ff2b57b 100644 (file)
@@ -1,3 +1,5 @@
+#ifndef ALL_C
+#define ALL_C
 #include "all.qh"
 
 #include "all.inc"
@@ -9,3 +11,5 @@ void ItemTest()
         ITEM_SEND(Default, it);
     }));
 }
+
+#endif
index cf2779aa02efc505977711a8f36d22593b275b9b..1c8939beb09800d497c9eab75f581c3bcc981075 100644 (file)
@@ -28,8 +28,10 @@ ITEM_SIGNALS(ITEM_SEND)
 
 int ITEM_COUNT;
 #define REGISTER_ITEM(id, class, body)          \
+    entity ITEM_##id;                           \
     void RegisterItems_##id() {                 \
         const noref entity this = NEW(class);   \
+        ITEM_##id = this;                       \
         ITEMS[ITEM_COUNT++] = this;             \
         body                                    \
     }                                           \
index 5868eeb844c5df86a8be2a9bc43893842dbe763f..9bce0839a28a1cb7fa00952100188f0659bf5f57 100644 (file)
@@ -1,11 +1,50 @@
 #include "ammo.qh"
+#include "../../../server/t_items.qh"
 
-#define REGISTER_AMMO(id) REGISTER_ITEM(id, Ammo, LAMBDA(this.ammoName = #id))
-REGISTER_AMMO(nails)
-REGISTER_AMMO(rockets)
-REGISTER_AMMO(cells)
-REGISTER_AMMO(plasma)
-REGISTER_AMMO(fuel)
+#define REGISTER_AMMO(id, model, sound, name, itemid, basevalue) \
+REGISTER_ITEM(id, Ammo, LAMBDA({    \
+    this.ammoModel = model;         \
+    this.ammoSound = sound;         \
+    this.ammoName = name;           \
+    this.ammoId = itemid;           \
+    this.ammoQuantity = basevalue;  \
+}))
+
+REGISTER_AMMO(Bullets,
+    "models/items/a_bullets.mdl",
+    "misc/itempickup.wav",
+    "bullets",
+    IT_NAILS,
+    2000
+)
+REGISTER_AMMO(Cells,
+    "models/items/a_cells.md3",
+    "misc/itempickup.wav",
+    "cells",
+    IT_ROCKETS,
+    2000
+)
+REGISTER_AMMO(Plasma,
+    "models/items/a_cells.md3",
+    "misc/itempickup.wav",
+    "plasma",
+    IT_ROCKETS,
+    2000
+)
+REGISTER_AMMO(Rockets,
+    "models/items/a_rockets.md3",
+    "misc/itempickup.wav",
+    "rockets",
+    IT_ROCKETS,
+    3000
+)
+REGISTER_AMMO(Shells,
+    "models/items/a_shells.md3",
+    "misc/itempickup.wav",
+    "shells",
+    IT_SHELLS,
+    500
+)
 
 bool Ammo_respondTo(entity this, int request)
 {
index 412ccc2d27f16edc45ee3b673b3870dd20068142..4ff7babfb03aff41e83e1d926ab516bab44b5a0c 100644 (file)
@@ -3,6 +3,10 @@
 #include "../item.qh"
 CLASS(Ammo, GameItem)
     METHOD(Ammo, respondTo, bool(entity, int))
+    ATTRIB(Ammo, ammoModel, string, string_null)
+    ATTRIB(Ammo, ammoSound, string, string_null)
     ATTRIB(Ammo, ammoName, string, string_null)
+    ATTRIB(Ammo, ammoId, int, 0)
+    ATTRIB(Ammo, ammoQuantity, int, 0)
 ENDCLASS(Ammo)
 #endif
index 6839091f4a4b4f5a97af1578dc94a7da832f487c..cb507fc204a15159664e4f6c68634522ad948d2e 100644 (file)
@@ -1,5 +1,7 @@
 #include "t_items.qh"
 
+#include "../common/items/all.qc"
+
 #if defined(SVQC)
     #include "_all.qh"
 
@@ -1151,12 +1153,18 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
                return;
        }
 }
+
+void StartItemA (entity a)
+{
+    StartItem(a.ammoModel, a.ammoSound, g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, a.ammoName, a.ammoId, 0, 0, commodity_pickupevalfunc, a.ammoQuantity);
+}
+
 void spawnfunc_item_rockets (void) {
        if(!self.ammo_rockets)
                self.ammo_rockets = g_pickup_rockets;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/a_rockets.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "rockets", IT_ROCKETS, 0, 0, commodity_pickupevalfunc, 3000);
+    StartItemA (ITEM_Rockets);
 }
 
 void spawnfunc_item_bullets (void) {
@@ -1174,7 +1182,7 @@ void spawnfunc_item_bullets (void) {
                self.ammo_nails = g_pickup_nails;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/a_bullets.mdl", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "bullets", IT_NAILS, 0, 0, commodity_pickupevalfunc, 2000);
+    StartItemA (ITEM_Bullets);
 }
 
 void spawnfunc_item_cells (void) {
@@ -1182,7 +1190,7 @@ void spawnfunc_item_cells (void) {
                self.ammo_cells = g_pickup_cells;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/a_cells.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "cells", IT_CELLS, 0, 0, commodity_pickupevalfunc, 2000);
+       StartItemA (ITEM_Cells);
 }
 
 void spawnfunc_item_plasma()
@@ -1191,7 +1199,7 @@ void spawnfunc_item_plasma()
                self.ammo_plasma = g_pickup_plasma;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/a_cells.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "plasma", IT_PLASMA, 0, 0, commodity_pickupevalfunc, 2000);
+       StartItemA (ITEM_Plasma);
 }
 
 void spawnfunc_item_shells (void) {
@@ -1209,7 +1217,7 @@ void spawnfunc_item_shells (void) {
                self.ammo_shells = g_pickup_shells;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/a_shells.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "shells", IT_SHELLS, 0, 0, commodity_pickupevalfunc, 500);
+       StartItemA (ITEM_Shells);
 }
 
 void spawnfunc_item_armor_small (void) {
index 7470d2f05b70feedf6a15e1a6e06095ec6c2b4c6..a33e45a82c388acbb55dd9cf59fe4c1819752803 100644 (file)
@@ -11,13 +11,13 @@ const int IT_FUEL_REGEN                     =      32; // fuel regeneration trigger
 // where is 64... ?
 const int IT_FUEL                                      =     128;
 // -Wdouble-declaration
-// const int IT_SHELLS                                 =     256;
+#define IT_SHELLS                                        256
 // -Wdouble-declaration
-// const int IT_NAILS                                  =     512;
+#define IT_NAILS                                         512
 // -Wdouble-declaration
-// const int IT_ROCKETS                                =    1024;
+#define IT_ROCKETS                                      1024
 // -Wdouble-declaration
-// const int IT_CELLS                                  =    2048;
+#define IT_CELLS                                        2048
 const int IT_SUPERWEAPON                               =    4096;
 const int IT_STRENGTH                                  =    8192;
 const int IT_INVINCIBLE                                =   16384;