protected override void OnTarget(Mobile from, object targeted) { bool hasForge, hasAnvil; DefBlacksmithy.CheckAnvilAndForge(from, 4, out hasAnvil, out hasForge); if (targeted is BaseIngot && m_Tool is BaseTool) { if (hasAnvil && hasForge) { BaseTool tool = (BaseTool)m_Tool; BaseIngot ingot = (BaseIngot)targeted; CraftSubRes subRes = CustomCraftMenu.GetSubRes(DefBlacksmithy.CraftSystem, targeted.GetType(), null); int num = CraftResources.GetIndex(ingot.Resource); if (subRes == null || !CustomCraftMenu.ResourceInfoList.ContainsKey(subRes)) { from.SendAsciiMessage("You can't use that."); return; } if (from.Skills[DefBlacksmithy.CraftSystem.MainSkill].Base < subRes.RequiredSkill) { from.SendAsciiMessage("You cannot work this strange and unusual metal."); return; } from.SendGump(new CraftGump(from, m_CraftSystem, tool, null, num)); //from.SendMenu( new CustomCraftMenu( from, DefBlacksmithy.CraftSystem, ( (BaseTool)m_Tool ), -1, targeted.GetType(), CustomCraftMenu.ResourceInfoList[subRes].ResourceIndex ) ); } else { from.SendAsciiMessage("You need to be close to a forge and anvil to smith."); } } else if (targeted is BaseIngot && !(m_Tool is BaseTool)) { from.SendAsciiMessage("You need to use a smith's hammer on that."); } else { if (!hasAnvil) { from.SendAsciiMessage("You need to be close to an anvil to repair."); return; } int number; if (targeted is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { double skillLevel = from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon)) { number = 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!weapon.IsChildOf(from.Backpack)) { number = 1044275; // The item must be in your backpack to repair it. } else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (weapon.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else { if (CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints)) { weapon.MaxHitPoints -= toWeaken; weapon.HitPoints = Math.Max(0, weapon.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); weapon.HitPoints = weapon.MaxHitPoints; } else { number = 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } } } else if (targeted is BaseArmor) { BaseArmor armor = (BaseArmor)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { double skillLevel = from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null) { number = 1044277; } // That item cannot be repaired. // You cannot repair that item with this type of repair contract. else if (!armor.IsChildOf(from.Backpack)) { number = 1044275; // The item must be in your backpack to repair it. } else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (armor.MaxHitPoints <= toWeaken) { number = 1044278; } // That item has been repaired many times, and will break if repairs are attempted again. else { if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints)) { armor.MaxHitPoints -= toWeaken; armor.HitPoints = Math.Max(0, armor.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); armor.HitPoints = armor.MaxHitPoints; } else { number = 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } } } else if (targeted is Item) { number = 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else { number = 500426; // You can't repair that. } from.SendAsciiMessage(CliLoc.LocToString(number)); } }
protected override void OnTick() { m_iCount++; m_From.DisruptiveAction(); if (m_iCount < m_iCountMax) { m_CraftSystem.PlayCraftEffect(m_From); } else { m_From.EndAction <CraftSystem>(); var badCraft = m_CraftSystem.CanCraft(m_From, m_Tool, m_CraftItem.ItemType); if (badCraft > 0) { if (m_Tool?.Deleted == false && m_Tool.UsesRemaining > 0) { m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, badCraft)); } else { m_From.SendLocalizedMessage(badCraft); } return; } var quality = 1; m_CraftItem.CheckSkills(m_From, m_TypeRes, m_CraftSystem, ref quality, out _, false); var context = m_CraftSystem.GetContext(m_From); if (context == null) { return; } if (typeof(CustomCraft).IsAssignableFrom(m_CraftItem.ItemType)) { try { m_CraftItem.ItemType.CreateInstance <CustomCraft>( m_From, m_CraftItem, m_CraftSystem, m_TypeRes, m_Tool, quality )?.EndCraftAction(); } catch (Exception e) { Console.WriteLine(e); } return; } var makersMark = false; if (quality == 2 && m_From.Skills[m_CraftSystem.MainSkill].Base >= 100.0) { makersMark = m_CraftItem.IsMarkable(m_CraftItem.ItemType); } if (makersMark && context.MarkOption == CraftMarkOption.PromptForMark) { m_From.SendGump( new QueryMakersMarkGump( quality, m_From, m_CraftItem, m_CraftSystem, m_TypeRes, m_Tool ) ); } else { if (context.MarkOption == CraftMarkOption.DoNotMark) { makersMark = false; } m_CraftItem.CompleteCraft(quality, makersMark, m_From, m_CraftSystem, m_TypeRes, m_Tool, null); } } }