Construct() public method

public Construct ( Server.Mobile from, bool spawning ) : Item
from Server.Mobile
spawning bool
return Item
示例#1
0
        public void Generate(Mobile from, Container cont, bool spawning)
        {
            if (cont == null)
            {
                return;
            }

            for (int i = 0; i < m_Entries.Length; ++i)
            {
                LootPackEntry entry = m_Entries[i];

                bool shouldAdd = (entry.Chance > Utility.Random(10000));

                if (!shouldAdd)
                {
                    continue;
                }

                Item item = entry.Construct(from, spawning);

                if (item != null)
                {
                    if (!item.Stackable || !cont.TryDropItem(from, item, false))
                    {
                        cont.DropItem(item);
                    }
                }
            }
        }
示例#2
0
        public void Generate(Mobile npc, Container cont)
        {
            if (cont == null || npc == null)
            {
                return;
            }

            for (int i = 0; i < m_Entries.Length; ++i)
            {
                LootPackEntry entry = m_Entries[i];
                if (!(entry.Chance > Utility.Random(10000)))
                {
                    continue;
                }

                Item item = entry.Construct();
                if (item != null)
                {
                    if (!item.Stackable || !cont.TryDropItem(npc, item, false))
                    {
                        cont.DropItem(item);
                    }
                }
            }
        }
示例#3
0
        public void Generate(BaseCreature npc)
        {
            if (npc == null || npc.Summoned)
            {
                return;
            }

            for (int i = 0; i < m_Entries.Length; ++i)
            {
                LootPackEntry entry = m_Entries[i];
                if (!(entry.Chance > Utility.Random(10000)))
                {
                    continue;
                }

                Item item = entry.Construct();
                if (item != null)
                {
                    if (npc.Backpack == null)
                    {
                        npc.AddItem(new Backpack());
                    }

                    if (!item.Stackable || !npc.Backpack.TryDropItem(npc, item, false))
                    {
                        npc.Backpack.DropItem(item);
                    }
                }
            }
        }
示例#4
0
		public void Generate( Mobile from, Container cont, bool spawning, int luckChance )
		{
			if ( cont == null )
				return;

			bool checkLuck = true;

			for ( int i = 0; i < m_Entries.Length; ++i )
			{
				LootPackEntry entry = m_Entries[i];

				bool shouldAdd = ( entry.Chance > Utility.Random( 10000 ) );

				if ( !shouldAdd && checkLuck )
				{
					checkLuck = false;

					if ( LootPack.CheckLuck( luckChance ) )
						shouldAdd = ( entry.Chance > Utility.Random( 10000 ) );
				}

				if ( !shouldAdd )
					continue;

				Item item = entry.Construct( from, luckChance, spawning );

				if ( item != null )
				{
					if ( !item.Stackable || !cont.TryDropItem( from, item, false ) )
						cont.DropItem( item );
				}
			}
		}
示例#5
0
        public void Generate(Container cont)
        {
            if (cont == null)
            {
                return;
            }

            Item item = m_Entry.Construct();

            if (item != null)
            {
                cont.AddItem(item);
            }
        }
示例#6
0
        public void Generate(Container cont)
        {
            if (cont == null)
            {
                return;
            }

            for (int i = 0; i < m_Entries.Length; ++i)
            {
                LootPackEntry entry = m_Entries[i];
                if (!(entry.Chance > Utility.Random(10000)))
                {
                    continue;
                }

                Item item = entry.Construct();
                if (item != null)
                {
                    cont.DropItem(item);
                }
            }
        }
示例#7
0
        public void Generate(Mobile from, Container cont, bool spawning, int luckChance)
        {
            if (cont == null)
            {
                return;
            }

            bool checkLuck = Core.AOS;

            for (int i = 0; i < m_Entries.Length; ++i)
            {
                LootPackEntry entry = m_Entries[i];

                bool shouldAdd = (entry.Chance > Utility.Random(10000));

                if (!shouldAdd && checkLuck)
                {
                    checkLuck = false;

                    if (LootPack.CheckLuck(luckChance))
                    {
                        shouldAdd = (entry.Chance > Utility.Random(10000));
                    }
                }

                if (!shouldAdd)
                {
                    continue;
                }

                Item item = entry.Construct(from, luckChance, spawning);

                // Plume begin check Identification
                if (item is BaseWeapon || item is BaseArmor || item is BaseClothing || item is BaseJewel)
                {
                    bool IsID = true;

                    int    bonusProps = entry.GetBonusProperties();
                    double min        = (double)entry.MinIntensity;
                    double max        = (double)entry.MaxIntensity;

                    if (bonusProps < entry.MaxProps && LootPack.CheckLuck(luckChance))
                    {
                        ++bonusProps;
                    }

                    int props = 1 + bonusProps;

                    double dblID = (((min / max) + (min / 5.0) + (max / 10.0)) * (props + props / 10.0)) / 100.0;

                    if (props >= 5 && Utility.Random(0, 100) > 1)
                    {
                        IsID = false;
                    }
                    else if (dblID > Utility.RandomDouble())
                    {
                        IsID = false;
                    }

                    if (!IsID)
                    {
                        if (item is BaseWeapon)
                        {
                            ((BaseWeapon)item).Identified = false;
                        }
                        else if (item is BaseArmor)
                        {
                            ((BaseArmor)item).Identified = false;
                        }
                        else if (item is BaseClothing)
                        {
                            ((BaseClothing)item).Identified = false;
                        }
                        else if (item is BaseJewel)
                        {
                            ((BaseJewel)item).Identified = false;
                        }
                    }
                }
                // End
                if (item != null)
                {
                    if (!item.Stackable || !cont.TryDropItem(from, item, false))
                    {
                        cont.DropItem(item);
                    }
                }
            }
        }
示例#8
0
        public void Generate(IEntity from, BaseContainer cont, LootStage stage, int luckChance, bool hasBeenStolenFrom)
        {
            if (cont == null)
            {
                return;
            }

            bool checkLuck = true;

            for (int i = 0; i < m_Entries.Length; ++i)
            {
                LootPackEntry entry = m_Entries[i];

                if (!entry.CanGenerate(stage, hasBeenStolenFrom))
                {
                    continue;
                }

                bool shouldAdd = entry.Chance > Utility.Random(10000);

                if (!shouldAdd && checkLuck)
                {
                    checkLuck = false;

                    if (CheckLuck(luckChance))
                    {
                        shouldAdd = entry.Chance > Utility.Random(10000);
                    }
                }

                if (!shouldAdd)
                {
                    continue;
                }

                Item item = entry.Construct(from, luckChance, stage, hasBeenStolenFrom);

                if (item != null)
                {
                    if (from is BaseCreature && item.LootType == LootType.Blessed)
                    {
                        Timer.DelayCall(TimeSpan.FromMilliseconds(25), () =>
                        {
                            var corpse = ((BaseCreature)from).Corpse;

                            if (corpse != null)
                            {
                                if (!corpse.TryDropItem((BaseCreature)from, item, false))
                                {
                                    corpse.DropItem(item);
                                }
                            }
                            else
                            {
                                item.Delete();
                            }
                        });
                    }
                    else if (item.Stackable)
                    {
                        cont.DropItemStacked(item);
                    }
                    else
                    {
                        cont.DropItem(item);
                    }
                }
            }
        }