Пример #1
0
		public override void AddContents( BaseContainer cont, Mobile creature, out int contentValue )
		{
			base.AddContents( cont, creature, out contentValue );

			if ( m_RuneChance > Utility.RandomDouble() )
				cont.DropItem( new RecallRune() );

			int scrollcount = Utility.RandomMinMax( MinAmount / 25, MaxAmount / 8 );

			for ( int i = 0; i < scrollcount; i++ )
			{
				if ( (m_RuneChance / 3.0) > Utility.RandomDouble() )
				{
					Item item = null;
					switch ( Utility.Random( 5 ) )
					{
						default:
						case 0: case 1: case 2: item = new RecallScroll(); break;
						case 3: item = new MarkScroll(); break;
						case 4: item = new GateTravelScroll(); break;
					}

					cont.DropItem( item );
				}
			}
		}
Пример #2
0
		public override void AddContents( BaseContainer cont, Mobile creature, out int contentValue )
		{
			base.AddContents( cont, creature, out contentValue );

			if ( m_HealChance > Utility.RandomDouble() )
				cont.DropItem( new Bandage( Utility.RandomMinMax( MinAmount / 2, MaxAmount ) ) );

			int potioncount = Utility.RandomMinMax( MinAmount / 25, MaxAmount / 10 );

			for ( int i = 0; i < potioncount; i++ )
				if ( (m_HealChance / 2.0) > Utility.RandomDouble() )
					cont.DropItem( Utility.RandomBool() ? (Item)new LesserHealPotion() : (Item)new HealPotion() );

			int scrollcount = Utility.RandomMinMax( MinAmount / 12, MaxAmount / 5 );

			for ( int i = 0; i < scrollcount; i++ )
			{
				if ( (m_HealChance / 3.0) > Utility.RandomDouble() )
				{
					Item item = null;
					switch ( Utility.Random( 4 ) )
					{
						default:
						case 0: item = new HealScroll(); break;
						case 1: item = new GreaterHealScroll(); break;
						case 2: item = new CureScroll(); break;
						case 3: item = new ArchCureScroll(); break;
					}

					cont.DropItem( item );
				}
			}
		}
		public override void AddContents( BaseContainer cont, Mobile creature, out int contentValue )
		{
			contentValue = 0;

			int count = Utility.RandomMinMax( m_MinCount, m_MaxCount );

			for ( int i = 0; i < count; i++ )
			{
				Type type = null;

				if ( m_Random )
					type = m_CommodityTypes[Utility.Random(m_CommodityTypes.Length)];
				else
					type = m_CommodityTypes[i % m_CommodityTypes.Length];

				Item com = Activator.CreateInstance( m_CommodityTypes[i] ) as Item;

				if ( com == null )
					throw new NullReferenceException( String.Format( "Type {0} is not an Item or could not be instantiated.", type.ToString() ) );
				else
				{
					if ( com.Stackable )
						com.Amount = Utility.RandomMinMax( m_MinAmount, m_MaxAmount );

					cont.DropItem( com );
				}
			}
		}
		public override void AddContents( BaseContainer cont, Mobile creature, out int contentValue )
		{
			base.AddContents( cont, creature, out contentValue );

			if ( m_BookChance > Utility.RandomDouble() )
			{
				BaseSpellbookLootSet spellbookloot = MagicSpellbookLootSets.LootSet( m_SpellbookGrade );

				if ( spellbookloot != null ) //sanity check
				{
					Tuple<Item[], int> spelltuple = spellbookloot.GenerateLootItem( creature );
					if ( spelltuple.Item1 != null ) // another sanity check
						for ( int i = 0;i < spelltuple.Item1.Length; i++ )
							if ( spelltuple.Item1[i] != null ) // more sanity checks
								cont.DropItem( spelltuple.Item1[i] );

					contentValue += spelltuple.Item2;
				}
			}
		}
Пример #5
0
                protected override void OnTick()
                {
                    Item item = (Item)m_Item;

                    int m_LockLvl    = m_Item.LockLevel - 5;
                    int m_MaxLockLvl = m_Item.MaxLockLevel - 5;

                    if (m_LockLvl <= 0)
                    {
                        m_LockLvl = 1;
                    }
                    if (m_MaxLockLvl <= 0)
                    {
                        m_MaxLockLvl = 1;
                    }

                    if (!m_From.InRange(item.GetWorldLocation(), 1))
                    {
                        return;
                    }

                    if (m_Item.LockLevel == 0 || m_Item.LockLevel == -255)
                    {
                        // LockLevel of 0 means that the door can't be picklocked
                        // LockLevel of -255 means it's magic locked
                        item.SendLocalizedMessageTo(m_From, 502073); // This lock cannot be picked by normal means
                        return;
                    }

                    if ((m_From.Skills[SkillName.Lockpicking].Value + 5.0) < m_Item.RequiredSkill)
                    {
                        // The LockLevel is higher thant the LockPicking of the player
                        item.SendLocalizedMessageTo(m_From, 502072); // You don't see how that lock can be manipulated.
                        return;
                    }

                    if (m_From.CheckTargetSkill(SkillName.Lockpicking, m_Item, m_LockLvl, m_MaxLockLvl))
                    {
                        // Success! Pick the lock!
                        item.SendLocalizedMessageTo(m_From, 502076); // The lock quickly yields to your skill.
                        m_From.PlaySound(0x4A);
                        m_Item.LockPick(m_From);
                        --m_Skey.UsesRemaining;
                    }
                    else
                    {
                        // The player failed to pick the lock
                        item.SendLocalizedMessageTo(m_From, 502075); // You are unable to pick the lock.
                        --m_Skey.UsesRemaining;
                        if (m_Skey.UsesRemaining <= 0)
                        {
                            m_From.SendMessage("You have used up your skeleton key");
                            m_Skey.Delete();
                        }

                        // ==== Random Item Disintergration upon Failure ====
                        if ((Core.SA) && m_Item is TreasureMapChest)
                        {
                            int i_Num = 0; Item i_Destroy = null;

                            BaseContainer m_chest = m_Item as BaseContainer;
                            Item          Dust    = new DustPile();

                            for (int i = 10; i > 0; i--)
                            {
                                i_Num = Utility.Random(m_chest.Items.Count);
                                // Make sure DustPiles aren't called for destruction
                                if ((m_chest.Items.Count > 0) && m_chest.Items[i_Num] is DustPile)
                                {
                                    for (int ci = (m_chest.Items.Count - 1); ci >= 0; ci--)
                                    {
                                        i_Num = ci;
                                        if (i_Num < 0)
                                        {
                                            i_Num = 0;
                                        }

                                        if (m_chest.Items[i_Num] is DustPile)
                                        {
                                            i_Destroy = null;
                                        }
                                        else
                                        {
                                            i_Destroy = m_chest.Items[i_Num];
                                            i_Num     = i_Num; i = 0;
                                        }
                                        // Nothing left but Dust
                                        if (ci < 0 && i > 0)
                                        {
                                            i_Destroy = null; i = 0;
                                        }
                                    }
                                }
                                // Item targetted =+= prepare for object DOOM! >;D
                                else
                                {
                                    i_Destroy = m_chest.Items[i_Num]; i = 0;
                                }
                            }
                            // Delete chosen Item and drop a Dust Pile
                            if (i_Destroy is Gold)
                            {
                                if (i_Destroy.Amount > 1000)
                                {
                                    i_Destroy.Amount -= 1000;
                                }
                                else
                                {
                                    i_Destroy.Delete();
                                }

                                Dust.Hue = 1177; m_chest.DropItem(Dust);
                            }
                            else if (i_Destroy != null)
                            {
                                i_Destroy.Delete(); m_chest.DropItem(Dust);
                            }
                            Effects.PlaySound(m_chest.Location, m_chest.Map, 0x1DE);
                            m_chest.PublicOverheadMessage(MessageType.Regular, 2004, false, "The sound of gas escaping is heard from the chest.");
                        }
                    }
                }
Пример #6
0
        private static void MakeCopy(Item toCopy, ref List<Item> itemList, BaseContainer parentCont)
        {
            Item newItem = null;
            

            try
            {
                newItem = (Item) Activator.CreateInstance(toCopy.GetType());
            }
            catch
            {
                Console.WriteLine("SupplySystem error, cannot create {0}, no parameterless constructor defined?", toCopy.GetType());
            }

            if (newItem == null)
                return;

            //Copy all the "item" related properties
            CopyBaseProperties(toCopy, newItem);

            if (newItem is Container)
            {
                Container newContainer = ((Container)newItem);

                // If a container gets duplicated it needs to get emptied.
                // ("BagOfReagents" problem, items which create content in the constructors have unwanted
                // contents after duping under certain circumstances.)
                Item[] found;

                //Delete all the items from the constructor
                found = newContainer.FindItemsByType(typeof(Item), false);
                for (int j = 0; j < found.Length; j++)
                    found[j].Delete();

                //Add the items from the orginal bag.
                found = ((Container)toCopy).FindItemsByType(typeof(Item), false);
                for (int i = 0; i < found.Length; i++)
                    MakeCopy(found[i], ref itemList, (BaseContainer)newItem);

            }
            else if (newItem is BaseWeapon)
                CopyProperties((BaseWeapon)toCopy, (BaseWeapon)newItem);
            else if (newItem is BaseArmor)
                CopyProperties((BaseArmor)toCopy, (BaseArmor)newItem);
            else if (newItem is BaseClothing)
                CopyProperties((BaseClothing)toCopy, (BaseClothing)newItem);
            else if (toCopy is Spellbook && newItem is Spellbook)
            {
                Spellbook bookToCopy = toCopy as Spellbook;
                Spellbook newBook = newItem as Spellbook;

                newBook.Content = bookToCopy.Content;
            }

            if (parentCont != null)
                parentCont.DropItem(newItem);

            itemList.Add(newItem);

        }
Пример #7
0
                protected override void OnTick()
                {
                    Item item = (Item)m_Item;

                    if (m_From.Skills[SkillName.Lockpicking].Base < 1)
                    {
                        int cycle = 10;

                        while (cycle > 0)
                        {
                            cycle--;
                            m_From.CheckTargetSkill(SkillName.Lockpicking, m_Item, 0, 10);
                        }
                    }

                    if (!m_From.InRange(item.GetWorldLocation(), 1))
                    {
                        return;
                    }

                    if (m_Item.LockLevel == 0 || m_Item.LockLevel == -255)
                    {
                        // LockLevel of 0 means that the door can't be picklocked
                        // LockLevel of -255 means it's magic locked
                        if (m_Lockpick.ItemID == 0x3A75)
                        {
                            m_From.PrivateOverheadMessage(0, 1150, false, "This lock cannot be hacked by normal means.", m_From.NetState);
                        }
                        else
                        {
                            m_From.PrivateOverheadMessage(0, 1150, false, "This lock cannot be picked by normal means.", m_From.NetState);
                        }

                        return;
                    }

                    if ((m_From.Skills[SkillName.Lockpicking].Value + 2) < m_Item.RequiredSkill)
                    {
                        /*
                         * // Do some training to gain skills
                         * m_From.CheckSkill( SkillName.Lockpicking, 0, m_Item.LockLevel );*/

                        // The LockLevel is higher thant the LockPicking of the player
                        if (m_Lockpick.ItemID == 0x3A75)
                        {
                            m_From.PrivateOverheadMessage(0, 1150, false, "You don't see how that lock can be hacked.", m_From.NetState);
                        }
                        else
                        {
                            m_From.PrivateOverheadMessage(0, 1150, false, "You don't see how that lock can be manipulated.", m_From.NetState);
                        }
                        return;
                    }

                    if (m_From.CheckTargetSkill(SkillName.Lockpicking, m_Item, m_Item.LockLevel, m_Item.MaxLockLevel))
                    {
                        // Success! Pick the lock!
                        if (m_Lockpick.ItemID == 0x3A75)
                        {
                            m_From.PlaySound(0x54B); m_From.PrivateOverheadMessage(0, 1150, false, "Your skill at hacking worked.", m_From.NetState);
                        }
                        else
                        {
                            m_From.PlaySound(0x4A); m_From.PrivateOverheadMessage(0, 1150, false, "The lock quickly yields to your skill.", m_From.NetState);
                        }

                        m_Item.LockPick(m_From);
                    }
                    else
                    {
                        // The player failed to pick the lock
                        BrokeLockPickTest();

                        if (m_Lockpick.ItemID == 0x3A75)
                        {
                            m_From.PrivateOverheadMessage(0, 1150, false, "You are unable to hack the lock.", m_From.NetState);
                        }
                        else
                        {
                            m_From.PrivateOverheadMessage(0, 1150, false, "You are unable to pick the lock.", m_From.NetState);
                        }

                        // ==== Random Item Disintergration upon Failure ====
                        if (m_Item is TreasureMapChest)
                        {
                            int i_Num = 0; Item i_Destroy = null;

                            BaseContainer m_chest = m_Item as BaseContainer;
                            Item          Dust    = new DustPile();

                            for (int i = 10; i > 0; i--)
                            {
                                i_Num = Utility.Random(m_chest.Items.Count);
                                // Make sure DustPiles aren't called for destruction
                                if ((m_chest.Items.Count > 0) && m_chest.Items[i_Num] is DustPile)
                                {
                                    for (int ci = (m_chest.Items.Count - 1); ci >= 0; ci--)
                                    {
                                        i_Num = ci;
                                        if (i_Num < 0)
                                        {
                                            i_Num = 0;
                                        }

                                        if (m_chest.Items[i_Num] is DustPile)
                                        {
                                            i_Destroy = null;
                                        }
                                        else
                                        {
                                            i_Destroy = m_chest.Items[i_Num];
                                            i         = 0;
                                        }
                                        // Nothing left but Dust
                                        if (ci < 0 && i > 0)
                                        {
                                            i_Destroy = null; i = 0;
                                        }
                                    }
                                }
                                // Item targeted =+= prepare for object DOOM! >;D
                                else
                                {
                                    i_Destroy = m_chest.Items[i_Num]; i = 0;
                                }
                            }
                            // Delete chosen Item and drop a Dust Pile
                            if (i_Destroy is Gold)
                            {
                                if (i_Destroy.Amount > 1000)
                                {
                                    i_Destroy.Amount -= 1000;
                                }
                                else
                                {
                                    i_Destroy.Delete();
                                }

                                Dust.Hue = 1177; m_chest.DropItem(Dust);
                            }
                            else if (i_Destroy != null)
                            {
                                i_Destroy.Delete(); m_chest.DropItem(Dust);
                            }
                            Effects.PlaySound(m_chest.Location, m_chest.Map, 0x1DE);
                            m_chest.PublicOverheadMessage(MessageType.Regular, 2004, false, "The sound of gas escaping is heard from the chest.");
                        }
                    }
                }
                protected override void OnTick()
                {
                    Item item = (Item)m_Item;

                    if (!m_From.InRange(item.GetWorldLocation(), 1))
                    {
                        return;
                    }

                    if (m_Item.LockLevel == 0 || m_Item.LockLevel == -255)
                    {
                        // LockLevel of 0 means that the door can't be picklocked
                        // LockLevel of -255 means it's magic locked
                        item.SendLocalizedMessageTo(m_From, 502073);                           // This lock cannot be picked by normal means
                        return;
                    }

                    if (m_From.Skills[SkillName.Lockpicking].Value < m_Item.RequiredSkill)
                    {
                        /*
                         * // Do some training to gain skills
                         * m_From.CheckSkill( SkillName.Lockpicking, 0, m_Item.LockLevel );*/

                        // The LockLevel is higher thant the LockPicking of the player
                        m_From.SendMessage("Trying to manipulate the contraption resulted in a broken lockpick.");
                        m_Lockpick.Consume();
                        return;
                    }

                    if (m_From.CheckTargetSkill(SkillName.Lockpicking, m_Item, m_Item.LockLevel, m_Item.MaxLockLevel))
                    {
                        // Success! Pick the lock!
                        m_From.SendMessage("Woot! You succeed at picking the lock.");
                        m_From.PlaySound(0x4A);
                        m_Item.LockPick(m_From);
                    }
                    else
                    {
                        // The player failed to pick the lock
                        BrokeLockPickTest();
                        item.SendLocalizedMessageTo(m_From, 502075);                           // You are unable to pick the lock.

                        // ==== Random Item Disintergration upon Failure ====
                        if ((Core.SA) && m_Item is TreasureMapChest)
                        {
                            int i_Num = 0; Item i_Destroy = null;

                            BaseContainer m_chest = m_Item as BaseContainer;
                            Item          Dust    = new DustPile();

                            for (int i = 10; i > 0; i--)
                            {
                                i_Num = Utility.Random(m_chest.Items.Count);
                                // Make sure DustPiles aren't called for destruction
                                if ((m_chest.Items.Count > 0) && m_chest.Items[i_Num] is DustPile)
                                {
                                    for (int ci = (m_chest.Items.Count - 1); ci >= 0; ci--)
                                    {
                                        i_Num = ci;
                                        if (i_Num < 0)
                                        {
                                            i_Num = 0;
                                        }

                                        if (m_chest.Items[i_Num] is DustPile)
                                        {
                                            i_Destroy = null;
                                        }
                                        else
                                        {
                                            i_Destroy = m_chest.Items[i_Num];
                                            i_Num     = i_Num; i = 0;
                                        }
                                        // Nothing left but Dust
                                        if (ci < 0 && i > 0)
                                        {
                                            i_Destroy = null; i = 0;
                                        }
                                    }
                                }
                                // Item targetted =+= prepare for object DOOM! >;D
                                else
                                {
                                    i_Destroy = m_chest.Items[i_Num]; i = 0;
                                }
                            }
                            // Delete chosen Item and drop a Dust Pile
                            if (i_Destroy is Gold)
                            {
                                if (i_Destroy.Amount > 1000)
                                {
                                    i_Destroy.Amount -= 1000;
                                }
                                else
                                {
                                    i_Destroy.Delete();
                                }

                                Dust.Hue = 1177; m_chest.DropItem(Dust);
                            }
                            else if (i_Destroy != null)
                            {
                                i_Destroy.Delete(); m_chest.DropItem(Dust);
                            }
                            Effects.PlaySound(m_chest.Location, m_chest.Map, 0x1DE);
                            m_chest.PublicOverheadMessage(MessageType.Regular, 2004, false, "The sound of gas escaping is heard from the chest.");
                        }
                    }
                }