#include "../../../server/t_items.qh"
#define WITH(it) this.m_##it;
+#define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
+#define DEFINE(id, ...) \
+ REGISTER_ITEM(id, Ammo, LAMBDA( \
+ IF(SV, CONFIGURE \
+ , respawntime = SPAWNTIME_AMMO \
+ , respawntimejitter = SPAWNTIME_AMMO \
+ ) \
+ MAP(IDENTITY, __VA_ARGS__) \
+ ))
-#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
- , model = "models/items/a_bullets.mdl"
- , sound = "misc/itempickup.wav"
- , name = "bullets"
- , itemid = IT_NAILS
- , botvalue = 2000
+DEFINE(Bullets
+ ,IF(ALL, CONFIGURE
+ , model = "models/items/a_bullets.mdl"
+ , sound = "misc/itempickup.wav"
+ , name = "bullets"
+ , itemid = IT_NAILS
+ )
+ ,IF(SV, CONFIGURE
+ , botvalue = 2000
+ )
)
-REGISTER_AMMO(Cells
- , model = "models/items/a_cells.md3"
- , sound = "misc/itempickup.wav"
- , name = "cells"
- , itemid = IT_ROCKETS
- , botvalue = 2000
+DEFINE(Cells
+ ,IF(ALL, CONFIGURE
+ , model = "models/items/a_cells.md3"
+ , sound = "misc/itempickup.wav"
+ , name = "cells"
+ , itemid = IT_ROCKETS
+ )
+ ,IF(SV, CONFIGURE
+ , botvalue = 2000
+ )
)
-REGISTER_AMMO(Plasma
- , model = "models/items/a_cells.md3"
- , sound = "misc/itempickup.wav"
- , name = "plasma"
- , itemid = IT_ROCKETS
- , botvalue = 2000
+DEFINE(Plasma
+ ,IF(ALL, CONFIGURE
+ , model = "models/items/a_cells.md3"
+ , sound = "misc/itempickup.wav"
+ , name = "plasma"
+ , itemid = IT_ROCKETS
+ )
+ ,IF(SV, CONFIGURE
+ , botvalue = 2000
+ )
)
-REGISTER_AMMO(Rockets
- , model = "models/items/a_rockets.md3"
- , sound = "misc/itempickup.wav"
- , name = "rockets"
- , itemid = IT_ROCKETS
- , botvalue = 3000
+DEFINE(Rockets
+ ,IF(ALL, CONFIGURE
+ , model = "models/items/a_rockets.md3"
+ , sound = "misc/itempickup.wav"
+ , name = "rockets"
+ , itemid = IT_ROCKETS
+ )
+ ,IF(SV, CONFIGURE
+ , botvalue = 3000
+ )
)
-REGISTER_AMMO(Shells
- , model = "models/items/a_shells.md3"
- , sound = "misc/itempickup.wav"
- , name = "shells"
- , itemid = IT_SHELLS
- , botvalue = 500
+DEFINE(Shells
+ ,IF(ALL, CONFIGURE
+ , model = "models/items/a_shells.md3"
+ , sound = "misc/itempickup.wav"
+ , name = "shells"
+ , itemid = IT_SHELLS
+ )
+ ,IF(SV, CONFIGURE
+ , botvalue = 500
+ )
)
#undef WITH
+#undef CONFIGURE
+#undef DEFINE
#include "../../../server/t_items.qh"
#define WITH(it) this.m_##it;
+#define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
+#define DEFINE(id, ...) REGISTER_ITEM(id, Armor, MAP(IDENTITY, __VA_ARGS__))
-#define REGISTER_ARMOR(id, ...) \
- REGISTER_ITEM(id, Armor, LAMBDA({ \
- MAP(WITH, __VA_ARGS__) \
- }))
-
-REGISTER_ARMOR(ArmorSmall
- , model = "models/items/item_armor_small.md3"
- , sound = "misc/armor1.wav"
- , respawntime = SPAWNTIME_SHORT
- , respawntimejitter = SPAWNTIME_SHORT
- , name = "5 Armor"
- , itemid = IT_ARMOR_SHARD
- , botvalue = BOT_PICKUP_RATING_LOW
+DEFINE(ArmorSmall
+ ,IF(ALL, CONFIGURE
+ , model = "models/items/item_armor_small.md3"
+ , sound = "misc/armor1.wav"
+ , name = "5 Armor"
+ , itemid = IT_ARMOR_SHARD
+ )
+ ,IF(SV, CONFIGURE
+ , botvalue = BOT_PICKUP_RATING_LOW
+ , respawntime = SPAWNTIME_SHORT
+ , respawntimejitter = SPAWNTIME_SHORT
+ )
)
-REGISTER_ARMOR(ArmorMedium
- , model = "models/items/item_armor_medium.md3"
- , sound = "misc/armor10.wav"
- , respawntime = SPAWNTIME_MEDIUM
- , respawntimejitter = SPAWNTIME_MEDIUM
- , name = "25 Armor"
- , itemid = IT_ARMOR
- , botvalue = BOT_PICKUP_RATING_MID
+DEFINE(ArmorMedium
+ ,IF(ALL, CONFIGURE
+ , model = "models/items/item_armor_medium.md3"
+ , sound = "misc/armor10.wav"
+ , name = "25 Armor"
+ , itemid = IT_ARMOR
+ )
+ ,IF(SV, CONFIGURE
+ , botvalue = BOT_PICKUP_RATING_MID
+ , respawntime = SPAWNTIME_MEDIUM
+ , respawntimejitter = SPAWNTIME_MEDIUM
+ )
)
-REGISTER_ARMOR(ArmorBig
- , model = "models/items/item_armor_big.md3"
- , sound = "misc/armor17_5.wav"
- , respawntime = SPAWNTIME_LONG
- , respawntimejitter = SPAWNTIME_LONG
- , name = "50 Armor"
- , itemid = IT_ARMOR
- , botvalue = 20000 // FIXME: higher than BOT_PICKUP_RATING_HIGH?
+DEFINE(ArmorBig
+ ,IF(ALL, CONFIGURE
+ , model = "models/items/item_armor_big.md3"
+ , sound = "misc/armor17_5.wav"
+ , name = "50 Armor"
+ , itemid = IT_ARMOR
+ )
+ ,IF(SV, CONFIGURE
+ , botvalue = 20000 // FIXME: higher than BOT_PICKUP_RATING_HIGH?
+ , respawntime = SPAWNTIME_LONG
+ , respawntimejitter = SPAWNTIME_LONG
+ )
)
-REGISTER_ARMOR(ArmorLarge
- , model = "models/items/item_armor_large.md3"
- , sound = "misc/armor25.wav"
- , respawntime = SPAWNTIME_LONG
- , respawntimejitter = SPAWNTIME_LONG
- , name = "100 Armor"
- , itemid = IT_ARMOR
- , botvalue = BOT_PICKUP_RATING_HIGH
+DEFINE(ArmorLarge
+ ,IF(ALL, CONFIGURE
+ , model = "models/items/item_armor_large.md3"
+ , sound = "misc/armor25.wav"
+ , name = "100 Armor"
+ , itemid = IT_ARMOR
+ )
+ ,IF(SV, CONFIGURE
+ , botvalue = BOT_PICKUP_RATING_HIGH
+ , respawntime = SPAWNTIME_LONG
+ , respawntimejitter = SPAWNTIME_LONG
+ )
)
#undef WITH
+#undef CONFIGURE
+#undef DEFINE
#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
METHOD(Pickup, respondTo, bool(entity, int))
ATTRIB(Pickup, m_model, string, string_null)
ATTRIB(Pickup, m_sound, string, string_null)
- ATTRIB(Pickup, m_respawntime, int, 0)
- ATTRIB(Pickup, m_respawntimejitter, int, 0)
ATTRIB(Pickup, m_name, string, string_null)
ATTRIB(Pickup, m_itemid, int, 0)
+#ifdef SVQC
ATTRIB(Pickup, m_botvalue, int, 0)
+ ATTRIB(Pickup, m_respawntime, int, 0)
+ ATTRIB(Pickup, m_respawntimejitter, int, 0)
+#endif
ENDCLASS(Pickup)
#define SPAWNTIMES(_) \
#define MAP_19(f, it, ...) f(it)MAP_18(f, __VA_ARGS__)
#define MAP_20(f, it, ...) f(it)MAP_19(f, __VA_ARGS__)
+#define IDENTITY(it) it
+
+#ifdef SVQC
+ #define SV(f, ...) f(__VA_ARGS__)
+#else
+ #define SV(f, ...)
+#endif
+
+#ifdef CSQC
+ #define CL(f, ...) f(__VA_ARGS__)
+#else
+ #define CL(f, ...)
+#endif
+
+#define ALL(f, ...) f(__VA_ARGS__)
+
+#define IF(pred, f, ...) pred(f, __VA_ARGS__)
+
#define BIT(n) (1 << (n))
#ifndef BRANCHLESS_BITSET
#define BITSET(var, mask, flag) (flag ? (var) | (mask) : (var) &~ (mask))