]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix dying players not dropping their weapon & cleanup item filtering
authorMario <mario.mario@y7mail.com>
Mon, 4 Feb 2013 15:55:32 +0000 (02:55 +1100)
committerMario <mario.mario@y7mail.com>
Mon, 4 Feb 2013 15:55:32 +0000 (02:55 +1100)
qcsrc/server/g_damage.qc
qcsrc/server/mutators/mutator_minstagib.qc

index 1a170d8aea79e528be8edf1b468e6e3256963204..f014ed3d5aecc9f61436c77da4d85b31e61b5715 100644 (file)
@@ -685,24 +685,27 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float
                mirrordamage = frag_mirrordamage;
                force = frag_force;
                
-               // apply strength multiplier
-               if (attacker.items & IT_STRENGTH)
+               if not(g_minstagib)
                {
-                       if(targ == attacker)
+                       // apply strength multiplier
+                       if (attacker.items & IT_STRENGTH)
                        {
-                               damage = damage * autocvar_g_balance_powerup_strength_selfdamage;
-                               force = force * autocvar_g_balance_powerup_strength_selfforce;
-                       }
-                       else
-                       {
-                               damage = damage * autocvar_g_balance_powerup_strength_damage;
-                               force = force * autocvar_g_balance_powerup_strength_force;
+                               if(targ == attacker)
+                               {
+                                       damage = damage * autocvar_g_balance_powerup_strength_selfdamage;
+                                       force = force * autocvar_g_balance_powerup_strength_selfforce;
+                               }
+                               else
+                               {
+                                       damage = damage * autocvar_g_balance_powerup_strength_damage;
+                                       force = force * autocvar_g_balance_powerup_strength_force;
+                               }
                        }
-               }
 
-               // apply invincibility multiplier
-               if (targ.items & IT_INVINCIBLE)
-                       damage = damage * autocvar_g_balance_powerup_invincible_takedamage;
+                       // apply invincibility multiplier
+                       if (targ.items & IT_INVINCIBLE)
+                               damage = damage * autocvar_g_balance_powerup_invincible_takedamage;
+               }
 
                if (targ == attacker)
                {
index bf4e6a2d3db103558dbe18c900d56bce2e517f8a..8b1fe6b49e04adf2e7b07530594797437c92d0c8 100644 (file)
@@ -1,10 +1,12 @@
 void spawnfunc_item_minst_cells (void) 
 {
-       if not(g_minstagib)
-       {
-               remove(self);
-               return;
-       }
+       if not(g_minstagib) { remove(self); return; }
+       if not(self.ammo_cells)
+               self.ammo_cells = autocvar_g_minstagib_ammo_drop;
+               
+       StartItem ("models/items/a_cells.md3",
+                          "misc/itempickup.wav", 45, 0,
+                          "MinstaNex Ammo", IT_CELLS, 0, 0, generic_pickupevalfunc, 100);
 }
 
 .float minstagib_nextthink;
@@ -274,56 +276,35 @@ MUTATOR_HOOKFUNCTION(minstagib_SetStartItems)
 
 MUTATOR_HOOKFUNCTION(minstagib_FilterItem)
 {
-       if(self.weapon == -2)
-               return FALSE;
+       if(self.classname == "item_cells")
+               return TRUE; // no normal cells?
                
-       if(self.classname == "item_minst_cells" || self.weapon == WEP_ROCKET_LAUNCHER || self.weapon == WEP_NEX)
+       if(self.weapon == WEP_MINSTANEX && self.classname == "droppedweapon")
        {
                self.ammo_cells = autocvar_g_minstagib_ammo_drop;
-               StartItem ("models/items/a_cells.md3",
-                       "misc/itempickup.wav", 45, 0,
-                       "MinstaNex Ammo", IT_CELLS, -2, 0, generic_pickupevalfunc, 100);
                return FALSE;
        }
+       
+       if(self.weapon == WEP_ROCKET_LAUNCHER || self.weapon == WEP_NEX)
+       {
+               entity e = spawn();
+               setorigin(e, self.origin);
+               entity oldself;
+               oldself = self;
+               self = e;
+               spawnfunc_item_minst_cells();
+               self = oldself;
+               return TRUE;
+       }
                
        if(self.flags & FL_POWERUP)
-       {
-               // randomize
-               float rnd = random() * 3;
-               if (rnd <= 1)
-                       self.items = IT_STRENGTH;
-               else if (rnd <= 2)
-                       self.items = IT_NAILS;
-               else
-                       self.items = IT_INVINCIBLE;
+               return FALSE;
                
-               if (self.items == IT_STRENGTH)
-               {
-                       if(!self.strength_finished)
-                               self.strength_finished = autocvar_g_balance_powerup_strength_time;
-                       StartItem ("models/items/g_strength.md3",
-                               "misc/powerup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup,
-                               "Invisibility", IT_STRENGTH, -2, FL_POWERUP, generic_pickupevalfunc, BOT_PICKUP_RATING_MID);
-               }
-               // replace with extra lives
-               else if (self.items == IT_NAILS)
-               {
-                       self.max_health = 1;
-                       StartItem ("models/items/g_h100.md3",
-                               "misc/megahealth.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup,
-                               "Extralife", IT_NAILS, -2, FL_POWERUP, generic_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
-               }
-               // replace with speed
-               else if (self.items == IT_INVINCIBLE)
-               {
-                       if(!self.invincible_finished)
-                               self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
-                       StartItem ("models/items/g_invincible.md3",
-                               "misc/powerup_shield.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup,
-                               "Speed", IT_INVINCIBLE, -2, FL_POWERUP, generic_pickupevalfunc, BOT_PICKUP_RATING_MID);
-               }
+       if(self.ammo_cells > autocvar_g_minstagib_ammo_drop && self.classname != "item_minst_cells")
+               self.ammo_cells = autocvar_g_minstagib_ammo_drop;
+               
+       if(self.ammo_cells && !self.weapon)
                return FALSE;
-       }
                
        return TRUE;
 }
@@ -344,7 +325,6 @@ MUTATOR_HOOKFUNCTION(minstagib_GiveItem)
        float it;
        float prevcells = giveplayer.ammo_cells;
        
-       player_pickedup |= Item_GiveAmmoTo(giveitem, giveplayer, ammo_fuel, g_pickup_fuel_max, ITEM_MODE_FUEL);
        player_pickedup |= Item_GiveAmmoTo(giveitem, giveplayer, ammo_cells, 999, ITEM_MODE_NONE);
 
        if(giveplayer.ammo_cells > prevcells)
@@ -361,7 +341,8 @@ MUTATOR_HOOKFUNCTION(minstagib_GiveItem)
 
                if (WEPSET_CONTAINS_EW(giveitem, WEP_MINSTANEX))
                        W_GiveWeapon (giveplayer, WEP_MINSTANEX, giveitem.netname);
-               giveplayer.health = 100;
+               if(giveplayer.health < 100)
+                       giveplayer.health = 100;
        }
 
        if((it = (giveitem.items - (giveitem.items & giveplayer.items)) & IT_PICKUPMASK))