public override void GetProperties(ObjectPropertyList list) { base.GetProperties(list); if (!CraftResources.IsStandard(m_Resource)) { int num = CraftResources.GetLocalizationNumber(m_Resource); if (num > 0) { list.Add(num); } else { list.Add(CraftResources.GetName(m_Resource)); } } }
public static EnhanceResult Invoke(Mobile from, CraftSystem craftSystem, BaseTool tool, Item item, CraftResource resource, Type resType, ref object resMessage) { if (item == null) { return(EnhanceResult.BadItem); } if (!item.IsChildOf(from.Backpack)) { return(EnhanceResult.NotInBackpack); } if (!(item is BaseArmor) && !(item is BaseWeapon)) { return(EnhanceResult.BadItem); } if (CraftResources.IsStandard(resource)) { return(EnhanceResult.BadResource); } CraftItem craftItem = craftSystem.CraftItems.SearchFor(item.GetType()); if (craftItem == null || craftItem.Ressources.Count == 0) { return(EnhanceResult.BadItem); } int quality = 0; bool allRequiredSkills = false; if (!craftItem.CheckSkills(from, resType, craftSystem, ref quality, ref allRequiredSkills, false)) { return(EnhanceResult.NoSkill); } CraftResourceInfo info = CraftResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) { return(EnhanceResult.BadResource); } CraftAttributeInfo attributes = info.AttributeInfo; if (attributes == null) { return(EnhanceResult.BadResource); } int resHue = 0, maxAmount = 0; if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref resMessage)) { return(EnhanceResult.NoResources); } AncientSmithyHammer hammer = from.FindItemOnLayer(Layer.OneHanded) as AncientSmithyHammer; if (hammer != null) { hammer.UsesRemaining--; if (hammer.UsesRemaining < 1) { hammer.Delete(); } } int phys = 0, fire = 0, cold = 0, pois = 0, nrgy = 0; int dura = 0, luck = 0, lreq = 0, dinc = 0; int baseChance = 0; bool physBonus = false; bool fireBonus = false; bool coldBonus = false; bool nrgyBonus = false; bool poisBonus = false; bool duraBonus = false; bool luckBonus = false; bool lreqBonus = false; bool dincBonus = false; if (item is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)item; if (!CraftResources.IsStandard(weapon.Resource)) { return(EnhanceResult.AlreadyEnhanced); } baseChance = 20; dura = weapon.MaxHits; luck = weapon.Attributes.Luck; lreq = weapon.WeaponAttributes.LowerStatReq; dinc = weapon.Attributes.WeaponDamage; fireBonus = (attributes.WeaponFireDamage > 0); coldBonus = (attributes.WeaponColdDamage > 0); nrgyBonus = (attributes.WeaponEnergyDamage > 0); poisBonus = (attributes.WeaponPoisonDamage > 0); duraBonus = (attributes.WeaponDurability > 0); luckBonus = (attributes.WeaponLuck > 0); lreqBonus = (attributes.WeaponLowerRequirements > 0); dincBonus = (dinc > 0); } else { BaseArmor armor = (BaseArmor)item; if (!CraftResources.IsStandard(armor.Resource)) { return(EnhanceResult.AlreadyEnhanced); } baseChance = 20; phys = armor.PhysicalResistance; fire = armor.FireResistance; cold = armor.ColdResistance; pois = armor.PoisonResistance; nrgy = armor.EnergyResistance; dura = armor.MaxHitPoints; luck = armor.Attributes.Luck; lreq = armor.ArmorAttributes.LowerStatReq; physBonus = (attributes.ArmorPhysicalResist > 0); fireBonus = (attributes.ArmorFireResist > 0); coldBonus = (attributes.ArmorColdResist > 0); nrgyBonus = (attributes.ArmorEnergyResist > 0); poisBonus = (attributes.ArmorPoisonResist > 0); duraBonus = (attributes.ArmorDurability > 0); luckBonus = (attributes.ArmorLuck > 0); lreqBonus = (attributes.ArmorLowerRequirements > 0); dincBonus = false; } int skill = from.Skills[craftSystem.MainSkill].Fixed / 10; if (skill >= 100) { baseChance -= (skill - 90) / 10; } EnhanceResult res = EnhanceResult.Success; if (physBonus) { CheckResult(ref res, baseChance + phys); } if (fireBonus) { CheckResult(ref res, baseChance + fire); } if (coldBonus) { CheckResult(ref res, baseChance + cold); } if (nrgyBonus) { CheckResult(ref res, baseChance + nrgy); } if (poisBonus) { CheckResult(ref res, baseChance + pois); } if (duraBonus) { CheckResult(ref res, baseChance + (dura / 40)); } if (luckBonus) { CheckResult(ref res, baseChance + 10 + (luck / 2)); } if (lreqBonus) { CheckResult(ref res, baseChance + (lreq / 4)); } if (dincBonus) { CheckResult(ref res, baseChance + (dinc / 4)); } switch (res) { case EnhanceResult.Broken: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage)) { return(EnhanceResult.NoResources); } item.Delete(); break; } case EnhanceResult.Success: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref resMessage)) { return(EnhanceResult.NoResources); } if (item is BaseWeapon) { ((BaseWeapon)item).Resource = resource; } else { ((BaseArmor)item).Resource = resource; } break; } case EnhanceResult.Failure: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage)) { return(EnhanceResult.NoResources); } break; } } return(res); }
public static EnhanceResult Invoke(Mobile from, CraftSystem craftSystem, ITool tool, Item item, CraftResource resource, Type resType, ref object resMessage) { if (item == null) { return(EnhanceResult.BadItem); } if (item is GargishNecklace || item is GargishEarrings) { return(EnhanceResult.BadItem); } if (!item.IsChildOf(from.Backpack)) { return(EnhanceResult.NotInBackpack); } IResource ires = item as IResource; if (!CanEnhance(item) || ires == null) { return(EnhanceResult.BadItem); } if (item is IArcaneEquip) { IArcaneEquip eq = (IArcaneEquip)item; if (eq.IsArcane) { return(EnhanceResult.BadItem); } } if (item is BaseWeapon && Spells.Mysticism.EnchantSpell.IsUnderSpellEffects(from, (BaseWeapon)item)) { return(EnhanceResult.Enchanted); } if (CraftResources.IsStandard(resource)) { return(EnhanceResult.BadResource); } int num = craftSystem.CanCraft(from, tool, item.GetType()); if (num > 0) { resMessage = num; return(EnhanceResult.None); } CraftItem craftItem = craftSystem.CraftItems.SearchFor(item.GetType()); if (IsSpecial(item, craftSystem)) { craftItem = craftSystem.CraftItems.SearchForSubclass(item.GetType()); } if (craftItem == null || craftItem.Resources.Count == 0) { return(EnhanceResult.BadItem); } #region Mondain's Legacy if (craftItem.ForceNonExceptional) { return(EnhanceResult.BadItem); } #endregion bool allRequiredSkills = false; if (craftItem.GetSuccessChance(from, resType, craftSystem, false, ref allRequiredSkills) <= 0.0) { return(EnhanceResult.NoSkill); } CraftResourceInfo info = CraftResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) { return(EnhanceResult.BadResource); } CraftAttributeInfo attributes = info.AttributeInfo; if (attributes == null) { return(EnhanceResult.BadResource); } int resHue = 0, maxAmount = 0; if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref resMessage)) { return(EnhanceResult.NoResources); } if (!CraftResources.IsStandard(ires.Resource)) { return(EnhanceResult.AlreadyEnhanced); } if (craftSystem is DefBlacksmithy) { AncientSmithyHammer hammer = from.FindItemOnLayer(Layer.OneHanded) as AncientSmithyHammer; if (hammer != null) { hammer.UsesRemaining--; if (hammer.UsesRemaining < 1) { hammer.Delete(); } } } int phys = 0, fire = 0, cold = 0, pois = 0, nrgy = 0; int dura = 0, luck = 0, lreq = 0, dinc = 0; int baseChance = 0; bool physBonus = false; bool fireBonus = false; bool coldBonus = false; bool nrgyBonus = false; bool poisBonus = false; bool duraBonus = false; bool luckBonus = false; bool lreqBonus = false; bool dincBonus = false; if (item is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)item; if (weapon.ExtendedWeaponAttributes.AssassinHoned > 0) { return(EnhanceResult.BadItem); } baseChance = 20; dura = weapon.MaxHitPoints; luck = weapon.Attributes.Luck; lreq = weapon.WeaponAttributes.LowerStatReq; dinc = weapon.Attributes.WeaponDamage; fireBonus = (attributes.WeaponFireDamage > 0); coldBonus = (attributes.WeaponColdDamage > 0); nrgyBonus = (attributes.WeaponEnergyDamage > 0); poisBonus = (attributes.WeaponPoisonDamage > 0); duraBonus = (attributes.WeaponDurability > 0); luckBonus = (attributes.WeaponLuck > 0); lreqBonus = (attributes.WeaponLowerRequirements > 0); dincBonus = (dinc > 0); } else if (item is BaseArmor) { BaseArmor armor = (BaseArmor)item; baseChance = 20; phys = armor.PhysicalResistance; fire = armor.FireResistance; cold = armor.ColdResistance; pois = armor.PoisonResistance; nrgy = armor.EnergyResistance; dura = armor.MaxHitPoints; luck = armor.Attributes.Luck; lreq = armor.ArmorAttributes.LowerStatReq; physBonus = (attributes.ArmorPhysicalResist > 0); fireBonus = (attributes.ArmorFireResist > 0); coldBonus = (attributes.ArmorColdResist > 0); nrgyBonus = (attributes.ArmorEnergyResist > 0); poisBonus = (attributes.ArmorPoisonResist > 0); duraBonus = (attributes.ArmorDurability > 0); luckBonus = (attributes.ArmorLuck > 0); lreqBonus = (attributes.ArmorLowerRequirements > 0); dincBonus = false; } else if (item is FishingPole) { FishingPole pole = (FishingPole)item; baseChance = 20; luck = pole.Attributes.Luck; luckBonus = (attributes.ArmorLuck > 0); lreqBonus = (attributes.ArmorLowerRequirements > 0); dincBonus = false; } int skill = from.Skills[craftSystem.MainSkill].Fixed / 10; if (skill >= 100) { baseChance -= (skill - 90) / 10; } EnhanceResult res = EnhanceResult.Success; PlayerMobile user = from as PlayerMobile; if (physBonus) { CheckResult(ref res, baseChance + phys); } if (fireBonus) { CheckResult(ref res, baseChance + fire); } if (coldBonus) { CheckResult(ref res, baseChance + cold); } if (nrgyBonus) { CheckResult(ref res, baseChance + nrgy); } if (poisBonus) { CheckResult(ref res, baseChance + pois); } if (duraBonus) { CheckResult(ref res, baseChance + (dura / 40)); } if (luckBonus) { CheckResult(ref res, baseChance + 10 + (luck / 2)); } if (lreqBonus) { CheckResult(ref res, baseChance + (lreq / 4)); } if (dincBonus) { CheckResult(ref res, baseChance + (dinc / 4)); } if (user.NextEnhanceSuccess) { user.NextEnhanceSuccess = false; user.SendLocalizedMessage(1149969); // The magical aura that surrounded you disipates and you feel that your item enhancement chances have returned to normal. res = EnhanceResult.Success; } switch (res) { case EnhanceResult.Broken: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage)) { return(EnhanceResult.NoResources); } item.Delete(); break; } case EnhanceResult.Success: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref resMessage)) { return(EnhanceResult.NoResources); } if (craftItem.CaddelliteCraft) { Caddellite.TryInfuse(from, item, craftSystem); } if (item is IResource) { ((IResource)item).Resource = resource; } if (item is BaseWeapon) { BaseWeapon w = (BaseWeapon)item; w.DistributeMaterialBonus(attributes); int hue = w.GetElementalDamageHue(); if (hue > 0) { w.Hue = hue; } } else if (item is BaseArmor) { ((BaseArmor)item).DistributeMaterialBonus(attributes); } else if (item is FishingPole) { ((FishingPole)item).DistributeMaterialBonus(attributes); } break; } case EnhanceResult.Failure: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage)) { return(EnhanceResult.NoResources); } break; } } return(res); }
public static EnhanceResult Invoke(Mobile from, CraftSystem craftSystem, BaseTool tool, Item item, CraftResource resource, Type resType, ref object resMessage) { if (item == null) { return(EnhanceResult.BadItem); } if (!item.IsChildOf(from.Backpack)) { return(EnhanceResult.NotInBackpack); } if (!(item is BaseArmor) && !(item is BaseWeapon)) { return(EnhanceResult.BadItem); } if (item is IArcaneEquip) { IArcaneEquip eq = (IArcaneEquip)item; if (eq.IsArcane) { return(EnhanceResult.BadItem); } } if (CraftResources.IsStandard(resource)) { return(EnhanceResult.BadResource); } int num = craftSystem.CanCraft(from, tool, item.GetType()); if (num > 0) { resMessage = num; return(EnhanceResult.None); } CraftItem craftItem = craftSystem.CraftItems.SearchFor(item.GetType()); if (IsSpecial(item, craftSystem)) { craftItem = craftSystem.CraftItems.SearchForSubclass(item.GetType()); } if (craftItem == null || craftItem.Resources.Count == 0) { return(EnhanceResult.BadItem); } #region Mondain's Legacy if (craftItem.ForceNonExceptional) { return(EnhanceResult.BadItem); } #endregion bool allRequiredSkills = false; if (craftItem.GetSuccessChance(from, resType, craftSystem, false, ref allRequiredSkills) <= 0.0) { return(EnhanceResult.NoSkill); } CraftResourceInfo info = CraftResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) { return(EnhanceResult.BadResource); } CraftAttributeInfo attributes = info.AttributeInfo; if (attributes == null) { return(EnhanceResult.BadResource); } int resHue = 0, maxAmount = 0; if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref resMessage)) { return(EnhanceResult.NoResources); } if (craftSystem is DefBlacksmithy) { AncientSmithyHammer hammer = from.FindItemOnLayer(Layer.OneHanded) as AncientSmithyHammer; if (hammer != null) { hammer.UsesRemaining--; if (hammer.UsesRemaining < 1) { hammer.Delete(); } } } int phys = 0, fire = 0, cold = 0, pois = 0, nrgy = 0; int dura = 0, luck = 0, lreq = 0, dinc = 0; int baseChance = 0; bool physBonus = false; bool fireBonus = false; bool coldBonus = false; bool nrgyBonus = false; bool poisBonus = false; bool duraBonus = false; bool luckBonus = false; bool lreqBonus = false; bool dincBonus = false; if (item is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)item; if (!CraftResources.IsStandard(weapon.Resource)) { return(EnhanceResult.AlreadyEnhanced); } if (weapon.ExtendedWeaponAttributes.AssassinHoned > 0) { return(EnhanceResult.BadItem); } baseChance = 20; dura = weapon.MaxHitPoints; luck = weapon.Attributes.Luck; lreq = weapon.WeaponAttributes.LowerStatReq; dinc = weapon.Attributes.WeaponDamage; fireBonus = (attributes.WeaponFireDamage > 0); coldBonus = (attributes.WeaponColdDamage > 0); nrgyBonus = (attributes.WeaponEnergyDamage > 0); poisBonus = (attributes.WeaponPoisonDamage > 0); duraBonus = (attributes.WeaponDurability > 0); luckBonus = (attributes.WeaponLuck > 0); lreqBonus = (attributes.WeaponLowerRequirements > 0); dincBonus = (dinc > 0); } else { BaseArmor armor = (BaseArmor)item; if (!CraftResources.IsStandard(armor.Resource)) { return(EnhanceResult.AlreadyEnhanced); } baseChance = 20; phys = armor.PhysicalResistance; fire = armor.FireResistance; cold = armor.ColdResistance; pois = armor.PoisonResistance; nrgy = armor.EnergyResistance; dura = armor.MaxHitPoints; luck = armor.Attributes.Luck; lreq = armor.ArmorAttributes.LowerStatReq; physBonus = (attributes.ArmorPhysicalResist > 0); fireBonus = (attributes.ArmorFireResist > 0); coldBonus = (attributes.ArmorColdResist > 0); nrgyBonus = (attributes.ArmorEnergyResist > 0); poisBonus = (attributes.ArmorPoisonResist > 0); duraBonus = (attributes.ArmorDurability > 0); luckBonus = (attributes.ArmorLuck > 0); lreqBonus = (attributes.ArmorLowerRequirements > 0); dincBonus = false; } int skill = from.Skills[craftSystem.MainSkill].Fixed / 10; if (skill >= 100) { baseChance -= (skill - 90) / 10; } EnhanceResult res = EnhanceResult.Success; PlayerMobile user = from as PlayerMobile; if (physBonus) { CheckResult(ref res, baseChance + phys); } if (fireBonus) { CheckResult(ref res, baseChance + fire); } if (coldBonus) { CheckResult(ref res, baseChance + cold); } if (nrgyBonus) { CheckResult(ref res, baseChance + nrgy); } if (poisBonus) { CheckResult(ref res, baseChance + pois); } if (duraBonus) { CheckResult(ref res, baseChance + (dura / 40)); } if (luckBonus) { CheckResult(ref res, baseChance + 10 + (luck / 2)); } if (lreqBonus) { CheckResult(ref res, baseChance + (lreq / 4)); } if (dincBonus) { CheckResult(ref res, baseChance + (dinc / 4)); } if (user.NextEnhanceSuccess) { user.NextEnhanceSuccess = false; user.SendLocalizedMessage(1149969); // The magical aura that surrounded you disipates and you feel that your item enhancement chances have returned to normal. res = EnhanceResult.Success; } switch (res) { case EnhanceResult.Broken: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage)) { return(EnhanceResult.NoResources); } item.Delete(); break; } case EnhanceResult.Success: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref resMessage)) { return(EnhanceResult.NoResources); } if (item is BaseWeapon) { BaseWeapon w = (BaseWeapon)item; w.Resource = resource; #region Mondain's Legacy if (resource != CraftResource.Heartwood) { w.Attributes.WeaponDamage += attributes.WeaponDamage; w.Attributes.WeaponSpeed += attributes.WeaponSwingSpeed; w.Attributes.AttackChance += attributes.WeaponHitChance; w.Attributes.RegenHits += attributes.WeaponRegenHits; w.WeaponAttributes.HitLeechHits += attributes.WeaponHitLifeLeech; } else { switch (Utility.Random(6)) { case 0: w.Attributes.WeaponDamage += attributes.WeaponDamage; break; case 1: w.Attributes.WeaponSpeed += attributes.WeaponSwingSpeed; break; case 2: w.Attributes.AttackChance += attributes.WeaponHitChance; break; case 3: w.Attributes.Luck += attributes.WeaponLuck; break; case 4: w.WeaponAttributes.LowerStatReq += attributes.WeaponLowerRequirements; break; case 5: w.WeaponAttributes.HitLeechHits += attributes.WeaponHitLifeLeech; break; } } #endregion int hue = w.GetElementalDamageHue(); if (hue > 0) { w.Hue = hue; } } #region Mondain's Legacy else if (item is BaseShield) { BaseShield shield = (BaseShield)item; shield.Resource = resource; switch (resource) { case CraftResource.AshWood: shield.ArmorAttributes.LowerStatReq += 20; break; case CraftResource.YewWood: shield.Attributes.RegenHits += 1; break; case CraftResource.Heartwood: switch (Utility.Random(7)) { case 0: shield.Attributes.BonusDex += 2; break; case 1: shield.Attributes.BonusStr += 2; break; case 2: shield.Attributes.ReflectPhysical += 5; break; case 3: shield.Attributes.SpellChanneling = 1; shield.Attributes.CastSpeed = -1; break; case 4: shield.ArmorAttributes.SelfRepair += 2; break; case 5: shield.PhysicalBonus += 5; break; case 6: shield.ColdBonus += 3; break; } break; case CraftResource.Bloodwood: shield.Attributes.RegenHits += 2; shield.Attributes.Luck += 40; break; case CraftResource.Frostwood: shield.Attributes.SpellChanneling = 1; shield.Attributes.CastSpeed = -1; break; } } #endregion else if (item is BaseArmor) //Sanity { ((BaseArmor)item).Resource = resource; #region Mondain's Legacy BaseArmor armor = (BaseArmor)item; if (resource != CraftResource.Heartwood) { armor.Attributes.WeaponDamage += attributes.ArmorDamage; armor.Attributes.AttackChance += attributes.ArmorHitChance; armor.Attributes.RegenHits += attributes.ArmorRegenHits; //armor.ArmorAttributes.MageArmor += attributes.ArmorMage; } else { switch (Utility.Random(5)) { case 0: armor.Attributes.WeaponDamage += attributes.ArmorDamage; break; case 1: armor.Attributes.AttackChance += attributes.ArmorHitChance; break; case 2: armor.ArmorAttributes.MageArmor += attributes.ArmorMage; break; case 3: armor.Attributes.Luck += attributes.ArmorLuck; break; case 4: armor.ArmorAttributes.LowerStatReq += attributes.ArmorLowerRequirements; break; } } #endregion } break; } case EnhanceResult.Failure: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage)) { return(EnhanceResult.NoResources); } break; } } return(res); }
public static EnhanceResult Invoke( Mobile from, CraftSystem craftSystem, BaseTool tool, Item item, CraftResource resource, Type resType, ref TextDefinition resMessage ) { if (item == null) { return(EnhanceResult.BadItem); } if (!item.IsChildOf(from.Backpack)) { return(EnhanceResult.NotInBackpack); } if (item is not BaseArmor && item is not BaseWeapon) { return(EnhanceResult.BadItem); } if (item is IArcaneEquip eq && eq.IsArcane) { return(EnhanceResult.BadItem); } if (CraftResources.IsStandard(resource)) { return(EnhanceResult.BadResource); } var num = craftSystem.CanCraft(from, tool, item.GetType()); if (num > 0) { resMessage = num; return(EnhanceResult.None); } var craftItem = craftSystem.CraftItems.SearchFor(item.GetType()); if (craftItem == null || craftItem.Resources.Count == 0) { return(EnhanceResult.BadItem); } if (craftItem.GetSuccessChance(from, resType, craftSystem, false, out _) <= 0.0) { return(EnhanceResult.NoSkill); } var info = CraftResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) { return(EnhanceResult.BadResource); } var attributes = info.AttributeInfo; if (attributes == null) { return(EnhanceResult.BadResource); } int resHue = 0, maxAmount = 0; if (!craftItem.ConsumeRes( from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref resMessage )) { return(EnhanceResult.NoResources); } if (craftSystem is DefBlacksmithy) { if (from.FindItemOnLayer(Layer.OneHanded) is AncientSmithyHammer hammer) { hammer.UsesRemaining--; if (hammer.UsesRemaining < 1) { hammer.Delete(); } } } int phys = 0, fire = 0, cold = 0, pois = 0, nrgy = 0; int dura, luck, lreq, dinc = 0; int baseChance; var physBonus = false; bool fireBonus; bool coldBonus; bool nrgyBonus; bool poisBonus; bool duraBonus; bool luckBonus; bool lreqBonus; bool dincBonus; if (item is BaseWeapon weapon) { if (!CraftResources.IsStandard(weapon.Resource)) { return(EnhanceResult.AlreadyEnhanced); } baseChance = 20; dura = weapon.MaxHitPoints; luck = weapon.Attributes.Luck; lreq = weapon.WeaponAttributes.LowerStatReq; dinc = weapon.Attributes.WeaponDamage; fireBonus = attributes.WeaponFireDamage > 0; coldBonus = attributes.WeaponColdDamage > 0; nrgyBonus = attributes.WeaponEnergyDamage > 0; poisBonus = attributes.WeaponPoisonDamage > 0; duraBonus = attributes.WeaponDurability > 0; luckBonus = attributes.WeaponLuck > 0; lreqBonus = attributes.WeaponLowerRequirements > 0; dincBonus = dinc > 0; } else { var armor = (BaseArmor)item; if (!CraftResources.IsStandard(armor.Resource)) { return(EnhanceResult.AlreadyEnhanced); } baseChance = 20; phys = armor.PhysicalResistance; fire = armor.FireResistance; cold = armor.ColdResistance; pois = armor.PoisonResistance; nrgy = armor.EnergyResistance; dura = armor.MaxHitPoints; luck = armor.Attributes.Luck; lreq = armor.ArmorAttributes.LowerStatReq; physBonus = attributes.ArmorPhysicalResist > 0; fireBonus = attributes.ArmorFireResist > 0; coldBonus = attributes.ArmorColdResist > 0; nrgyBonus = attributes.ArmorEnergyResist > 0; poisBonus = attributes.ArmorPoisonResist > 0; duraBonus = attributes.ArmorDurability > 0; luckBonus = attributes.ArmorLuck > 0; lreqBonus = attributes.ArmorLowerRequirements > 0; dincBonus = false; } var skill = from.Skills[craftSystem.MainSkill].Fixed / 10; if (skill >= 100) { baseChance -= (skill - 90) / 10; } var res = EnhanceResult.Success; if (physBonus) { CheckResult(ref res, baseChance + phys); } if (fireBonus) { CheckResult(ref res, baseChance + fire); } if (coldBonus) { CheckResult(ref res, baseChance + cold); } if (nrgyBonus) { CheckResult(ref res, baseChance + nrgy); } if (poisBonus) { CheckResult(ref res, baseChance + pois); } if (duraBonus) { CheckResult(ref res, baseChance + dura / 40); } if (luckBonus) { CheckResult(ref res, baseChance + 10 + luck / 2); } if (lreqBonus) { CheckResult(ref res, baseChance + lreq / 4); } if (dincBonus) { CheckResult(ref res, baseChance + dinc / 4); } switch (res) { case EnhanceResult.Broken: { if (!craftItem.ConsumeRes( from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage )) { return(EnhanceResult.NoResources); } item.Delete(); break; } case EnhanceResult.Success: { if (!craftItem.ConsumeRes( from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref resMessage )) { return(EnhanceResult.NoResources); } if (item is BaseWeapon w) { w.Resource = resource; var hue = w.GetElementalDamageHue(); if (hue > 0) { w.Hue = hue; } } else { ((BaseArmor)item).Resource = resource; } break; } case EnhanceResult.Failure: { if (!craftItem.ConsumeRes( from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage )) { return(EnhanceResult.NoResources); } break; } } return(res); }
public static EnhanceResult Invoke(Mobile from, CraftSystem craftSystem, BaseTool tool, Item item, CraftResource resource, Type resType, ref object resMessage) { if (item == null) { return(EnhanceResult.BadItem); } if (!item.IsChildOf(from.Backpack)) { return(EnhanceResult.NotInBackpack); } if (!(item is BaseArmor) && !(item is BaseWeapon) && !(item is BaseOtherEquipable)) { return(EnhanceResult.BadItem); } if (item is IArcaneEquip) { IArcaneEquip eq = (IArcaneEquip)item; if (eq.IsArcane) { return(EnhanceResult.BadItem); } } if (CraftResources.IsStandard(resource)) { return(EnhanceResult.BadResource); } int num = craftSystem.CanCraft(from, tool, item.GetType()); if (num > 0) { resMessage = num; return(EnhanceResult.None); } CraftItem craftItem = craftSystem.CraftItems.SearchFor(item.GetType()); if (craftItem == null || craftItem.Resources.Count == 0) { return(EnhanceResult.BadItem); } bool allRequiredSkills = false; if (craftItem.GetSuccessChance(from, resType, craftSystem, false, ref allRequiredSkills) <= 0.0) { return(EnhanceResult.NoSkill); } CraftResourceInfo info = CraftResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) { return(EnhanceResult.BadResource); } CraftAttributeInfo attributes = info.AttributeInfo; if (attributes == null) { return(EnhanceResult.BadResource); } int resHue = 0, maxAmount = 0; if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref resMessage)) { return(EnhanceResult.NoResources); } if (craftSystem is DefBlacksmithy) { AncientSmithyHammer hammer = from.FindItemOnLayer(Layer.OneHanded) as AncientSmithyHammer; if (hammer != null) { hammer.UsesRemaining--; if (hammer.UsesRemaining < 1) { hammer.Delete(); } } } int baseChance = 0; BonusAttribute[] bonusAttrs = null; BonusAttribute[] randomAttrs = null; if (item is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)item; if (!CraftResources.IsStandard(weapon.Resource)) { return(EnhanceResult.AlreadyEnhanced); } baseChance = 20; CheckSkill(ref baseChance, from, craftSystem); int numOfRand = attributes.RandomAttributeCount; bonusAttrs = attributes.WeaponAttributes; randomAttrs = BonusAttributesHelper.GetRandomAttributes(attributes.WeaponRandomAttributes, numOfRand); } else if (item is BaseArmor) { BaseArmor armor = (BaseArmor)item; if (!CraftResources.IsStandard(armor.Resource)) { return(EnhanceResult.AlreadyEnhanced); } baseChance = 20; CheckSkill(ref baseChance, from, craftSystem); int numOfRand = attributes.RandomAttributeCount; if (armor.UsesShieldAttrs) { bonusAttrs = attributes.ShieldAttributes; randomAttrs = BonusAttributesHelper.GetRandomAttributes(attributes.ShieldRandomAttributes, numOfRand); } else { bonusAttrs = info.AttributeInfo.ArmorAttributes; randomAttrs = BonusAttributesHelper.GetRandomAttributes(attributes.ArmorRandomAttributes, numOfRand); } } else if (item is BaseOtherEquipable) { BaseOtherEquipable otherEquip = (BaseOtherEquipable)item; if (!CraftResources.IsStandard(otherEquip.Resource)) { return(EnhanceResult.AlreadyEnhanced); } baseChance = 20; CheckSkill(ref baseChance, from, craftSystem); int numOfRand = attributes.RandomAttributeCount; bonusAttrs = attributes.OtherAttributes; randomAttrs = BonusAttributesHelper.GetRandomAttributes(attributes.OtherRandomAttributes, numOfRand); } List <BonusAttribute> attrs = new List <BonusAttribute>(); if (bonusAttrs != null && bonusAttrs.Length > 0) { attrs.AddRange(bonusAttrs); } if (randomAttrs != null && randomAttrs.Length > 0) { attrs.AddRange(randomAttrs); } EnhanceResult res = EnhanceResult.Success; TryEnhance(attrs, item, baseChance, ref res); switch (res) { case EnhanceResult.Broken: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage)) { return(EnhanceResult.NoResources); } item.Delete(); break; } case EnhanceResult.Success: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref resMessage)) { return(EnhanceResult.NoResources); } if (item is BaseWeapon) { BaseWeapon w = (BaseWeapon)item; w.RandomAttributes = randomAttrs; w.Resource = resource; w.Hue = w.GetElementalDamageHue(w.Hue); } else if (item is BaseArmor) { BaseArmor ar = (BaseArmor)item; ar.RandomAttributes = randomAttrs; ((BaseArmor)item).Resource = resource; } else if (item is BaseOtherEquipable) //Sanity { BaseOtherEquipable otherEquip = (BaseOtherEquipable)item; otherEquip.RandomAttributes = randomAttrs; ((BaseOtherEquipable)item).Resource = resource; } break; } case EnhanceResult.Failure: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage)) { return(EnhanceResult.NoResources); } break; } } return(res); }
public static EnhanceResult Invoke(Mobile from, CraftSystem craftSystem, IBaseTool tool, Item item, CraftResource resource, Type resType, ref object resMessage) { if (item == null) { return(EnhanceResult.BadItem); } if (!item.IsChildOf(from.Backpack)) { return(EnhanceResult.NotInBackpack); } if (!(item is BaseArmor) && !(item is BaseWeapon)) { return(EnhanceResult.BadItem); } if (item is IArcaneEquip) { IArcaneEquip eq = (IArcaneEquip)item; if (eq.IsArcane) { return(EnhanceResult.BadItem); } } if (CraftResources.IsStandard(resource)) { return(EnhanceResult.BadResource); } int num = craftSystem.CanCraft(from, tool, item.GetType()); if (num > 0) { resMessage = num; return(EnhanceResult.None); } CraftItem craftItem = craftSystem.CraftItems.SearchFor(item.GetType()); if (craftItem == null || craftItem.Resources.Count == 0) { return(EnhanceResult.BadItem); } bool allRequiredSkills = false; if (craftItem.GetSuccessChance(from, resType, craftSystem, false, ref allRequiredSkills) <= 0.0) { return(EnhanceResult.NoSkill); } CraftResourceInfo info = CraftResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) { return(EnhanceResult.BadResource); } CraftAttributeInfo attributes = info.AttributeInfo; if (attributes == null) { return(EnhanceResult.BadResource); } int resHue = 0, maxAmount = 0; if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref resMessage)) { return(EnhanceResult.NoResources); } if (craftSystem is DefBlacksmithy) { AncientSmithHammerWeapon hammer = from.FindItemOnLayer(Layer.OneHanded) as AncientSmithHammerWeapon; if (hammer != null) { hammer.UsesRemaining--; if (hammer.UsesRemaining < 1) { hammer.Delete(); } } } /* * int phys = 0, fire = 0, cold = 0, pois = 0, nrgy = 0; * int dura = 0, luck = 0, lreq = 0, dinc = 0; * int baseChance = 0; * * bool physBonus = false; * bool fireBonus = false; * bool coldBonus = false; * bool nrgyBonus = false; * bool poisBonus = false; * bool duraBonus = false; * bool luckBonus = false; * bool lreqBonus = false; * bool dincBonus = false; * * if ( item is BaseWeapon ) * { * BaseWeapon weapon = (BaseWeapon)item; * * if ( !CraftResources.IsStandard( weapon.Resource ) ) * return EnhanceResult.AlreadyEnhanced; * * baseChance = 20; * * dura = weapon.MaxHitPoints; * luck = weapon.Attributes.Luck; * lreq = weapon.WeaponAttributes.LowerStatReq; * dinc = weapon.Attributes.WeaponDamage; * * fireBonus = ( attributes.WeaponFireDamage > 0 ); * coldBonus = ( attributes.WeaponColdDamage > 0 ); * nrgyBonus = ( attributes.WeaponEnergyDamage > 0 ); * poisBonus = ( attributes.WeaponPoisonDamage > 0 ); * * duraBonus = ( attributes.WeaponDurability > 0 ); * luckBonus = ( attributes.WeaponLuck > 0 ); * lreqBonus = ( attributes.WeaponLowerRequirements > 0 ); * dincBonus = ( dinc > 0 ); * } * else * { * BaseArmor armor = (BaseArmor)item; * * if ( !CraftResources.IsStandard( armor.Resource ) ) * return EnhanceResult.AlreadyEnhanced; * * baseChance = 20; * * phys = armor.PhysicalResistance; * fire = armor.FireResistance; * cold = armor.ColdResistance; * pois = armor.PoisonResistance; * nrgy = armor.EnergyResistance; * * dura = armor.MaxHitPoints; * luck = armor.Attributes.Luck; * lreq = armor.ArmorAttributes.LowerStatReq; * * physBonus = ( attributes.ArmorPhysicalResist > 0 ); * fireBonus = ( attributes.ArmorFireResist > 0 ); * coldBonus = ( attributes.ArmorColdResist > 0 ); * nrgyBonus = ( attributes.ArmorEnergyResist > 0 ); * poisBonus = ( attributes.ArmorPoisonResist > 0 ); * * duraBonus = ( attributes.ArmorDurability > 0 ); * luckBonus = ( attributes.ArmorLuck > 0 ); * lreqBonus = ( attributes.ArmorLowerRequirements > 0 ); * dincBonus = false; * } */ int skill = from.Skills[craftSystem.MainSkill].Fixed / 10; //if ( skill >= 100 ) // baseChance -= (skill - 90) / 10; EnhanceResult res = EnhanceResult.Success; /* * if ( physBonus ) * CheckResult( ref res, baseChance + phys ); * * if ( fireBonus ) * CheckResult( ref res, baseChance + fire ); * * if ( coldBonus ) * CheckResult( ref res, baseChance + cold ); * * if ( nrgyBonus ) * CheckResult( ref res, baseChance + nrgy ); * * if ( poisBonus ) * CheckResult( ref res, baseChance + pois ); * * if ( duraBonus ) * CheckResult( ref res, baseChance + (dura / 40) ); * * if ( luckBonus ) * CheckResult( ref res, baseChance + 10 + (luck / 2) ); * * if ( lreqBonus ) * CheckResult( ref res, baseChance + (lreq / 4) ); * * if ( dincBonus ) * CheckResult( ref res, baseChance + (dinc / 4) ); */ switch (res) { case EnhanceResult.Broken: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage)) { return(EnhanceResult.NoResources); } item.Delete(); break; } case EnhanceResult.Success: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref resMessage)) { return(EnhanceResult.NoResources); } if (item is BaseWeapon) { BaseWeapon w = (BaseWeapon)item; w.Resource = resource; //change hue somehow? } else if (item is BaseArmor) //Sanity { ((BaseArmor)item).Resource = resource; } break; } case EnhanceResult.Failure: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage)) { return(EnhanceResult.NoResources); } break; } } return(res); }
public static EnhanceResult Invoke(Mobile from, CraftSystem craftSystem, BaseTool tool, Item item, CraftResource resource, Type resType, ref object resMessage) { if (item == null) { return(EnhanceResult.BadItem); } if (!item.IsChildOf(from.Backpack)) { return(EnhanceResult.NotInBackpack); } if (!(item is BaseArmor) && !(item is BaseWeapon)) { return(EnhanceResult.BadItem); } if (CraftResources.IsStandard(resource)) { return(EnhanceResult.BadResource); } CraftItem craftItem; if (m_CheckForSubclass.Contains(item.GetType())) { craftItem = craftSystem.CraftItems.SearchForSubclass(item.GetType()); } else { craftItem = craftSystem.CraftItems.SearchFor(item.GetType()); } if (craftItem == null || craftItem.Ressources.Count == 0 || craftItem.ForceCannotEnhance) { return(EnhanceResult.BadItem); } if (CraftableArtifacts.IsCraftableArtifact(item)) { return(EnhanceResult.BadItem); } bool exceptional = false; bool allRequiredSkills = false; if (!craftItem.CheckSkills(from, resType, craftSystem, ref exceptional, ref allRequiredSkills, false)) { return(EnhanceResult.NoSkill); } CraftResourceInfo info = CraftResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) { return(EnhanceResult.BadResource); } CraftAttributeInfo attributes = info.AttributeInfo; if (attributes == null) { return(EnhanceResult.BadResource); } int resHue = 0, maxAmount = 0; if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref resMessage)) { return(EnhanceResult.NoResources); } AncientSmithyHammer hammer = from.FindItemOnLayer(Layer.OneHanded) as AncientSmithyHammer; if (hammer != null) { if (!(tool != null && (tool is SewingKit || tool is RunicSewingKit))) { hammer.UsesRemaining--; if (hammer.UsesRemaining < 1) { hammer.Delete(); } } } int phys = 0, fire = 0, cold = 0, pois = 0, nrgy = 0; int dura = 0, luck = 0, lreq = 0, dinc = 0; int baseChance = 0; bool physBonus = false; bool fireBonus = false; bool coldBonus = false; bool nrgyBonus = false; bool poisBonus = false; bool duraBonus = false; bool luckBonus = false; bool lreqBonus = false; bool dincBonus = false; if (item is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)item; if (!CraftResources.IsStandard(weapon.Resource)) { return(EnhanceResult.AlreadyEnhanced); } baseChance = 20; dura = weapon.MaxHitPoints; luck = weapon.Attributes.Luck; lreq = weapon.WeaponAttributes.LowerStatReq; dinc = weapon.Attributes.WeaponDamage; fireBonus = (attributes.WeaponFireDamage > 0); coldBonus = (attributes.WeaponColdDamage > 0); nrgyBonus = (attributes.WeaponEnergyDamage > 0); poisBonus = (attributes.WeaponPoisonDamage > 0); duraBonus = (attributes.WeaponDurability > 0); luckBonus = (attributes.WeaponLuck > 0); lreqBonus = (attributes.WeaponLowerRequirements > 0); dincBonus = (dinc > 0); } else { BaseArmor armor = (BaseArmor)item; if (!CraftResources.IsStandard(armor.Resource)) { return(EnhanceResult.AlreadyEnhanced); } baseChance = 20; phys = armor.PhysicalResistance; fire = armor.FireResistance; cold = armor.ColdResistance; pois = armor.PoisonResistance; nrgy = armor.EnergyResistance; dura = armor.MaxHitPoints; luck = armor.Attributes.Luck; lreq = armor.ArmorAttributes.LowerStatReq; physBonus = (attributes.ArmorPhysicalResist > 0); fireBonus = (attributes.ArmorFireResist > 0); coldBonus = (attributes.ArmorColdResist > 0); nrgyBonus = (attributes.ArmorEnergyResist > 0); poisBonus = (attributes.ArmorPoisonResist > 0); duraBonus = (attributes.ArmorDurability > 0); luckBonus = (attributes.ArmorLuck > 0); lreqBonus = (attributes.ArmorLowerRequirements > 0); dincBonus = false; } int skill = from.Skills[craftSystem.MainSkill].Fixed / 10; if (skill >= 100) { baseChance -= (skill - 90) / 10; } EnhanceResult res = EnhanceResult.Success; PlayerMobile user = from as PlayerMobile; if (physBonus) { CheckResult(ref res, baseChance + phys); } if (fireBonus) { CheckResult(ref res, baseChance + fire); } if (coldBonus) { CheckResult(ref res, baseChance + cold); } if (nrgyBonus) { CheckResult(ref res, baseChance + nrgy); } if (poisBonus) { CheckResult(ref res, baseChance + pois); } if (duraBonus) { CheckResult(ref res, baseChance + (dura / 40)); } if (luckBonus) { CheckResult(ref res, baseChance + 10 + (luck / 2)); } if (lreqBonus) { CheckResult(ref res, baseChance + (lreq / 4)); } if (dincBonus) { CheckResult(ref res, baseChance + (dinc / 4)); } if (user.NextEnhanceSuccess) { user.NextEnhanceSuccess = false; user.SendLocalizedMessage(1149969); // The magical aura that surrounded you disipates and you feel that your item enhancement chances have returned to normal. res = EnhanceResult.Success; } switch (res) { case EnhanceResult.Broken: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage)) { return(EnhanceResult.NoResources); } item.Delete(); break; } case EnhanceResult.Success: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref resMessage)) { return(EnhanceResult.NoResources); } if (item is BaseWeapon) { BaseWeapon w = (BaseWeapon)item; w.Resource = resource; int hue = w.GetElementalDamageHue(); if (hue > 0) { w.Hue = hue; } } else if (item is BaseArmor) { ((BaseArmor)item).Resource = resource; } break; } case EnhanceResult.Failure: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage)) { return(EnhanceResult.NoResources); } break; } } return(res); }
public static EnhanceResult Invoke(Mobile from, CraftSystem craftSystem, BaseTool tool, Item item, CraftResource resource, Type resType, ref object resMessage) { if (item == null) { return(EnhanceResult.BadItem); } if (!item.IsChildOf(from.Backpack)) { return(EnhanceResult.NotInBackpack); } if (!(item is BaseArmor) && !(item is BaseWeapon)) { return(EnhanceResult.BadItem); } if (CraftResources.IsStandard(resource)) { return(EnhanceResult.BadResource); } int num = craftSystem.CanCraft(from, tool, item.GetType()); if (num > 0) { resMessage = num; return(EnhanceResult.None); } CraftItem craftItem = craftSystem.CraftItems.SearchFor(item.GetType()); if (craftItem == null || craftItem.Resources.Count == 0) { return(EnhanceResult.BadItem); } bool allRequiredSkills = false; if (craftItem.GetSuccessChance(from, resType, craftSystem, false, ref allRequiredSkills) <= 0.0) { return(EnhanceResult.NoSkill); } CraftResourceInfo info = CraftResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) { return(EnhanceResult.BadResource); } CraftAttributeInfo attributes = info.AttributeInfo; if (attributes == null) { return(EnhanceResult.BadResource); } int resHue = 0, maxAmount = 0; if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref resMessage)) { return(EnhanceResult.NoResources); } if (craftSystem is DefBlacksmithy) { AncientSmithyHammer hammer = from.FindItemOnLayer(Layer.OneHanded) as AncientSmithyHammer; if (hammer != null) { hammer.UsesRemaining--; if (hammer.UsesRemaining < 1) { hammer.Delete(); } } } int phys = 0, fire = 0, cold = 0, pois = 0, nrgy = 0; int dura = 0, dinc = 0; int baseChance = 0; bool physBonus = false; bool fireBonus = false; bool coldBonus = false; bool nrgyBonus = false; bool poisBonus = false; bool duraBonus = false; bool dincBonus = false; double arms = from.Skills[SkillName.ArmsLore].Base; if (item is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)item; if (!CraftResources.IsStandard(weapon.Resource)) { return(EnhanceResult.AlreadyEnhanced); } if (arms >= 100.1) { baseChance = Utility.RandomMinMax(2, 5); } else if (arms >= 80.1 && arms <= 100) { baseChance = Utility.RandomMinMax(8, 14); } else if (arms >= 50 && arms <= 80) { baseChance = Utility.RandomMinMax(16, 20); } else { baseChance = 25; } } else { BaseArmor armor = (BaseArmor)item; if (!CraftResources.IsStandard(armor.Resource)) { return(EnhanceResult.AlreadyEnhanced); } if (arms >= 100.1) { baseChance = Utility.RandomMinMax(2, 5); } else if (arms >= 80.1 && arms <= 100) { baseChance = Utility.RandomMinMax(8, 14); } else if (arms >= 50 && arms <= 80) { baseChance = Utility.RandomMinMax(16, 20); } else { baseChance = 25; } phys = armor.PhysicalResistance; fire = armor.FireResistance; cold = armor.ColdResistance; pois = armor.PoisonResistance; nrgy = armor.EnergyResistance; dura = armor.MaxHitPoints; physBonus = (attributes.ArmorPhysicalResist > 4); fireBonus = (attributes.ArmorFireResist > 5); coldBonus = (attributes.ArmorColdResist > 7); nrgyBonus = (attributes.ArmorEnergyResist > 2); poisBonus = (attributes.ArmorPoisonResist > 1); duraBonus = (attributes.ArmorDurability > 0); dincBonus = true; } /*int skill = from.Skills[craftSystem.MainSkill].Fixed / 10; * * if ( skill >= 100 ) * baseChance -= (skill - 90) / 10;*/ EnhanceResult res = EnhanceResult.Success; if (physBonus) { CheckResult(ref res, baseChance + phys); } if (fireBonus) { CheckResult(ref res, baseChance + fire); } if (coldBonus) { CheckResult(ref res, baseChance + cold); } if (nrgyBonus) { CheckResult(ref res, baseChance + nrgy); } if (poisBonus) { CheckResult(ref res, baseChance + pois); } if (duraBonus) { CheckResult(ref res, baseChance + (dura / 20)); } if (dincBonus) { CheckResult(ref res, baseChance + (dinc / 5)); } switch (res) { case EnhanceResult.Broken: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage)) { return(EnhanceResult.NoResources); } item.Delete(); break; } case EnhanceResult.Success: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref resMessage)) { return(EnhanceResult.NoResources); } if (item is BaseWeapon) { ((BaseWeapon)item).Resource = resource; } else { ((BaseArmor)item).Resource = resource; } break; } case EnhanceResult.Failure: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage)) { return(EnhanceResult.NoResources); } break; } } return(res); }
public static EnhanceResult Invoke(Mobile from, CraftSystem craftSystem, BaseTool tool, Item item, CraftResource resource, Type resType, ref object resMessage) { if (item == null) { return(EnhanceResult.BadItem); } if (!item.IsChildOf(from.Backpack)) { return(EnhanceResult.NotInBackpack); } if (!(item is BaseArmor) && !(item is BaseWeapon)) { return(EnhanceResult.BadItem); } if (CraftResources.IsStandard(resource)) { return(EnhanceResult.BadResource); } int num = craftSystem.CanCraft(from, tool, item.GetType()); if (num > 0) { resMessage = num; return(EnhanceResult.None); } CraftItem craftItem = craftSystem.CraftItems.SearchFor(item.GetType()); if (craftItem == null || craftItem.Resources.Count == 0) { return(EnhanceResult.BadItem); } bool allRequiredSkills = false; if (craftItem.GetSuccessChance(from, resType, craftSystem, false, ref allRequiredSkills) <= 0.0) { return(EnhanceResult.NoSkill); } CraftResourceInfo info = CraftResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) { return(EnhanceResult.BadResource); } CraftAttributeInfo attributes = info.AttributeInfo; if (attributes == null) { return(EnhanceResult.BadResource); } int resHue = 0, maxAmount = 0; if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref resMessage)) { return(EnhanceResult.NoResources); } int phys = 0, fire = 0, cold = 0, pois = 0, nrgy = 0; int dura = 0, luck = 0, lreq = 0, dinc = 0; int baseChance = 0; bool physBonus = false; bool fireBonus = false; bool coldBonus = false; bool nrgyBonus = false; bool poisBonus = false; bool duraBonus = false; bool luckBonus = false; bool lreqBonus = false; bool dincBonus = false; if (item is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)item; if (!CraftResources.IsStandard(weapon.Resource)) { return(EnhanceResult.AlreadyEnhanced); } baseChance = 20; dura = weapon.MaxHitPoints; duraBonus = attributes.WeaponDurability > 0; lreqBonus = attributes.WeaponLowerRequirements > 0; dincBonus = dinc > 0; } else { BaseArmor armor = (BaseArmor)item; if (!CraftResources.IsStandard(armor.Resource)) { return(EnhanceResult.AlreadyEnhanced); } baseChance = 20; dura = armor.MaxHitPoints; duraBonus = attributes.ArmorDurability > 0; lreqBonus = attributes.ArmorLowerRequirements > 0; dincBonus = false; } int skill = from.Skills[craftSystem.MainSkill].Fixed / 10; if (skill >= 100) { baseChance -= (skill - 90) / 10; } EnhanceResult res = EnhanceResult.Success; if (physBonus) { CheckResult(ref res, baseChance + phys); } if (fireBonus) { CheckResult(ref res, baseChance + fire); } if (coldBonus) { CheckResult(ref res, baseChance + cold); } if (nrgyBonus) { CheckResult(ref res, baseChance + nrgy); } if (poisBonus) { CheckResult(ref res, baseChance + pois); } if (duraBonus) { CheckResult(ref res, baseChance + dura / 40); } if (luckBonus) { CheckResult(ref res, baseChance + 10 + luck / 2); } if (lreqBonus) { CheckResult(ref res, baseChance + lreq / 4); } if (dincBonus) { CheckResult(ref res, baseChance + dinc / 4); } switch (res) { case EnhanceResult.Broken: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage)) { return(EnhanceResult.NoResources); } item.Delete(); break; } case EnhanceResult.Success: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref resMessage)) { return(EnhanceResult.NoResources); } if (item is BaseArmor) //Sanity { ((BaseArmor)item).Resource = resource; } break; } case EnhanceResult.Failure: { if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, ref resMessage)) { return(EnhanceResult.NoResources); } break; } } return(res); }