From b27924feaa494acfa734d98be7ae16a87a7d31b3 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Thu, 15 Dec 2011 15:57:22 +0100 Subject: [PATCH] apply same logic to g_pickup_items: -1 is default, 0 = off, 1 = on --- defaultXonotic.cfg | 2 +- qcsrc/server/autocvars.qh | 1 - qcsrc/server/g_world.qc | 4 +- qcsrc/server/t_items.qc | 87 ++++++++++++++++++--------------------- 4 files changed, 44 insertions(+), 50 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 7f0844af8..0231923ce 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -502,7 +502,7 @@ set g_weapon_stay 0 "if set to 1 or 2, weapons stay after they were picked up (1 set g_weapon_throwable 1 "if set to 1, weapons can be dropped" set g_powerups -1 "if set to 0 the strength and shield (invincibility) will not spawn on the map, if 1 they will spawn in all game modes, -1 is game mode default" set g_use_ammunition 1 "if set to 0 all weapons have unlimited ammunition" -set g_pickup_items 1 "if set to 0 all items (health, armor, ammo, weapons...) are removed from the map" +set g_pickup_items -1 "if set to 0 all items (health, armor, ammo, weapons...) are removed from the map, if 1 they are forced to spawn" set g_minstagib 0 "enable minstagib" set g_minstagib_extralives 2 "how many extra lives you will get per powerup" set g_minstagib_ammo_start 10 "starting ammo" diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index ae832d817..255f78aaf 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -73,7 +73,6 @@ float autocvar_g_antilag_nudge; float autocvar_g_arena_maxspawned; float autocvar_g_arena_point_leadlimit; float autocvar_g_arena_point_limit; -float autocvar_g_arena_powerups; float autocvar_g_arena_roundbased; float autocvar_g_arena_warmup; float autocvar_g_assault; diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 3b6ada702..5d2a63324 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -747,8 +747,10 @@ void spawnfunc_worldspawn (void) s = strcat(s, ":no_use_ammunition"); // initialiation stuff, not good in the mutator system - if(!autocvar_g_pickup_items) + if(autocvar_g_pickup_items == 0) s = strcat(s, ":no_pickup_items"); + if(autocvar_g_pickup_items > 0) + s = strcat(s, ":pickup_items"); // initialiation stuff, not good in the mutator system if(autocvar_g_weaponarena != "0") diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 6cf81edca..7d2273fe5 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -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) @@ -744,35 +784,6 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, } */ - 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) - { - startitem_failed = TRUE; - remove (self); - return; - } - if(autocvar_spawn_debug >= 2) { entity otheritem; @@ -1240,22 +1251,7 @@ void spawnfunc_item_health1() { spawnfunc_item_health_small(); } void spawnfunc_item_health25() { spawnfunc_item_health_medium(); } void spawnfunc_item_health100() { spawnfunc_item_health_mega(); } -float have_powerups(void) -{ - if(autocvar_g_powerups > 0) - return TRUE; - else if(autocvar_g_powerups == 0) - return FALSE; - else if(g_arena) - return FALSE; - else - return TRUE; -} - void spawnfunc_item_strength (void) { - if(!have_powerups()) - return; - if(g_minstagib) { minstagib_items(IT_STRENGTH); } else { @@ -1266,9 +1262,6 @@ void spawnfunc_item_strength (void) { } void spawnfunc_item_invincible (void) { - if(!have_powerups()) - return; - if(g_minstagib) { minstagib_items(IT_INVINCIBLE); } else { -- 2.39.2