]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/items/item/ammo.qc
Do something awesome with macros
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items / item / ammo.qc
index a2381ab99ff991f8def7a0e2b1131cfa82023b19..dc0909d1ee8404f6aca32cf13b692ee508b1a992 100644 (file)
@@ -1,49 +1,49 @@
 #include "ammo.qh"
 #include "../../../server/t_items.qh"
 
-#define REGISTER_AMMO(id, model, sound, name, itemid, botvalue) \
-REGISTER_ITEM(id, Ammo, LAMBDA({                                \
-    this.m_model = model;                                       \
-    this.m_sound = sound;                                       \
-    this.m_respawntime = SPAWNTIME_AMMO;                        \
-    this.m_respawntimejitter = SPAWNTIME_AMMO;                  \
-    this.m_name = name;                                         \
-    this.m_itemid = itemid;                                     \
-    this.m_botvalue = botvalue;                                 \
-}))
+#define WITH(it) this.m_##it;
+
+#define REGISTER_AMMO(id, ...)                      \
+    REGISTER_ITEM(id, Ammo, LAMBDA({                \
+        MAP(WITH, __VA_ARGS__)                      \
+        this.m_respawntime = SPAWNTIME_AMMO;        \
+        this.m_respawntimejitter = SPAWNTIME_AMMO;  \
+    }))
 
 REGISTER_AMMO(Bullets
-    , "models/items/a_bullets.mdl"
-    , "misc/itempickup.wav"
-    , "bullets"
-    , IT_NAILS
-    , 2000
+    , model     = "models/items/a_bullets.mdl"
+    , sound     = "misc/itempickup.wav"
+    , name      = "bullets"
+    , itemid    = IT_NAILS
+    , botvalue  = 2000
 )
 REGISTER_AMMO(Cells
-    , "models/items/a_cells.md3"
-    , "misc/itempickup.wav"
-    , "cells"
-    , IT_ROCKETS
-    , 2000
+    , model     = "models/items/a_cells.md3"
+    , sound     = "misc/itempickup.wav"
+    , name      = "cells"
+    , itemid    = IT_ROCKETS
+    , botvalue  = 2000
 )
 REGISTER_AMMO(Plasma
-    , "models/items/a_cells.md3"
-    , "misc/itempickup.wav"
-    , "plasma"
-    , IT_ROCKETS
-    , 2000
+    , model     = "models/items/a_cells.md3"
+    , sound     = "misc/itempickup.wav"
+    , name      = "plasma"
+    , itemid    = IT_ROCKETS
+    , botvalue  = 2000
 )
 REGISTER_AMMO(Rockets
-    , "models/items/a_rockets.md3"
-    , "misc/itempickup.wav"
-    , "rockets"
-    , IT_ROCKETS
-    , 3000
+    , model     = "models/items/a_rockets.md3"
+    , sound     = "misc/itempickup.wav"
+    , name      = "rockets"
+    , itemid    = IT_ROCKETS
+    , botvalue  = 3000
 )
 REGISTER_AMMO(Shells
-    , "models/items/a_shells.md3"
-    , "misc/itempickup.wav"
-    , "shells"
-    , IT_SHELLS
-    , 500
+    , model     = "models/items/a_shells.md3"
+    , sound     = "misc/itempickup.wav"
+    , name      = "shells"
+    , itemid    = IT_SHELLS
+    , botvalue  = 500
 )
+
+#undef WITH