Exemplo n.º 1
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 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 );
			}
		}
Exemplo n.º 2
0
        protected override void OnTarget(Mobile from, object o)
        {
            int number = -1;

            Item      origItem = o as Item;
            SkillName skill    = m_System.MainSkill;
            double    value    = from.Skills[skill].Value;

            var alterInfo = GetAlterableAttribute(o, false);

            if (alterInfo == null)
            {
                alterInfo = GetAlterableAttribute(o, true);
            }

            if (origItem == null || !origItem.IsChildOf(from.Backpack))
            {
                number = 1094729; // The item must be in your backpack for you to alter it.
            }
            else if (origItem is BlankScroll)
            {
                if (m_Contract == null)
                {
                    if (value >= 100.0)
                    {
                        Item contract = null;

                        if (skill == SkillName.Blacksmith)
                        {
                            contract = new AlterContract(RepairDeed.RepairSkillType.Smithing, from);
                        }
                        else if (skill == SkillName.Carpentry)
                        {
                            contract = new AlterContract(RepairDeed.RepairSkillType.Carpentry, from);
                        }
                        else if (skill == SkillName.Tailoring)
                        {
                            contract = new AlterContract(RepairDeed.RepairSkillType.Tailoring, from);
                        }
                        else if (skill == SkillName.Tinkering)
                        {
                            contract = new AlterContract(RepairDeed.RepairSkillType.Tinkering, from);
                        }

                        if (contract != null)
                        {
                            from.AddToBackpack(contract);

                            number = 1044154; // You create the item.

                            // Consume a blank scroll
                            origItem.Consume();
                        }
                    }
                    else
                    {
                        number = 1111869; // You must be at least grandmaster level to create an alter service contract.
                    }
                }
                else
                {
                    number = 1094728; // You may not alter that item.
                }
            }
            else if (alterInfo == null)
            {
                number = 1094728; // You may not alter that item.
            }
            else if (!IsAlterable(origItem))
            {
                number = 1094728; // You may not alter that item.
            }
            else if (alterInfo.CraftSystem != m_System.GetType())
            {
                if (m_Tool != null)
                {
                    // You may not alter that item.
                    number = 1094728;
                }
                else
                {
                    // You cannot alter that item with this type of alter contract.
                    number = 1094793;
                }
            }
            else if (!Server.SkillHandlers.Imbuing.CheckSoulForge(from, 2, false, false))
            {
                number = 1111867; // You must be near a soulforge to alter an item.
            }
            else if (m_Contract == null && value < 100.0)
            {
                number = 1111870; // You must be at least grandmaster level to alter an item.
            }
            else if (origItem is BaseWeapon && ((BaseWeapon)origItem).EnchantedWeilder != null)
            {
                number = 1111849; // You cannot alter an item that is currently enchanted.
            }
            else
            {
                Item newitem = Activator.CreateInstance(alterInfo.AlteredType) as Item;

                if (newitem == null)
                {
                    return;
                }

                if (origItem is BaseWeapon && newitem is BaseWeapon)
                {
                    BaseWeapon oldweapon = (BaseWeapon)origItem;
                    BaseWeapon newweapon = (BaseWeapon)newitem;

                    newweapon.Slayer   = oldweapon.Slayer;
                    newweapon.Slayer2  = oldweapon.Slayer2;
                    newweapon.Slayer3  = oldweapon.Slayer3;
                    newweapon.Resource = oldweapon.Resource;

                    if (oldweapon.PlayerConstructed)
                    {
                        newweapon.PlayerConstructed = true;
                        newweapon.Crafter           = oldweapon.Crafter;
                        newweapon.Quality           = oldweapon.Quality;
                    }

                    newweapon.Altered = true;
                }
                else if (origItem is BaseArmor && newitem is BaseArmor)
                {
                    BaseArmor oldarmor = (BaseArmor)origItem;
                    BaseArmor newarmor = (BaseArmor)newitem;

                    if (oldarmor.PlayerConstructed)
                    {
                        newarmor.PlayerConstructed = true;
                        newarmor.Crafter           = oldarmor.Crafter;
                        newarmor.Quality           = oldarmor.Quality;
                    }

                    newarmor.Resource = oldarmor.Resource;

                    newarmor.PhysicalBonus = oldarmor.PhysicalBonus;
                    newarmor.FireBonus     = oldarmor.FireBonus;
                    newarmor.ColdBonus     = oldarmor.ColdBonus;
                    newarmor.PoisonBonus   = oldarmor.PoisonBonus;
                    newarmor.EnergyBonus   = oldarmor.EnergyBonus;

                    newarmor.Altered = true;
                }
                else if (origItem is BaseClothing && newitem is BaseClothing)
                {
                    BaseClothing oldcloth = (BaseClothing)origItem;
                    BaseClothing newcloth = (BaseClothing)newitem;

                    if (oldcloth.PlayerConstructed)
                    {
                        newcloth.PlayerConstructed = true;
                        newcloth.Crafter           = oldcloth.Crafter;
                        newcloth.Quality           = oldcloth.Quality;
                    }

                    newcloth.Altered = true;
                }
                else if (origItem is BaseClothing && newitem is BaseArmor)
                {
                    BaseClothing oldcloth = (BaseClothing)origItem;
                    BaseArmor    newarmor = (BaseArmor)newitem;

                    if (oldcloth.PlayerConstructed)
                    {
                        int qual = (int)oldcloth.Quality;

                        newarmor.PlayerConstructed = true;
                        newarmor.Crafter           = oldcloth.Crafter;
                        newarmor.Quality           = (ItemQuality)qual;
                    }

                    newarmor.Altered = true;
                }
                else if (origItem is BaseQuiver && newitem is BaseArmor)
                {
                    /*BaseQuiver oldquiver = (BaseQuiver)origItem;
                     * BaseArmor newarmor = (BaseArmor)newitem;*/

                    ((BaseArmor)newitem).Altered = true;
                }
                else
                {
                    return;
                }

                if (origItem.Name != null)
                {
                    newitem.Name = origItem.Name;
                }
                else if (Server.Engines.VendorSearching.VendorSearch.StringList != null)
                {
                    if (origItem.LabelNumber > 0 && RetainsName(origItem))
                    {
                        newitem.Name = Server.Engines.VendorSearching.VendorSearch.StringList.GetString(origItem.LabelNumber);
                    }
                }

                newitem.Hue      = origItem.Hue;
                newitem.LootType = origItem.LootType;
                newitem.Insured  = origItem.Insured;

                origItem.OnAfterDuped(newitem);
                newitem.Parent = null;

                if (origItem is IDurability && newitem is IDurability)
                {
                    ((IDurability)newitem).MaxHitPoints = ((IDurability)origItem).MaxHitPoints;
                    ((IDurability)newitem).HitPoints    = ((IDurability)origItem).HitPoints;
                }

                if (from.Backpack == null)
                {
                    newitem.MoveToWorld(from.Location, from.Map);
                }
                else
                {
                    from.Backpack.DropItem(newitem);
                }

                newitem.InvalidateProperties();

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

                origItem.Delete();

                number = 1094727; // You have altered the item.
            }

            if (m_Tool != null)
            {
                from.SendGump(new CraftGump(from, m_System, m_Tool, number));
            }
            else
            {
                from.SendLocalizedMessage(number);
            }
        }
Exemplo n.º 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);

					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);
				}
			}
		}
Exemplo n.º 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 && tool.BreakOnDepletion)
                {
                    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.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 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;
                        }
                    }

                    if (from is Player)
                    {
                        Player    p  = from as Player;
                        Craftsman cm = Perk.GetByType <Craftsman>(p);

                        if (cm != null && cm.Craftsmanship())
                        {
                            if (item is BaseArmor)
                            {
                                ((BaseArmor)item).MaxHitPoints += Utility.RandomMinMax(25, 30);
                                ((BaseArmor)item).HitPoints     = ((BaseWeapon)item).MaxHitPoints;
                            }

                            if (item is BaseWeapon)
                            {
                                ((BaseWeapon)item).MaxHitPoints += Utility.RandomMinMax(25, 30);
                                ((BaseWeapon)item).HitPoints     = ((BaseWeapon)item).MaxHitPoints;
                            }

                            if (item is BaseClothing)
                            {
                                ((BaseClothing)item).MaxHitPoints += Utility.RandomMinMax(25, 30);
                                ((BaseClothing)item).HitPoints     = ((BaseClothing)item).MaxHitPoints;
                            }
                        }
                    }

                    from.AddToBackpack(item);

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

                    from.PlaySound(0x57);
                }

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

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

                EventDispatcher.InvokeItemCraft(new ItemCraftEventArgs((Player)from, true, this, craftSystem));
            }
            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 && tool.BreakOnDepletion)
                {
                    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);
                }

                EventDispatcher.InvokeItemCraft(new ItemCraftEventArgs((Player)from, false, this, craftSystem));
            }
        }
Exemplo n.º 5
0
		public void CompleteCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CustomCraft customCraft, bool showGumps)
		{
			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;
            }

		    if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
		    {
		        if (tool.CraftSystem == DefBlacksmithy.CraftSystem)
		        {
		            if (from.FindItemOnLayer(Layer.OneHanded) != tool)
		            {
		                from.SendGump(new CraftGump(from, craftSystem, tool, string.Format("You must have your smith hammer equipped!")));
		                return;
		            }
		        }
		        else
		        {
		            if (!tool.IsChildOf(from.Backpack))
		            {
		                from.SendGump(new CraftGump(from, craftSystem, tool, string.Format("You must have your tool in your backpack!")));
		                return;
		            }
		        }
		    }
		    else
		    {
		        from.SendLocalizedMessage(badCraft);
		        return;
		    }


		    object checkMessage = null;
			int checkResHue = 0, checkMaxAmount = 0;
			
			// Not enough resource to craft it
			if ( !ConsumeRes( from, typeRes, craftSystem, ref checkResHue, ref checkMaxAmount, ConsumeType.None, ref checkMessage ) )
			{
                if (!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;
			}
			if (!ConsumeAttributes(from, ref checkMessage, false))
			{
				if (!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.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;
				}
			    if (!ConsumeAttributes(from, ref message, true))
			    {
			        if (!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;
			    }

			    if (tool is WeaversSpool)
                    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 && !item.Deleted)
				{
                    if (craftSystem is DefCarpentry)
                    {
                        if (RetainsColorFrom(m_System, item.GetType()))
                        {
                            if (typeRes == typeof (OakLog))
                                item.Name = string.Format("Oak {0}", !string.IsNullOrEmpty(item.Name) ? item.Name.ToLower() : CliLoc.LocToString(item.LabelNumber).ToLower());
                            else if (typeRes == typeof (AshLog))
                                item.Name = string.Format("Ash {0}", !string.IsNullOrEmpty(item.Name) ? item.Name.ToLower() : CliLoc.LocToString(item.LabelNumber).ToLower());
                            else if (typeRes == typeof (YewLog))
                                item.Name = string.Format("Yew {0}", !string.IsNullOrEmpty(item.Name) ? item.Name.ToLower() : CliLoc.LocToString(item.LabelNumber).ToLower());
                            else if (typeRes == typeof (HeartwoodLog))
                                item.Name = string.Format("Heartwood {0}", !string.IsNullOrEmpty(item.Name) ? item.Name.ToLower() : CliLoc.LocToString(item.LabelNumber).ToLower());
                            else if (typeRes == typeof (BloodwoodLog))
                                item.Name = string.Format("Bloodwood {0}", !string.IsNullOrEmpty(item.Name) ? item.Name.ToLower() : CliLoc.LocToString(item.LabelNumber).ToLower());
                            else if (typeRes == typeof (FrostwoodLog))
                                item.Name = string.Format("Frostwood {0}", !string.IsNullOrEmpty(item.Name) ? item.Name.ToLower() : CliLoc.LocToString(item.LabelNumber).ToLower());
                            else if (typeRes == typeof(MahoganyLog))
                                item.Name = string.Format("Mahoganywood {0}", !string.IsNullOrEmpty(item.Name) ? item.Name.ToLower() : CliLoc.LocToString(item.LabelNumber).ToLower());
                            else if (typeRes == typeof(CedarLog))
                                item.Name = string.Format("Cedarwood {0}", !string.IsNullOrEmpty(item.Name) ? item.Name.ToLower() : CliLoc.LocToString(item.LabelNumber).ToLower());
                            else if (typeRes == typeof(WillowLog))
                                item.Name = string.Format("Willowwood {0}", !string.IsNullOrEmpty(item.Name) ? item.Name.ToLower() : CliLoc.LocToString(item.LabelNumber).ToLower());
                            else if (typeRes == typeof(MystWoodLog))
                                item.Name = string.Format("Mystwood {0}", !string.IsNullOrEmpty(item.Name) ? item.Name.ToLower() : CliLoc.LocToString(item.LabelNumber).ToLower());
                        }
                    }

					if (item is ICraftable)
					{
                        if (item.Hue == 0)
                            item.Hue = resHue;

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

					    //Flag all high quality non ICraftable with a makers mark in the string
						if (craftSystem.MarkOption && makersMark && quality == 2 && from.Skills[craftSystem.MainSkill].Base >= 100.0)
						{
							endquality = quality;

						    item.Name = string.Format("{0} crafted by {1}", !string.IsNullOrEmpty(item.Name) ? item.Name : CliLoc.LocToString(item.LabelNumber), from.Name);
						}
					}

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

                    #region Add to pack or ground if overweight
                    //Taran: Check to see if player is overweight. If they are and the item drops to the
                    //ground then a check is made to see if it can be stacked. If it can't and  more than 
                    //20 items of the same type exist in the same tile then the last item gets removed. This 
                    //check is made so thousands of items can't exist in 1 tile and crash people in the same area.
                    if (from.AddToBackpack(item))
                    {
                        if (item is SpellScroll)
                            from.SendAsciiMessage("You put the {0} scroll in your pack.", item.Name ?? CliLoc.LocToString(item.LabelNumber));
                        else
                            from.SendAsciiMessage("You put the {0} in your pack.", item.Name ?? CliLoc.LocToString(item.LabelNumber));
                    }
                    else if (!item.Deleted)
                    {
                        IPooledEnumerable eable = from.Map.GetItemsInRange(from.Location, 0);
                        int amount = 0;
                        Item toRemove = null;

                        foreach (Item i in eable)
                        {
                            if (i != item && i.ItemID == item.ItemID)
                            {
                                if (i.StackWith(from, item, false))
                                {
                                    toRemove = item;
                                    break;
                                }
                                
                                amount++;
                            }
                        }

                        from.SendAsciiMessage("You are overweight and put the {0} on the ground.", item.Name ?? CliLoc.LocToString(item.LabelNumber));

                        if (toRemove != null)
                            toRemove.Delete();

                        else if (amount >= 5 && amount < 20)
                            from.LocalOverheadMessage(MessageType.Regular, 906, true, string.Format("{0} identical items on the ground detected, no more than 20 is allowed!", amount));

                        else if (amount >= 20)
                        {
                            from.LocalOverheadMessage(MessageType.Regular, 906, true, "Too many identical items on the ground, removing!");
                            item.Delete();
                        }

                        eable.Free();
                    }
                    #endregion

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

				}

				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.Deleted && tool.UsesRemaining > 0)
					from.SendGump(new CraftGump(from, craftSystem, tool, num));
				else if (num > 0)
					from.SendLocalizedMessage(num);
			}
			else if (!allRequiredSkills)
				if (!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.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 is WeaversSpool)
                    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.Deleted && tool.UsesRemaining > 0)
                    from.SendGump(new CraftGump(from, craftSystem, tool, num));
				else if (num > 0)
					from.SendLocalizedMessage(num);
			}
		}
Exemplo n.º 6
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 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);
                }
            }
        }
Exemplo n.º 7
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 ICraftable)
                    {
                        endquality = ((ICraftable)item).OnCraft(quality, makersMark, from, craftSystem, typeRes, tool, this, resHue);

                        //TEST: CHECK THIS
                        if (craftSystem is DefCarpentry)
                        {
                            item.Hue = resHue;
                        }
                    }

                    else if (item.Hue == 0 && resHue != 0)
                    {
                        item.Hue = resHue;
                    }

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

                        else
                        {
                            item.Amount = maxAmount;
                        }
                    }

                    item.CraftedBy   = from;
                    item.CrafterName = from.RawName;
                    item.ItemGroup   = ItemGroupType.Crafted;

                    if (m_Count > 1)
                    {
                        if (item.Stackable)
                        {
                            item.Amount = m_Count;
                            from.AddToBackpack(item);
                        }

                        else
                        {
                            for (int a = 0; a < m_Count; a++)
                            {
                                Item duplicate = Dupe.DupeItem(item);

                                if (duplicate != null)
                                {
                                    from.AddToBackpack(duplicate);
                                }
                            }
                        }
                    }

                    else
                    {
                        from.AddToBackpack(item);
                    }

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

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

                bool queryFactionImbue = false;

                int availableSilver = 0;

                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();
                }

                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);
                }
            }
        }
Exemplo n.º 8
0
        protected override void OnTarget(Mobile from, object o)
        {
            int number = -1;

            Item      origItem = o as Item;
            SkillName skill    = m_System.MainSkill;
            double    value    = from.Skills[skill].Value;

            var alterInfo = GetAlterableAttribute(o, false);

            if (alterInfo == null)
            {
                alterInfo = GetAlterableAttribute(o, true);
            }

            if (origItem == null || !origItem.IsChildOf(from.Backpack))
            {
                number = 1094729; // The item must be in your backpack for you to alter it.
            }
            else if (origItem is BlankScroll)
            {
                if (m_Contract == null)
                {
                    if (value >= 100.0)
                    {
                        Item contract = null;

                        if (skill == SkillName.Blacksmith)
                        {
                            contract = new AlterContract(RepairDeed.RepairSkillType.Smithing, from);
                        }
                        else if (skill == SkillName.Carpentry)
                        {
                            contract = new AlterContract(RepairDeed.RepairSkillType.Carpentry, from);
                        }
                        else if (skill == SkillName.Tailoring)
                        {
                            contract = new AlterContract(RepairDeed.RepairSkillType.Tailoring, from);
                        }
                        else if (skill == SkillName.Tinkering)
                        {
                            contract = new AlterContract(RepairDeed.RepairSkillType.Tinkering, from);
                        }

                        if (contract != null)
                        {
                            from.AddToBackpack(contract);

                            number = 1044154; // You create the item.

                            // Consume a blank scroll
                            origItem.Consume();
                        }
                    }
                    else
                    {
                        number = 1111869; // You must be at least grandmaster level to create an alter service contract.
                    }
                }
                else
                {
                    number = 1094728; // You may not alter that item.
                }
            }
            else if (alterInfo == null)
            {
                // You may not alter that item.
                number = 1094728;
            }
            else if (!IsAlterable(origItem))
            {
                number = 1094728; // You may not alter that item.
            }
            else if (alterInfo.CraftSystem != m_System.GetType())
            {
                if (m_Tool != null)
                {
                    // You may not alter that item.
                    number = 1094728;
                }
                else
                {
                    // You cannot alter that item with this type of alter contract.
                    number = 1094793;
                }
            }
            else if (!Server.SkillHandlers.Imbuing.CheckSoulForge(from, 2, false))
            {
                number = 1111867; // You must be near a soulforge to alter an item.
            }
            else if (!Server.SkillHandlers.Imbuing.CheckQueen(from))
            {
                number = 1113736; // You must rise to the rank of noble in the eyes of the Gargoyle Queen before her majesty will allow you to use this soulforge.
            }
            else if (m_Contract == null && value < 100.0)
            {
                number = 1111870; // You must be at least grandmaster level to alter an item.
            }
            else if (origItem is BaseWeapon && ((BaseWeapon)origItem).EnchantedWeilder != null)
            {
                number = 1111849; // You cannot alter an item that is currently enchanted.
            }
            else
            {
                Item newitem = Activator.CreateInstance(alterInfo.AlteredType) as Item;

                if (newitem == null)
                {
                    return;
                }

                if (origItem is BaseWeapon && newitem is BaseWeapon)
                {
                    BaseWeapon oldweapon = (BaseWeapon)origItem;
                    BaseWeapon newweapon = (BaseWeapon)newitem;

                    newweapon.Attributes = new AosAttributes(oldweapon, newweapon.Attributes);
                    //newweapon.ElementDamages = new AosElementAttributes( oldweapon, newweapon.ElementDamages ); To Do
                    newweapon.SkillBonuses         = new AosSkillBonuses(oldweapon, newweapon.SkillBonuses);
                    newweapon.WeaponAttributes     = new AosWeaponAttributes(oldweapon, newweapon.WeaponAttributes);
                    newweapon.AbsorptionAttributes = new SAAbsorptionAttributes(oldweapon, newweapon.AbsorptionAttributes);
                    newweapon.Altered = true;
                }
                else if (origItem is BaseArmor && newitem is BaseArmor)
                {
                    BaseArmor oldarmor = (BaseArmor)origItem;
                    BaseArmor newarmor = (BaseArmor)newitem;

                    newarmor.Attributes           = new AosAttributes(oldarmor, newarmor.Attributes);
                    newarmor.ArmorAttributes      = new AosArmorAttributes(oldarmor, newarmor.ArmorAttributes);
                    newarmor.SkillBonuses         = new AosSkillBonuses(oldarmor, newarmor.SkillBonuses);
                    newarmor.AbsorptionAttributes = new SAAbsorptionAttributes(oldarmor, newarmor.AbsorptionAttributes);
                    newarmor.Altered = true;
                }
                else if (origItem is BaseClothing && newitem is BaseClothing)
                {
                    BaseClothing oldcloth = (BaseClothing)origItem;
                    BaseClothing newcloth = (BaseClothing)newitem;

                    newcloth.Attributes             = new AosAttributes(oldcloth, newcloth.Attributes);
                    newcloth.SkillBonuses           = new AosSkillBonuses(oldcloth, newcloth.SkillBonuses);
                    newcloth.SAAbsorptionAttributes = new SAAbsorptionAttributes(oldcloth, newcloth.SAAbsorptionAttributes);
                    newcloth.Altered = true;
                }
                else if (origItem is BaseClothing && newitem is BaseArmor)
                {
                    BaseClothing oldcloth = (BaseClothing)origItem;
                    BaseArmor    newarmor = (BaseArmor)newitem;

                    newarmor.Attributes           = new AosAttributes(oldcloth, newarmor.Attributes);
                    newarmor.ArmorAttributes      = new AosArmorAttributes(oldcloth, newarmor.ArmorAttributes);
                    newarmor.SkillBonuses         = new AosSkillBonuses(oldcloth, newarmor.SkillBonuses);
                    newarmor.AbsorptionAttributes = new SAAbsorptionAttributes(oldcloth, newarmor.AbsorptionAttributes);
                    newarmor.Altered = true;
                }
                else if (origItem is BaseQuiver && newitem is BaseArmor)
                {
                    BaseQuiver oldquiver = (BaseQuiver)origItem;
                    BaseArmor  newarmor  = (BaseArmor)newitem;

                    newarmor.Attributes           = new AosAttributes(oldquiver, newarmor.Attributes);
                    newarmor.ArmorAttributes      = new AosArmorAttributes(oldquiver, newarmor.ArmorAttributes);
                    newarmor.SkillBonuses         = new AosSkillBonuses(oldquiver, newarmor.SkillBonuses);
                    newarmor.AbsorptionAttributes = new SAAbsorptionAttributes(oldquiver, newarmor.AbsorptionAttributes);
                    newarmor.Altered = true;
                }
                else
                {
                    return;
                }

                newitem.Name = origItem.Name;
                newitem.Hue  = origItem.Hue;

                newitem.LootType = origItem.LootType;

                origItem.Delete();
                origItem.OnAfterDuped(newitem);
                newitem.Parent = null;

                if (from.Backpack == null)
                {
                    newitem.MoveToWorld(from.Location, from.Map);
                }
                else
                {
                    from.Backpack.DropItem(newitem);
                }

                newitem.InvalidateProperties();

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

                number = 1094727; // You have altered the item.
            }

            if (m_Tool != null)
            {
                from.SendGump(new CraftGump(from, m_System, m_Tool, number));
            }
            else
            {
                from.SendLocalizedMessage(number);
            }
        }
Exemplo n.º 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, 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 (tool.UsesRemaining < 1 && tool.BreakOnDepletion)
                    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.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 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);
                
                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 && tool.BreakOnDepletion)
                    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);
            }
        }
Exemplo n.º 10
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 = 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.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);

//I Added FOR CRAFTBAG                    
                    Container craftbag = GetCraftBag(from);
                    if (!craftbag.TryDropItem(from, item, false))
                    {
                        from.AddToBackpack(item);
                    }
//I Added For craftbacg above. The original below
//originaly was there above                    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)
//I added for autoloop                	
                {
                    CraftContext context = craftSystem.GetContext(from);
                    if (context != null && context.AutoLoop)
                    {
                        context.Count++;
                        if (context.TotalCount == 0 || context.Count < context.TotalCount)
                        {
                            this.Craft(from, craftSystem, typeRes, tool);
                        }
                        else
                            from.SendGump(new CraftGump(from, craftSystem, tool, num));
                    }
                    else
                        from.SendGump(new CraftGump(from, craftSystem, tool, num));
                }
                	
//I ADDED autoloop this originaly there                   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)
//I added auto loop
                 {
                    CraftContext context = craftSystem.GetContext(from);
                    if (context != null && context.AutoLoop)
                    {
                        context.Count++;
                        if (context.TotalCount == 0 || context.Count < context.TotalCount)
                        {
                            this.Craft(from, craftSystem, typeRes, tool);
                        }
                        else
                            from.SendGump(new CraftGump(from, craftSystem, tool, num));
                    }
                    else
                        from.SendGump(new CraftGump(from, craftSystem, tool, num));
                }
//I added autoloop this originaly there                    from.SendGump(new CraftGump(from, craftSystem, tool, num));
                else if (num > 0)
                    from.SendLocalizedMessage(num);
            }
        }
Exemplo n.º 11
0
        protected override void OnTarget(Mobile from, object o)
        {
            int number = -1;

            Item      origItem = o as Item;
            SkillName skill    = m_System.MainSkill;
            double    value    = from.Skills[skill].Value;

            AlterableAttribute alterInfo = GetAlterableAttribute(o, false);

            if (alterInfo == null)
            {
                alterInfo = GetAlterableAttribute(o, true);
            }

            if (origItem == null || !origItem.IsChildOf(from.Backpack))
            {
                number = 1094729; // The item must be in your backpack for you to alter it.
            }
            else if (origItem is BlankScroll)
            {
                if (m_Contract == null)
                {
                    if (value >= 100.0)
                    {
                        Item contract = null;

                        if (skill == SkillName.Blacksmith)
                        {
                            contract = new AlterContract(RepairSkillType.Smithing, from);
                        }
                        else if (skill == SkillName.Carpentry)
                        {
                            contract = new AlterContract(RepairSkillType.Carpentry, from);
                        }
                        else if (skill == SkillName.Tailoring)
                        {
                            contract = new AlterContract(RepairSkillType.Tailoring, from);
                        }
                        else if (skill == SkillName.Tinkering)
                        {
                            contract = new AlterContract(RepairSkillType.Tinkering, from);
                        }

                        if (contract != null)
                        {
                            from.AddToBackpack(contract);

                            number = 1044154; // You create the item.

                            // Consume a blank scroll
                            origItem.Consume();
                        }
                    }
                    else
                    {
                        number = 1111869; // You must be at least grandmaster level to create an alter service contract.
                    }
                }
                else
                {
                    number = 1094728; // You may not alter that item.
                }
            }
            else if (alterInfo == null)
            {
                number = 1094728; // You may not alter that item.
            }
            else if (!IsAlterable(origItem))
            {
                number = 1094728; // You may not alter that item.
            }
            else if (alterInfo.CraftSystem != m_System.GetType())
            {
                if (m_Tool != null)
                {
                    // You may not alter that item.
                    number = 1094728;
                }
                else
                {
                    // You cannot alter that item with this type of alter contract.
                    number = 1094793;
                }
            }
            else if (!Imbuing.CheckSoulForge(from, 2, false, false))
            {
                number = 1111867; // You must be near a soulforge to alter an item.
            }
            else if (m_Contract == null && value < 100.0)
            {
                number = 1111870; // You must be at least grandmaster level to alter an item.
            }
            else if (origItem is BaseWeapon weapon && weapon.EnchantedWeilder != null)
            {
                number = 1111849; // You cannot alter an item that is currently enchanted.
            }
Exemplo n.º 12
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID <= 0)
            {
                return;                 // Canceled
            }
            int buttonID = info.ButtonID - 1;
            int type     = buttonID % 7;
            int index    = buttonID / 7;

            CraftSystem   system  = m_CraftSystem;
            CraftGroupCol groups  = system.CraftGroups;
            CraftContext  context = system.GetContext(m_From);

            if (m_CraftSystem != null && m_CraftSystem.GetType() == typeof(DefBlacksmithy))
            {
                if (m_From != null && m_Tool != null && (type == 6 || type == 1) && index != 1 && m_Tool.GetType() != typeof(SmithHammer))
                {
                    if (m_From.FindItemOnLayer(Layer.OneHanded) != m_Tool)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, string.Format("You must have your smith hammer equipped!")));
                        return;
                    }
                }
            }

            switch (type)
            {
            case 0:                     // Show group
            {
                if (context == null)
                {
                    break;
                }

                if (index >= 0 && index < groups.Count)
                {
                    context.LastGroupIndex = index;
                    m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                }

                break;
            }

            case 1:                     // Create item
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    CraftGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.CraftItems.Count)
                    {
                        CraftItem(group.CraftItems.GetAt(index));
                    }
                }

                break;
            }

            case 2:                     // Item details
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    CraftGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.CraftItems.Count)
                    {
                        m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems.GetAt(index), m_Tool));
                    }
                }

                break;
            }

            case 3:                     // Create item (last 10)
            {
                if (context == null)
                {
                    break;
                }

                List <CraftItem> lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    CraftItem(lastTen[index]);
                }

                break;
            }

            case 4:                     // Item details (last 10)
            {
                if (context == null)
                {
                    break;
                }

                List <CraftItem> lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    m_From.SendGump(new CraftGumpItem(m_From, system, lastTen[index], m_Tool));
                }

                break;
            }

            case 5:                     // Resource selected
            {
                if (m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count)
                {
                    int groupIndex = (context == null ? -1 : context.LastGroupIndex);

                    CraftSubRes res = system.CraftSubRes.GetAt(index);

                    if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex = index;
                        }

                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                    }
                }
                else if (m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count)
                {
                    int groupIndex = (context == null ? -1 : context.LastGroupIndex);

                    CraftSubRes res = system.CraftSubRes2.GetAt(index);

                    if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex2 = index;
                        }

                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                    }
                }

                break;
            }

            case 6:                     // Misc. buttons
            {
                switch (index)
                {
                case 0:                                 // Resource selection
                {
                    if (system.CraftSubRes.Init)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource));
                    }

                    break;
                }

                case 1:                                 // Smelt item
                {
                    if (system.Resmelt)
                    {
                        Resmelt.Do(m_From, system, m_Tool);
                    }

                    break;
                }

                case 2:                                 // Make last
                {
                    if (context == null)
                    {
                        break;
                    }

                    CraftItem item = context.LastMade;

                    if (item != null)
                    {
                        CraftItem(item);
                    }
                    else
                    {
                        m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, 1044165, m_Page));                                             // You haven't made anything yet.
                    }
                    break;
                }

                case 3:                                 // Last 10
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.LastGroupIndex = 501;
                    m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));

                    break;
                }

                case 4:                                 // Toggle use resource hue
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.DoNotColor = !context.DoNotColor;

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 5:                                 // Repair item
                {
                    if (system.Repair)
                    {
                        Repair.Do(m_From, system, m_Tool);
                    }

                    break;
                }

                case 6:                                 // Toggle mark option
                {
                    if (context == null || !system.MarkOption)
                    {
                        break;
                    }

                    switch (context.MarkOption)
                    {
                    case CraftMarkOption.MarkItem: context.MarkOption = CraftMarkOption.DoNotMark; break;

                    case CraftMarkOption.DoNotMark: context.MarkOption = CraftMarkOption.PromptForMark; break;

                    case CraftMarkOption.PromptForMark: context.MarkOption = CraftMarkOption.MarkItem; break;
                    }

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 7:                                 // Resource selection 2
                {
                    if (system.CraftSubRes2.Init)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource2));
                    }

                    break;
                }

                case 8:                                 // Enhance item
                {
                    if (system.CanEnhance)
                    {
                        Enhance.BeginTarget(m_From, system, m_Tool);
                    }

                    break;
                }
                }

                break;
            }
            }
        }
Exemplo n.º 13
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);
            }
        }
Exemplo n.º 14
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int       number   = -1;
                Item      origItem = targeted as Item;
                SkillName skill    = m_CraftSystem.MainSkill;
                double    value    = from.Skills[skill].Value;

                var alterInfo = GetAlterableAttribute(targeted, false);

                if (alterInfo == null)
                {
                    alterInfo = GetAlterableAttribute(targeted, true);
                }

                if (origItem == null || !origItem.IsChildOf(from.Backpack))
                {
                    // The item must be in your backpack for you to alter it.
                    number = 1094729;
                }
                else if (origItem is BlankScroll)
                {
                    if (m_Contract == null)
                    {
                        if (value >= 100.0)
                        {
                            Item contract = null;

                            if (skill == SkillName.Blacksmith)
                            {
                                contract = new AlterContract(ContractType.Blacksmith, from);
                            }
                            else if (skill == SkillName.Carpentry)
                            {
                                contract = new AlterContract(ContractType.Carpenter, from);
                            }
                            else if (skill == SkillName.Tailoring)
                            {
                                contract = new AlterContract(ContractType.Tailor, from);
                            }
                            else if (skill == SkillName.Tinkering)
                            {
                                contract = new AlterContract(ContractType.Tinker, from);
                            }

                            if (contract != null)
                            {
                                from.AddToBackpack(contract);

                                number = 1044154;                                 // You create the item.

                                // Consume a blank scroll
                                origItem.Consume();
                            }
                        }
                        else
                        {
                            // You must be at least grandmaster level to create an alter service contract.
                            number = 1111869;
                        }
                    }
                    else
                    {
                        // You may not alter that item.
                        number = 1094728;
                    }
                }
                else if (alterInfo == null)
                {
                    // You may not alter that item.
                    number = 1094728;
                }
                else if (!IsAlterable(origItem))
                {
                    // You may not alter that item.
                    number = 1094728;
                }
                else if (alterInfo.CraftSystem != m_CraftSystem.GetType())
                {
                    if (m_Tool != null)
                    {
                        // You may not alter that item.
                        number = 1094728;
                    }
                    else
                    {
                        // You cannot alter that item with this type of alter contract.
                        number = 1094793;
                    }
                }
                else if (!Imbuing.Soulforge.CheckProximity(from, 2))
                {
                    // You must be near a soulforge to alter an item.
                    number = 1111867;
                }
                else if (!Imbuing.Soulforge.CheckQueen(from))
                {
                    // You must rise to the rank of noble in the eyes of the Gargoyle Queen before her majesty will allow you to use this soulforge.
                    number = 1113736;
                }
                else if (origItem is BaseWeapon && ((BaseWeapon)origItem).Enchanted)
                {
                    // You cannot alter an item that is currently enchanted.
                    number = 1111849;
                }
                else if (m_Contract == null && value < 100.0)
                {
                    // You must be at least grandmaster level to alter an item.
                    number = 1111870;
                }
                else
                {
                    Item alteredItem = Activator.CreateInstance(alterInfo.AlteredType) as Item;

                    alteredItem.Hue            = origItem.Hue;
                    alteredItem.Insured        = origItem.Insured;
                    alteredItem.PayedInsurance = origItem.PayedInsurance;
                    alteredItem.Label1         = origItem.Label1;
                    alteredItem.Label2         = origItem.Label2;
                    alteredItem.Label3         = origItem.Label3;
                    alteredItem.LootType       = origItem.LootType;

                    if (origItem.LabelNumber != origItem.DefaultLabelNumber)
                    {
                        alteredItem.LabelNumber = origItem.LabelNumber;
                    }

                    AlterFrom(origItem, alteredItem);

                    alteredItem.Hue = origItem.PrivateHue;

                    from.PlaceInBackpack(alteredItem);
                    alteredItem.Location = origItem.Location;
                    origItem.Delete();

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

                    // You have altered the item.
                    number = 1094727;
                }

                if (m_Tool != null)
                {
                    from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
                }
                else
                {
                    from.SendLocalizedMessage(number);
                }
            }
Exemplo n.º 15
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

					if (tool.Parent is Container) {
					Container cntnr = (Container) tool.Parent;
                                        cntnr.TryDropItem(from, item, false);
					}
					else {
					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);
				}
			}
		}