Esempio n. 1
0
		public override bool OnDragDrop( Mobile from, Item dropped )
		{
			PlayerMobile player = from as PlayerMobile;

			if ( player != null )
			{
				QuestSystem qs = player.Quest;

				if ( qs is EminosUndertakingQuest )
				{
					if ( dropped is NoteForZoel )
					{
						QuestObjective obj = qs.FindObjective( typeof( GiveZoelNoteObjective ) );

						if ( obj != null && !obj.Completed )
						{
							dropped.Delete();
							obj.Complete();
							return true;
						}
					}
				}
			}

			return base.OnDragDrop( from, dropped );
		}
Esempio n. 2
0
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();

            switch ( version )
            {
                case 0:
                    {
                        m_Platform = reader.ReadItem() as PeerlessPlatform;
                        m_Key = reader.ReadItem();

                        if ( m_Platform == null )
                            Delete();

                        if ( m_Key != null )
                        {
                            m_Key.Delete();
                            m_Key = null;
                        }

                        break;
                    }
            }
        }
Esempio n. 3
0
 public override bool OnDragDrop(Mobile from, Item item)
 {
     if (item is GoblinEars)
     {
         Say(1049368); // You have been rewarded for your dedication to Justice!
         from.Backpack.AddItem(new Factions.Silver(1, 5));
         item.Delete();
         return true;
     }
     else if (item is OutlanderHead)
     {
         Say(1049368); // You have been rewarded for your dedication to Justice!
         from.Backpack.AddItem(new Factions.Silver(10, 50));
         item.Delete();
         return true;
     }
     else if (item is GilwiremarHead)
     {
         Say(1049368); // You have been rewarded for your dedication to Justice!
         from.Backpack.AddItem(new Factions.Silver(100, 500));
         item.Delete();
         return true;
     }
     else
     {
         Say(502816); // You feel that such an action would be inappropriate
         return false;
     }
 }
		public override bool OnDragDrop( Mobile from, Item dropped )
		{          		
			if ( from == null )
				return false;

			if( dropped is GrandmasBrace )
			{
				if ( alFinished.Contains( from ) )
				{
					from.SendMessage(32, "You can do the quest only once");
					return false;
				}
				alFinished.Add( from );
				from.AddToBackpack( new Gold( 5000 ) );
				if (dropped.Amount > 1)
					dropped.Amount--;
				else
					dropped.Delete();
				from.SendMessage( "Thank you kind neighbor!" );
				from.SendGump( new LauraFinishGump());
			}
			else
				PrivateOverheadMessage( MessageType.Regular, 1153, false, "I have no use of this!", from.NetState );
			return false;
		}
Esempio n. 5
0
        private void DestroyFurniture( Mobile from, Item item )
        {
            if ( !from.InRange( item.GetWorldLocation(), 3 ) )
            {
                from.SendLocalizedMessage( 500446 ); // That is too far away.
                return;
            }
            else if ( !item.Movable || !item.IsChildOf( from.Backpack ) )
            {
                from.SendLocalizedMessage( 500462 ); // You can't destroy that while it is here.
                return;
            }

            from.SendLocalizedMessage( 500461 ); // You destroy the item.
            Effects.PlaySound( item.GetWorldLocation(), item.Map, 0x3B3 );

            if ( item is Container )
            {
                if ( item is TrapableContainer )
                    ((TrapableContainer)item).ExecuteTrap( from );
                ((Container)item).Destroy();
            }
            else
            {
                item.Delete();
            }
        }
Esempio n. 6
0
		public override bool OnDragDrop( Mobile from, Item dropped )
		{
			if ( dropped is LargeBOD )
			{
				if ( !IsChildOf( from.Backpack ) )
				{
					from.SendLocalizedMessage( 1062385 ); // You must have the book in your backpack to add deeds to it.
					return false;
				}
				else if ( m_Entries.Count < 500 )
				{
					m_Entries.Add( new BOBLargeEntry( (LargeBOD)dropped ) );
					InvalidateProperties();

					from.SendLocalizedMessage( 1062386 ); // Deed added to book.

					if ( from is PlayerMobile )
						from.SendGump( new BOBGump( (PlayerMobile)from, this ) );

					dropped.Delete();
					return true;
				}
				else
				{
					from.SendLocalizedMessage( 1062387 ); // The book is full of deeds.
					return false;
				}
			}
			else if ( dropped is SmallBOD )
			{
				if ( !IsChildOf( from.Backpack ) )
				{
					from.SendLocalizedMessage( 1062385 ); // You must have the book in your backpack to add deeds to it.
					return false;
				}
				else if ( m_Entries.Count < 500 )
				{
					m_Entries.Add( new BOBSmallEntry( (SmallBOD)dropped ) );
					InvalidateProperties();

					from.SendLocalizedMessage( 1062386 ); // Deed added to book.

					if ( from is PlayerMobile )
						from.SendGump( new BOBGump( (PlayerMobile)from, this ) );

					dropped.Delete();
					return true;
				}
				else
				{
					from.SendLocalizedMessage( 1062387 ); // The book is full of deeds.
					return false;
				}
			}

			from.SendLocalizedMessage( 1062388 ); // That is not a bulk order deed.
			return false;
		}
Esempio n. 7
0
        public static void PackItem( Mobile m, Item item )
        {
            if ( item is BaseArmor )
                ((BaseArmor)item).Quality = ArmorQuality.Exceptional;
            else if ( item is BaseWeapon )
                ((BaseWeapon)item).Quality = WeaponQuality.Exceptional;

            if ( !m.PlaceInBackpack( item ) )
                item.Delete();
        }
Esempio n. 8
0
        public static void GiveItem( Mobile m, Item item )
        {
            if ( item is BaseArmor )
                ((BaseArmor)item).Quality = ArmorQuality.Exceptional;
            else if ( item is BaseWeapon )
                ((BaseWeapon)item).Quality = WeaponQuality.Exceptional;

            Item move = m.FindItemOnLayer( item.Layer );
            if ( move != null )
            {
                if ( !m.PlaceInBackpack( move ) )
                {
                    item.Delete();
                    return;
                }
            }

            if ( !m.EquipItem( item ) && !m.PlaceInBackpack( item ) )
                item.Delete();
        }
Esempio n. 9
0
			private static void PackItem( Item item )
			{
				if ( !Core.AOS )
					item.LootType = LootType.Newbied;

				Container pack = m_Mobile.Backpack;

				if ( pack != null )
					pack.DropItem( item );
				else
					item.Delete();
			}
Esempio n. 10
0
			private static void EquipItem( Item item, bool mustEquip )
			{
				if ( !Core.AOS )
					item.LootType = LootType.Newbied;

				if ( m_Mobile != null && m_Mobile.EquipItem( item ) )
					return;

				Container pack = m_Mobile.Backpack;

				if ( !mustEquip && pack != null )
					pack.DropItem( item );
				else
					item.Delete();
			}
Esempio n. 11
0
		public override bool TryDropItem(Mobile from, Item dropped, bool message)
		{
			if(dropped is ExperimentalGem && ((ExperimentalGem)dropped).Complete && from.InRange(this.Location, 2))
			{
				dropped.Delete();
				
				Item toDrop = GetRandomDrop();
				
				if(toDrop != null)
					AddItemFor(toDrop, from);
				
				base.OnDoubleClick(from);
			}
			
			return false;
		}
Esempio n. 12
0
			private bool Resmelt( Mobile from, Item item, CraftResource resource )
			{
				try
				{
					if ( CraftResources.GetType( resource ) != CraftResourceType.Metal )
						return false;

					CraftResourceInfo info = CraftResources.GetInfo( resource );

					if ( info == null || info.ResourceTypes.Length == 0 )
						return false;

					CraftItem craftItem = m_CraftSystem.CraftItems.SearchFor( item.GetType() );

					if ( craftItem == null || craftItem.Ressources.Count == 0 )
						return false;

					CraftRes craftResource = craftItem.Ressources.GetAt( 0 );

					if ( craftResource.Amount < 2 )
						return false; // Not enough metal to resmelt

					Type resourceType = info.ResourceTypes[0];
					Item ingot = (Item)Activator.CreateInstance( resourceType );

					if ( item is DragonBardingDeed || (item is BaseArmor && ((BaseArmor)item).PlayerConstructed) || (item is BaseWeapon && ((BaseWeapon)item).PlayerConstructed) || (item is BaseClothing && ((BaseClothing)item).PlayerConstructed) )
						ingot.Amount = craftResource.Amount / 2;
					else
						ingot.Amount = 1;

					item.Delete();
					from.AddToBackpack( ingot );

					from.PlaySound( 0x2A );
					from.PlaySound( 0x240 );
					return true;
				}
				catch
				{
				}

				return false;
			}
		public static Item TryCreateItem( int x, int y, int z, Item srcItem )
		{
			IPooledEnumerable eable = Map.Felucca.GetItemsInBounds( new Rectangle2D( x, y, 1, 1 ) );

				foreach ( Item item in eable )
				{
					if ( item.GetType() == srcItem.GetType() )
					{
						eable.Free();
						srcItem.Delete();
						return item;
					}
				}

			eable.Free();
			srcItem.MoveToWorld( new Point3D( x, y, z ), Map.Felucca );
			m_Count++;

			return srcItem;
		}
		public override bool OnDragDrop( Mobile from, Item dropped )
		{
			if ( !( dropped is FactionSilver ) )
			{
				from.SendMessage( "You can only drop old faction silver here." );
				return false;
			}
			else
			{
				if ( from.Backpack != null )
				{
					Silver silver = new Silver( ((FactionSilver)dropped).Amount );
					from.Backpack.DropItem( silver );
					dropped.Delete();
					from.SendMessage( "You successfully converted the old silver to new silver!" );
				}
				else
					from.SendMessage( "Where is your backpack?!" );
				return true;
			}
		}
		public void AddReg( Type type, int amount, Item dropped, Mobile from)
		{
			if ( m_Regs == null )
				m_Regs = new Hashtable();
			if (m_Regs[type] == null)
			{
				if (amount <= StorageLimit)
				{
					m_Regs.Add(type,amount);
					dropped.Delete();
					BeginCombine(from);
					from.SendGump( new SpellCastersBoxGump( (PlayerMobile)from, this ) ); 
					from.SendMessage("You added the item.");
				}
				else
				{
					BeginCombine(from);
					from.SendMessage("You have too much of that item.");
				}
			}
			else if ( (amount + (int)m_Regs[type]) <= StorageLimit)
			{
				if ( m_Regs.ContainsKey(type) )
				{
					m_Regs[type] = (int)m_Regs[type] + amount;
				}
				else
					m_Regs.Add(type,amount);
				dropped.Delete();
				BeginCombine(from);
				from.SendGump( new SpellCastersBoxGump( (PlayerMobile)from, this ) ); 
				from.SendMessage("You added the item.");
			}
			else
			{
				BeginCombine(from);
				from.SendMessage("You have too much of that item.");
			}
		}
Esempio n. 16
0
        public void HarvestPlant(Mobile from, Item i_item, BaseRegentPlant i_item2)
        {
            item = i_item;
            item2 = i_item2;
            m = from;

            if (m.InRange(this.GetWorldLocation(), 2))
            {

                item.Amount = held;

                if (m.Skills[SkillName.Cooking].Value > 95.0 && held >= 0 || m.Skills[SkillName.Lumberjacking].Value > 95.0 && held >= 0)
                {
                    item.Amount += (int)(m.Skills[SkillName.Cooking].Value - 95.0);
                    item.Amount += (int)(m.Skills[SkillName.Lumberjacking].Value - 95.0);
                    m.SendMessage("You use you expert skill to gain more then average from the plant.");
                }

                if (held > 0)
                {
                    double chance = Utility.RandomDouble();

                    if (0.30 > chance)
                        GiveSeed(m, item2);

                    m.SendMessage("You harvest from the plant.");
                    AddHarvestToPack(m, item);
                    item2.Delete();
                }
                else
                {
                    m.SendMessage("There is not enough there to harvest.");
                    item.Delete();
                    return;
                }

            }
        }
Esempio n. 17
0
		public bool TryAddBrokerEntry(Item item, Mobile from)
		{
            Item realItem = item;

            if (item is CommodityDeed)
                realItem = ((CommodityDeed)item).Commodity;

            Type type = realItem.GetType();
            int amount = realItem.Amount;

			if(HasType(type))
				return false;

            CommodityBrokerEntry entry = new CommodityBrokerEntry(realItem, this, amount);
            m_CommodityEntries.Add(entry);

            if(amount > 0)
                from.SendLocalizedMessage(1150220, String.Format("{0}\t#{1}\t{2}", amount.ToString(), entry.Label, Plot.ShopName == null ? "an unnamed shop" : Plot.ShopName)); // You have added ~1_QUANTITY~ units of ~2_ITEMNAME~ to the inventory of "~3_SHOPNAME~"

            item.Delete();

			return true;
		}
		public override bool OnDragDrop( Mobile from, Item dropped )
		{
			if ( dropped is MonsterContract )
			{
				MonsterContract MC = dropped as MonsterContract;
				if ( !IsChildOf( from.Backpack ) )
				{
					from.SendLocalizedMessage( 1062385 ); // You must have the book in your backpack to add deeds to it.
					return false;
				}
				else if ( m_Entries.Count < 20 )
				{
					m_Entries.Add( new MonsterContractEntry( MC.Monster, MC.AmountKilled, MC.AmountToKill, MC.Reward ) );
					
					m_Entries.Sort();//#01
					
					InvalidateProperties();

					from.SendLocalizedMessage( 1062386 ); // Deed added to book.

					if ( from is PlayerMobile )
						from.SendGump( new MonsterContractBookGump( (PlayerMobile)from, this ) );

					dropped.Delete();
					return true;
				}
				else
				{
					from.SendLocalizedMessage( 1062387 ); // The book is full of deeds.
					return false;
				}
			}

			from.SendMessage( "This is not a valid contract.");
			return false;
		}
Esempio n. 19
0
		public bool TryAdd( Item item )
		{
			foreach( Type[] cat in m_AllTypes )
			{
				foreach( Type type in cat )
				{
					if( item.GetType() == type )
					{
						if( m_Resources.ContainsKey( type ) && (int)m_Resources[type] + item.Amount >= 100000 )
						{
							this.PublicOverheadMessage( MessageType.Whisper, 0, false, "I cannot hold more of that resource!" );
							return false;
						}
                    								
						AddResource( type, item.Amount );
						this.PublicOverheadMessage( MessageType.Whisper, 0, false, "Resource Added." );
						item.Delete();
						return true;
					}
				}
			}
			this.PublicOverheadMessage( MessageType.Whisper, 0, false, "I don't hold that resource!" );
			return false;
		}
Esempio n. 20
0
        public static void AddSpawnItem(XmlSpawner spawner, object invoker, XmlSpawner.SpawnObject theSpawn, Item item, Point3D location, Map map, Mobile trigmob, bool requiresurface,
            List<XmlSpawner.SpawnPositionInfo> spawnpositioning, string propertyString, bool smartspawn, out string status_str)
        {
            status_str = null;
            if (item == null || theSpawn == null) return;

            // add the item to the spawned list
            theSpawn.SpawnedObjects.Add(item);

            item.Spawner = spawner;

            if (spawner != null)
            {
                // this is being called by a spawner so use spawner information for placement
                if (!spawner.Deleted)
                {
                    // set the item amount
                    if (spawner.StackAmount > 1 && item.Stackable)
                    {
                        item.Amount = spawner.StackAmount;
                    }
                    // if this is in any container such as a pack then add to the container.
                    if (spawner.Parent is Container)
                    {
                        Container c = (Container)spawner.Parent;

                        Point3D loc = spawner.Location;

                        if (!smartspawn)
                        {
                            item.OnBeforeSpawn(loc, map);
                        }

                        item.Location = loc;

                        // check to see whether we drop or add the item based on the spawnrange
                        // this will distribute multiple items around the spawn point, and allow precise
                        // placement of single spawns at the spawn point
                        if (spawner.SpawnRange > 0)
                            c.DropItem(item);
                        else
                            c.AddItem(item);

                    }
                    else
                    {
                        // if the spawn entry is in a subgroup and has a packrange, then get the packcoord

                        Point3D packcoord = Point3D.Zero;
                        if (theSpawn.PackRange >= 0 && theSpawn.SubGroup > 0)
                        {
                            packcoord = spawner.GetPackCoord(theSpawn.SubGroup);
                        }
                        Point3D loc = spawner.GetSpawnPosition(requiresurface, theSpawn.PackRange, packcoord, spawnpositioning);

                        if (!smartspawn)
                        {
                            item.OnBeforeSpawn(loc, map);
                        }

                        // standard placement for all items in the world
                        item.MoveToWorld(loc, map);
                    }
                }
                else
                {
                    // if the spawner has already been deleted then delete the item since it cannot be cleaned up by spawner deletion any longer
                    item.Delete();
                    return;
                }
            }
            else
            {
                if (!smartspawn)
                {
                    item.OnBeforeSpawn(location, map);
                }
                // use the location and map info passed in
                // this allows AddSpawnItem to be called by objects other than spawners as long as they pass in a valid SpawnObject
                item.MoveToWorld(location, map);
            }

            // clear the taken flag on all newly spawned items
            ItemFlags.SetTaken(item, false);

            if (!smartspawn)
            {
                item.OnAfterSpawn();
            }

            // apply the parsed arguments from the typestring using setcommand
            // be sure to do this after setting map and location so that errors dont place the mob on the internal map
            BaseXmlSpawner.ApplyObjectStringProperties(spawner, propertyString, item, trigmob, spawner, out status_str);

            // if the object has an OnAfterSpawnAndModify method, then invoke it
            //InvokeOnAfterSpawnAndModify(item);
        }
Esempio n. 21
0
        public void GiveArtifact(Mobile to, Item artifact)
        {
            if (to == null || artifact == null)
                return;

            Container pack = to.Backpack;

            if (pack == null || !pack.TryDropItem(to, artifact, false))
                artifact.Delete();
            else
                to.SendLocalizedMessage(1062317); // For your valor in combating the fallen beast, a special artifact has been bestowed on you.
        }
Esempio n. 22
0
        public override bool OnDragDrop( Mobile from, Item dropped )
        {
			if ( Movable )
                    return false;

            if ( !( dropped is Seed ) )
            {
                from.SendMessage( "You can only store seeds in this box." );
                return false;
            }

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

            Seed seed = ( Seed ) dropped;

			if( !seed.ShowType )
			{
				from.SendMessage( "You cannot store that seed since you are are not sure of its type." );
				return false;
			}

            //int type = (int)seed.PlantType + 8;
            //int hue = GetSeedHue( seed.Hue );
			int type = ConvertType( seed.PlantType );
			int hue = ConvertHue( seed.PlantHue );

            m_counts[ type, hue ] ++;
            dropped.Delete();
			InvalidateProperties();
            return true;
        }
Esempio n. 23
0
		public override bool OnDragDrop( Mobile from, Item item )
		{
			if ( !IsOwner( from ) )
			{
				SayTo( from, 503209 ); // I can only take item from the shop owner.
				return false;
			}

			if ( item is Gold )
			{
				if ( BaseHouse.NewVendorSystem )
				{
					if ( this.HoldGold < 1000000 )
					{
						SayTo( from, 503210 ); // I'll take that to fund my services.

						this.HoldGold += item.Amount;
						item.Delete();

						return true;
					}
					else
					{
						from.SendLocalizedMessage( 1062493 ); // Your vendor has sufficient funds for operation and cannot accept this gold.

						return false;
					}
				}
				else
				{
					if ( this.BankAccount < 1000000 )
					{
						SayTo( from, 503210 ); // I'll take that to fund my services.

						this.BankAccount += item.Amount;
						item.Delete();

						return true;
					}
					else
					{
						from.SendLocalizedMessage( 1062493 ); // Your vendor has sufficient funds for operation and cannot accept this gold.

						return false;
					}
				}
			}
			else
			{
				bool newItem = ( GetVendorItem( item ) == null );

				if ( this.Backpack != null && this.Backpack.TryDropItem( from, item, false ) )
				{
					if ( newItem )
						OnItemGiven( from, item );

					return true;
				}
				else
				{
					SayTo( from, 503211 ); // I can't carry any more.
					return false;
				}
			}
		}
Esempio n. 24
0
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            Mobile m = from;
            PlayerMobile mobile = m as PlayerMobile;

            if ( mobile != null)
            {
                if (dropped is Gold && dropped.Amount == 100)
             			{
                        mobile.AddToBackpack ( new QuestScroll(1) );
                        this.PrivateOverheadMessage( MessageType.Regular, 1153, false, "Me devolva este Scroll quando terminar...para receber sua recompensa..", mobile.NetState );
             				return true;
             			}
                    else if (dropped is Gold && dropped.Amount == 200)
             			{
                        mobile.AddToBackpack ( new QuestScroll(2) );
                        this.PrivateOverheadMessage(MessageType.Regular, 1153, false, "Me devolva este Scroll quando terminar...para receber sua recompensa..", mobile.NetState);
             				return true;
             			}
                else if (dropped is Gold && dropped.Amount == 300)
             			{
                        mobile.AddToBackpack ( new QuestScroll(3) );
                        this.PrivateOverheadMessage(MessageType.Regular, 1153, false, "Me devolva este Scroll quando terminar...para receber sua recompensa..", mobile.NetState);
             				return true;
             			}
                else if (dropped is Gold && dropped.Amount == 400)
             			{
                        mobile.AddToBackpack ( new QuestScroll(4) );
                        this.PrivateOverheadMessage(MessageType.Regular, 1153, false, "Me devolva este Scroll quando terminar...para receber sua recompensa..", mobile.NetState);
             				return true;
             			}
                else if (dropped is Gold && dropped.Amount == 500)
             			{
                        mobile.AddToBackpack ( new QuestScroll(5) );
                        this.PrivateOverheadMessage(MessageType.Regular, 1153, false, "Me devolva este Scroll quando terminar...para receber sua recompensa..", mobile.NetState);
             				return true;
             			}
                else if (dropped is Gold && dropped.Amount == 600)
             			{
                        mobile.AddToBackpack ( new QuestScroll(6) );
                        this.PrivateOverheadMessage(MessageType.Regular, 1153, false, "Me devolva este Scroll quando terminar...para receber sua recompensa..", mobile.NetState);
             				return true;
             			}
             			else if(dropped is Gold)
             			{
                        this.PrivateOverheadMessage( MessageType.Regular, 1153, false, "Nao tenho nada para voce por esta quantia de gold.", mobile.NetState );
             				return false;
             			}
                    else if( dropped is QuestScroll )
             			{
                        QuestScroll m_Quest = (QuestScroll)dropped;

             				if(m_Quest.NNeed > m_Quest.NGot)
             				{
                            mobile.AddToBackpack ( dropped );
                            this.PrivateOverheadMessage( MessageType.Regular, 1153, false, "Voce nao completou essa quest.", mobile.NetState );
             					return false;
             				}

                        string sMessage = "";
                        if (m_Quest.NType == 1) { sMessage = "Vejo que voce voltou vitorioso. Aqui esta sua recompensa!"; }
                        else { sMessage = "Ahh... voce encontrou " + m_Quest.NItemName + "! Aqui esta sua recompensa!"; }

                        Bag bagReward = new Bag();

                        // Skill Reward
                        int randomSkillType = 1;
                        if (Utility.RandomDouble() >= 0.8)
                            randomSkillType = (int)SkillRewardItemType.Tammer;
                        else
                            randomSkillType = Utility.Random(1, 3);

                        int randomSkillAmount = 1;
                        randomSkillAmount = m_Quest.NLevel;
                        if (randomSkillAmount > 5)
                            randomSkillAmount = 5;

                        bagReward.DropItem(new SkillRewardItem(1, randomSkillType, randomSkillAmount));
                        //mobile.AddToBackpack(new SkillRewardItem(1, randomSkillType, randomSkillAmount));
                        // Skill Reward

                        if ( Utility.RandomMinMax( 1, 4 ) == 1 )
                        {
                            bagReward.DropItem(new Gold(m_Quest.NLevel * 500));
                            //mobile.AddToBackpack ( new Gold( m_Quest.NLevel * 500 ) );
                        }
                        else
                        {
                            bagReward.DropItem(new Gold(m_Quest.NLevel * 400));
                            //mobile.AddToBackpack ( new Gold( m_Quest.NLevel * 400 ) );

                            Item item;

                            if ( Core.AOS )
                                item = Loot.RandomArmorOrShieldOrWeaponOrJewelry();
                            else
                                item = Loot.RandomArmorOrShieldOrWeapon();

                            bagReward.DropItem(item);
                            //mobile.AddToBackpack(item);

                            //if ( item is BaseWeapon )
                            //{
                            //    BaseWeapon weapon = (BaseWeapon)item;

                            //    if ( Core.AOS )
                            //    {
                            //        int attributeCount;
                            //        int min, max;

                            //        GetRandomAOSStats( out attributeCount, out min, out max, m_Quest.NLevel );

                            //        BaseRunicTool.ApplyAttributesTo( weapon, attributeCount, min, max );
                            //    }
                            //    else
                            //    {
                            //        weapon.DamageLevel = (WeaponDamageLevel)Utility.Random( 6 );
                            //        weapon.AccuracyLevel = (WeaponAccuracyLevel)Utility.Random( 6 );
                            //        weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random( 6 );
                            //    }

                            //    mobile.AddToBackpack ( item );
                            //}
                            //else if ( item is BaseArmor )
                            //{
                            //    BaseArmor armor = (BaseArmor)item;

                            //    if ( Core.AOS )
                            //    {
                            //        int attributeCount;
                            //        int min, max;

                            //        GetRandomAOSStats( out attributeCount, out min, out max, m_Quest.NLevel );

                            //        BaseRunicTool.ApplyAttributesTo( armor, attributeCount, min, max );
                            //    }
                            //    else
                            //    {
                            //        armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
                            //        armor.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
                            //    }

                            //    mobile.AddToBackpack ( item );
                            //}
                            //else if( item is BaseHat )
                            //{
                            //    BaseHat hat = (BaseHat)item;

                            //    if( Core.AOS )
                            //    {
                            //        int attributeCount;
                            //        int min, max;

                            //        GetRandomAOSStats( out attributeCount, out min, out  max, m_Quest.NLevel );

                            //        BaseRunicTool.ApplyAttributesTo( hat, attributeCount, min, max );
                            //    }

                            //    mobile.AddToBackpack ( item );
                            //}
                            //else if( item is BaseJewel )
                            //{
                            //    int attributeCount;
                            //    int min, max;

                            //    GetRandomAOSStats( out attributeCount, out min, out max, m_Quest.NLevel );

                            //    BaseRunicTool.ApplyAttributesTo( (BaseJewel)item, attributeCount, min, max );

                            //    mobile.AddToBackpack ( item );
                            //}
                        }

                        mobile.AddToBackpack(bagReward);

                        this.PrivateOverheadMessage(MessageType.Regular, 1153, false, sMessage, mobile.NetState);

                        dropped.Delete();

                        return true;
                }
                else
                {
                    mobile.AddToBackpack ( dropped );
                    this.PrivateOverheadMessage(MessageType.Regular, 1153, false, "I have no need for this...", mobile.NetState); return true;
                }

            }

            return false;
        }
Esempio n. 25
0
		public Item Mutate(Mobile from, int luckChance, Item item)
		{
			if (item != null)
			{
				if (item is BaseWeapon && 1 > Utility.Random(100))
				{
					item.Delete();
					item = new FireHorn();
					return item;
				}

				if (item is BaseWeapon || item is BaseArmor || item is BaseJewel || item is BaseHat)
				{
					if (Core.AOS)
					{
                        // Try to generate a new random item based on the creature killed
                        if (from is BaseCreature)
                        {
                            if (RandomItemGenerator.GenerateRandomItem(item, ((BaseCreature)from).LastKiller, (BaseCreature)from))
                                return item;
                        }

                        int bonusProps = GetBonusProperties();
						int min = m_MinIntensity;
						int max = m_MaxIntensity;

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

						int props = 1 + bonusProps;

						// Make sure we're not spawning items with 6 properties.
						if (props > m_MaxProps)
						{
							props = m_MaxProps;
						}

                        // Use the older style random generation
						if (item is BaseWeapon)
						{
							BaseRunicTool.ApplyAttributesTo((BaseWeapon)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
						}
						else if (item is BaseArmor)
						{
							BaseRunicTool.ApplyAttributesTo((BaseArmor)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
						}
						else if (item is BaseJewel)
						{
							BaseRunicTool.ApplyAttributesTo((BaseJewel)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
						}
						else if (item is BaseHat)
						{
							BaseRunicTool.ApplyAttributesTo((BaseHat)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
						}
					}
					else // not aos
					{
						if (item is BaseWeapon)
						{
							BaseWeapon weapon = (BaseWeapon)item;

							if (80 > Utility.Random(100))
							{
								weapon.AccuracyLevel = (WeaponAccuracyLevel)GetRandomOldBonus();
							}

							if (60 > Utility.Random(100))
							{
								weapon.DamageLevel = (WeaponDamageLevel)GetRandomOldBonus();
							}

							if (40 > Utility.Random(100))
							{
								weapon.DurabilityLevel = (WeaponDurabilityLevel)GetRandomOldBonus();
							}

							if (5 > Utility.Random(100))
							{
								weapon.Slayer = SlayerName.Silver;
							}

							if (from != null && weapon.AccuracyLevel == 0 && weapon.DamageLevel == 0 && weapon.DurabilityLevel == 0 &&
								weapon.Slayer == SlayerName.None && 5 > Utility.Random(100))
							{
								weapon.Slayer = SlayerGroup.GetLootSlayerType(from.GetType());
							}
						}
						else if (item is BaseArmor)
						{
							BaseArmor armor = (BaseArmor)item;

							if (80 > Utility.Random(100))
							{
								armor.ProtectionLevel = (ArmorProtectionLevel)GetRandomOldBonus();
							}

							if (40 > Utility.Random(100))
							{
								armor.Durability = (ArmorDurabilityLevel)GetRandomOldBonus();
							}
						}
					}
				}
				else if (item is BaseInstrument)
				{
					SlayerName slayer = SlayerName.None;

					if (Core.AOS)
					{
						slayer = BaseRunicTool.GetRandomSlayer();
					}
					else
					{
						slayer = SlayerGroup.GetLootSlayerType(from.GetType());
					}

					if (slayer == SlayerName.None)
					{
						item.Delete();
						return null;
					}

					BaseInstrument instr = (BaseInstrument)item;

					instr.Quality = InstrumentQuality.Regular;
					instr.Slayer = slayer;
				}

				if (item.Stackable)
				{
					item.Amount = m_Quantity.Roll();
				}
			}

			return item;
		}
Esempio n. 26
0
		private static void ReturnCollected(IXmlQuest quest, Item item)
		{
			if (item == null) return;

			// if this was player made, then return the item to the creator
			// dont allow players to return items to themselves.  This prevents possible exploits where quests are used as
			// item transporters
			if (quest != null && quest.PlayerMade && (quest.Creator != null) && !quest.Creator.Deleted && (quest.Creator != quest.Owner) && !item.QuestItem)
			{
				bool returned = false;
				if ((quest.ReturnContainer != null) && !quest.ReturnContainer.Deleted)
				{
					returned = quest.ReturnContainer.TryDropItem(quest.Creator, item, false);

					//ReturnContainer.DropItem(m_RewardItem);
				}
				if (!returned)
				{
					quest.Creator.AddToBackpack(item);
				}

                quest.Creator.SendMessage("You receive {0} from quest {1}", item.GetType().Name, quest.Name);
			}
			else
			{
				// just delete it
				item.Delete();
			}
		}
Esempio n. 27
0
        public virtual bool StackWith( Mobile from, Item dropped, bool playSound )
        {
            if ( Stackable && dropped.Stackable && dropped.GetType() == GetType() && dropped.ItemID == ItemID && dropped.Hue == Hue && (dropped.Amount + Amount) <= 60000 )
            {
                if ( m_LootType != dropped.m_LootType )
                    m_LootType = LootType.Regular;

                Amount += dropped.Amount;
                dropped.Delete();

                if ( playSound )
                {
                    int soundID = GetDropSound();

                    if ( soundID == -1 )
                        soundID = 0x42;

                    from.SendSound( soundID, GetWorldLocation() );
                }

                return true;
            }

            return false;
        }
		public override bool OnDragDrop( Mobile from, Item dropped )
		{          		
         	        Mobile m = from;
			PlayerMobile mobile = m as PlayerMobile;

			if ( mobile != null)
			{
				if( dropped is LightEnhancingCrystal )
         		{
         			

					dropped.Delete();
 
				mobile.SendMessage( "Thank you for bringing me a Light Enhancing Crystal. Many sailors thank you! I hope you find your reward useful." );
				mobile.AddToBackpack( new TravelBook() );
					
					return true;

         		}
				
         		else
         		{
					SayTo( from, "I have no need for that. I only need a Light Enhancing Crystal." );
     			}
			}
			return false;

		
		}
Esempio n. 29
0
        public Item Mutate(Mobile from, int luckChance, Item item)
        {
            if (item != null)
            {
                if (item is BaseWeapon && 1 > Utility.Random(100))
                {
                    item.Delete();
                    item = new FireHorn();
                    return(item);
                }

                if (item is BaseWeapon || item is BaseArmor || item is BaseJewel || item is BaseHat)
                {
                    // Try to generate a new random item based on the creature killed
                    if (RandomItemGenerator.Enabled && from is BaseCreature)
                    {
                        if (RandomItemGenerator.GenerateRandomItem(item, ((BaseCreature)from).LastKiller, (BaseCreature)from))
                        {
                            return(item);
                        }
                    }

                    int bonusProps = GetBonusProperties();
                    int min        = m_MinIntensity;
                    int max        = m_MaxIntensity;

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

                    int props = 1 + bonusProps;

                    // Make sure we're not spawning items with 6 properties.
                    if (props > m_MaxProps)
                    {
                        props = m_MaxProps;
                    }

                    // Use the older style random generation
                    if (item is BaseWeapon)
                    {
                        BaseRunicTool.ApplyAttributesTo((BaseWeapon)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
                    }
                    else if (item is BaseArmor)
                    {
                        BaseRunicTool.ApplyAttributesTo((BaseArmor)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
                    }
                    else if (item is BaseJewel)
                    {
                        BaseRunicTool.ApplyAttributesTo((BaseJewel)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
                    }
                    else if (item is BaseHat)
                    {
                        BaseRunicTool.ApplyAttributesTo((BaseHat)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
                    }
                }
                else if (item is BaseInstrument)
                {
                    SlayerName slayer = SlayerName.None;

                    slayer = BaseRunicTool.GetRandomSlayer();

                    if (slayer == SlayerName.None)
                    {
                        item.Delete();
                        return(null);
                    }

                    BaseInstrument instr = (BaseInstrument)item;

                    instr.Quality = ItemQuality.Normal;
                    instr.Slayer  = slayer;
                }

                if (item.Stackable)
                {
                    item.Amount = m_Quantity.Roll();
                }
            }

            return(item);
        }
Esempio n. 30
0
        public static void Freeze(Mobile from, Map targetMap, Point3D start3d, Point3D end3d)
        {
            Hashtable mapTable = new Hashtable();

            if (start3d == NullP3D && end3d == NullP3D)
            {
                if (targetMap == null)
                {
                    CommandLogging.WriteLine(from, "{0} {1} invoking freeze for every item in every map", from.AccessLevel, CommandLogging.Format(from));
                }
                else
                {
                    CommandLogging.WriteLine(from, "{0} {1} invoking freeze for every item in {0}", from.AccessLevel, CommandLogging.Format(from), targetMap);
                }

                foreach (Item item in World.Items.Values)
                {
                    if (targetMap != null && item.Map != targetMap)
                    {
                        continue;
                    }

                    if (item.Parent != null)
                    {
                        continue;
                    }

                    if (item is Static || item is BaseFloor || item is BaseWall)
                    {
                        Map itemMap = item.Map;

                        if (itemMap == null || itemMap == Map.Internal)
                        {
                            continue;
                        }

                        Hashtable table = (Hashtable)mapTable[itemMap];

                        if (table == null)
                        {
                            mapTable[itemMap] = table = new Hashtable();
                        }

                        Point2D p = new Point2D(item.X >> 3, item.Y >> 3);

                        DeltaState state = (DeltaState)table[p];

                        if (state == null)
                        {
                            table[p] = state = new DeltaState(p);
                        }

                        state.m_List.Add(item);
                    }
                }
            }
            else if (targetMap != null)
            {
                Point2D start = targetMap.Bound(new Point2D(start3d)), end = targetMap.Bound(new Point2D(end3d));

                CommandLogging.WriteLine(from, "{0} {1} invoking freeze from {2} to {3} in {4}", from.AccessLevel, CommandLogging.Format(from), start, end, targetMap);

                IPooledEnumerable eable = targetMap.GetItemsInBounds(new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1));

                foreach (Item item in eable)
                {
                    if (item is Static || item is BaseFloor || item is BaseWall)
                    {
                        Map itemMap = item.Map;

                        if (itemMap == null || itemMap == Map.Internal)
                        {
                            continue;
                        }

                        Hashtable table = (Hashtable)mapTable[itemMap];

                        if (table == null)
                        {
                            mapTable[itemMap] = table = new Hashtable();
                        }

                        Point2D p = new Point2D(item.X >> 3, item.Y >> 3);

                        DeltaState state = (DeltaState)table[p];

                        if (state == null)
                        {
                            table[p] = state = new DeltaState(p);
                        }

                        state.m_List.Add(item);
                    }
                }

                eable.Free();
            }

            if (mapTable.Count == 0)
            {
                from.SendGump(new NoticeGump(1060637, 30720, "No freezable items were found.  Only the following item types are frozen:<br> - Static<br> - BaseFloor<br> - BaseWall", 0xFFC000, 320, 240, null, null));
                return;
            }

            bool badDataFile = false;

            int totalFrozen = 0;

            foreach (DictionaryEntry de in mapTable)
            {
                Map       map   = (Map)de.Key;
                Hashtable table = (Hashtable)de.Value;

                TileMatrix matrix = map.Tiles;

                using (FileStream idxStream = OpenWrite(matrix.IndexStream))
                {
                    using (FileStream mulStream = OpenWrite(matrix.DataStream))
                    {
                        if (idxStream == null || mulStream == null)
                        {
                            badDataFile = true;
                            continue;
                        }

                        BinaryReader idxReader = new BinaryReader(idxStream);

                        BinaryWriter idxWriter = new BinaryWriter(idxStream);
                        BinaryWriter mulWriter = new BinaryWriter(mulStream);

                        foreach (DeltaState state in table.Values)
                        {
                            int          oldTileCount;
                            StaticTile[] oldTiles = ReadStaticBlock(idxReader, mulStream, state.m_X, state.m_Y, matrix.BlockWidth, matrix.BlockHeight, out oldTileCount);

                            if (oldTileCount < 0)
                            {
                                continue;
                            }

                            int          newTileCount = 0;
                            StaticTile[] newTiles     = new StaticTile[state.m_List.Count];

                            for (int i = 0; i < state.m_List.Count; ++i)
                            {
                                Item item = state.m_List[i];

                                int xOffset = item.X - (state.m_X * 8);
                                int yOffset = item.Y - (state.m_Y * 8);

                                if (xOffset < 0 || xOffset >= 8 || yOffset < 0 || yOffset >= 8)
                                {
                                    continue;
                                }

                                StaticTile newTile = new StaticTile((ushort)item.ItemID, (byte)xOffset, (byte)yOffset, (sbyte)item.Z, (short)item.Hue);

                                newTiles[newTileCount++] = newTile;

                                item.Delete();

                                ++totalFrozen;
                            }

                            int mulPos = -1;
                            int length = -1;
                            int extra  = 0;

                            if ((oldTileCount + newTileCount) > 0)
                            {
                                mulWriter.Seek(0, SeekOrigin.End);

                                mulPos = (int)mulWriter.BaseStream.Position;
                                length = (oldTileCount + newTileCount) * 7;
                                extra  = 1;

                                for (int i = 0; i < oldTileCount; ++i)
                                {
                                    StaticTile toWrite = oldTiles[i];

                                    mulWriter.Write((ushort)toWrite.ID);
                                    mulWriter.Write((byte)toWrite.X);
                                    mulWriter.Write((byte)toWrite.Y);
                                    mulWriter.Write((sbyte)toWrite.Z);
                                    mulWriter.Write((short)toWrite.Hue);
                                }

                                for (int i = 0; i < newTileCount; ++i)
                                {
                                    StaticTile toWrite = newTiles[i];

                                    mulWriter.Write((ushort)toWrite.ID);
                                    mulWriter.Write((byte)toWrite.X);
                                    mulWriter.Write((byte)toWrite.Y);
                                    mulWriter.Write((sbyte)toWrite.Z);
                                    mulWriter.Write((short)toWrite.Hue);
                                }

                                mulWriter.Flush();
                            }

                            int idxPos = ((state.m_X * matrix.BlockHeight) + state.m_Y) * 12;

                            idxWriter.Seek(idxPos, SeekOrigin.Begin);
                            idxWriter.Write(mulPos);
                            idxWriter.Write(length);
                            idxWriter.Write(extra);

                            idxWriter.Flush();

                            matrix.SetStaticBlock(state.m_X, state.m_Y, null);
                        }
                    }
                }
            }

            if (totalFrozen == 0 && badDataFile)
            {
                from.SendGump(new NoticeGump(1060637, 30720, "Output data files could not be opened and the freeze operation has been aborted.<br><br>This probably means your server and client are using the same data files.  Instructions on how to resolve this can be found in the first warning window.", 0xFFC000, 320, 240, null, null));
            }
            else
            {
                from.SendGump(new NoticeGump(1060637, 30720, String.Format("Freeze operation completed successfully.<br><br>{0} item{1} frozen.<br><br>You must restart your client and update it's data files to see the changes.", totalFrozen, totalFrozen != 1 ? "s were" : " was"), 0xFFC000, 320, 240, null, null));
            }
        }
Esempio n. 31
0
        public static GiveFlags GiveTo(this Item item, Mobile m, GiveFlags flags = GiveFlags.All, bool message = true)
        {
            if (item == null || item.Deleted || m == null || m.Deleted || flags == GiveFlags.None)
            {
                return(GiveFlags.None);
            }

            var pack   = flags.HasFlag(GiveFlags.Pack);
            var bank   = flags.HasFlag(GiveFlags.Bank);
            var feet   = flags.HasFlag(GiveFlags.Feet);
            var delete = flags.HasFlag(GiveFlags.Delete);

            if (bank && !m.Player)
            {
                bank   = false;
                flags &= ~GiveFlags.Bank;
            }

            if (feet && (m.Map == null || m.Map == Map.Internal))
            {
                feet   = false;
                flags &= ~GiveFlags.Feet;
            }

            var result = VitaNexCore.TryCatchGet(
                f =>
            {
                if (pack && m.PlaceInBackpack(item))
                {
                    return(GiveFlags.Pack);
                }

                if (bank && m.BankBox.TryDropItem(m, item, false))
                {
                    return(GiveFlags.Bank);
                }

                if (feet)
                {
                    item.MoveToWorld(m.Location, m.Map);

                    if (m.Player)
                    {
                        item.SendInfoTo(m.NetState);
                    }

                    return(GiveFlags.Feet);
                }

                if (delete)
                {
                    item.Delete();
                    return(GiveFlags.Delete);
                }

                return(GiveFlags.None);
            },
                flags);

            if (!message || result == GiveFlags.None || result == GiveFlags.Delete)
            {
                return(result);
            }

            var amount = String.Empty;
            var name   = ResolveName(item, m);

            var p = false;

            if (item.Stackable && item.Amount > 1)
            {
                amount = item.Amount.ToString("#,0") + " ";
                p      = true;

                if (!Insensitive.EndsWith(name, "s") && !Insensitive.EndsWith(name, "z"))
                {
                    name += "s";
                }
            }

            switch (result)
            {
            case GiveFlags.Pack:
                m.SendMessage("{0}{1} {2} been placed in your pack.", amount, name, p ? "have" : "has");
                break;

            case GiveFlags.Bank:
                m.SendMessage("{0}{1} {2} been placed in your bank.", amount, name, p ? "have" : "has");
                break;

            case GiveFlags.Feet:
                m.SendMessage("{0}{1} {2} been placed at your feet.", amount, name, p ? "have" : "has");
                break;
            }

            return(result);
        }
Esempio n. 32
0
        private static void SaveItems()
        {
            ArrayList decaying = new ArrayList();

            GenericWriter idx;
            GenericWriter tdb;
            GenericWriter bin;

            if (SaveType == SaveOption.Normal)
            {
                idx = new BinaryFileWriter(itemIdxPath, false);
                tdb = new BinaryFileWriter(itemTdbPath, false);
                bin = new BinaryFileWriter(itemBinPath, true);
            }
            else
            {
                idx = new AsyncWriter(itemIdxPath, false);
                tdb = new AsyncWriter(itemTdbPath, false);
                bin = new AsyncWriter(itemBinPath, true);
            }

            idx.Write((int)m_Items.Count);
            foreach (Item item in m_Items.Values)
            {
                if (item.Decays && item.Parent == null && item.Map != Map.Internal && (item.LastMoved + item.DecayTime) <= DateTime.Now)
                {
                    decaying.Add(item);
                }

                long start = bin.Position;

                idx.Write((int)item.m_TypeRef);
                idx.Write((int)item.Serial);
                idx.Write((long)start);

                item.Serialize(bin);

                idx.Write((int)(bin.Position - start));

                item.FreeCache();
            }

            tdb.Write((int)m_ItemTypes.Count);
            for (int i = 0; i < m_ItemTypes.Count; ++i)
            {
                tdb.Write(((Type)m_ItemTypes[i]).FullName);
            }

            idx.Close();
            tdb.Close();
            bin.Close();

            for (int i = 0; i < decaying.Count; ++i)
            {
                Item item = (Item)decaying[i];

                if (item.OnDecay())
                {
                    item.Delete();
                }
            }
        }
Esempio n. 33
0
        public override bool OnDragDrop( Mobile from, Item dropped )
        {
            if ( dropped is RecallRune )
            {
                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.
                }
            }

            return false;
        }
Esempio n. 34
0
        public Item Mutate(Mobile from, int luckChance, Item item)
        {
            if (item != null)
            {
                if (item is BaseWeapon && 1 > Utility.Random(100))
                {
                    item.Delete();
                    item = new FireHorn();
                    return(item);
                }

                if (item is BaseWeapon || item is BaseArmor || item is BaseJewel || item is BaseHat)
                {
                    if (Core.AOS)
                    {
                        // Try to generate a new random item based on the creature killed
                        if (RandomItemGenerator.Enabled && from is BaseCreature)
                        {
                            if (RandomItemGenerator.GenerateRandomItem(item, ((BaseCreature)from).LastKiller, (BaseCreature)from))
                            {
                                return(item);
                            }
                        }

                        int bonusProps = GetBonusProperties();
                        int min        = m_MinIntensity;
                        int max        = m_MaxIntensity;

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

                        int props = 1 + bonusProps;

                        // Make sure we're not spawning items with 6 properties.
                        if (props > m_MaxProps)
                        {
                            props = m_MaxProps;
                        }

                        // Use the older style random generation
                        if (item is BaseWeapon)
                        {
                            BaseRunicTool.ApplyAttributesTo((BaseWeapon)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
                        }
                        else if (item is BaseArmor)
                        {
                            BaseRunicTool.ApplyAttributesTo((BaseArmor)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
                        }
                        else if (item is BaseJewel)
                        {
                            BaseRunicTool.ApplyAttributesTo((BaseJewel)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
                        }
                        else if (item is BaseHat)
                        {
                            BaseRunicTool.ApplyAttributesTo((BaseHat)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
                        }
                    }
                    else // not aos
                    {
                        if (item is BaseWeapon)
                        {
                            BaseWeapon weapon = (BaseWeapon)item;

                            if (80 > Utility.Random(100))
                            {
                                weapon.AccuracyLevel = (WeaponAccuracyLevel)GetRandomOldBonus();
                            }

                            if (60 > Utility.Random(100))
                            {
                                weapon.DamageLevel = (WeaponDamageLevel)GetRandomOldBonus();
                            }

                            if (40 > Utility.Random(100))
                            {
                                weapon.DurabilityLevel = (WeaponDurabilityLevel)GetRandomOldBonus();
                            }

                            if (5 > Utility.Random(100))
                            {
                                weapon.Slayer = SlayerName.Silver;
                            }

                            if (from != null && weapon.AccuracyLevel == 0 && weapon.DamageLevel == 0 && weapon.DurabilityLevel == 0 &&
                                weapon.Slayer == SlayerName.None && 5 > Utility.Random(100))
                            {
                                weapon.Slayer = SlayerGroup.GetLootSlayerType(from.GetType());
                            }
                        }
                        else if (item is BaseArmor)
                        {
                            BaseArmor armor = (BaseArmor)item;

                            if (80 > Utility.Random(100))
                            {
                                armor.ProtectionLevel = (ArmorProtectionLevel)GetRandomOldBonus();
                            }

                            if (40 > Utility.Random(100))
                            {
                                armor.Durability = (ArmorDurabilityLevel)GetRandomOldBonus();
                            }
                        }
                    }
                }
                else if (item is BaseInstrument)
                {
                    SlayerName slayer = SlayerName.None;

                    if (Core.AOS)
                    {
                        slayer = BaseRunicTool.GetRandomSlayer();
                    }
                    else
                    {
                        slayer = SlayerGroup.GetLootSlayerType(from.GetType());
                    }

                    if (slayer == SlayerName.None)
                    {
                        item.Delete();
                        return(null);
                    }

                    BaseInstrument instr = (BaseInstrument)item;

                    instr.Quality = ItemQuality.Normal;
                    instr.Slayer  = slayer;
                }

                if (item.Stackable)
                {
                    item.Amount = m_Quantity.Roll();
                }
            }

            return(item);
        }
Esempio n. 35
0
		public virtual void FinishHarvesting( Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked )
		{
			from.EndAction( locked );

			if ( !CheckHarvest( from, tool ) )
				return;

			int tileID;
			Map map;
			Point3D loc;

			if ( !GetHarvestDetails( from, tool, toHarvest, out tileID, out map, out loc ) )
			{
				OnBadHarvestTarget( from, tool, toHarvest );
				return;
			}
			else if ( !def.Validate( tileID ) )
			{
				OnBadHarvestTarget( from, tool, toHarvest );
				return;
			}
			
			if ( !CheckRange( from, tool, def, map, loc, true ) )
				return;
			else if ( !CheckResources( from, tool, def, map, loc, true ) )
				return;
			else if ( !CheckHarvest( from, tool, def, toHarvest ) )
				return;

			if ( SpecialHarvest( from, tool, def, map, loc ) )
				return;

			HarvestBank bank = def.GetBank( map, loc.X, loc.Y );

			if ( bank == null )
				return;

			HarvestVein vein = bank.Vein;

			if ( vein != null )
				vein = MutateVein( from, tool, def, bank, toHarvest, vein );

			if ( vein == null )
				return;

			HarvestResource primary = vein.PrimaryResource;
			HarvestResource fallback = vein.FallbackResource;
			HarvestResource resource = MutateResource( from, tool, def, map, loc, vein, primary, fallback );

			double skillBase = from.Skills[def.Skill].Base;
			double skillValue = from.Skills[def.Skill].Value;

			Type type = null;

			if ( skillBase >= resource.ReqSkill && from.CheckSkill( def.Skill, resource.MinSkill, resource.MaxSkill ) )
			{
				type = GetResourceType( from, tool, def, map, loc, resource );

				if ( type != null )
					type = MutateType( type, from, tool, def, map, loc, resource );

				if ( type != null )
				{
					Item item = Construct( type, from );

					if ( item == null )
					{
						type = null;
					}
					else
					{
						//The whole harvest system is kludgy and I'm sure this is just adding to it.
						if ( item.Stackable )
						{
							int amount = def.ConsumedPerHarvest;
							int feluccaAmount = def.ConsumedPerFeluccaHarvest;

							int racialAmount = (int)Math.Ceiling( amount * 1.1 );
							int feluccaRacialAmount = (int)Math.Ceiling( feluccaAmount * 1.1 );

							bool eligableForRacialBonus = ( def.RaceBonus && from.Race == Race.Human );
							bool inFelucca = (map == Map.Felucca);

							if( eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount )
								item.Amount = feluccaRacialAmount;
							else if( inFelucca && bank.Current >= feluccaAmount )
								item.Amount = feluccaAmount;
							else if( eligableForRacialBonus && bank.Current >= racialAmount )
								item.Amount = racialAmount;
							else
								item.Amount = amount;
						}

						bank.Consume( item.Amount, from );

						if ( Give( from, item, def.PlaceAtFeetIfFull ) )
						{
							SendSuccessTo( from, item, resource );
						}
						else
						{
							SendPackFullTo( from, item, def, resource );
							item.Delete();
						}

						BonusHarvestResource bonus = def.GetBonusResource();

						if ( bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill )
						{
							Item bonusItem = Construct( bonus.Type, from );

							if ( Give( from, bonusItem, true ) )	//Bonuses always allow placing at feet, even if pack is full irregrdless of def
							{
								bonus.SendSuccessTo( from );
							}
							else
							{
                                //28JUL2008 Typo in RC2 - SVN 295: in HarvestSystem.cs *** START ***
                                //item.Delete();
                                bonusItem.Delete();
                                //28JUL2008 Typo in RC2 - SVN 295: in HarvestSystem.cs *** END   ***
							}
						}

						if ( tool is IUsesRemaining )
						{
							IUsesRemaining toolWithUses = (IUsesRemaining)tool;

							toolWithUses.ShowUsesRemaining = true;

							if ( toolWithUses.UsesRemaining > 0 )
								--toolWithUses.UsesRemaining;

							if ( toolWithUses.UsesRemaining < 1 )
							{
								tool.Delete();
								def.SendMessageTo( from, def.ToolBrokeMessage );
							}
						}
					}
				}
			}

			if ( type == null )
				def.SendMessageTo( from, def.FailMessage );

			OnHarvestFinished( from, tool, def, vein, bank, resource, toHarvest );
		}
Esempio n. 36
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);
                    }
                }
            }
        }