]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Disable ammo buff in melee only mode
authorMario <mario.mario@y7mail.com>
Fri, 30 May 2014 15:07:33 +0000 (01:07 +1000)
committerMario <mario.mario@y7mail.com>
Fri, 30 May 2014 15:07:33 +0000 (01:07 +1000)
qcsrc/server/mutators/mutator_buffs.qc

index 70b5246fbbefed03928d4aa6dc0ab1fea5da0b7b..38d262ca73637ccbbf22f6cad233c7a1a3e8cebd 100644 (file)
@@ -130,18 +130,27 @@ void buff_Touch()
        other.buffs |= (self.buffs);
 }
 
+float buff_Available(float buffid)
+{
+       if(buffid == BUFF_AMMO && ((start_items & IT_UNLIMITED_WEAPON_AMMO) || (start_items & IT_UNLIMITED_AMMO) || (cvar("g_melee_only"))))
+               return FALSE;
+
+       if(buffid == BUFF_VAMPIRE && cvar("g_vampire"))
+               return FALSE;
+
+       if(!cvar(strcat("g_buffs_", Buff_Name(buffid))))
+               return FALSE;
+
+       return TRUE;
+}
+
 void buff_NewType(entity ent, float cb)
 {
        entity e;
        RandomSelection_Init();
        for(e = Buff_Type_first; e; e = e.enemy)
+       if(buff_Available(e.items))
        {
-               if(e.items == BUFF_AMMO && ((start_items & IT_UNLIMITED_WEAPON_AMMO) || (start_items & IT_UNLIMITED_AMMO)))
-                       continue;
-               if(e.items == BUFF_VAMPIRE && cvar("g_vampire"))
-                       continue;
-               if(!cvar(strcat("g_buffs_", e.netname)))
-                       continue;
                RandomSelection_Add(world, e.items, string_null, 1, 1 / e.count); // if it's already been chosen, give it a lower priority
                e.count += 1;
        }
@@ -257,7 +266,7 @@ void buff_Init(entity ent)
 
        entity oldself = self;
        self = ent;
-       if(!self.buffs || !cvar(strcat("g_buffs_", Buff_Name(self.buffs))))
+       if(!self.buffs || buff_Available(self.buffs))
                buff_NewType(self, 0);
        
        self.classname = "item_buff";