Exemplo n.º 1
0
        private bool MoveItemsToBank(Mobile m)
        {
            Backpack  bag   = new Backpack();
            ArrayList equip = new ArrayList(m.Items);

            if (m.Backpack != null)
            {
                // count clothing items
                int WornCount = 0;
                foreach (Item i in equip)
                {
                    if (Moongate.RestrictedItem(m, i) == false)
                    {
                        continue;                               // not clothes
                    }
                    else
                    {
                        WornCount++;
                    }
                }

                // erl: added check for Mobile.Alive property... will not return false if mobile is not alive
                if (125 - m.BankBox.TotalItems - 1 - m.Backpack.TotalItems - WornCount < 0 && m.Alive)
                {
                    return(false);
                }

                // Unequip any items being worn
                foreach (Item i in equip)
                {
                    if (Moongate.RestrictedItem(m, i) == false)
                    {
                        continue;
                    }
                    else
                    {
                        m.Backpack.DropItem(i);
                    }
                }

                // Get a count of all items in the player's backpack.
                ArrayList items = new ArrayList(m.Backpack.Items);

                // Drop our new bag in the player's bank
                m.BankBox.DropItem(bag);

                // Run through all items in player's pack, move them to the bag we just dropped in the bank
                foreach (Item i in items)
                {
                    // If there's room, drop the item in the bank, otherwise drop it on the ground
                    if (bag.TryDropItem(m, i, false) || !m.Alive)
                    {
                        bag.DropItem(i);
                    }
                    else
                    {
                        i.DropToWorld(m, m.Location);
                    }
                }
            }

            // Give them a Deathrobe, Stinger dagger, and a blank spell book
            if (m.Alive)
            {
                Item robe = new Server.Items.DeathRobe();
                if (!m.EquipItem(robe))
                {
                    robe.Delete();
                }
            }

            Item aiStinger = new Server.Items.AIStinger();

            if (!m.AddToBackpack(aiStinger))
            {
                aiStinger.Delete();
            }

            Item spellbook = new Server.Items.Spellbook();

            if (!m.AddToBackpack(spellbook))
            {
                spellbook.Delete();
            }
            return(true);
        }
Exemplo n.º 2
0
		private bool MoveItemsToBank( Mobile m )
		{
			Backpack bag = new Backpack();
			ArrayList equip = new ArrayList( m.Items );
			
			if ( m.Backpack != null )
			{
				// count clothing items
				int WornCount = 0;
				foreach ( Item i in equip )
				{
					if ( Moongate.RestrictedItem(m, i) == false ) 
						continue;	// not clothes
					else
						WornCount++;
				}

				// erl: added check for Mobile.Alive property... will not return false if mobile is not alive
				if (125 - m.BankBox.TotalItems - 1 - m.Backpack.TotalItems - WornCount < 0 && m.Alive)
				{
					return false;
				}

				// Unequip any items being worn
				foreach ( Item i in equip )
				{
					if (Moongate.RestrictedItem(m, i) == false )
						continue;
					else
						m.Backpack.DropItem( i );
				}

				// Get a count of all items in the player's backpack.
				ArrayList items = new ArrayList( m.Backpack.Items );

				// Drop our new bag in the player's bank
				m.BankBox.DropItem( bag );

				// Run through all items in player's pack, move them to the bag we just dropped in the bank
				foreach ( Item i in items )
				{
					// If there's room, drop the item in the bank, otherwise drop it on the ground
					if ( bag.TryDropItem( m, i, false ) || !m.Alive )
						bag.DropItem( i );
					else
						i.DropToWorld( m, m.Location );
				}
			}

			// Give them a Deathrobe, Stinger dagger, and a blank spell book
			if ( m.Alive )
			{
				Item robe = new Server.Items.DeathRobe();
				if ( !m.EquipItem( robe ) )
					robe.Delete();
			}

			Item aiStinger = new Server.Items.AIStinger();
			if ( !m.AddToBackpack( aiStinger ) )
				aiStinger.Delete();

			Item spellbook = new Server.Items.Spellbook();
			if ( !m.AddToBackpack( spellbook ) )
				spellbook.Delete();
			return true;
		}