Exemple #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);
                    }
                }
            }
        }
Exemple #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);
                    }
                }
            }
        }
Exemple #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);
                    }
                }
            }
        }
Exemple #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 );
				}
			}
		}
Exemple #5
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);
                }
            }
        }
Exemple #6
0
		public LootPack(LootPackEntry[] entries)
		{
			m_Entries = entries;
		}
Exemple #7
0
 public LootPack(LootPackEntry entry)
 {
     m_Entry = entry;
 }
Exemple #8
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);
                    }
                }
            }
        }
Exemple #9
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);
                    }
                }
            }
        }