]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/items/item/health.qc
Support #ifdef in item declarations
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items / item / health.qc
index 33f6ccfb0ad881ec7cd94238afc7a79d511ec7bb..fb2f23f8c3601a382e6085a7fe051935d0fd9a4c 100644 (file)
@@ -2,50 +2,65 @@
 #include "../../../server/t_items.qh"
 
 #define WITH(it) this.m_##it;
+#define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
+#define DEFINE(id, ...) REGISTER_ITEM(id, Health, MAP(IDENTITY, __VA_ARGS__))
 
-#define REGISTER_HEALTH(id, ...)        \
-    REGISTER_ITEM(id, Health, LAMBDA({  \
-        MAP(WITH, __VA_ARGS__)          \
-    }))
-
-REGISTER_HEALTH(HealthSmall
-    , model             =   "models/items/g_h1.md3"
-    , sound             =   "misc/minihealth.wav"
-    , respawntime       =   SPAWNTIME_SHORT
-    , respawntimejitter =   SPAWNTIME_SHORT
-    , name              =   "5 Health"
-    , itemid            =   IT_5HP
-    , botvalue          =   BOT_PICKUP_RATING_LOW
+DEFINE(HealthSmall
+    ,IF(ALL, CONFIGURE
+    ,   model               =   "models/items/g_h1.md3"
+    ,   sound               =   "misc/minihealth.wav"
+    ,   name                =   "5 Health"
+    ,   itemid              =   IT_5HP
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   BOT_PICKUP_RATING_LOW
+    ,   respawntime         =   SPAWNTIME_SHORT
+    ,   respawntimejitter   =   SPAWNTIME_SHORT
+    )
 )
 
-REGISTER_HEALTH(HealthMedium
-    , model             =   "models/items/g_h25.md3"
-    , sound             =   "misc/mediumhealth.wav"
-    , respawntime       =   SPAWNTIME_SHORT
-    , respawntimejitter =   SPAWNTIME_SHORT
-    , name              =   "25 Health"
-    , itemid            =   IT_25HP
-    , botvalue          =   BOT_PICKUP_RATING_MID
+DEFINE(HealthMedium
+    ,IF(ALL, CONFIGURE
+    ,   model               =   "models/items/g_h25.md3"
+    ,   sound               =   "misc/mediumhealth.wav"
+    ,   name                =   "25 Health"
+    ,   itemid              =   IT_25HP
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   BOT_PICKUP_RATING_MID
+    ,   respawntime         =   SPAWNTIME_SHORT
+    ,   respawntimejitter   =   SPAWNTIME_SHORT
+    )
 )
 
-REGISTER_HEALTH(HealthLarge
-    , model             =   "models/items/g_h50.md3"
-    , sound             =   "misc/mediumhealth.wav"
-    , respawntime       =   SPAWNTIME_MEDIUM
-    , respawntimejitter =   SPAWNTIME_MEDIUM
-    , name              =   "50 Health"
-    , itemid            =   IT_25HP
-    , botvalue          =   BOT_PICKUP_RATING_MID
+DEFINE(HealthLarge
+    ,IF(ALL, CONFIGURE
+    ,   model               =   "models/items/g_h50.md3"
+    ,   sound               =   "misc/mediumhealth.wav"
+    ,   name                =   "50 Health"
+    ,   itemid              =   IT_25HP
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   BOT_PICKUP_RATING_MID
+    ,   respawntime         =   SPAWNTIME_MEDIUM
+    ,   respawntimejitter   =   SPAWNTIME_MEDIUM
+    )
 )
 
-REGISTER_HEALTH(HealthMega
-    , model             =   "models/items/g_h100.md3"
-    , sound             =   "misc/megahealth.wav"
-    , respawntime       =   SPAWNTIME_LONG
-    , respawntimejitter =   SPAWNTIME_LONG
-    , name              =   "100 Health"
-    , itemid            =   IT_HEALTH
-    , botvalue          =   BOT_PICKUP_RATING_HIGH
+DEFINE(HealthMega
+    ,IF(ALL, CONFIGURE
+    ,   model               =   "models/items/g_h100.md3"
+    ,   sound               =   "misc/megahealth.wav"
+    ,   name                =   "100 Health"
+    ,   itemid              =   IT_HEALTH
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   BOT_PICKUP_RATING_HIGH
+    ,   respawntime         =   SPAWNTIME_LONG
+    ,   respawntimejitter   =   SPAWNTIME_LONG
+    )
 )
 
 #undef WITH
+#undef CONFIGURE
+#undef DEFINE