]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/t_items.qc
apply same logic to g_pickup_items: -1 is default, 0 = off, 1 = on
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / t_items.qc
index f7a8d2aec157a966e0299a89402e2b280af92721..7d2273fe55ac2cf57a2d4fe0915c069cc5ea80e0 100644 (file)
@@ -1,3 +1,36 @@
+float have_pickup_item(void)
+{
+       // minstagib: only allow filtered items
+       if(g_minstagib)
+               if(self.classname != "minstagib")
+                       return FALSE;
+
+       if(self.items == IT_STRENGTH || self.items == IT_INVINCIBLE)
+       {
+               if(autocvar_g_powerups > 0)
+                       return TRUE;
+               if(autocvar_g_powerups == 0)
+                       return FALSE;
+               if(g_arena)
+                       return FALSE;
+       }
+       else
+       {
+               if(autocvar_g_pickup_items > 0)
+                       return TRUE;
+               if(autocvar_g_pickup_items == 0)
+                       return FALSE;
+               if(g_lms)
+                       return FALSE;
+               if(g_ca)
+                       return FALSE;
+               if(g_weaponarena)
+                       if((self.weapons & WEPBIT_ALL) || (self.items & IT_AMMO))
+                               return FALSE;
+       }
+       return TRUE;
+}
+
 #define ITEM_RESPAWN_TICKS 10
 
 #define ITEM_RESPAWNTIME(i)         ((i).respawntime + crandom() * (i).respawntimejitter)
@@ -707,6 +740,13 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
                        return;
                }
 
+               if(!have_pickup_item())
+               {
+                       startitem_failed = TRUE;
+                       remove (self);
+                       return;
+               }
+
                self.reset = Item_Reset;
                // it's a level item
                if(self.spawnflags & 1)
@@ -759,35 +799,6 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
                        self.is_item = TRUE;
                }
 
-               if(g_lms || g_ca)
-               {
-                       startitem_failed = TRUE;
-                       remove(self);
-                       return;
-               }
-               else if (g_weaponarena && ((weaponid & WEPBIT_ALL) || (itemid & IT_AMMO)))
-               {
-                       startitem_failed = TRUE;
-                       remove(self);
-                       return;
-               }
-               else if (g_minstagib)
-               {
-                       // don't remove dropped items and powerups
-                       if (self.classname != "minstagib")
-                       {
-                               startitem_failed = TRUE;
-                               remove (self);
-                               return;
-                       }
-               }
-               else if (!autocvar_g_pickup_items && itemid != IT_STRENGTH && itemid != IT_INVINCIBLE && itemid != IT_HEALTH)
-               {
-                       startitem_failed = TRUE;
-                       remove (self);
-                       return;
-               }
-
                weaponsInMap |= weaponid;
 
                precache_model (itemmodel);
@@ -1220,12 +1231,6 @@ void spawnfunc_item_health_large (void) {
 }
 
 void spawnfunc_item_health_mega (void) {
-       if(!autocvar_g_powerup_superhealth)
-               return;
-
-       if((g_arena || g_ca) && !autocvar_g_arena_powerups)
-               return;
-
        if(g_minstagib) {
                minstagib_items(IT_NAILS);
        } else {
@@ -1247,12 +1252,6 @@ void spawnfunc_item_health25() { spawnfunc_item_health_medium(); }
 void spawnfunc_item_health100() { spawnfunc_item_health_mega(); }
 
 void spawnfunc_item_strength (void) {
-       if(!autocvar_g_powerup_strength)
-               return;
-
-       if((g_arena || g_ca) && !autocvar_g_arena_powerups)
-               return;
-
        if(g_minstagib) {
                minstagib_items(IT_STRENGTH);
        } else {
@@ -1263,12 +1262,6 @@ void spawnfunc_item_strength (void) {
 }
 
 void spawnfunc_item_invincible (void) {
-       if(!autocvar_g_powerup_shield)
-               return;
-
-       if((g_arena || g_ca) && !autocvar_g_arena_powerups)
-               return;
-
        if(g_minstagib) {
                minstagib_items(IT_INVINCIBLE);
        } else {