예제 #1
0
        public override bool OnDragDrop(Mobile from, Item item)
        {
            bool bReturn = false;

            if (item is Key)
            {
                if (Count < MAX_KEYS)
                {
                    bReturn = base.OnDragDrop(from, item);
                    if (bReturn)
                    {
                        item.Movable = false;
                    }
                    UpdateItemID();
                }
                else
                {
                    from.SendMessage("That key can't fit on that key ring.");
                    bReturn = false;
                }
            }
            else
            {
                // Adam: anything other than a key will get dropped into your backpack
                // (so your best sword doesn't get dropped on the ground.)
                from.AddToBackpack(item);
                //	For richness, we add the drop sound of the item dropped.
                from.PlaySound(item.GetDropSound());
                return(true);
            }

            return(bReturn);
        }
예제 #2
0
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            if (!(dropped is BasePiece))
            {
                // Adam: anything other than a scroll will get dropped into your backpack
                // (so your best sword doesn't get dropped on the ground.)
                from.AddToBackpack(dropped);
                //	For richness, we add the drop sound of the item dropped.
                from.PlaySound(dropped.GetDropSound());
                return(true);
            }

            BasePiece piece = dropped as BasePiece;

            return(piece != null && piece.Board == this && base.OnDragDrop(from, dropped));
        }
예제 #3
0
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            if (dropped is SpellScroll && dropped.Amount == 1)
            {
                SpellScroll scroll = (SpellScroll)dropped;

                SpellbookType type = GetTypeForSpell(scroll.SpellID);

                if (type != this.SpellbookType)
                {
                    return(false);
                }
                else if (HasSpell(scroll.SpellID))
                {
                    from.SendLocalizedMessage(500179);                       // That spell is already present in that spellbook.
                    return(false);
                }
                else
                {
                    int val = scroll.SpellID - BookOffset;

                    if (val >= 0 && val < BookCount)
                    {
                        m_Content |= (ulong)1 << val;
                        ++m_Count;

                        InvalidateProperties();

                        scroll.Delete();

                        from.Send(new PlaySound(0x249, GetWorldLocation()));
                        return(true);
                    }

                    return(false);
                }
            }
            else
            {
                // Adam: anything other than a scroll will get dropped into your backpack
                // (so your best sword doesn't get dropped on the ground.)
                from.AddToBackpack(dropped);
                //	For richness, we add the drop sound of the item dropped.
                from.PlaySound(dropped.GetDropSound());
                return(true);
            }
        }
예제 #4
0
        public virtual int GetDroppedSound(Item item)
        {
            int dropSound = item.GetDropSound();

            return(dropSound != -1 ? dropSound : DropSound);
        }
예제 #5
0
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            if (dropped is RecallRune)
            {
                //Close all runebooks
                from.CloseGump(typeof(RunebookGump));

                if (!CheckAccess(from))
                {
                    from.SendLocalizedMessage(502413);                       // That cannot be done while the book is locked down.
                }
                //else if ( IsOpen( from ) )
                //{
                //	from.SendLocalizedMessage( 1005571 ); // You cannot place objects in the book while viewing the contents.
                //}
                else if (m_Entries.Count < 16)
                {
                    RecallRune rune = (RecallRune)dropped;

                    if (rune.Marked && rune.TargetMap != null)
                    {
                        m_Entries.Add(new RunebookEntry(rune.Target, rune.TargetMap, rune.Description, rune.House));

                        dropped.Delete();

                        from.Send(new PlaySound(0x42, GetWorldLocation()));

                        string desc = rune.Description;

                        if (desc == null || (desc = desc.Trim()).Length == 0)
                        {
                            desc = "(indescript)";
                        }

                        from.SendMessage(desc);

                        return(true);
                    }
                    else
                    {
                        from.SendLocalizedMessage(502409);                           // This rune does not have a marked location.
                    }
                }
                else
                {
                    from.SendLocalizedMessage(502401);                       // This runebook is full.
                }
            }
            else if (dropped is RecallScroll)
            {
                if (m_CurCharges < m_MaxCharges)
                {
                    from.Send(new PlaySound(0x249, GetWorldLocation()));

                    int amount = dropped.Amount;

                    if (amount > (m_MaxCharges - m_CurCharges))
                    {
                        dropped.Consume(m_MaxCharges - m_CurCharges);
                        m_CurCharges = m_MaxCharges;
                    }
                    else
                    {
                        m_CurCharges += amount;
                        dropped.Delete();

                        return(true);
                    }
                }
                else
                {
                    from.SendLocalizedMessage(502410);                       // This book already has the maximum amount of charges.
                }
            }
            else
            {
                // Adam: anything other than a scroll will get dropped into your backpack
                // (so your best sword doesn't get dropped on the ground.)
                from.AddToBackpack(dropped);
                //	For richness, we add the drop sound of the item dropped.
                from.PlaySound(dropped.GetDropSound());
                return(true);
            }

            return(false);
        }
예제 #6
0
        public override void OnDoubleClick(Mobile from)
        {
            Type type = SpawnerType.GetType(m_ItemType);

            if (type != null && typeof(Item).IsAssignableFrom(type))
            {
                object o = null;

                try
                {
                    ConstructorInfo[] ctors = type.GetConstructors();

                    for (int i = 0; i < ctors.Length; ++i)
                    {
                        ConstructorInfo ctor = ctors[i];

                        if (Add.IsConstructable(ctor, AccessLevel.GameMaster))
                        {
                            ParameterInfo[] paramList = ctor.GetParameters();

                            if (m_ParamList.Length == paramList.Length)
                            {
                                object[] paramValues = Add.ParseValues(paramList, m_ParamList);

                                if (paramValues != null)
                                {
                                    o = ctor.Invoke(paramValues);
                                    break;
                                }
                            }
                        }
                    }
                }
                catch
                {
                    Console.WriteLine("VendStone: Invalid constructor or parameters for {0}: {1} {2}", Serial, m_ItemType, m_Parameters);
                }

                Item item = o as Item;

                if (m_Value < 0)
                {
                    m_Value = 0;
                }

                int amt = from.AccessLevel >= AccessLevel.GameMaster ? 0 : Currency.Consume(from, m_Value, true, CurrencyType.Both);

                if (amt > 0)
                {
                    from.SendMessage(1153, "You lack {0}gp for this", amt);
                    item.Delete();
                }
                else if (from.AddToBackpack(item))
                {
                    from.SendMessage("You place the {0} into your backpack.", FullName);
                    from.PlaySound(from.Backpack.GetDroppedSound(item));
                }
                else
                {
                    from.SendMessage("You do not have room for this item in your backpack and it has been dropped to the ground.");
                    int sound = item.GetDropSound();
                    from.PlaySound(sound == -1 ? 0x42 : sound);
                }
            }
            else
            {
                from.SendMessage("There is nothing being sold on this stone.");
            }
        }
예제 #7
0
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            if (!Movable && !CheckAccess(from))
            {
                from.SendMessage("You cannot access	this");
                return(false);
            }

            if (!(dropped is Seed))
            {
                from.SendMessage("You can only	store seeds	in this	box.");
                return(false);
            }
            BaseHouse house     = BaseHouse.FindHouseAt(from);
            int       lockdowns = 0;

            if (house != null)
            {
                lockdowns = house.LockDownCount;
            }
            int seeds = lockdowns + 1;

            if (house != null && !Movable && seeds > house.MaxLockDowns)
            {
                from.SendMessage("This	would exceed the houses	lockdown limit.");
                return(false);
            }

            int seedcount = SeedCount();

            if (seedcount > m_maxSeeds)
            {
                from.SendMessage("This	seed box cannot	hold any more seeds.");
                return(false);
            }


            Seed seed = (Seed)dropped;
            int  type = ConvertType(seed.PlantType);
            int  hue  = ConvertHue(seed.PlantHue);

            m_counts[type, hue]++;
            itemcount       = SeedCount() / 5;
            this.TotalItems = itemcount;

            if (Parent is Container)
            {
                // calling the full version with (-itemcount - 1) prevents double-counting the seedbox
                if (!((Container)Parent).CheckHold(from, this, true, true, (-TotalItems - 1), (int)(-TotalWeight - Weight)))
                {
                    m_counts[type, hue]--;                     // reverse the change to our state
                    itemcount  = SeedCount() / 5;
                    TotalItems = itemcount;
                    return(false);
                }
            }

            from.SendSound(((dropped.GetDropSound() != -1) ? dropped.GetDropSound() : 0x42), GetWorldLocation());

            dropped.Delete();
            InvalidateProperties();
            return(true);
        }
예제 #8
0
        public override void OnDoubleClick(Mobile from)
        {
            Type type = SpawnerType.GetType(m_ItemType);

            if (type != null && typeof(Item).IsAssignableFrom(type))
            {
                if (m_Price < 0)
                {
                    m_Price = 0;
                }

                if (from.AccessLevel < AccessLevel.GameMaster && m_Price > 0)
                {
                    int totalGold = 0;

                    if (from.Backpack != null)
                    {
                        totalGold += from.Backpack.GetAmount(typeof(Gold));
                    }

                    totalGold += Banker.GetBalance(from);

                    if (totalGold < m_Price)
                    {
                        from.SendMessage(1153, "You lack the funds to purchase this.");
                        return;
                    }
                }

                object o = null;

                try
                {
                    ConstructorInfo[] ctors = type.GetConstructors();

                    for (int i = 0; i < ctors.Length; ++i)
                    {
                        ConstructorInfo ctor = ctors[i];

                        if (Add.IsConstructable(ctor, AccessLevel.GameMaster))
                        {
                            ParameterInfo[] paramList = ctor.GetParameters();

                            if (m_ParamList.Length == paramList.Length)
                            {
                                object[] paramValues = Add.ParseValues(paramList, m_ParamList);

                                if (paramValues != null)
                                {
                                    o = ctor.Invoke(paramValues);
                                    break;
                                }
                            }
                        }
                    }
                }
                catch
                {
                    Console.WriteLine("VendStone: Invalid constructor or parameters for {0}: {1} {2}", Serial, m_ItemType, m_Parameters);
                }

                Item item = o as Item;

                if (item != null && from.Backpack != null)
                {
                    if (from.AddToBackpack(item))
                    {
                        from.SendMessage("You place the {0} into your backpack.", FullName);
                        from.PlaySound(from.Backpack.GetDroppedSound(item));

                        int leftPrice = m_Price;

                        if (from.Backpack != null)
                        {
                            leftPrice -= from.Backpack.ConsumeUpTo(typeof(Gold), leftPrice);
                        }

                        if (leftPrice > 0)
                        {
                            Banker.Withdraw(from, leftPrice);
                        }
                    }
                    else
                    {
                        from.SendMessage("You do not have room for this item in your backpack.");
                        int sound = item.GetDropSound();
                        from.PlaySound(sound == -1 ? 0x42 : sound);
                    }
                }
            }
            else
            {
                from.SendMessage("The magic from this stone has faded.");
            }
        }
예제 #9
0
        public override bool OnDragDrop(Mobile from, Item item)
        {
            if (item is BasePotion)
            {
                BasePotion pot = (BasePotion)item;

                if (m_Held == 0)
                {
                    if (GiveBottle(from))
                    {
                        m_Type = pot.PotionEffect;
                        Held   = 1;

                        from.PlaySound(0x240);

                        from.SendLocalizedMessage(502237);                         // You place the empty bottle in your backpack.

                        item.Delete();
                        return(true);
                    }
                    else
                    {
                        from.SendLocalizedMessage(502238);                         // You don't have room for the empty bottle in your backpack.
                        return(false);
                    }
                }
                else if (pot.PotionEffect != m_Type)
                {
                    from.SendLocalizedMessage(502236);                     // You decide that it would be a bad idea to mix different types of potions.
                    return(false);
                }
                else if (m_Held >= 100)
                {
                    from.SendLocalizedMessage(502233);                     // The keg will not hold any more!
                    return(false);
                }
                else
                {
                    if (GiveBottle(from))
                    {
                        ++Held;
                        item.Delete();

                        from.PlaySound(0x240);

                        from.SendLocalizedMessage(502237);                         // You place the empty bottle in your backpack.

                        item.Delete();
                        return(true);
                    }
                    else
                    {
                        from.SendLocalizedMessage(502238);                         // You don't have room for the empty bottle in your backpack.
                        return(false);
                    }
                }
            }
            else
            {
                from.SendLocalizedMessage(502232);                 // The keg is not designed to hold that type of object.

                // Adam: anything other than a potion will get dropped into your backpack
                // (so your best sword doesn't get dropped on the ground.)
                from.AddToBackpack(item);
                //	For richness, we add the drop sound of the item dropped.
                from.PlaySound(item.GetDropSound());
                return(true);
            }
        }