示例#1
0
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            int amounttocut = 0;

            if (!from.InRange(this.GetWorldLocation(), 1))
            {
                from.SendMessage(89, "You are too far from the machine, step closer."); return(false);
            }
            else
            {
                if (dropped is Log)
                {
                    Log yourlogs = (Log)dropped;
                    dropped.Delete();
                    amounttocut = yourlogs.Amount;
                    from.SendMessage(89, "You recieve {0} boards", amounttocut);
                    Effects.PlaySound(from.Location, from.Map, 0x218);
                    string s_resource = Convert.ToString(yourlogs.Resource);
                    Item   spawn;
                    switch (s_resource)
                    {
                    default: spawn = new Board(yourlogs.Amount); spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map); break;

                    //case "Pine": spawn = new PineBoard(yourlogs.Amount); spawn.MoveToWorld(new Point3D(this.X, this.Y-3, this.Z+3), this.Map); break;
                    case "AshWood": spawn = new AshBoard(yourlogs.Amount); spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map); break;

                    //case "Mahogany": spawn = new MahoganyBoard(yourlogs.Amount); spawn.MoveToWorld(new Point3D(this.X, this.Y-3, this.Z+3), this.Map); break;
                    case "YewWood": spawn = new YewBoard(yourlogs.Amount); spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map); break;

                    case "OakWood": spawn = new OakBoard(yourlogs.Amount); spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map); break;

                    //case "Cedar": spawn = new CedarBoard(yourlogs.Amount); spawn.MoveToWorld(new Point3D(this.X, this.Y-3, this.Z+3), this.Map); break;
                    //case "Cherry": spawn = new CherryBoard(yourlogs.Amount); spawn.MoveToWorld(new Point3D(this.X, this.Y-3, this.Z+3), this.Map); break;
                    case "Heartwood": spawn = new HeartwoodBoard(yourlogs.Amount); spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map); break;

                    case "Frostwood": spawn = new FrostwoodBoard(yourlogs.Amount); spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map); break;

                    case "Bloodwood": spawn = new BloodwoodBoard(yourlogs.Amount); spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map); break;
                        //case "Eucalyptus": spawn = new EucalyptusBoard(yourlogs.Amount); spawn.MoveToWorld(new Point3D(this.X, this.Y-3, this.Z+3), this.Map); //break;
                        //case "Willow": spawn = new WillowBoard(yourlogs.Amount); spawn.MoveToWorld(new Point3D(this.X, this.Y-3, this.Z+3), this.Map); //break;
                        //case "Cherry": spawn = new CherryBoard(yourlogs.Amount); spawn.MoveToWorld(new Point3D(this.X, this.Y-3, this.Z+3), this.Map); //break;
                        //case "Heartwood": spawn = new HeartwoodBoard(yourlogs.Amount); spawn.MoveToWorld(new Point3D(this.X, this.Y-3, this.Z+3), this.Map); //break;
                    }
                    return(true);
                }

                from.SendMessage(89, "This can only cut logs.");
                return(false);
            }
            return(false);
        }
示例#2
0
		public void CompleteCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CustomCraft customCraft )
		{
			int badCraft = craftSystem.CanCraft( from, tool, m_Type );

			if ( badCraft > 0 )
			{
				if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
					from.SendGump( new CraftGump( from, craftSystem, tool, badCraft ) );
				else
					from.SendLocalizedMessage( badCraft );

				return;
			}

			int checkResHue = 0, checkMaxAmount = 0;
			object checkMessage = null;

			// Not enough resource to craft it
			if ( !ConsumeRes( from, typeRes, craftSystem, ref checkResHue, ref checkMaxAmount, ConsumeType.None, ref checkMessage ) )
			{
				if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
					from.SendGump( new CraftGump( from, craftSystem, tool, checkMessage ) );
				else if ( checkMessage is int && (int)checkMessage > 0 )
					from.SendLocalizedMessage( (int)checkMessage );
				else if ( checkMessage is string )
					from.SendMessage( (string)checkMessage );

				return;
			}
			else if ( !ConsumeAttributes( from, ref checkMessage, false ) )
			{
				if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
					from.SendGump( new CraftGump( from, craftSystem, tool, checkMessage ) );
				else if ( checkMessage is int && (int)checkMessage > 0 )
					from.SendLocalizedMessage( (int)checkMessage );
				else if ( checkMessage is string )
					from.SendMessage( (string)checkMessage );

				return;
			}

			bool toolBroken = false;

			int ignored = 1;
			int endquality = 1;

			bool allRequiredSkills = true;

			if ( CheckSkills( from, typeRes, craftSystem, ref ignored, ref allRequiredSkills ) )
			{
				// Resource
				int resHue = 0;
				int maxAmount = 0;

				object message = null;

				// Not enough resource to craft it
				if ( !ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message ) )
				{
					if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
						from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
					else if ( message is int && (int)message > 0 )
						from.SendLocalizedMessage( (int)message );
					else if ( message is string )
						from.SendMessage( (string)message );

					return;
				}
				else if ( !ConsumeAttributes( from, ref message, true ) )
				{
					if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
						from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
					else if ( message is int && (int)message > 0 )
						from.SendLocalizedMessage( (int)message );
					else if ( message is string )
						from.SendMessage( (string)message );

					return;
				}

				tool.UsesRemaining--;

				if ( craftSystem is DefBlacksmithy )
				{
					AncientSmithyHammer hammer = from.FindItemOnLayer( Layer.OneHanded ) as AncientSmithyHammer;
					
					if ( hammer != null && hammer != tool )
					{
						// Genova: suporte ao UO:ML.												
						#region Mondain's Legacy
						if ( hammer is HammerOfHephaestus )
						{
							if ( hammer.UsesRemaining > 0 )
								hammer.UsesRemaining--;
							
							if ( hammer.UsesRemaining < 1 )
								from.PlaceInBackpack( hammer );
						}
						else
						{						
							hammer.UsesRemaining--;
							
							if ( hammer.UsesRemaining < 1 )
								hammer.Delete();
						}
						#endregion
					}
				}

				// Genova: suporte ao UO:ML.					
				#region Mondain's Legacy
				if ( tool is HammerOfHephaestus )
				{
					if ( tool.UsesRemaining < 1 )
						tool.UsesRemaining = 0;
				}
				else
				{
					if ( tool.UsesRemaining < 1 )
						toolBroken = true;
	
					if ( toolBroken )
						tool.Delete();
				}
				#endregion
				
				int num = 0;

				Item item;
				if ( customCraft != null )
				{
					item = customCraft.CompleteCraft( out num );
				}
				else if ( typeof( MapItem ).IsAssignableFrom( ItemType ) && from.Map != Map.Trammel && from.Map != Map.Felucca )
				{
					item = new IndecipherableMap();
					from.SendLocalizedMessage( 1070800 ); // The map you create becomes mysteriously indecipherable.
				}
				else
				{
					item = Activator.CreateInstance( ItemType ) as Item;
				}

				if ( item != null )
				{
					// Genova: suporte ao UO:ML.
					#region Mondain's Legacy
					if ( item is Board )
					{
						Type resourceType = typeRes;
						
						if ( resourceType == null )
							resourceType = Ressources.GetAt( 0 ).ItemType;

						CraftResource thisResource = CraftResources.GetFromType( resourceType );
						
						switch ( thisResource )
						{
							case CraftResource.OakWood:		item = new OakBoard(); break;
							case CraftResource.AshWood:		item = new AshBoard(); break;
							case CraftResource.YewWood:		item = new YewBoard(); break;
							case CraftResource.Heartwood: 	item = new HeartwoodBoard(); break;
							case CraftResource.Bloodwood: 	item = new BloodwoodBoard(); break;
							case CraftResource.Frostwood: 	item = new FrostwoodBoard(); break;							
							default: item = new Board(); break;
						}					
					}
					#endregion
					
					if( item is ICraftable )
						endquality = ((ICraftable)item).OnCraft( quality, makersMark, from, craftSystem, typeRes, tool, this, resHue );
					else if ( item.Hue == 0 )
						item.Hue = resHue;

					if ( maxAmount > 0 )
					{
						if ( !item.Stackable && item is IUsesRemaining )
							((IUsesRemaining)item).UsesRemaining *= maxAmount;
						else
							item.Amount = maxAmount;
					}

					from.AddToBackpack( item );

					if( from.AccessLevel > AccessLevel.Player )
						CommandLogging.WriteLine( from, "Crafting {0} with craft system {1}", CommandLogging.Format( item ), craftSystem.GetType().Name );

					//from.PlaySound( 0x57 );
				}

				if ( num == 0 )
					num = craftSystem.PlayEndingEffect( from, false, true, toolBroken, endquality, makersMark, this );

				bool queryFactionImbue = false;
				int availableSilver = 0;
				FactionItemDefinition def = null;
				Faction faction = null;

				if ( item is IFactionItem )
				{
					def = FactionItemDefinition.Identify( item );

					if ( def != null )
					{
						faction = Faction.Find( from );

						if ( faction != null )
						{
							Town town = Town.FromRegion( from.Region );

							if ( town != null && town.Owner == faction )
							{
								Container pack = from.Backpack;

								if ( pack != null )
								{
									availableSilver = pack.GetAmount( typeof( Silver ) );

									if ( availableSilver >= def.SilverCost )
										queryFactionImbue = Faction.IsNearType( from, def.VendorType, 12 );
								}
							}
						}
					}
				}

				// TODO: Scroll imbuing

				if ( queryFactionImbue )
					from.SendGump( new FactionImbueGump( quality, item, from, craftSystem, tool, num, availableSilver, faction, def ) );
				else if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
					from.SendGump( new CraftGump( from, craftSystem, tool, num ) );
				else if ( num > 0 )
					from.SendLocalizedMessage( num );
			}
			else if ( !allRequiredSkills )
			{
				if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
					from.SendGump( new CraftGump( from, craftSystem, tool, 1044153 ) );
				else
					from.SendLocalizedMessage( 1044153 ); // You don't have the required skills to attempt this item.
			}
			else
			{
				ConsumeType consumeType = ( UseAllRes ? ConsumeType.Half : ConsumeType.All );
				int resHue = 0;
				int maxAmount = 0;

				object message = null;

				// Not enough resource to craft it
				if ( !ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, true ) )
				{
					if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
						from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
					else if ( message is int && (int)message > 0 )
						from.SendLocalizedMessage( (int)message );
					else if ( message is string )
						from.SendMessage( (string)message );

					return;
				}

				tool.UsesRemaining--;

				if ( tool.UsesRemaining < 1 )
					toolBroken = true;

				if ( toolBroken )
					tool.Delete();

				// SkillCheck failed.
				int num = craftSystem.PlayEndingEffect( from, true, true, toolBroken, endquality, false, this );

				if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
					from.SendGump( new CraftGump( from, craftSystem, tool, num ) );
				else if ( num > 0 )
					from.SendLocalizedMessage( num );
			}
		}
示例#3
0
		public void CompleteCraft(
			int quality,
			bool makersMark,
			Mobile from,
			CraftSystem craftSystem,
			Type typeRes,
			BaseTool tool,
			CustomCraft customCraft)
		{
			int badCraft = craftSystem.CanCraft(from, tool, m_Type);

			if (badCraft > 0)
			{
				if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
				{
					from.SendGump(new CraftGump(from, craftSystem, tool, badCraft));
				}
				else
				{
					from.SendLocalizedMessage(badCraft);
				}

                AutoCraftTimer.EndTimer(from);

				return;
			}

			int checkResHue = 0, checkMaxAmount = 0;
			object checkMessage = null;

			// Not enough resource to craft it
			if (!ConsumeRes(from, typeRes, craftSystem, ref checkResHue, ref checkMaxAmount, ConsumeType.None, ref checkMessage))
			{
				if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
				{
					from.SendGump(new CraftGump(from, craftSystem, tool, checkMessage));
				}
				else if (checkMessage is int && (int)checkMessage > 0)
				{
					from.SendLocalizedMessage((int)checkMessage);
				}
				else if (checkMessage is string)
				{
					from.SendMessage((string)checkMessage);
				}

                AutoCraftTimer.EndTimer(from);

				return;
			}
			else if (!ConsumeAttributes(from, ref checkMessage, false))
			{
				if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
				{
					from.SendGump(new CraftGump(from, craftSystem, tool, checkMessage));
				}
				else if (checkMessage is int && (int)checkMessage > 0)
				{
					from.SendLocalizedMessage((int)checkMessage);
				}
				else if (checkMessage is string)
				{
					from.SendMessage((string)checkMessage);
				}

                AutoCraftTimer.EndTimer(from);

				return;
			}

			bool toolBroken = false;

			int ignored = 1;
			int endquality = 1;

			bool allRequiredSkills = true;

			if (CheckSkills(from, typeRes, craftSystem, ref ignored, ref allRequiredSkills))
			{
				// Resource
				int resHue = 0;
				int maxAmount = 0;

				object message = null;

				// Not enough resource to craft it
				if (!ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message))
				{
					if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
					{
						from.SendGump(new CraftGump(from, craftSystem, tool, message));
					}
					else if (message is int && (int)message > 0)
					{
						from.SendLocalizedMessage((int)message);
					}
					else if (message is string)
					{
						from.SendMessage((string)message);
					}

                    AutoCraftTimer.EndTimer(from);

					return;
				}
				else if (!ConsumeAttributes(from, ref message, true))
				{
					if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
					{
						from.SendGump(new CraftGump(from, craftSystem, tool, message));
					}
					else if (message is int && (int)message > 0)
					{
						from.SendLocalizedMessage((int)message);
					}
					else if (message is string)
					{
						from.SendMessage((string)message);
					}

                    AutoCraftTimer.EndTimer(from);

					return;
				}

				tool.UsesRemaining--;

				if (craftSystem is DefBlacksmithy)
				{
					AncientSmithyHammer hammer = from.FindItemOnLayer(Layer.OneHanded) as AncientSmithyHammer;
					if (hammer != null && hammer != tool)
					{
						#region Mondain's Legacy
						if (hammer is HammerOfHephaestus)
						{
							if (hammer.UsesRemaining > 0)
							{
								hammer.UsesRemaining--;
							}

							if (hammer.UsesRemaining < 1)
							{
								from.PlaceInBackpack(hammer);
							}
						}
						else
						{
							hammer.UsesRemaining--;

							if (hammer.UsesRemaining < 1)
							{
								hammer.Delete();
							}
						}
						#endregion
					}
				}

				#region Mondain's Legacy
				if (tool is HammerOfHephaestus)
				{
					if (tool.UsesRemaining < 1)
					{
						tool.UsesRemaining = 0;
					}
				}
				else
				{
					if (tool.UsesRemaining < 1)
					{
						toolBroken = true;
					}

					if (toolBroken)
					{
						tool.Delete();
					}
				}
				#endregion

				int num = 0;

				Item item;
				if (customCraft != null)
				{
					item = customCraft.CompleteCraft(out num);
				}
				else if (typeof(MapItem).IsAssignableFrom(ItemType) && from.Map != Map.Trammel && from.Map != Map.Felucca)
				{
					item = new IndecipherableMap();
					from.SendLocalizedMessage(1070800); // The map you create becomes mysteriously indecipherable.
				}
				else
				{
					item = Activator.CreateInstance(ItemType) as Item;
				}

				if (item != null)
				{
					#region Mondain's Legacy
					if (item is Board)
					{
						Type resourceType = typeRes;

						if (resourceType == null)
						{
							resourceType = Resources.GetAt(0).ItemType;
						}

						CraftResource thisResource = CraftResources.GetFromType(resourceType);

						switch (thisResource)
						{
							case CraftResource.OakWood:
								item = new OakBoard();
								break;
							case CraftResource.AshWood:
								item = new AshBoard();
								break;
							case CraftResource.YewWood:
								item = new YewBoard();
								break;
							case CraftResource.Heartwood:
								item = new HeartwoodBoard();
								break;
							case CraftResource.Bloodwood:
								item = new BloodwoodBoard();
								break;
							case CraftResource.Frostwood:
								item = new FrostwoodBoard();
								break;
							default:
								item = new Board();
								break;
						}
					}
					#endregion

					if (item is ICraftable)
					{
						endquality = ((ICraftable)item).OnCraft(quality, makersMark, from, craftSystem, typeRes, tool, this, resHue);
					}
					else if (item is Food)
					{
						((Food)item).PlayerConstructed = true;
					}
					else if (item.Hue == 0)
					{
						item.Hue = resHue;
					}

					if (maxAmount > 0)
					{
						if (!item.Stackable && item is IUsesRemaining)
						{
							((IUsesRemaining)item).UsesRemaining *= maxAmount;
						}
						else
						{
							item.Amount = maxAmount;
						}
					}

					#region Plant Pigments
					if (item is PlantPigment && (craftSystem is DefAlchemy || craftSystem is DefCooking))
					{
						((PlantPigment)item).PigmentHue = PlantPigmentHueInfo.HueFromPlantHue(m_PlantHue);
					}

					if (item is NaturalDye && (craftSystem is DefAlchemy || craftSystem is DefCooking))
					{
						((NaturalDye)item).PigmentHue = PlantPigmentHueInfo.GetInfo(m_PlantPigmentHue).PlantPigmentHue;
					}

					if (item is SoftenedReeds && (craftSystem is DefAlchemy || craftSystem is DefCooking))
					{
						((SoftenedReeds)item).PlantHue = PlantHueInfo.GetInfo(m_PlantHue).PlantHue;
					}

					if (item is BaseContainer && (craftSystem is DefBasketweaving))
					{
						(item).Hue = PlantHueInfo.GetInfo(m_PlantHue).Hue;
					}

                    CraftContext context = craftSystem.GetContext(from);

                    if (context.QuestOption == CraftQuestOption.QuestItem)
                    {
                        PlayerMobile px = from as PlayerMobile;

                        if (!QuestHelper.CheckItem(px, item))
                            from.SendLocalizedMessage(1072355, null, 0x23); // That item does not match any of your quest criteria	
                    }
					#endregion

					from.AddToBackpack(item);

					EventSink.InvokeCraftSuccess(new CraftSuccessEventArgs(from, item, tool));

					if (from.IsStaff())
					{
						CommandLogging.WriteLine(
							from, "Crafting {0} with craft system {1}", CommandLogging.Format(item), craftSystem.GetType().Name);
					}

                    AutoCraftTimer.OnSuccessfulCraft(from);
					//from.PlaySound( 0x57 );
				}

				if (num == 0)
				{
					num = craftSystem.PlayEndingEffect(from, false, true, toolBroken, endquality, makersMark, this);
				}

				bool queryFactionImbue = false;
				int availableSilver = 0;
				FactionItemDefinition def = null;
				Faction faction = null;

				if (item is IFactionItem)
				{
					def = FactionItemDefinition.Identify(item);

					if (def != null)
					{
						faction = Faction.Find(from);

						if (faction != null)
						{
							Town town = Town.FromRegion(from.Region);

							if (town != null && town.Owner == faction)
							{
								Container pack = from.Backpack;

								if (pack != null)
								{
									availableSilver = pack.GetAmount(typeof(Silver));

									if (availableSilver >= def.SilverCost)
									{
										queryFactionImbue = Faction.IsNearType(from, def.VendorType, 12);
									}
								}
							}
						}
					}
				}

				// TODO: Scroll imbuing

				if (queryFactionImbue)
				{
					from.SendGump(new FactionImbueGump(quality, item, from, craftSystem, tool, num, availableSilver, faction, def));
				}
				else if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
				{
					from.SendGump(new CraftGump(from, craftSystem, tool, num));
				}
				else if (num > 0)
				{
					from.SendLocalizedMessage(num);
				}
			}
			else if (!allRequiredSkills)
			{
				if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
				{
					from.SendGump(new CraftGump(from, craftSystem, tool, 1044153));
				}
				else
				{
					from.SendLocalizedMessage(1044153); // You don't have the required skills to attempt this item.
				}

                AutoCraftTimer.EndTimer(from);
			}
			else
			{
				ConsumeType consumeType = (UseAllRes ? ConsumeType.Half : ConsumeType.All);
				int resHue = 0;
				int maxAmount = 0;

				object message = null;

				// Not enough resource to craft it
				if (!ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, true))
				{
					if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
					{
						from.SendGump(new CraftGump(from, craftSystem, tool, message));
					}
					else if (message is int && (int)message > 0)
					{
						from.SendLocalizedMessage((int)message);
					}
					else if (message is string)
					{
						from.SendMessage((string)message);
					}

                    AutoCraftTimer.EndTimer(from);

					return;
				}

				tool.UsesRemaining--;

				if (tool.UsesRemaining < 1)
				{
					toolBroken = true;
				}

				if (toolBroken)
				{
					tool.Delete();
				}

				// SkillCheck failed.
				int num = craftSystem.PlayEndingEffect(from, true, true, toolBroken, endquality, false, this);

				if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
				{
					from.SendGump(new CraftGump(from, craftSystem, tool, num));
				}
				else if (num > 0)
				{
					from.SendLocalizedMessage(num);
				}
			}
		}
示例#4
0
		public void CompleteCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CustomCraft customCraft )
		{
			int badCraft = craftSystem.CanCraft( from, tool, m_Type );

			if ( badCraft > 0 )
			{
				if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
					from.SendGump( new CraftGump( from, craftSystem, tool, badCraft ) );
				else
					from.SendLocalizedMessage( badCraft );

				return;
			}

			int checkResHue = 0, checkMaxAmount = 0;
			object checkMessage = null;

			// Not enough resource to craft it
			if ( !ConsumeRes( from, typeRes, craftSystem, ref checkResHue, ref checkMaxAmount, ConsumeType.None, ref checkMessage ) )
			{
				if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
					from.SendGump( new CraftGump( from, craftSystem, tool, checkMessage ) );
				else if ( checkMessage is int && (int)checkMessage > 0 )
					from.SendLocalizedMessage( (int)checkMessage );
				else if ( checkMessage is string )
					from.SendMessage( (string)checkMessage );

				return;
			}
			else if ( !ConsumeAttributes( from, ref checkMessage, false ) )
			{
				if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
					from.SendGump( new CraftGump( from, craftSystem, tool, checkMessage ) );
				else if ( checkMessage is int && (int)checkMessage > 0 )
					from.SendLocalizedMessage( (int)checkMessage );
				else if ( checkMessage is string )
					from.SendMessage( (string)checkMessage );

				return;
			}

			bool toolBroken = false;

			int ignored = 1;
			int endquality = 1;

			bool allRequiredSkills = true;

			if ( CheckSkills( from, typeRes, craftSystem, ref ignored, ref allRequiredSkills ) )
			{
				// Resource
				int resHue = 0;
				int maxAmount = 0;

				object message = null;

				// Not enough resource to craft it
				if ( !ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message ) )
				{
					if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
						from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
					else if ( message is int && (int)message > 0 )
						from.SendLocalizedMessage( (int)message );
					else if ( message is string )
						from.SendMessage( (string)message );

					return;
				}
				else if ( !ConsumeAttributes( from, ref message, true ) )
				{
					if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
						from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
					else if ( message is int && (int)message > 0 )
						from.SendLocalizedMessage( (int)message );
					else if ( message is string )
						from.SendMessage( (string)message );

					return;
				}

				tool.UsesRemaining--;

				if ( craftSystem is DefBlacksmithy )
				{
					AncientSmithyHammer hammer = from.FindItemOnLayer( Layer.OneHanded ) as AncientSmithyHammer;
					if ( hammer != null && hammer != tool )
					{
						hammer.UsesRemaining--;
						if ( hammer.UsesRemaining < 1 )
							hammer.Delete();
					}
				}

				if ( tool.UsesRemaining < 1 )
					toolBroken = true;

				if ( toolBroken )
					tool.Delete();

				int num = 0;

				Item item;
				if ( customCraft != null )
				{
					item = customCraft.CompleteCraft( out num );
				}
				else if ( typeof( MapItem ).IsAssignableFrom( ItemType ) && from.Map != Map.Trammel && from.Map != Map.Felucca )
				{
					item = new IndecipherableMap();
					from.SendLocalizedMessage( 1070800 ); // The map you create becomes mysteriously indecipherable.
				}
				else
				{
					item = Activator.CreateInstance( ItemType ) as Item;
				}

				if ( item != null )
				{

					if ( item is BaseWeapon )
						((BaseWeapon)item).Identified = true;
					if ( item is BaseArmor )
						((BaseArmor)item).Identified = true;
					if ( item is BaseClothing )
						((BaseClothing)item).Identified = true;
					if ( item is BaseJewel )
						((BaseJewel)item).Identified = true;
				
					//For new boards system
					if ( item is Board )
					{
						Type resourceType = typeRes;
						if ( resourceType == null )
							resourceType = Ressources.GetAt( 0 ).ItemType;

						CraftResource thisResource = CraftResources.GetFromType( resourceType );
						
						switch ( thisResource )
						{
							case CraftResource.Pine: 	item = new PineBoard(); break;
							case CraftResource.Cedar: 	item = new CedarBoard(); break;
							case CraftResource.Cherry: 	item = new CherryBoard(); break;
							case CraftResource.Mahogany: 	item = new MahoganyBoard(); break;
							case CraftResource.Oak: 	item = new OakBoard(); break;
							case CraftResource.Ash: 	item = new AshBoard(); break;
							case CraftResource.Yew: 	item = new YewBoard(); break;
							case CraftResource.Heartwood: 	item = new HeartwoodBoard(); break;
							case CraftResource.Bloodwood: 	item = new BloodwoodBoard(); break;
							case CraftResource.Frostwood: 	item = new FrostwoodBoard(); break;
							default: item = new Board(); break;
						}
						
					}
					//end for new boards system
					
					//For new marble system
					if ( item is Marble )
					{
						Type resourceType = typeRes;
						if ( resourceType == null )
							resourceType = Ressources.GetAt( 0 ).ItemType;

						CraftResource thisResource = CraftResources.GetFromType( resourceType );
						
						switch ( thisResource )
						{
							case CraftResource.DullCopper: 		item = new DullCopperMarble(); break;
							case CraftResource.ShadowIron: 		item = new ShadowIronMarble(); break;
							case CraftResource.Copper: 		item = new CopperMarble(); break;
							case CraftResource.Bronze: 		item = new BronzeMarble(); break;
							case CraftResource.Gold: 		item = new GoldMarble(); break;
							case CraftResource.Agapite: 		item = new AgapiteMarble(); break;
							case CraftResource.Verite: 		item = new VeriteMarble(); break;
							case CraftResource.Valorite: 		item = new ValoriteMarble(); break;
							case CraftResource.Silver: 		item = new SilverMarble(); break;
							case CraftResource.Platinum: 		item = new PlatinumMarble(); break;
							case CraftResource.Mythril: 		item = new MythrilMarble(); break;
							case CraftResource.Obsidian: 		item = new ObsidianMarble(); break;
							case CraftResource.Jade: 		item = new JadeMarble(); break;
							case CraftResource.Moonstone: 		item = new MoonstoneMarble(); break;
							case CraftResource.Sunstone: 		item = new SunstoneMarble(); break;
							case CraftResource.Bloodstone: 		item = new BloodstoneMarble(); break;
							default: item = new Marble(); break;
						}
						
					}
					//end for new marble system

					if( item is ICraftable )
						endquality = ((ICraftable)item).OnCraft( quality, makersMark, from, craftSystem, typeRes, tool, this, resHue );
					else if ( item.Hue == 0 )
						item.Hue = resHue;

					if ( maxAmount > 0 )
					{
						if ( !item.Stackable && item is IUsesRemaining )
							((IUsesRemaining)item).UsesRemaining *= maxAmount;
						else
						item.Amount = maxAmount;
					}

					from.AddToBackpack( item );

					//from.PlaySound( 0x57 );
				}

				if ( num == 0 )
					num = craftSystem.PlayEndingEffect( from, false, true, toolBroken, endquality, makersMark, this );

				bool queryFactionImbue = false;
				int availableSilver = 0;
				FactionItemDefinition def = null;
				Faction faction = null;

				if ( item is IFactionItem )
				{
					def = FactionItemDefinition.Identify( item );

					if ( def != null )
					{
						faction = Faction.Find( from );

						if ( faction != null )
						{
							Town town = Town.FromRegion( from.Region );

							if ( town != null && town.Owner == faction )
							{
								Container pack = from.Backpack;

								if ( pack != null )
								{
									availableSilver = pack.GetAmount( typeof( Silver ) );

									if ( availableSilver >= def.SilverCost )
										queryFactionImbue = Faction.IsNearType( from, def.VendorType, 12 );
								}
							}
						}
					}
				}

				// TODO: Scroll imbuing

				if ( queryFactionImbue )
					from.SendGump( new FactionImbueGump( quality, item, from, craftSystem, tool, num, availableSilver, faction, def ) );
				else if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
					from.SendGump( new CraftGump( from, craftSystem, tool, num ) );
				else if ( num > 0 )
					from.SendLocalizedMessage( num );
			}
			else if ( !allRequiredSkills )
			{
				if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
					from.SendGump( new CraftGump( from, craftSystem, tool, 1044153 ) );
				else
					from.SendLocalizedMessage( 1044153 ); // You don't have the required skills to attempt this item.
			}
			else
			{
				ConsumeType consumeType = ( UseAllRes ? ConsumeType.Half : ConsumeType.All );
				int resHue = 0;
				int maxAmount = 0;

				object message = null;

				// Not enough resource to craft it
				if ( !ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, true ) )
				{
					if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
						from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
					else if ( message is int && (int)message > 0 )
						from.SendLocalizedMessage( (int)message );
					else if ( message is string )
						from.SendMessage( (string)message );

					return;
				}

				tool.UsesRemaining--;

				if ( tool.UsesRemaining < 1 )
					toolBroken = true;

				if ( toolBroken )
					tool.Delete();

				// SkillCheck failed.
				int num = craftSystem.PlayEndingEffect( from, true, true, toolBroken, endquality, false, this );

				if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
					from.SendGump( new CraftGump( from, craftSystem, tool, num ) );
				else if ( num > 0 )
					from.SendLocalizedMessage( num );
			}
		}
示例#5
0
		protected override void OnTarget( Mobile from, object targeted )
		{
			if ( m_System is Mining && targeted is StaticTarget )
			{
				int itemID = ((StaticTarget)targeted).ItemID;

				// grave
				if ( itemID == 0xED3 || itemID == 0xEDF || itemID == 0xEE0 || itemID == 0xEE1 || itemID == 0xEE2 || itemID == 0xEE8 )
				{
					PlayerMobile player = from as PlayerMobile;

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

						if ( qs is WitchApprenticeQuest )
						{
							FindIngredientObjective obj = qs.FindObjective( typeof( FindIngredientObjective ) ) as FindIngredientObjective;

							if ( obj != null && !obj.Completed && obj.Ingredient == Ingredient.Bones )
							{
								player.SendLocalizedMessage( 1055037 ); // You finish your grim work, finding some of the specific bones listed in the Hag's recipe.
								obj.Complete();

								return;
							}
						}
					}
				}
			}

            if (m_System is Lumberjacking && targeted is IChopable)
                ((IChopable)targeted).OnChop(from);
            else if (m_System is Lumberjacking && targeted is ICarvable)
                ((ICarvable)targeted).Carve(from, m_Tool);
            else if (m_System is Lumberjacking && FurnitureAttribute.Check(targeted as Item))
                DestroyFurniture(from, (Item)targeted);
            else if (m_System is Mining && targeted is TreasureMap)
                ((TreasureMap)targeted).OnBeginDig(from);
            else if (m_System is Lumberjacking && targeted is GuildContainer) //Taran: Turn guildcontainer into deed
            {
                Guild guild = from.Guild as Guild;
                if (guild != null && !guild.Disbanded)
                {
                    GuildContainer gc = (GuildContainer)targeted;
                    Mobile leader = guild.Leader;

                    if (from.Guild.Id == gc.GuildID && from == leader)
                    {
                        Container cont = (Container)targeted;
                        Item[] found = cont.FindItemsByType(typeof(Item), true);

                        if (found.Length > 0)
                            from.SendAsciiMessage("The container must be empty before you can re-deed it");
                        else
                        {
                            cont.Delete();
                            from.AddToBackpack(new GuildContainerDeed());
                            from.SendAsciiMessage("You put the guild container deed in your backpack");
                        }
                    }
                    else
                        from.SendAsciiMessage("You must be the leader of the guild to do that");
                }
                else
                    from.SendAsciiMessage("You can't use an axe on that.");
            }

            #region Turn logs into boards
            else if (m_System is Lumberjacking && targeted is BaseLog) //Turn logs into boards
            {
                BaseLog log = (BaseLog)targeted;

                if (log.IsChildOf(from.Backpack))
                {
                    CraftResource cr = log.Resource;
                    int amount = log.Amount;

                    log.Delete();

                    switch (cr)
                    {
                        case CraftResource.RegularWood:
                            {
                                Board board = new Board(amount);
                                from.AddToBackpack(board);
                                break;
                            }
                        case CraftResource.OakWood:
                            {
                                OakBoard board = new OakBoard(amount);
                                from.AddToBackpack(board);
                                break;
                            }
                        case CraftResource.AshWood:
                            {
                                AshBoard board = new AshBoard(amount);
                                from.AddToBackpack(board);
                                break;
                            }
                        case CraftResource.YewWood:
                            {
                                YewBoard board = new YewBoard(amount);
                                from.AddToBackpack(board);
                                break;
                            }
                        case CraftResource.Heartwood:
                            {
                                HeartwoodBoard board = new HeartwoodBoard(amount);
                                from.AddToBackpack(board);
                                break;
                            }
                        case CraftResource.Bloodwood:
                            {
                                BloodwoodBoard board = new BloodwoodBoard(amount);
                                from.AddToBackpack(board);
                                break;
                            }
                        case CraftResource.Frostwood:
                            {
                                FrostwoodBoard board = new FrostwoodBoard(amount);
                                from.AddToBackpack(board);
                                break;
                            }
                        case CraftResource.Mahoganywood:
                            {
                                MahoganyBoard board = new MahoganyBoard(amount);
                                from.AddToBackpack(board);
                                break;
                            }
                        case CraftResource.Cedarwood:
                            {
                                CedarBoard board = new CedarBoard(amount);
                                from.AddToBackpack(board);
                                break;
                            }
                        case CraftResource.Willowwood:
                            {
                                WillowBoard board = new WillowBoard(amount);
                                from.AddToBackpack(board);
                                break;
                            }
                        case CraftResource.Mystwood:
                            {
                                MystWoodBoard board = new MystWoodBoard(amount);
                                from.AddToBackpack(board);
                                break;
                            }
                        default:
                            {
                                from.SendAsciiMessage("Error, no check for that log is made.");
                                break;
                            }
                    }
                    if (from.Mounted)
                        from.Animate(26, 5, 1, true, false, 0);
                    else
                        from.Animate(9, 5, 1, true, false, 0);
                    
                    from.PlaySound(573);
                    from.SendAsciiMessage("You chop the logs and turn them into boards");
                }
                else
                    from.SendAsciiMessage("That must be in your backpack before you can chop it");
            }
            #endregion
            else
            {
                if (!CheckAllowed(from))
                    return;
                m_System.StartHarvesting(from, m_Tool, targeted);
            }
		}
示例#6
0
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            int amounttocut = 0;

            if (!from.InRange(this.GetWorldLocation(), 1))
            {
                from.SendMessage(89, "You are too far from the machine, step closer.");
                return(false);
            }
            else
            {
                if (dropped is Log) // Log is now BaseLog
                {
                    if (dropped is OakLog)
                    {
                        // It's an OAK log
                        OakLog yourlogs = (OakLog)dropped;
                        dropped.Delete();
                        amounttocut = yourlogs.Amount;
                        from.SendMessage(89, "You recieve {0} boards", amounttocut);
                        Effects.PlaySound(from.Location, from.Map, 0x218);  // Plays the saw sound
                        Item spawn = new OakBoard(amounttocut);
                        spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map);
                        return(true);
                    }

                    else if (dropped is AshLog)
                    {
                        // It's an ASH log
                        AshLog yourlogs = (AshLog)dropped;
                        dropped.Delete();
                        amounttocut = yourlogs.Amount;
                        from.SendMessage(89, "You recieve {0} boards", amounttocut);
                        Effects.PlaySound(from.Location, from.Map, 0x218);  // Plays the saw sound
                        Item spawn = new AshBoard(amounttocut);
                        spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map);
                        return(true);
                    }

                    else if (dropped is YewLog)
                    {
                        // It's a YEW log
                        YewLog yourlogs = (YewLog)dropped;
                        dropped.Delete();
                        amounttocut = yourlogs.Amount;
                        from.SendMessage(89, "You recieve {0} boards", amounttocut);
                        Effects.PlaySound(from.Location, from.Map, 0x218);  // Plays the saw sound
                        Item spawn = new YewBoard(amounttocut);
                        spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map);
                        return(true);
                    }

                    else if (dropped is HeartwoodLog)
                    {
                        // It's a HEARTWOOD log
                        HeartwoodLog yourlogs = (HeartwoodLog)dropped;
                        dropped.Delete();
                        amounttocut = yourlogs.Amount;
                        from.SendMessage(89, "You recieve {0} boards", amounttocut);
                        Effects.PlaySound(from.Location, from.Map, 0x218);  // Plays the saw sound
                        Item spawn = new HeartwoodBoard(amounttocut);
                        spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map);
                        return(true);
                    }

                    else if (dropped is BloodwoodLog)
                    {
                        // It's a BLOODWOOD log
                        BloodwoodLog yourlogs = (BloodwoodLog)dropped;
                        dropped.Delete();
                        amounttocut = yourlogs.Amount;
                        from.SendMessage(89, "You recieve {0} boards", amounttocut);
                        Effects.PlaySound(from.Location, from.Map, 0x218);  // Plays the saw sound
                        Item spawn = new BloodwoodBoard(amounttocut);
                        spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map);
                        return(true);
                    }

                    else if (dropped is FrostwoodLog)
                    {
                        // It's a FROSTWOOD log
                        FrostwoodLog yourlogs = (FrostwoodLog)dropped;
                        dropped.Delete();
                        amounttocut = yourlogs.Amount;
                        from.SendMessage(89, "You recieve {0} boards", amounttocut);
                        Effects.PlaySound(from.Location, from.Map, 0x218);  // Plays the saw sound
                        Item spawn = new FrostwoodBoard(amounttocut);
                        spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map);
                        return(true);
                    }

                    else if (dropped is Log)
                    {
                        // It's a NORMAL log
                        Log yourlogs = (Log)dropped;
                        dropped.Delete();
                        amounttocut = yourlogs.Amount;
                        from.SendMessage(89, "You recieve {0} boards", amounttocut);
                        Effects.PlaySound(from.Location, from.Map, 0x218);  // Plays the saw sound
                        Item spawn = new Board(amounttocut);
                        spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map);
                        return(true);
                    }
                }

                from.SendMessage(89, "This can only cut logs.");
                return(false);
            }
            return(false);
        }
示例#7
0
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            int amounttocut = 0;

            if (!from.InRange(this.GetWorldLocation(), 1))
            {
                from.SendMessage(89, "You are too far from the machine, step closer.");
                return false;
            }
            else
            {
                if (dropped is Log) // Log is now BaseLog
                {
                    if (dropped is OakLog)
                    {
                        // It's an OAK log
                        OakLog yourlogs = (OakLog)dropped;
                        dropped.Delete();
                        amounttocut = yourlogs.Amount;
                        from.SendMessage(89, "You recieve {0} boards", amounttocut);
                        Effects.PlaySound(from.Location, from.Map, 0x218);  // Plays the saw sound
                        Item spawn = new OakBoard(amounttocut);
                        spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map);
                        return true;
                    }

                    else if (dropped is AshLog)
                    {
                        // It's an ASH log
                        AshLog yourlogs = (AshLog)dropped;
                        dropped.Delete();
                        amounttocut = yourlogs.Amount;
                        from.SendMessage(89, "You recieve {0} boards", amounttocut);
                        Effects.PlaySound(from.Location, from.Map, 0x218);  // Plays the saw sound
                        Item spawn = new AshBoard(amounttocut);
                        spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map);
                        return true;
                    }

                    else if (dropped is YewLog)
                    {
                        // It's a YEW log
                        YewLog yourlogs = (YewLog)dropped;
                        dropped.Delete();
                        amounttocut = yourlogs.Amount;
                        from.SendMessage(89, "You recieve {0} boards", amounttocut);
                        Effects.PlaySound(from.Location, from.Map, 0x218);  // Plays the saw sound
                        Item spawn = new YewBoard(amounttocut);
                        spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map);
                        return true;
                    }

                    else if (dropped is HeartwoodLog)
                    {
                        // It's a HEARTWOOD log
                        HeartwoodLog yourlogs = (HeartwoodLog)dropped;
                        dropped.Delete();
                        amounttocut = yourlogs.Amount;
                        from.SendMessage(89, "You recieve {0} boards", amounttocut);
                        Effects.PlaySound(from.Location, from.Map, 0x218);  // Plays the saw sound
                        Item spawn = new HeartwoodBoard(amounttocut);
                        spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map);
                        return true;
                    }

                    else if (dropped is BloodwoodLog)
                    {
                        // It's a BLOODWOOD log
                        BloodwoodLog yourlogs = (BloodwoodLog)dropped;
                        dropped.Delete();
                        amounttocut = yourlogs.Amount;
                        from.SendMessage(89, "You recieve {0} boards", amounttocut);
                        Effects.PlaySound(from.Location, from.Map, 0x218);  // Plays the saw sound
                        Item spawn = new BloodwoodBoard(amounttocut);
                        spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map);
                        return true;
                    }

                    else if (dropped is FrostwoodLog)
                    {
                        // It's a FROSTWOOD log
                        FrostwoodLog yourlogs = (FrostwoodLog)dropped;
                        dropped.Delete();
                        amounttocut = yourlogs.Amount;
                        from.SendMessage(89, "You recieve {0} boards", amounttocut);
                        Effects.PlaySound(from.Location, from.Map, 0x218);  // Plays the saw sound
                        Item spawn = new FrostwoodBoard(amounttocut);
                        spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map);
                        return true;
                    }

                    else if (dropped is Log)
                    {
                        // It's a NORMAL log
                        Log yourlogs = (Log)dropped;
                        dropped.Delete();
                        amounttocut = yourlogs.Amount;
                        from.SendMessage(89, "You recieve {0} boards", amounttocut);
                        Effects.PlaySound(from.Location, from.Map, 0x218);  // Plays the saw sound
                        Item spawn = new Board(amounttocut);
                        spawn.MoveToWorld(new Point3D(this.X, this.Y - 3, this.Z + 3), this.Map);
                        return true;
                    }
                }

                from.SendMessage(89, "This can only cut logs.");
                return false;
            }
            return false;
        }
示例#8
0
 public override void OnBadHarvestTarget(Mobile from, Item tool, object toHarvest)
 {
     if (tool is TreeHatchet)
     {
         if (toHarvest is CustomTreeLog)
         {
             Item boards = null;
             CustomTreeLog log = (CustomTreeLog) toHarvest;
             switch (log.Resource)
             {
                 case CraftResource.Bloodwood:
                     boards = new BloodwoodBoard(log.Amount);
                     break;
                 case CraftResource.Frostwood:
                     boards = new FrostwoodBoard(log.Amount);
                     break;
                 case CraftResource.Heartwood:
                     boards = new HeartwoodBoard(log.Amount);
                     break;
                 case CraftResource.YewWood:
                     boards = new YewBoard(log.Amount);
                     break;
                 case CraftResource.AshWood:
                     boards = new AshBoard(log.Amount);
                     break;
                 case CraftResource.OakWood:
                     boards = new OakBoard(log.Amount);
                     break;
                 case CraftResource.RegularWood:
                     boards = new Board(log.Amount);
                     break;
             }
             if (boards != null)
             {
                 if (Give(from, boards, true))
                 {
                     log.Delete();
                     from.SendMessage("You convert the logs into boards.");
                     return;
                 }
             }
         }
     }
     from.SendMessage("You cannot harvest anything there using {0}.", tool.Name);
 }
示例#9
0
        public void CompleteCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CustomCraft customCraft)
        {
            int badCraft = craftSystem.CanCraft(from, tool, m_Type);

            if (badCraft > 0)
            {
                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                    from.SendGump(new CraftGump(from, craftSystem, tool, badCraft));
                else
                    from.SendLocalizedMessage(badCraft);

                return;
            }

            int checkResHue = 0, checkMaxAmount = 0;
            object checkMessage = null;

            // Not enough resource to craft it
            if (!ConsumeRes(from, typeRes, craftSystem, ref checkResHue, ref checkMaxAmount, ConsumeType.None, ref checkMessage))
            {
                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                    from.SendGump(new CraftGump(from, craftSystem, tool, checkMessage));
                else if (checkMessage is int && (int)checkMessage > 0)
                    from.SendLocalizedMessage((int)checkMessage);
                else if (checkMessage is string)
                    from.SendMessage((string)checkMessage);

                return;
            }
            else if (!ConsumeAttributes(from, ref checkMessage, false))
            {
                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                    from.SendGump(new CraftGump(from, craftSystem, tool, checkMessage));
                else if (checkMessage is int && (int)checkMessage > 0)
                    from.SendLocalizedMessage((int)checkMessage);
                else if (checkMessage is string)
                    from.SendMessage((string)checkMessage);

                return;
            }

            bool toolBroken = false;

            int ignored = 1;
            int endquality = 1;

            bool allRequiredSkills = true;

            if (CheckSkills(from, typeRes, craftSystem, ref ignored, ref allRequiredSkills))
            {
                // Resource
                int resHue = 0;
                int maxAmount = 0;

                object message = null;

                // Not enough resource to craft it
                if (!ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message))
                {
                    if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                        from.SendGump(new CraftGump(from, craftSystem, tool, message));
                    else if (message is int && (int)message > 0)
                        from.SendLocalizedMessage((int)message);
                    else if (message is string)
                        from.SendMessage((string)message);

                    return;
                }
                else if (!ConsumeAttributes(from, ref message, true))
                {
                    if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                        from.SendGump(new CraftGump(from, craftSystem, tool, message));
                    else if (message is int && (int)message > 0)
                        from.SendLocalizedMessage((int)message);
                    else if (message is string)
                        from.SendMessage((string)message);

                    return;
                }

                tool.UsesRemaining--;

                if (craftSystem is DefBlacksmithy)
                {
                    AncientSmithyHammer hammer = from.FindItemOnLayer(Layer.OneHanded) as AncientSmithyHammer;
                    if (hammer != null && hammer != tool)
                    {
                        #region Mondain's Legacy
                        if (hammer is HammerOfHephaestus)
                        {
                            if (hammer.UsesRemaining > 0)
                                hammer.UsesRemaining--;

                            if (hammer.UsesRemaining < 1)
                                from.PlaceInBackpack(hammer);
                        }
                        else
                        {
                            hammer.UsesRemaining--;

                            if (hammer.UsesRemaining < 1)
                                hammer.Delete();
                        }
                        #endregion
                    }
                }

                #region Mondain's Legacy
                if (tool is HammerOfHephaestus)
                {
                    if (tool.UsesRemaining < 1)
                        tool.UsesRemaining = 0;
                }
                else
                {
                    if (tool.UsesRemaining < 1)
                        toolBroken = true;

                    if (toolBroken)
                        tool.Delete();
                }
                #endregion

                int num = 0;

                Item item;
                if (customCraft != null)
                {
                    item = customCraft.CompleteCraft(out num);
                }
                else if (typeof(MapItem).IsAssignableFrom(ItemType) && from.Map != Map.Trammel && from.Map != Map.Felucca)
                {
                    item = new IndecipherableMap();
                    from.SendLocalizedMessage(1070800); // The map you create becomes mysteriously indecipherable.
                }
                else
                {
                    item = Activator.CreateInstance(ItemType) as Item;
                }

                if (item != null)
                {
                    #region Mondain's Legacy
                    if (item is Board)
                    {
                        Type resourceType = typeRes;

                        if (resourceType == null)
                            resourceType = Ressources.GetAt(0).ItemType;

                        CraftResource thisResource = CraftResources.GetFromType(resourceType);

                        switch (thisResource)
                        {
                            case CraftResource.Oak: item = new OakBoard(); break;
                            case CraftResource.Ash: item = new AshBoard(); break;
                            case CraftResource.Yew: item = new YewBoard(); break;
                            case CraftResource.Heartwood: item = new HeartwoodBoard(); break;
                            case CraftResource.Bloodwood: item = new BloodwoodBoard(); break;
                            case CraftResource.Frostwood: item = new FrostwoodBoard(); break;
                            case CraftResource.Pine: item = new PineBoard(); break;
                            case CraftResource.Cedar: item = new CedarBoard(); break;
                            case CraftResource.Cherry: item = new CherryBoard(); break;
                            case CraftResource.Mahogany: item = new MahoganyBoard(); break;
                            default: item = new Board(); break;
                        }
                    }
                    #endregion

                    if (item is ICraftable)
                        endquality = ((ICraftable)item).OnCraft(quality, makersMark, from, craftSystem, typeRes, tool, this, resHue);
                    else if (item.Hue == 0)
                        item.Hue = resHue;

                    if (maxAmount > 0)
                    {
                        if (!item.Stackable && item is IUsesRemaining)
                            ((IUsesRemaining)item).UsesRemaining *= maxAmount;
                        else
                            item.Amount = maxAmount;
                    }
					
					#region Plant Pigments
					if( item is PlantPigment && ( craftSystem is DefAlchemy || craftSystem is DefCooking ) )
					{
						((PlantPigment)item).PigmentHue = PlantPigmentHueInfo.HueFromPlantHue(m_PlantHue);
					}
					
					if( item is NaturalDye && ( craftSystem is DefAlchemy || craftSystem is DefCooking ) )
					{
						((NaturalDye)item).PigmentHue = PlantPigmentHueInfo.GetInfo(m_PlantPigmentHue).PlantPigmentHue;
					}

                    if (item is SoftenedReeds && (craftSystem is DefAlchemy || craftSystem is DefCooking))
                    {
                        ((SoftenedReeds)item).PlantHue = PlantHueInfo.GetInfo(this.m_PlantHue).PlantHue;
                    }

                    if (item is BaseContainer && (craftSystem is DefBasketweaving))
                    {
                        ((BaseContainer)item).Hue = PlantHueInfo.GetInfo(this.m_PlantHue).Hue;
                    }
					#endregion
					
                    from.AddToBackpack(item);

                    //typeres amount quality  Type resourceType = typeRes;
                    if (!m_UseAllRes)
                    {
                        int m_TokensAmount = 1;

                        if (typeRes != null)
                        {
                            CraftResource thisResource = CraftResources.GetFromType(typeRes);
                            switch (thisResource)
                            {
                                default: m_TokensAmount *= 1; break;
                                case CraftResource.SpinedLeather: m_TokensAmount *= 2; break;
                                case CraftResource.HornedLeather: m_TokensAmount *= 3; break;
                                case CraftResource.BarbedLeather: m_TokensAmount *= 4; break;
                                case CraftResource.DaemonLeather: m_TokensAmount *= 5; break;
                                case CraftResource.DragonLeather: m_TokensAmount *= 6; break;
                                //case CraftResource.BlazeLeather: i_TokensAmount *= 7; break;
                                //case CraftResource.DaemonicLeather: i_TokensAmount *= 8; break;
                                //case CraftResource.ShadowLeather: i_TokensAmount *= 9; break;
                                //case CraftResource.FrostLeather: i_TokensAmount *= 10; break;
                                //case CraftResource.EtherealLeather: i_TokensAmount *= 11; break;
                                case CraftResource.DullCopper: m_TokensAmount *= 2; break;
                                case CraftResource.ShadowIron: m_TokensAmount *= 3; break;
                                case CraftResource.Copper: m_TokensAmount *= 4; break;
                                case CraftResource.Bronze: m_TokensAmount *= 5; break;
                                case CraftResource.Gold: m_TokensAmount *= 6; break;
                                case CraftResource.Agapite: m_TokensAmount *= 7; break;
                                case CraftResource.Verite: m_TokensAmount *= 8; break;
                                case CraftResource.Valorite: m_TokensAmount *= 9; break;
                                case CraftResource.Silver: m_TokensAmount *= 10; break;
                                case CraftResource.Jade: m_TokensAmount *= 11; break;
                                case CraftResource.Moonstone: m_TokensAmount *= 12; break;
                                case CraftResource.Sunstone: m_TokensAmount *= 13; break;
                                //case CraftResource.Platinum: i_TokensAmount *= 14; break;
                                case CraftResource.RedScales: m_TokensAmount *= 2; break;
                                case CraftResource.YellowScales: m_TokensAmount *= 3; break;
                                case CraftResource.BlackScales: m_TokensAmount *= 4; break;
                                case CraftResource.GreenScales: m_TokensAmount *= 5; break;
                                case CraftResource.WhiteScales: m_TokensAmount *= 6; break;
                                case CraftResource.BlueScales: m_TokensAmount *= 7; break;
                                //case CraftResource.CopperScales: i_TokensAmount *= 8; break;
                                //case CraftResource.SilverScales: i_TokensAmount *= 9; break;
                                //case CraftResource.GoldScales: i_TokensAmount *= 10; break;
                                case CraftResource.Pine: m_TokensAmount *= 2; break;
                                case CraftResource.Oak: m_TokensAmount *= 3; break;
                                case CraftResource.Ash: m_TokensAmount *= 4; break;
                                case CraftResource.Yew: m_TokensAmount *= 5; break;
                                //case CraftResource.Oak: m_TokensAmount *= 6; break;
                                case CraftResource.Cherry: m_TokensAmount *= 7; break;
                                case CraftResource.Cedar: m_TokensAmount *= 8; break;
                                case CraftResource.Mahogany: m_TokensAmount *= 9; break;
                                // case CraftResource.PurpleHeart: i_TokensAmount *= 10; break;
                                // case CraftResource.Redwood: i_TokensAmount *= 11; break;
                                // case CraftResource.Petrified: i_TokensAmount *= 12; break;
                                case CraftResource.Heartwood: m_TokensAmount *= 10; break;
                                case CraftResource.Bloodwood: m_TokensAmount *= 11; break;
                                case CraftResource.Frostwood: m_TokensAmount *= 12; break;
                            }
                        }
                        m_TokensAmount *= Ressources.GetAt(0).Amount;
                        double tok = m_TokensAmount;
                        if (quality == 2)
                            tok *= 1.35;
                        tok /= 8;
                        if (tok >= 1)
                            m_TokensAmount = (int)tok;
                        else
                            m_TokensAmount = 1;
                        TokenValidate.RewardTokens(from, m_TokensAmount);
                    }

                    if (from.AccessLevel > AccessLevel.Player)
                        CommandLogging.WriteLine(from, "Crafting {0} with craft system {1}", CommandLogging.Format(item), craftSystem.GetType().Name);

                    //from.PlaySound( 0x57 );
                }

                if (num == 0)
                    num = craftSystem.PlayEndingEffect(from, false, true, toolBroken, endquality, makersMark, this);

                bool queryFactionImbue = false;
                int availableSilver = 0;
                FactionItemDefinition def = null;
                Faction faction = null;

                if (item is IFactionItem)
                {
                    def = FactionItemDefinition.Identify(item);

                    if (def != null)
                    {
                        faction = Faction.Find(from);

                        if (faction != null)
                        {
                            Town town = Town.FromRegion(from.Region);

                            if (town != null && town.Owner == faction)
                            {
                                Container pack = from.Backpack;

                                if (pack != null)
                                {
                                    availableSilver = pack.GetAmount(typeof(Silver));

                                    if (availableSilver >= def.SilverCost)
                                        queryFactionImbue = Faction.IsNearType(from, def.VendorType, 12);
                                }
                            }
                        }
                    }
                }

                // TODO: Scroll imbuing

                if (queryFactionImbue)
                    from.SendGump(new FactionImbueGump(quality, item, from, craftSystem, tool, num, availableSilver, faction, def));
                else if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                    from.SendGump(new CraftGump(from, craftSystem, tool, num));
                else if (num > 0)
                    from.SendLocalizedMessage(num);
            }
            else if (!allRequiredSkills)
            {
                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                    from.SendGump(new CraftGump(from, craftSystem, tool, 1044153));
                else
                    from.SendLocalizedMessage(1044153); // You don't have the required skills to attempt this item.
            }
            else
            {
                ConsumeType consumeType = (UseAllRes ? ConsumeType.Half : ConsumeType.All);
                int resHue = 0;
                int maxAmount = 0;

                object message = null;

                // Not enough resource to craft it
                if (!ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, true))
                {
                    if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                        from.SendGump(new CraftGump(from, craftSystem, tool, message));
                    else if (message is int && (int)message > 0)
                        from.SendLocalizedMessage((int)message);
                    else if (message is string)
                        from.SendMessage((string)message);

                    return;
                }

                tool.UsesRemaining--;

                if (tool.UsesRemaining < 1)
                    toolBroken = true;

                if (toolBroken)
                    tool.Delete();

                // SkillCheck failed.
                int num = craftSystem.PlayEndingEffect(from, true, true, toolBroken, endquality, false, this);

                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                    from.SendGump(new CraftGump(from, craftSystem, tool, num));
                else if (num > 0)
                    from.SendLocalizedMessage(num);
            }
        }
示例#10
0
文件: Log.cs 项目: nogu3ira/xrunuo
        public static void ConvertToBoards(Item log, Mobile from)
        {
            if (!log.IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1054107);                   // This item must be in your backpack to be used.
            }
            else
            {
                double skillBase = from.Skills[Lumberjacking.System.Definition.Skill].Base;
                double reqSkill  = 0.0;

                HarvestResource[] lumberResources = Lumberjacking.System.Definition.Resources;
                for (int i = 0; i < lumberResources.Length; i++)
                {
                    for (int j = 0; j < lumberResources[i].Types.Length; j++)
                    {
                        if (lumberResources[i].Types[j] == log.GetType())
                        {
                            reqSkill = lumberResources[i].ReqSkill;
                        }
                    }
                }


                if (skillBase >= reqSkill)
                {
                    Item board;

                    if (log.GetType() == typeof(OakLog))
                    {
                        board = new OakBoard(log.Amount);
                    }
                    else if (log.GetType() == typeof(AshLog))
                    {
                        board = new AshBoard(log.Amount);
                    }
                    else if (log.GetType() == typeof(YewLog))
                    {
                        board = new YewBoard(log.Amount);
                    }
                    else if (log.GetType() == typeof(HeartwoodLog))
                    {
                        board = new HeartwoodBoard(log.Amount);
                    }
                    else if (log.GetType() == typeof(BloodwoodLog))
                    {
                        board = new BloodwoodBoard(log.Amount);
                    }
                    else if (log.GetType() == typeof(FrostwoodLog))
                    {
                        board = new FrostwoodBoard(log.Amount);
                    }
                    else
                    {
                        board = new Board(log.Amount);
                    }

                    log.Delete();
                    from.AddToBackpack(board);
                }
                else
                {
                    from.SendLocalizedMessage(1072652);                       // You cannot work this strange and unusual wood.
                }
            }
        }