Beispiel #1
0
        public override bool OnDragDrop(Mobile from, Item item)
        {
            if (item is BasePotion)
            {
                BasePotion pot = (BasePotion)item;

                if (pot.PotionEffect != m_Type && m_Held != 0)
                {
                    from.SendLocalizedMessage(502236); // You decide that it would be a bad idea to mix different types of potions.
                }
                else if (m_Held >= m_MaxAmount)
                {
                    from.SendLocalizedMessage(502233); // The keg will not hold any more!
                }
                else if (pot.Amount > (m_MaxAmount - m_Held))
                {
                    from.SendAsciiMessage("That keg can't contain all those potions!");
                }
                else
                {
                    if (m_Held == 0)
                    {
                        m_Type = pot.PotionEffect;
                    }

                    int toConsume = m_MaxAmount - m_Held;

                    if (toConsume > pot.Amount)
                    {
                        toConsume = pot.Amount;
                    }

                    m_Held += toConsume;

                    pot.Consume(toConsume);

                    Bottle emptyBottles = new Bottle(toConsume);

                    if (!from.AddToBackpack(emptyBottles))
                    {
                        from.SendAsciiMessage(string.Format("You are too heavey, you place the bottle{0} on the ground.", emptyBottles.Amount == 1 ? string.Empty : "s"));
                        emptyBottles.MoveToWorld(from.Location);
                    }
                    else
                    {
                        from.SendAsciiMessage(string.Format("You place the empty bottle{0} in your backpack.", emptyBottles.Amount == 1 ? string.Empty : "s"));
                    }

                    ColorKeg();
                    from.PlaySound(0x240);
                }
            }
            else
            {
                from.SendLocalizedMessage(502232);                   // The keg is not designed to hold that type of object.
            }
            //Always return false
            return(false);
        }
Beispiel #2
0
		public static void PlayDrinkEffect( Mobile m, BasePotion potion )
		{
            if ( m is PlayerMobile && !(m as PlayerMobile).HiddenWithSpell )
			    m.RevealingAction();

			m.PlaySound( 0x31 );

            if (potion != null)
            {
                if (!potion.EventItem || (potion.EventItem && potion.EventItemConsume))
                {
                    Bottle b = new Bottle();

                    if (potion.EventItem)
                    {
                        b.EventItem = true;
                        b.Hue = potion.Hue;
                        b.Name = "event Empty bottle";
                    }

                    #region Add to pack or ground if overweight
                    //Taran: Check to see if player is overweight. If they are and the item drops to the
                    //ground then a check is made to see if it can be stacked. If it can't and  more than 
                    //20 items of the same type exist in the same tile then the last item gets removed. This 
                    //check is made so thousands of items can't exist in 1 tile and crash people in the same area.
                    if (!m.AddToBackpack(b))
                    {
                        IPooledEnumerable eable = m.Map.GetItemsInRange(m.Location, 0);
                        int amount = 0;
                        Item toRemove = null;

                        foreach (Item i in eable)
                        {
                            if (i != b && i.ItemID == b.ItemID)
                            {
                                if (i.StackWith(m, b, false))
                                {
                                    toRemove = b;
                                    break;
                                }

                                amount++;
                            }
                        }

                        m.SendAsciiMessage("You are overweight and put the {0} on the ground.", b.Name ?? CliLoc.LocToString(b.LabelNumber));

                        if (toRemove != null)
                            toRemove.Delete();
                        else if (amount >= 5 && amount < 20)
                            m.LocalOverheadMessage(MessageType.Regular, 906, true, string.Format("{0} identical items on the ground detected, no more than 20 is allowed!", amount));
                        else if (amount >= 20)
                        {
                            m.LocalOverheadMessage(MessageType.Regular, 906, true, "Too many identical items on the ground, removing!");
                            b.Delete();
                        }

                        eable.Free();
                    }
                    #endregion

                    potion.Consume(1);
                }
            }

		    if( m.Body.IsHuman )
			    m.Animate(m.Mounted ? 28 : 34, 5, 1, true, false, 0);
		}
Beispiel #3
0
        public static void PlayDrinkEffect(Mobile m, BasePotion potion)
        {
            if (m is PlayerMobile && !(m as PlayerMobile).HiddenWithSpell)
            {
                m.RevealingAction();
            }

            m.PlaySound(0x31);

            if (potion != null)
            {
                if (!potion.EventItem || (potion.EventItem && potion.EventItemConsume))
                {
                    Bottle b = new Bottle();

                    if (potion.EventItem)
                    {
                        b.EventItem = true;
                        b.Hue       = potion.Hue;
                        b.Name      = "event Empty bottle";
                    }

                    #region Add to pack or ground if overweight
                    //Taran: Check to see if player is overweight. If they are and the item drops to the
                    //ground then a check is made to see if it can be stacked. If it can't and  more than
                    //20 items of the same type exist in the same tile then the last item gets removed. This
                    //check is made so thousands of items can't exist in 1 tile and crash people in the same area.
                    if (!m.AddToBackpack(b))
                    {
                        IPooledEnumerable eable = m.Map.GetItemsInRange(m.Location, 0);
                        int  amount             = 0;
                        Item toRemove           = null;

                        foreach (Item i in eable)
                        {
                            if (i != b && i.ItemID == b.ItemID)
                            {
                                if (i.StackWith(m, b, false))
                                {
                                    toRemove = b;
                                    break;
                                }

                                amount++;
                            }
                        }

                        m.SendAsciiMessage("You are overweight and put the {0} on the ground.", b.Name ?? CliLoc.LocToString(b.LabelNumber));

                        if (toRemove != null)
                        {
                            toRemove.Delete();
                        }
                        else if (amount >= 5 && amount < 20)
                        {
                            m.LocalOverheadMessage(MessageType.Regular, 906, true, string.Format("{0} identical items on the ground detected, no more than 20 is allowed!", amount));
                        }
                        else if (amount >= 20)
                        {
                            m.LocalOverheadMessage(MessageType.Regular, 906, true, "Too many identical items on the ground, removing!");
                            b.Delete();
                        }

                        eable.Free();
                    }
                    #endregion

                    potion.Consume(1);
                }
            }

            if (m.Body.IsHuman)
            {
                m.Animate(m.Mounted ? 28 : 34, 5, 1, true, false, 0);
            }
        }