From: Lyberta Date: Fri, 10 Nov 2017 10:24:19 +0000 (+0300) Subject: Added ITEM_FLAG_INSTAGIB. X-Git-Tag: xonotic-v0.8.5~2426^2~8 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f47e7aa40af150936892797bc52bf0c2f09a4211;p=xonotic%2Fxonotic-data.pk3dir.git Added ITEM_FLAG_INSTAGIB. --- diff --git a/qcsrc/common/items/item.qh b/qcsrc/common/items/item.qh index 6ec6dd8a4..1d2c8d671 100644 --- a/qcsrc/common/items/item.qh +++ b/qcsrc/common/items/item.qh @@ -56,8 +56,10 @@ const int IT_PICKUPMASK = IT_UNLIMITED_AMMO | IT_JETPACK | IT_FU #endif -enum { - ITEM_FLAG_MUTATORBLOCKED = BIT(0) +enum +{ + ITEM_FLAG_INSTAGIB = BIT(0), ///< Item is usable in instagib. + ITEM_FLAG_MUTATORBLOCKED = BIT(1) }; #define ITEM_HANDLE(signal, ...) __Item_Send_##signal(__VA_ARGS__) diff --git a/qcsrc/common/mutators/mutator/instagib/items.qh b/qcsrc/common/mutators/mutator/instagib/items.qh index 597fddc11..e6354c936 100644 --- a/qcsrc/common/mutators/mutator/instagib/items.qh +++ b/qcsrc/common/mutators/mutator/instagib/items.qh @@ -24,7 +24,7 @@ void ammo_vaporizercells_init(entity item) #endif REGISTER_ITEM(VaporizerCells, Ammo) { this.m_canonical_spawnfunc = "item_vaporizer_cells"; - this.spawnflags = ITEM_FLAG_MUTATORBLOCKED; + this.spawnflags = ITEM_FLAG_INSTAGIB | ITEM_FLAG_MUTATORBLOCKED; #ifdef GAMEQC this.m_model = MDL_VaporizerCells_ITEM; this.m_sound = SND_VaporizerCells; @@ -51,6 +51,7 @@ SOUND(ExtraLife, Item_Sound("megahealth")); REGISTER_ITEM(ExtraLife, Powerup) { this.m_canonical_spawnfunc = "item_extralife"; + this.spawnflags = ITEM_FLAG_INSTAGIB; #ifdef GAMEQC this.m_model = MDL_ExtraLife_ITEM; this.m_sound = SND_ExtraLife; @@ -80,6 +81,7 @@ void powerup_invisibility_init(entity item); REGISTER_ITEM(Invisibility, Powerup) { this.m_canonical_spawnfunc = "item_invisibility"; + this.spawnflags = ITEM_FLAG_INSTAGIB; #ifdef GAMEQC this.m_model = MDL_Invisibility_ITEM; this.m_sound = SND_Invisibility; @@ -114,6 +116,7 @@ void powerup_speed_init(entity item); REGISTER_ITEM(Speed, Powerup) { this.m_canonical_spawnfunc = "item_speed"; + this.spawnflags = ITEM_FLAG_INSTAGIB; #ifdef GAMEQC this.m_model = MDL_Speed_ITEM; this.m_sound = SND_Speed; diff --git a/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc b/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc index 2de2dbf69..2cf4b0a77 100644 --- a/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc +++ b/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc @@ -144,17 +144,12 @@ string RandomItems_GetRandomVanillaItemClassName(string prefix) string RandomItems_GetRandomInstagibItemClassName(string prefix) { RandomSelection_Init(); - #define X(classname) \ - RandomSelection_AddString( \ - classname, \ - cvar(sprintf("g_%s_%s_probability", prefix, classname)), \ - 1 \ - ) - X("item_vaporizer_cells"); - X("item_invisibility"); - X("item_extralife"); - X("item_speed"); - #undef X + FOREACH(Items, it.spawnflags & ITEM_FLAG_INSTAGIB, + { + RandomSelection_AddString(it.m_canonical_spawnfunc, + cvar(sprintf("g_%s_%s_probability", prefix, + it.m_canonical_spawnfunc)), 1); + }); return RandomSelection_chosen_string; }