]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/t_items.qc
Merge branch 'master' into Mario/wepent_experimental
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / t_items.qc
index 2b9a1f5d9860c9151cf1f4c3fa8ed947b919a88f..17fb9fce0cba011f19ed36f4bd5d0985199c5489 100644 (file)
@@ -183,7 +183,7 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
             if(this.ItemStatus & ITS_ALLOWFB)
                 this.effects |= EF_FULLBRIGHT;
 
-        if(this.ItemStatus & ITS_POWERUP)
+        if(this.ItemStatus & ITS_GLOW)
         {
             if(this.ItemStatus & ITS_AVAILABLE)
                 this.effects |= (EF_ADDITIVE | EF_FULLBRIGHT);
@@ -463,8 +463,8 @@ void Item_Show (entity e, float mode)
                e.ItemStatus &= ~ITS_AVAILABLE;
        }}
 
-       if (def == ITEM_Strength || def == ITEM_Shield)
-               e.ItemStatus |= ITS_POWERUP;
+       if (def.m_glow)
+               e.ItemStatus |= ITS_GLOW;
 
        if (autocvar_g_nodepthtestitems)
                e.effects |= EF_NODEPTHTEST;
@@ -497,19 +497,7 @@ void Item_ItemsTime_SetTimesForAllPlayers();
 void Item_Respawn (entity this)
 {
        Item_Show(this, 1);
-       // this is ugly...
-       switch(this.itemdef)
-       {
-               case ITEM_Strength:
-                       sound(this, CH_TRIGGER, SND_STRENGTH_RESPAWN, VOL_BASE, ATTEN_NORM);    // play respawn sound
-                       break;
-               case ITEM_Shield:
-                       sound(this, CH_TRIGGER, SND_SHIELD_RESPAWN, VOL_BASE, ATTEN_NORM);      // play respawn sound
-                       break;
-               default:
-                       sound(this, CH_TRIGGER, SND_ITEMRESPAWN, VOL_BASE, ATTEN_NORM); // play respawn sound
-                       break;
-       }
+       sound(this, CH_TRIGGER, this.itemdef.m_respawnsound, VOL_BASE, ATTEN_NORM);     // play respawn sound
        setorigin(this, this.origin);
 
     if (Item_ItemsTime_Allow(this.itemdef) || this.weapons & WEPSET_SUPERWEAPONS)
@@ -678,21 +666,30 @@ LABEL(YEAH)
 
 float Item_GiveTo(entity item, entity player)
 {
-       float _switchweapon;
        float pickedup;
 
        // if nothing happens to player, just return without taking the item
        pickedup = false;
-       _switchweapon = false;
+       int _switchweapon = 0;
        // in case the player has autoswitch enabled do the following:
        // if the player is using their best weapon before items are given, they
        // probably want to switch to an even better weapon after items are given
-       if (player.autoswitch)
-       if (PS(player).m_switchweapon == w_getbestweapon(player))
-               _switchweapon = true;
 
-       if (!(player.weapons & WepSet_FromWeapon(PS(player).m_switchweapon)))
-               _switchweapon = true;
+       if(player.autoswitch)
+       {
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               {
+                       .entity weaponentity = weaponentities[slot];
+                       if(player.(weaponentity).m_weapon != WEP_Null || slot == 0)
+                       {
+                               if(player.(weaponentity).m_switchweapon == w_getbestweapon(player, weaponentity))
+                                       _switchweapon |= BIT(slot);
+
+                               if(!(player.weapons & WepSet_FromWeapon(player.(weaponentity).m_switchweapon)))
+                                       _switchweapon |= BIT(slot);
+                       }
+               }
+       }
 
        pickedup |= Item_GiveAmmoTo(item, player, ammo_fuel, g_pickup_fuel_max, ITEM_MODE_FUEL);
        pickedup |= Item_GiveAmmoTo(item, player, ammo_shells, g_pickup_shells_max, ITEM_MODE_NONE);
@@ -715,7 +712,12 @@ float Item_GiveTo(entity item, entity player)
                        FOREACH(Weapons, it != WEP_Null, {
                                if(w & (it.m_wepset))
                                {
-                                       W_DropEvent(wr_pickup, player, it.m_id, item);
+                                       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+                                       {
+                                               .entity weaponentity = weaponentities[slot];
+                                               if(player.(weaponentity).m_weapon != WEP_Null || slot == 0)
+                                                       W_DropEvent(wr_pickup, player, it.m_id, item, weaponentity);
+                                       }
                                        W_GiveWeapon(player, it.m_id);
                                }
                        });
@@ -766,13 +768,25 @@ LABEL(skip)
        // crude hack to enforce switching weapons
        if(g_cts && item.itemdef.instanceOfWeaponPickup)
        {
-               W_SwitchWeapon_Force(player, Weapons_from(item.weapon));
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               {
+                       .entity weaponentity = weaponentities[slot];
+                       if(player.(weaponentity).m_weapon != WEP_Null || slot == 0)
+                               W_SwitchWeapon_Force(player, Weapons_from(item.weapon), weaponentity);
+               }
                return 1;
        }
 
-       if (_switchweapon)
-               if (PS(player).m_switchweapon != w_getbestweapon(player))
-                       W_SwitchWeapon_Force(player, w_getbestweapon(player));
+       if(_switchweapon)
+       {
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               {
+                       .entity weaponentity = weaponentities[slot];
+                       if(_switchweapon & BIT(slot))
+                       if(player.(weaponentity).m_switchweapon != w_getbestweapon(player, weaponentity))
+                               W_SwitchWeapon_Force(player, w_getbestweapon(player, weaponentity), weaponentity);
+               }
+       }
 
        return 1;
 }
@@ -1651,7 +1665,6 @@ void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .floa
 float GiveItems(entity e, float beginarg, float endarg)
 {
        float got, i, val, op;
-       float _switchweapon;
        string cmd;
 
        val = 999;
@@ -1659,10 +1672,18 @@ float GiveItems(entity e, float beginarg, float endarg)
 
        got = 0;
 
-       _switchweapon = false;
-       if (e.autoswitch)
-               if (PS(e).m_switchweapon == w_getbestweapon(e))
-                       _switchweapon = true;
+       int _switchweapon = 0;
+
+       if(e.autoswitch)
+       {
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               {
+                       .entity weaponentity = weaponentities[slot];
+                       if(e.(weaponentity).m_weapon != WEP_Null || slot == 0)
+                       if(e.(weaponentity).m_switchweapon == w_getbestweapon(e, weaponentity))
+                               _switchweapon |= BIT(slot);
+               }
+       }
 
        e.strength_finished = max(0, e.strength_finished - time);
        e.invincible_finished = max(0, e.invincible_finished - time);
@@ -1827,10 +1848,23 @@ float GiveItems(entity e, float beginarg, float endarg)
        else
                e.superweapons_finished += time;
 
-       if (!(e.weapons & WepSet_FromWeapon(PS(e).m_switchweapon)))
-               _switchweapon = true;
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+       {
+               .entity weaponentity = weaponentities[slot];
+               if(e.(weaponentity).m_weapon != WEP_Null || slot == 0)
+               if(!(e.weapons & WepSet_FromWeapon(e.(weaponentity).m_switchweapon)))
+                       _switchweapon |= BIT(slot);
+       }
+
        if(_switchweapon)
-               W_SwitchWeapon_Force(e, w_getbestweapon(e));
+       {
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               {
+                       .entity weaponentity = weaponentities[slot];
+                       if(_switchweapon & BIT(slot))
+                               W_SwitchWeapon_Force(e, w_getbestweapon(e, weaponentity), weaponentity);
+               }
+       }
 
        return got;
 }