protected override void OnTarget(Mobile from, object targeted) { int number; if (m_CraftSystem is DefTinkering && targeted is Golem) { Golem g = (Golem)targeted; int damage = g.HitsMax - g.Hits; if (g.IsDeadBondedPet) { number = 500426; // You can't repair that. } else if (damage <= 0) { number = 500423; // That is already in full repair. } else { double skillValue = from.Skills[SkillName.Tinkering].Value; if (skillValue < 60.0) { number = 1044153; // You don't have the required skills to attempt this item. } else if (!from.CanBeginAction(typeof(Golem))) { number = 501789; // You must wait before trying again. } else { if (damage > (int)(skillValue * 0.3)) { damage = (int)(skillValue * 0.3); } damage += 30; if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0)) { damage /= 2; } Container pack = from.Backpack; if (pack != null) { int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5); if (v > 0) { g.Hits += v * 5; number = 1044279; // You repair the item. from.BeginAction(typeof(Golem)); Timer.DelayCall(TimeSpan.FromSeconds(12.0), new TimerStateCallback(EndGolemRepair), from); } else { number = 1044037; // You do not have sufficient metal to make that. } } else { number = 1044037; // You do not have sufficient metal to make that. } } } } else 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. } else if (!weapon.IsChildOf(from.Backpack)) { number = 1044275; // The item must be in your backpack to repair it. } else if (weapon.MaxHits <= 0 || weapon.Hits == weapon.MaxHits) { number = 1044281; // That item is in full repair } else if (weapon.MaxHits <= toWeaken) { number = 500424; // You destroyed the item. m_CraftSystem.PlayCraftEffect(from); weapon.Delete(); } else if (from.CheckSkill(skill, -285.0, 100.0)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); weapon.MaxHits -= toWeaken; weapon.Hits = weapon.MaxHits; } else { number = 1044280; // You fail to repair the item. m_CraftSystem.PlayCraftEffect(from); weapon.MaxHits -= toWeaken; if (weapon.Hits - toWeaken < 0) { weapon.Hits = 0; } else { weapon.Hits -= toWeaken; } } if (weapon.MaxHits <= toWeaken) { from.SendLocalizedMessage(1044278); // That item has been repaired many times, and will break if repairs are attempted again. } } 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 && !IsSpecialArmor(armor)) { number = 1044277; // That item cannot be repaired. } 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 = 500424; // You destroyed the item. m_CraftSystem.PlayCraftEffect(from); armor.Delete(); } else if (from.CheckSkill(skill, -285.0, 100.0)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); armor.MaxHitPoints -= toWeaken; armor.HitPoints = armor.MaxHitPoints; } else { number = 1044280; // You fail to repair the item. m_CraftSystem.PlayCraftEffect(from); armor.MaxHitPoints -= toWeaken; if (armor.HitPoints - toWeaken < 0) { armor.HitPoints = 0; } else { armor.HitPoints -= toWeaken; } } if (armor.MaxHitPoints <= toWeaken) { from.SendLocalizedMessage(1044278); // That item has been repaired many times, and will break if repairs are attempted again. } } else if (targeted is Item) { SkillName skill = m_CraftSystem.MainSkill; if (targeted is BlankScroll) { if (skill == SkillName.Blacksmith && from.Skills[SkillName.Blacksmith].Value >= 55.0) { BlackSmithRepair r1 = new BlackSmithRepair(); r1.SkillLevel = from.Skills[SkillName.Blacksmith].Value; r1.Maker = from.Name; r1.Uses = 8; from.AddToBackpack(r1); number = 1044154; BlankScroll i_blank = targeted as BlankScroll; if (i_blank.Amount >= 2) { i_blank.Amount -= 1; } else { i_blank.Delete(); } } else if (skill == SkillName.Tailoring && from.Skills[SkillName.Tailoring].Value >= 55.0) { TailorRepair r1 = new TailorRepair(); r1.SkillLevel = from.Skills[SkillName.Tailoring].Value; r1.Maker = from.Name; r1.Uses = 8; from.AddToBackpack(r1); number = 1044154; BlankScroll i_blank = targeted as BlankScroll; if (i_blank.Amount >= 2) { i_blank.Amount -= 1; } else { i_blank.Delete(); } } else { number = 1044277; // That item cannot be repaired. } } else { number = 1044277; // That item cannot be repaired. } } else { number = 500426; // You can't repair that. } CraftContext context = m_CraftSystem.GetContext(from); from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number)); }
protected override void OnTarget(Mobile from, object targeted) { int number; if (m_CraftSystem is DefBlacksmithy) { bool anvil, forge; DefBlacksmithy.CheckAnvilAndForge(from, 2, out anvil, out forge); if (anvil && forge) { // You must be near a forge and and anvil to repair items. number = 1044282; } } if (m_CraftSystem is DefTinkering && targeted is Golem) { Golem g = (Golem)targeted; int damage = g.HitsMax - g.Hits; if (g.IsDeadBondedPet) { number = 500426; // You can't repair that. } else if (damage <= 0) { number = 500423; // That is already in full repair. } else { double skillValue = from.Skills[SkillName.Tinkering].Value; if (skillValue < 60.0) { number = 1044153; // You don't have the required skills to attempt this item. } else if (!from.CanBeginAction(typeof(Golem))) { number = 501789; // You must wait before trying again. } else { if (damage > (int)(skillValue * 0.3)) { damage = (int)(skillValue * 0.3); } damage += 30; if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0)) { damage /= 2; } Container pack = from.Backpack; if (pack != null) { int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5); if (v > 0) { g.Hits += v * 5; number = 1044279; // You repair the item. from.BeginAction(typeof(Golem)); Timer.DelayCall(TimeSpan.FromSeconds(12.0), new TimerStateCallback(EndGolemRepair), from); if (m_Contract != null) { m_Contract.Delete(); } } else { number = 1044037; // You do not have sufficient metal to make that. } } else { number = 1044037; // You do not have sufficient metal to make that. } } } } else 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 (m_Tool == null) { skillLevel = m_SkillLevel; } 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)) { if (m_Contract != null) { // You cannot repair that item with this type of repair contract. number = 1061136; } else { // You cannot repair that using this type of tool. number = 1061139; } } else if (!weapon.IsChildOf(from.Backpack)) { number = 1044275; // The item must be in your backpack to repair it. } else if (weapon.MaxHits <= 0 || weapon.Hits == weapon.MaxHits) { number = 1044281; // That item is in full repair } else if (weapon.MaxHits <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else { if (CheckWeaken(from, skill, weapon.Hits, weapon.MaxHits)) { weapon.MaxHits -= toWeaken; weapon.Hits = Math.Max(0, weapon.Hits - toWeaken); } if (CheckRepairDifficulty(from, skill, weapon.Hits, weapon.MaxHits)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); weapon.Hits = weapon.MaxHits; if (from.AccessLevel > AccessLevel.Player) { weapon.Cheater_Name = String.Format("This item repaired by GM {0}", from.Name); } } else { if (m_Contract != null) { // You fail to repair the item and the repair contract is destroyed. number = 1061137; } else { // You fail to repair the item. number = 1044280; } m_CraftSystem.PlayCraftEffect(from); } if (m_Contract != null) { m_Contract.Delete(); } } } 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 (m_Tool == null) { skillLevel = m_SkillLevel; } if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null) { if (m_Contract != null) { // You cannot repair that item with this type of repair contract. number = 1061136; } else { // You cannot repair that using this type of tool. number = 1061139; } } 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; if (from.AccessLevel > AccessLevel.Player) { armor.Cheater_Name = String.Format("This item repaired by GM {0}", from.Name); } } else { if (m_Contract != null) { // You fail to repair the item and the repair contract is destroyed. number = 1061137; } else { // You fail to repair the item. number = 1044280; } m_CraftSystem.PlayCraftEffect(from); } if (m_Contract != null) { m_Contract.Delete(); } } } else if (targeted is Item) { number = 1044283; // You cannot repair that. SkillName skill = m_CraftSystem.MainSkill; double value = from.Skills[skill].Value; if (targeted is BlankScroll) { Item contract = null; if (value < 50.0) { // You must be at least apprentice level to create a repair service contract. number = 1047005; } else { if (skill == SkillName.Blacksmith) { contract = new RepairContract(ContractType.Blacksmith, value, from.Name); } else if (skill == SkillName.Carpentry) { contract = new RepairContract(ContractType.Carpenter, value, from.Name); } else if (skill == SkillName.Fletching) { contract = new RepairContract(ContractType.Fletcher, value, from.Name); } else if (skill == SkillName.Tailoring) { contract = new RepairContract(ContractType.Tailor, value, from.Name); } else if (skill == SkillName.Tinkering) { contract = new RepairContract(ContractType.Tinker, value, from.Name); } } if (contract != null) { if (from.AccessLevel > AccessLevel.Player) { contract.Cheater_Name = String.Format("This item crafted by GM {0}", from.Name); } from.AddToBackpack(contract); number = 1044154; // You create the item. BlankScroll scroll = targeted as BlankScroll; if (scroll.Amount >= 2) { scroll.Amount -= 1; } else { scroll.Delete(); } } } } else { number = 500426; // You can't repair that. } if (m_Tool != null) { CraftContext context = m_CraftSystem.GetContext(from); from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number)); } else { from.SendLocalizedMessage(number); } }