X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fitems%2Fitem.qh;h=8ba0096713342a7c7a5364b95ffe8fb58674c2e2;hp=b7fc933e8b5dbaf35dde8a37fca1762c51a4e08a;hb=565754a35f9e84a3b8e6eac08635ec27145b369a;hpb=b34b4a1dbfe6c43ce6ffbec3ad7af782bcb561db diff --git a/qcsrc/common/items/item.qh b/qcsrc/common/items/item.qh index b7fc933e8..8ba009671 100644 --- a/qcsrc/common/items/item.qh +++ b/qcsrc/common/items/item.qh @@ -7,7 +7,11 @@ #include #endif -const int IT_UNLIMITED_WEAPON_AMMO = BIT(0); // when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup. +#ifdef SVQC +#include +#endif + +const int IT_UNLIMITED_AMMO = BIT(0); // when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup. const int IT_UNLIMITED_SUPERWEAPONS = BIT(1); // when this bit is set, superweapons don't expire. Checkpoints can give this powerup. const int IT_JETPACK = BIT(2); // actual item @@ -40,15 +44,33 @@ const int IT_SUPERWEAPON = BIT(21); // suit const int IT_STRENGTH = BIT(22); // item masks -const int IT_UNLIMITED_AMMO = IT_UNLIMITED_WEAPON_AMMO | IT_UNLIMITED_SUPERWEAPONS; -const int IT_PICKUPMASK = IT_UNLIMITED_AMMO | IT_JETPACK | IT_FUEL_REGEN; // strength and invincible are handled separately +const int IT_PICKUPMASK = IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS | IT_JETPACK | IT_FUEL_REGEN; // strength and invincible are handled separately #ifdef SVQC -.float strength_finished = _STAT(STRENGTH_FINISHED); -.float invincible_finished = _STAT(INVINCIBLE_FINISHED); +const .float strength_finished = _STAT(STRENGTH_FINISHED); +const .float invincible_finished = _STAT(INVINCIBLE_FINISHED); + +#define spawnfunc_body(item) \ + if (!Item_IsDefinitionAllowed(item)) \ + { \ + startitem_failed = true; \ + delete(this); \ + return; \ + } \ + StartItem(this, item) #define SPAWNFUNC_ITEM(name, item) \ - spawnfunc(name) { StartItem(this, item); } + spawnfunc(name) \ + { \ + spawnfunc_body(item); \ + } + +#define SPAWNFUNC_ITEM_COND(name, cond, item1, item2) \ + spawnfunc(name) \ + { \ + entity item = (cond) ? item1 : item2; \ + spawnfunc_body(item); \ + } #else @@ -59,9 +81,8 @@ const int IT_PICKUPMASK = IT_UNLIMITED_AMMO | IT_JETPACK | IT_FU enum { ITEM_FLAG_NORMAL = BIT(0), ///< Item is usable during normal gameplay. - ITEM_FLAG_INSTAGIB = BIT(1), ///< Item is usable in instagib. - ITEM_FLAG_OVERKILL = BIT(2), ///< Item is usable in overkill. - ITEM_FLAG_MUTATORBLOCKED = BIT(3) + ITEM_FLAG_MUTATORBLOCKED = BIT(1), + ITEM_FLAG_RESOURCE = BIT(2) ///< Item is is a resource, not a held item. }; #define ITEM_HANDLE(signal, ...) __Item_Send_##signal(__VA_ARGS__)