GetSuccessChance() public method

public GetSuccessChance ( Server.Mobile from, CraftSystem craftSystem, bool gainSkills, bool &allRequiredSkills ) : double
from Server.Mobile
craftSystem CraftSystem
gainSkills bool
allRequiredSkills bool
return double
Ejemplo n.º 1
0
        public void DrawSkill()
        {
            for (int i = 0; i < m_CraftItem.Skills.Count; i++)
            {
                CraftSkill skill = m_CraftItem.Skills.GetAt(i);
                double     minSkill = skill.MinSkill, maxSkill = skill.MaxSkill;

                if (minSkill < 0)
                {
                    minSkill = 0;
                }

                AddHtmlLocalized(170, 132 + (i * 20), 200, 18, 1044060 + (int)skill.SkillToMake, LabelColor, false, false);
                AddLabel(430, 132 + (i * 20), LabelHue, String.Format("{0:F1}", minSkill));
            }

            CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
            int            resIndex = -1;

            CraftContext context = m_CraftSystem.GetContext(m_From);

            if (context != null)
            {
                resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
            }

            bool   allRequiredSkills = true;
            double chance            = m_CraftItem.GetSuccessChance(m_From, resIndex > -1 ? res.GetAt(resIndex).ItemType : null, m_CraftSystem, false, ref allRequiredSkills);

            double excepChance = m_CraftItem.GetExceptionalChance(m_CraftSystem, chance, m_From);

            if (chance < 0.0)
            {
                chance = 0.0;
            }
            else if (chance > 1.0)
            {
                chance = 1.0;
            }

            if (excepChance < 0.0)
            {
                excepChance = 0.0;
            }
            else if (excepChance > 1.0)
            {
                excepChance = 1.0;
            }

            AddHtmlLocalized(170, 80, 250, 18, 1044057, LabelColor, false, false);               // Success Chance:
            AddLabel(430, 80, LabelHue, String.Format("{0:F1}%", chance * 100));

            if (m_ShowExceptionalChance)
            {
                AddHtmlLocalized(170, 100, 250, 18, 1044058, 32767, false, false);                   // Exceptional Chance:
                AddLabel(430, 100, LabelHue, String.Format("{0:F1}%", excepChance * 100));
            }
        }
Ejemplo n.º 2
0
        public void DrawChances()
        {
            CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
            int            resIndex = -1;

            CraftContext context = m_CraftSystem.GetContext(m_From);

            if (context != null)
            {
                resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
            }

            bool   allRequiredSkills = true;
            double chance            = m_CraftItem.GetSuccessChance(m_From, resIndex > -1 ? res.GetAt(resIndex).ItemType : null, m_CraftSystem, false, ref allRequiredSkills);
            double excepChance       = m_CraftItem.GetExceptionalChance(m_CraftSystem, chance, m_From);

            if (chance > 0.0)
            {
                chance += m_CraftItem.GetTalismanBonus(m_From, m_CraftSystem);
            }

            if (chance < 0.0)
            {
                chance = 0.0;
            }
            else if (chance > 1.0)
            {
                chance = 1.0;
            }

            if (excepChance < 0.0)
            {
                excepChance = 0.0;
            }
            else if (excepChance > 1.0)
            {
                excepChance = 1.0;
            }

            AddHtmlLocalized(170, 80, 250, 18, 1044057, LabelColor, false, false);               // Success Chance:
            AddLabel(430, 80, LabelHue, String.Format("{0:F1}%", chance * 100).Replace(",", "."));

            if (m_ShowExceptionalChance)
            {
                AddHtmlLocalized(170, 100, 250, 18, 1044058, 32767, false, false);                   // Exceptional Chance:
                AddLabel(430, 100, LabelHue, String.Format("{0:F1}%", excepChance * 100).Replace(",", "."));
            }
        }
Ejemplo n.º 3
0
        public void DrawSkill()
        {
            for (int i = 0; i < CraftItem.Skills.Count; i++)
            {
                var    skill = CraftItem.Skills[i];
                double minSkill = skill.MinSkill, maxSkill = skill.MaxSkill;

                if (minSkill < 0)
                {
                    minSkill = 0;
                }

                AddHtmlLocalized(170, 132 + i * 20, 200, 18, 1044060 + (int)skill.SkillToMake, LabelColor, false,
                                 false);
                AddLabel(430, 132 + i * 20, LabelHue, $"{minSkill:F1}");
            }

            var res      = CraftItem.UseSubRes2 ? CraftSystem.CraftSubRes2 : CraftSystem.CraftSubRes;
            var resIndex = -1;

            var context = CraftSystem.GetContext(From);

            if (context != null)
            {
                resIndex = CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex;
            }

            var allRequiredSkills = true;
            var chance            = CraftItem.GetSuccessChance(From, resIndex > -1 ? res.GetAt(resIndex).ItemType : null,
                                                               CraftSystem, false, ref allRequiredSkills);
            var craftSkillRequired = CraftItem.GetCraftSkillRequired(From,
                                                                     resIndex > -1 ? res.GetAt(resIndex).ItemType : null, CraftSystem);
            var excepChance = CraftItem.GetExceptionalChance(From, CraftSystem, ref craftSkillRequired);

            AddHtmlLocalized(170, 80, 250, 18, 1044057, LabelColor, false, false); // Success Chance:
            AddLabel(430, 80, LabelHue, $"{chance * 100:F1}%");

            if (m_ShowExceptionalChance)
            {
                AddHtmlLocalized(170, 100, 250, 18, 1044058, 32767, false, false); // Exceptional Chance:
                AddLabel(430, 100, LabelHue, $"{excepChance:F1}%");
            }
        }
Ejemplo n.º 4
0
        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.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, 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;

                    int hue = w.GetElementalDamageHue();
                    if (hue > 0)
                    {
                        w.Hue = hue;
                    }
                }
                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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        public void DrawSkill()
        {
            for (int i = 0; i < m_CraftItem.Skills.Count; i++)
            {
                CraftSkill skill = m_CraftItem.Skills.GetAt(i);
                double     minSkill = skill.MinSkill, maxSkill = skill.MaxSkill;

                if (minSkill < 0)
                {
                    minSkill = 0;
                }

                AddHtmlLocalized(170, 155 + (i * 20), 200, 18, AosSkillBonuses.GetLabel(skill.SkillToMake), LabelColor, false, false);
                AddLabel(430, 155 + (i * 20), LabelHue, String.Format("{0:F1}", minSkill));
            }

            CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
            int            resIndex = -1;

            CraftContext context = m_CraftSystem.GetContext(m_From);

            if (context != null)
            {
                resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
            }

            bool allRequiredSkills = true;

            double successChance     = m_CraftItem.GetSuccessChance(m_From, resIndex > -1 ? res.GetAt(resIndex).ItemType : null, m_CraftSystem, false, ref allRequiredSkills);
            double exceptionalChance = m_CraftItem.GetExceptionalChance(m_CraftSystem, successChance, m_From);

            bool skillGainPossible = false;

            if (successChance < 0.0)
            {
                successChance = 0.0;
            }

            else if (successChance > 1.0)
            {
                successChance = 1.0;
            }

            if (exceptionalChance < 0.0)
            {
                exceptionalChance = 0.0;
            }

            else if (exceptionalChance > 1.0)
            {
                exceptionalChance = 1.0;
            }

            if (successChance > 0 && successChance < 1.0)
            {
                skillGainPossible = true;
            }

            int startY = 80;

            AddHtmlLocalized(170, startY, 250, 18, 1044057, LabelColor, false, false); // Success Chance:
            AddLabel(430, startY, LabelHue, String.Format("{0:F1}%", successChance * 100));

            startY += 20;

            if (m_ShowExceptionalChance)
            {
                if (exceptionalChance < 0.0)
                {
                    exceptionalChance = 0.0;
                }

                else if (exceptionalChance > 1.0)
                {
                    exceptionalChance = 1.0;
                }

                AddHtmlLocalized(170, startY, 250, 18, 1044058, 32767, false, false); // Exceptional Chance:
                AddLabel(430, startY, LabelHue, String.Format("{0:F1}%", exceptionalChance * 100));

                startY += 20;
            }

            if (skillGainPossible)
            {
                AddLabel(169, startY, 2599, "Skill Gain Possible");
            }
        }
Ejemplo n.º 9
0
		public virtual int OnCraft(
			int quality,
			bool makersMark,
			Mobile from,
			CraftSystem craftSystem,
			Type typeRes,
			IBaseTool tool,
			CraftItem craftItem,
			int resHue)
		{
			int magery = from.Skills.Magery.BaseFixedPoint;

			if (makersMark)
			{
				Crafter = from;
			}

			m_Quality = (BookQuality)(quality - 1);

			if (craftItem.Recipe != null && craftItem.Recipe.ID == 1001) //Full spellbook
			{
				Content = ulong.MaxValue;

				bool allRequiredSkills = true;
				double chance = craftItem.GetSuccessChance(from, typeRes, craftSystem, false, ref allRequiredSkills);
				double excepChance = craftItem.GetExceptionalChance(craftSystem, chance, from);

				double blessChance = excepChance / 3.0;
				if (blessChance < 0.025 && from.Skills[SkillName.Inscribe].Value >= 100.0)
				{
					blessChance = 0.025;
				}

				if (Crafter != null && m_Quality == BookQuality.Exceptional && blessChance > Utility.RandomDouble())
				{
					LootType = LootType.Blessed;
				}
			}

			return quality;
		}
Ejemplo n.º 10
0
        public void DrawSkill()
        {
            for (int i = 0; i < m_CraftItem.Skills.Count; i++)
            {
                CraftSkill skill = m_CraftItem.Skills.GetAt(i);
                double     minSkill = skill.MinSkill, maxSkill = skill.MaxSkill;

                if (minSkill < 0)
                {
                    minSkill = 0;
                }

                string textminSkills = "Débutant";

                if (minSkill >= 30 && minSkill < 40)
                {
                    textminSkills = "Néophite";
                }
                else if (minSkill >= 40 && minSkill < 50)
                {
                    textminSkills = "Novice";
                }
                else if (minSkill >= 50 && minSkill < 60)
                {
                    textminSkills = "Apprenti";
                }
                else if (minSkill >= 60 && minSkill < 70)
                {
                    textminSkills = "Compagnon";
                }
                else if (minSkill >= 70 && minSkill < 80)
                {
                    textminSkills = "Expert";
                }
                else if (minSkill >= 80 && minSkill < 90)
                {
                    textminSkills = "Adepte";
                }
                else if (minSkill >= 90 && minSkill < 100)
                {
                    textminSkills = "Maître";
                }
                else if (minSkill >= 100 && minSkill < 110)
                {
                    textminSkills = "Grand Maître";
                }

                AddHtmlLocalized(170, 132 + (i * 20), 200, 18, AosSkillBonuses.GetLabel(skill.SkillToMake), LabelColor, false, false);

                if (m_From.AccessLevel >= AccessLevel.GameMaster)
                {
                    AddLabel(430, 132 + (i * 20), LabelHue, String.Format("{0:F1}", minSkill));
                }
                else
                {
                    AddLabel(430, 132 + (i * 20), LabelHue, String.Format("{0}", textminSkills));
                }
            }

            CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
            int            resIndex = -1;

            CraftContext context = m_CraftSystem.GetContext(m_From);

            if (context != null)
            {
                resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
            }

            bool   allRequiredSkills = true;
            double chance            = m_CraftItem.GetSuccessChance(m_From, resIndex > -1 ? res.GetAt(resIndex).ItemType : null, m_CraftSystem, false, ref allRequiredSkills);
            double excepChance       = m_CraftItem.GetExceptionalChance(m_CraftSystem, chance, m_From);

            m_Chance = chance;  // Scriptiz : on stocke la chance

            if (chance < 0.0)
            {
                chance = 0.0;
            }
            else if (chance > 1.0)
            {
                chance = 1.0;
            }

            string textchance = "Nulle";

            if (chance > 0 && chance <= 0.2)
            {
                textchance = "Faible";
            }
            else if (chance > 0.2 && chance <= 0.4)
            {
                textchance = "Possible";
            }
            else if (chance > 0.4 && chance <= 0.6)
            {
                textchance = "Moyenne";
            }
            else if (chance > 0.6 && chance <= 0.8)
            {
                textchance = "Favorable";
            }
            else if (chance > 0.8 && chance < 1)
            {
                textchance = "Grande";
            }
            else if (chance == 1)
            {
                textchance = "Aisée";
            }

            AddHtmlLocalized(170, 80, 250, 18, 1044057, LabelColor, false, false);

            if (m_From.AccessLevel >= AccessLevel.GameMaster)
            {
                AddLabel(430, 80, LabelHue, String.Format("{0:F1}%", chance * 100));
            }
            else
            {
                AddLabel(430, 80, LabelHue, String.Format("{0}", textchance));
            }

            if (m_ShowExceptionalChance)
            {
                if (excepChance < 0.0)
                {
                    excepChance = 0.0;
                }
                else if (excepChance > 1.0)
                {
                    excepChance = 1.0;
                }
                if (m_From.AccessLevel >= AccessLevel.GameMaster)
                {
                    AddHtmlLocalized(170, 100, 250, 18, 1044058, 32767, false, false);   // Exceptional Chance:
                    AddLabel(430, 100, LabelHue, String.Format("{0:F1}%", excepChance * 100));
                }
            }
        }
Ejemplo n.º 11
0
        public static void DoCraft( Mobile from, CraftSystem system, Type typeRes, BaseTool tool, CraftItem craftItem, PlantPigment pigments )
        {
            CraftContext context = system.GetContext( from );

            if ( context != null )
                context.OnMade( craftItem );

            bool allRequiredSkills = true;

            double chance = craftItem.GetSuccessChance( from, typeRes, system, true, ref allRequiredSkills );

            if ( chance > 0.0 )
                chance += craftItem.GetTalismanBonus( from, system );

            if ( allRequiredSkills )
            {
                pigments.Consume();

                if ( chance < Utility.RandomDouble() )
                {
                    from.SendGump( new CraftGump( from, system, tool, 1044043 ) ); // You failed to create the item, and some of your materials are lost.
                }
                else
                {
                    from.Backpack.ConsumeTotal( typeof( ColorFixative ), 1 );

                    bool toolBroken = false;

                    tool.UsesRemaining--;

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

                    if ( toolBroken )
                    {
                        tool.Delete();

                        from.SendLocalizedMessage( 1044038 ); // You have worn out your tool!
                        from.SendLocalizedMessage( 1044154 ); // You create the item.
                    }
                    else
                    {
                        // You create the item.
                        from.SendGump( new CraftGump( from, system, tool, 1044154 ) );
                    }

                    from.AddToBackpack( new NaturalDye( pigments.PlantHue ) );
                }
            }
            else
            {
                // You don't have the required skills to attempt this item.
                from.SendGump( new CraftGump( from, system, tool, 1044153 ) );
            }
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
        public void DrawSkill()
        {
            CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
            int            resIndex = -1;

            for (int i = 0; i < m_CraftItem.Skills.Count; i++)
            {
                CraftSkill skill    = m_CraftItem.Skills.GetAt(i);
                double     minSkill = m_CraftItem.ScaleWithRessource(skill.MinSkill, m_From, m_CraftSystem);

                if (minSkill < 0)
                {
                    minSkill = 0;
                }

                AddHtml(170, 132 + (i * 20), 300, 20, "<h3><basefont color=#FFFFFF>" + skill.SkillToMake.ToString() + "<basefont></h3>", false, false);
                AddHtml(480, 132 + (i * 20), 300, 20, "<h3><basefont color=#FFFFFF>" + Convert.ToInt32(minSkill) + "%<basefont></h3>", false, false);
            }

            CraftContext context = m_CraftSystem.GetContext(m_From);

            if (context != null)
            {
                resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
            }

            bool   allRequiredSkills = true;
            double chance            = m_CraftItem.GetSuccessChance(m_From, resIndex > -1 ? res.GetAt(resIndex).ItemType : null, m_CraftSystem, false, ref allRequiredSkills);
            double excepChance       = m_CraftItem.GetExceptionalChance(chance, m_From, false);

            if (chance < 0.0)
            {
                chance = 0.0;
            }
            else if (chance > 1.0)
            {
                chance = 1.0;
            }
            try
            {
                int chan = Convert.ToInt32(chance * 100);

                AddHtml(170, 80, 300, 20, "<h3><basefont color=#FFFFFF>Chance de Succès :<basefont></h3>", false, false);
                AddHtml(480, 80, 300, 20, "<h3><basefont color=#FFFFFF>" + chan.ToString() + "%<basefont></h3>", false, false);
            }
            catch (OverflowException e)
            {
                Misc.ExceptionLogging.WriteLine(e, "La valeur convertie en int était {0} * 100. L'item était {1}",
                                                chance, m_CraftItem.ItemType.ToString());
            }

            if (excepChance < 0.0)
            {
                excepChance = 0.0;
            }
            else if (excepChance > 1.0)
            {
                excepChance = 1.0;
            }
            try
            {
                int exept = Convert.ToInt32(excepChance * 100);

                AddHtml(170, 100, 300, 20, "<h3><basefont color=#FFFFFF>Chance d'Objet Exceptionel:<basefont></h3>", false, false);
                AddHtml(480, 100, 300, 20, "<h3><basefont color=#FFFFFF>" + exept.ToString() + "%<basefont></h3>", false, false);
            }
            catch (OverflowException e)
            {
                Misc.ExceptionLogging.WriteLine(e, "La valeur convertie en int était {0} * 100. The original chance value was : {1}. L'item était {2}",
                                                excepChance, chance, m_CraftItem.ItemType.ToString());
            }
        }