#define WITH(it) this.m_##it;
#define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
-#define DEFINE(id, ...) \
- REGISTER_ITEM(id, Ammo, LAMBDA( \
- IF(SV, CONFIGURE \
- , respawntime = g_pickup_respawntime_ammo \
- , respawntimejitter = g_pickup_respawntimejitter_ammo \
- ) \
- MAP(IDENTITY, __VA_ARGS__) \
+#define DEFINE(id, ...) \
+ REGISTER_ITEM(id, Ammo, LAMBDA( \
+ IF(SV, CONFIGURE \
+ , respawntime = GET(g_pickup_respawntime_ammo) \
+ , respawntimejitter = GET(g_pickup_respawntimejitter_ammo) \
+ ) \
+ MAP(IDENTITY, __VA_ARGS__) \
))
DEFINE(Bullets
)
,IF(SV, CONFIGURE
, botvalue = BOT_PICKUP_RATING_LOW
- , respawntime = g_pickup_respawntime_short
- , respawntimejitter = g_pickup_respawntimejitter_short
+ , respawntime = GET(g_pickup_respawntime_short)
+ , respawntimejitter = GET(g_pickup_respawntimejitter_short)
)
)
)
,IF(SV, CONFIGURE
, botvalue = BOT_PICKUP_RATING_MID
- , respawntime = g_pickup_respawntime_medium
- , respawntimejitter = g_pickup_respawntimejitter_medium
+ , respawntime = GET(g_pickup_respawntime_medium)
+ , respawntimejitter = GET(g_pickup_respawntimejitter_medium)
)
)
)
,IF(SV, CONFIGURE
, botvalue = 20000 // FIXME: higher than BOT_PICKUP_RATING_HIGH?
- , respawntime = g_pickup_respawntime_long
- , respawntimejitter = g_pickup_respawntimejitter_long
+ , respawntime = GET(g_pickup_respawntime_long)
+ , respawntimejitter = GET(g_pickup_respawntimejitter_long)
)
)
)
,IF(SV, CONFIGURE
, botvalue = BOT_PICKUP_RATING_HIGH
- , respawntime = g_pickup_respawntime_long
- , respawntimejitter = g_pickup_respawntimejitter_long
+ , respawntime = GET(g_pickup_respawntime_long)
+ , respawntimejitter = GET(g_pickup_respawntimejitter_long)
)
)
)
,IF(SV, CONFIGURE
, botvalue = BOT_PICKUP_RATING_LOW
- , respawntime = g_pickup_respawntime_short
- , respawntimejitter = g_pickup_respawntimejitter_short
+ , respawntime = GET(g_pickup_respawntime_short)
+ , respawntimejitter = GET(g_pickup_respawntimejitter_short)
)
)
)
,IF(SV, CONFIGURE
, botvalue = BOT_PICKUP_RATING_MID
- , respawntime = g_pickup_respawntime_short
- , respawntimejitter = g_pickup_respawntimejitter_short
+ , respawntime = GET(g_pickup_respawntime_short)
+ , respawntimejitter = GET(g_pickup_respawntimejitter_short)
)
)
)
,IF(SV, CONFIGURE
, botvalue = BOT_PICKUP_RATING_MID
- , respawntime = g_pickup_respawntime_medium
- , respawntimejitter = g_pickup_respawntimejitter_medium
+ , respawntime = GET(g_pickup_respawntime_medium)
+ , respawntimejitter = GET(g_pickup_respawntimejitter_medium)
)
)
)
,IF(SV, CONFIGURE
, botvalue = BOT_PICKUP_RATING_HIGH
- , respawntime = g_pickup_respawntime_long
- , respawntimejitter = g_pickup_respawntimejitter_long
+ , respawntime = GET(g_pickup_respawntime_long)
+ , respawntimejitter = GET(g_pickup_respawntimejitter_long)
)
)
ATTRIB(Pickup, m_botvalue, int, 0)
ATTRIB(Pickup, m_itemflags, int, 0)
ATTRIB(Pickup, m_pickupevalfunc, float(entity player, entity item), generic_pickupevalfunc)
- ATTRIB(Pickup, m_respawntime, int, 0)
- ATTRIB(Pickup, m_respawntimejitter, int, 0)
+ ATTRIB(Pickup, m_respawntime, float(), func_null)
+ ATTRIB(Pickup, m_respawntimejitter, float(), func_null)
#endif
ENDCLASS(Pickup)
#ifdef SVQC
// For g_pickup_respawntime
#include "../../../server/defs.qh"
+// Getters to dynamically retrieve the values of g_pickup_respawntime* as they aren't autocvars
+GETTER(float, g_pickup_respawntime_weapon)
+GETTER(float, g_pickup_respawntime_superweapon)
+GETTER(float, g_pickup_respawntime_ammo)
+GETTER(float, g_pickup_respawntime_short)
+GETTER(float, g_pickup_respawntime_medium)
+GETTER(float, g_pickup_respawntime_long)
+GETTER(float, g_pickup_respawntime_powerup)
+GETTER(float, g_pickup_respawntimejitter_weapon)
+GETTER(float, g_pickup_respawntimejitter_superweapon)
+GETTER(float, g_pickup_respawntimejitter_ammo)
+GETTER(float, g_pickup_respawntimejitter_short)
+GETTER(float, g_pickup_respawntimejitter_medium)
+GETTER(float, g_pickup_respawntimejitter_long)
+GETTER(float, g_pickup_respawntimejitter_powerup)
#endif
bool Pickup_respondTo(entity this, int request)
#define WITH(it) this.m_##it;
#define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
-#define DEFINE(id, ...) \
- REGISTER_ITEM(id, Ammo, LAMBDA( \
- IF(SV, CONFIGURE \
- , botvalue = 100000 \
- , itemflags = FL_POWERUP \
- , respawntime = g_pickup_respawntime_powerup \
- , respawntimejitter = g_pickup_respawntimejitter_powerup \
- ) \
- MAP(IDENTITY, __VA_ARGS__) \
+#define DEFINE(id, ...) \
+ REGISTER_ITEM(id, Ammo, LAMBDA( \
+ IF(SV, CONFIGURE \
+ , botvalue = 100000 \
+ , itemflags = FL_POWERUP \
+ , respawntime = GET(g_pickup_respawntime_powerup) \
+ , respawntimejitter = GET(g_pickup_respawntimejitter_powerup) \
+ ) \
+ MAP(IDENTITY, __VA_ARGS__) \
))
DEFINE(Strength
#define IF(pred, f, ...) pred(f, __VA_ARGS__)
+#define GET(name) name##get
+#define GETTER(type, name) type GET(name)() { return name; }
+
#define BIT(n) (1 << (n))
#ifndef BRANCHLESS_BITSET
#define BITSET(var, mask, flag) (flag ? (var) | (mask) : (var) &~ (mask))
void StartItemA (entity a)
{
- StartItem(a.m_model, a.m_sound, a.m_respawntime, a.m_respawntimejitter, a.m_name, a.m_itemid, 0, a.m_itemflags, a.m_pickupevalfunc, a.m_botvalue);
+ StartItem(a.m_model, a.m_sound, a.m_respawntime(), a.m_respawntimejitter(), a.m_name, a.m_itemid, 0, a.m_itemflags, a.m_pickupevalfunc, a.m_botvalue);
}
void spawnfunc_item_rockets (void) {