X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fitems%2Fitem.qh;h=cf4e288ba6cd1769c127ef9ca27ab16ca8411579;hb=e0012447bfce1b551df3dc01b043655aa93dafad;hp=c302ae40281d43699b335ab24a7d382b7d3d667e;hpb=e87123e5fba23f7a8907e6fbab241c5eec5be168;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/items/item.qh b/qcsrc/common/items/item.qh index c302ae402..cf4e288ba 100644 --- a/qcsrc/common/items/item.qh +++ b/qcsrc/common/items/item.qh @@ -1,9 +1,14 @@ #pragma once -#include #ifdef GAMEQC +#include #include #include +#include +#endif + +#ifdef SVQC +#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. @@ -43,13 +48,50 @@ const int IT_UNLIMITED_AMMO = IT_UNLIMITED_WEAPON_AMMO | IT_UNLIMITE const int IT_PICKUPMASK = IT_UNLIMITED_AMMO | 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) \ + { \ + spawnfunc_body(item); \ + } + +#define SPAWNFUNC_ITEM_COND(name, cond, item1, item2) \ + spawnfunc(name) \ + { \ + entity item = (cond) ? item1 : item2; \ + spawnfunc_body(item); \ + } + +#else + +#define SPAWNFUNC_ITEM(name, item) + #endif +enum +{ + ITEM_FLAG_NORMAL = BIT(0), ///< Item is usable during normal gameplay. + 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__) CLASS(GameItem, Object) ATTRIB(GameItem, m_id, int, 0); + /** the canonical spawnfunc name */ + ATTRIB(GameItem, m_canonical_spawnfunc, string); + METHOD(GameItem, m_spawnfunc_hookreplace, GameItem(GameItem this, entity e)) { return this; } ATTRIB(GameItem, m_name, string); ATTRIB(GameItem, m_icon, string); ATTRIB(GameItem, m_color, vector, '1 1 1');