]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Added ITEM_FLAG_OVERKILL.
authorLyberta <lyberta@lyberta.net>
Fri, 10 Nov 2017 11:09:29 +0000 (14:09 +0300)
committerLyberta <lyberta@lyberta.net>
Fri, 10 Nov 2017 11:09:29 +0000 (14:09 +0300)
qcsrc/common/items/item.qh
qcsrc/common/items/item/armor.qh
qcsrc/common/items/item/health.qh
qcsrc/common/mutators/mutator/instagib/items.qh
qcsrc/common/mutators/mutator/overkill/sv_overkill.qc
qcsrc/common/mutators/mutator/random_items/sv_random_items.qc

index 1d2c8d67138fb0853e7ae0ad929368794d7d3c00..01bf81a9d49632cbf880e64f6412b124b97699ce 100644 (file)
@@ -59,7 +59,8 @@ const int IT_PICKUPMASK                       = IT_UNLIMITED_AMMO | IT_JETPACK | IT_FU
 enum
 {
        ITEM_FLAG_INSTAGIB = BIT(0), ///< Item is usable in instagib.
-    ITEM_FLAG_MUTATORBLOCKED = BIT(1)
+       ITEM_FLAG_OVERKILL = BIT(1), ///< Item is usable in overkill.
+    ITEM_FLAG_MUTATORBLOCKED = BIT(2)
 };
 
 #define ITEM_HANDLE(signal, ...) __Item_Send_##signal(__VA_ARGS__)
index 9a9326c43e1ae20a7a469ea2786ab5120fdf0195..53255f9f10eaf8d45d61517e9bf5cd49350c24f5 100644 (file)
@@ -34,6 +34,7 @@ void item_armorsmall_init(entity item)
 REGISTER_ITEM(ArmorSmall, Armor) {
     this.m_canonical_spawnfunc = "item_armor_small";
 #ifdef GAMEQC
+    this.spawnflags = ITEM_FLAG_OVERKILL;
     this.m_model                =   MDL_ArmorSmall_ITEM;
     this.m_sound                =   SND_ArmorSmall;
 #endif
@@ -71,6 +72,7 @@ void item_armormedium_init(entity item)
 REGISTER_ITEM(ArmorMedium, Armor) {
     this.m_canonical_spawnfunc = "item_armor_medium";
 #ifdef GAMEQC
+    this.spawnflags = ITEM_FLAG_OVERKILL;
     this.m_model                =   MDL_ArmorMedium_ITEM;
     this.m_sound                =   SND_ArmorMedium;
 #endif
@@ -108,6 +110,7 @@ void item_armorbig_init(entity item)
 REGISTER_ITEM(ArmorBig, Armor) {
     this.m_canonical_spawnfunc = "item_armor_big";
 #ifdef GAMEQC
+    this.spawnflags = ITEM_FLAG_OVERKILL;
     this.m_model                =   MDL_ArmorBig_ITEM;
     this.m_sound                =   SND_ArmorBig;
 #endif
@@ -147,6 +150,7 @@ void item_armormega_init(entity item)
 REGISTER_ITEM(ArmorMega, Armor) {
     this.m_canonical_spawnfunc = "item_armor_mega";
 #ifdef GAMEQC
+    this.spawnflags = ITEM_FLAG_OVERKILL;
     this.m_model                =   MDL_ArmorMega_ITEM;
     this.m_sound                =   SND_ArmorMega;
 #endif
index 3ffb5728b1a1d86ea51b8ea93f53824ffb088b28..a64a37701d2abe9a097929e61f76b4c1c3c42b30 100644 (file)
@@ -147,6 +147,7 @@ void item_healthmega_init(entity item)
 REGISTER_ITEM(HealthMega, Health) {
     this.m_canonical_spawnfunc = "item_health_mega";
 #ifdef GAMEQC
+    this.spawnflags = ITEM_FLAG_OVERKILL;
     this.m_model                =   MDL_HealthMega_ITEM;
     this.m_sound                =   SND_HealthMega;
 #endif
index e6354c9361bc4323ce01d38b575023877e09b85a..ab6843ed53ea7e358ceed756771c0515d3f07e65 100644 (file)
@@ -24,8 +24,8 @@ void ammo_vaporizercells_init(entity item)
 #endif
 REGISTER_ITEM(VaporizerCells, Ammo) {
     this.m_canonical_spawnfunc = "item_vaporizer_cells";
-    this.spawnflags = ITEM_FLAG_INSTAGIB | ITEM_FLAG_MUTATORBLOCKED;
 #ifdef GAMEQC
+    this.spawnflags = ITEM_FLAG_INSTAGIB | ITEM_FLAG_MUTATORBLOCKED;
     this.m_model                =   MDL_VaporizerCells_ITEM;
     this.m_sound                =   SND_VaporizerCells;
 #endif
@@ -51,8 +51,8 @@ SOUND(ExtraLife, Item_Sound("megahealth"));
 
 REGISTER_ITEM(ExtraLife, Powerup) {
     this.m_canonical_spawnfunc = "item_extralife";
-       this.spawnflags = ITEM_FLAG_INSTAGIB;
 #ifdef GAMEQC
+       this.spawnflags = ITEM_FLAG_INSTAGIB;
     this.m_model                =   MDL_ExtraLife_ITEM;
     this.m_sound                =   SND_ExtraLife;
 #endif
@@ -81,8 +81,8 @@ void powerup_invisibility_init(entity item);
 
 REGISTER_ITEM(Invisibility, Powerup) {
     this.m_canonical_spawnfunc = "item_invisibility";
-       this.spawnflags = ITEM_FLAG_INSTAGIB;
 #ifdef GAMEQC
+       this.spawnflags = ITEM_FLAG_INSTAGIB;
     this.m_model            =   MDL_Invisibility_ITEM;
     this.m_sound            =   SND_Invisibility;
     this.m_glow             =   true;
@@ -116,8 +116,8 @@ void powerup_speed_init(entity item);
 
 REGISTER_ITEM(Speed, Powerup) {
     this.m_canonical_spawnfunc = "item_speed";
-       this.spawnflags = ITEM_FLAG_INSTAGIB;
 #ifdef GAMEQC
+       this.spawnflags = ITEM_FLAG_INSTAGIB;
     this.m_model            =   MDL_Speed_ITEM;
     this.m_sound            =   SND_Speed;
     this.m_glow             =   true;
index 120fabe569198b59b83a46f462b5024edc1b1805..7462de81f2a03a37cccab8794fee8e884f6fec79 100644 (file)
@@ -17,6 +17,23 @@ REGISTER_MUTATOR(ok, expr_evaluate(autocvar_g_overkill) && !cvar("g_instagib") &
        {
                precache_all_playermodels("models/ok_player/*.dpm");
 
+               if (autocvar_g_overkill_filter_healthmega)
+               {
+                       ITEM_HealthMega.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
+               }
+               if (autocvar_g_overkill_filter_armormedium)
+               {
+                       ITEM_ArmorMedium.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
+               }
+               if (autocvar_g_overkill_filter_armorbig)
+               {
+                       ITEM_ArmorBig.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
+               }
+               if (autocvar_g_overkill_filter_armormega)
+               {
+                       ITEM_ArmorMega.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
+               }
+
                WEP_RPC.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
                WEP_HMG.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
 
@@ -27,6 +44,11 @@ REGISTER_MUTATOR(ok, expr_evaluate(autocvar_g_overkill) && !cvar("g_instagib") &
 
        MUTATOR_ONREMOVE
        {
+               ITEM_HealthMega.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
+               ITEM_ArmorMedium.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
+               ITEM_ArmorBig.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
+               ITEM_ArmorMega.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
+
                WEP_RPC.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
                WEP_HMG.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
        }
@@ -247,14 +269,6 @@ MUTATOR_HOOKFUNCTION(ok, FilterItem)
        if(item.ok_item)
                return false;
 
-       switch(item.itemdef)
-       {
-               case ITEM_HealthMega: return autocvar_g_overkill_filter_healthmega;
-               case ITEM_ArmorMedium: return autocvar_g_overkill_filter_armormedium;
-               case ITEM_ArmorBig: return autocvar_g_overkill_filter_armorbig;
-               case ITEM_ArmorMega: return autocvar_g_overkill_filter_armormega;
-       }
-
        return true;
 }
 
index 2cf4b0a7738497ba50dc8917d84c26fc11367ce9..3e11d3af5bc63ac386d97fbd475611207fbfe7cd 100644 (file)
@@ -60,8 +60,6 @@ bool random_items_is_spawning = false;
 string RandomItems_GetRandomItemClassNameWithProperty(string prefix,
        .bool item_property);
 
-string RandomItems_GetItemVarName(string class_name);
-
 //=========================== Public API ======================================
 
 string RandomItems_GetRandomItemClassName(string prefix)
@@ -156,55 +154,22 @@ string RandomItems_GetRandomInstagibItemClassName(string prefix)
 string RandomItems_GetRandomOverkillItemClassName(string prefix)
 {
        RandomSelection_Init();
-       string varname;
-       #define X(classname) MACRO_BEGIN \
-               if ((varname = RandomItems_GetItemVarName(classname))) \
-               { \
-                       RandomSelection_AddString( \
-                               classname, \
-                               cvar(sprintf("g_%s_overkill_%s_probability", prefix, varname)), \
-                               1 \
-                       ); \
-               } \
-       MACRO_END
-       X("item_health_mega");
-       X("item_armor_small");
-       X("item_armor_medium");
-       X("item_armor_big");
-       X("item_armor_mega");
-       X("weapon_hmg");
-       X("weapon_rpc");
-       #undef X
+       FOREACH(Items, (it.spawnflags & ITEM_FLAG_OVERKILL) &&
+               !(it.spawnflags & ITEM_FLAG_MUTATORBLOCKED),
+       {
+               RandomSelection_AddString(it.m_canonical_spawnfunc,
+                       cvar(sprintf("g_%s_overkill_%s_probability", prefix,
+                       it.m_canonical_spawnfunc)), 1);
+       });
+       RandomSelection_AddString("weapon_hmg",
+               cvar(sprintf("g_%s_overkill_weapon_hmg_probability", prefix)), 1);
+       RandomSelection_AddString("weapon_rpc",
+               cvar(sprintf("g_%s_overkill_weapon_rpc_probability", prefix)), 1);
        return RandomSelection_chosen_string;
 }
 
 //========================= Free functions ====================================
 
-string RandomItems_GetItemVarName(string class_name)
-{
-       if (startsWith(class_name, "weapon_"))
-       {
-               FOREACH(Weapons, it.m_canonical_spawnfunc == class_name, {
-                       if (it.spawnflags & WEP_FLAG_MUTATORBLOCKED)
-                       {
-                               return "";
-                       }
-                       return class_name;
-               });
-       }
-       switch (class_name)
-       {
-               #define XCOND(classname, expr) case #classname: if (expr) return #classname; else break
-               XCOND(item_health_mega, !autocvar_g_overkill_filter_healthmega);
-               case "item_armor_small": return "item_armor_small";
-               XCOND(item_armor_medium, !autocvar_g_overkill_filter_armormedium);
-               XCOND(item_armor_big, !autocvar_g_overkill_filter_armorbig);
-               XCOND(item_armor_mega, !autocvar_g_overkill_filter_armormega);
-               #undef XCOND
-       }
-       return "";
-}
-
 /// \brief Returns list of classnames to replace a map item with.
 /// \param[in] item Item to inspect.
 /// \return List of classnames to replace a map item with.