Пример #1
0
            public override void Confirm(Mobile from)
            {
                if (From == null)
                {
                    return;
                }

                if (!CanConvertArmor(Armor))
                {
                    from.SendLocalizedMessage(1154119); // This action would exceed a stat cap
                    return;
                }

                if (From.Account == null || !From.Account.WithdrawGold(250000))
                {
                    From.SendLocalizedMessage(1019022); // You do not have enough gold.
                    return;
                }

                if (!Armor.IsChildOf(From.Backpack))
                {
                    return;
                }

                if (Armor.ArmorAttributes.MageArmor > 0)
                {
                    Armor.ArmorAttributes.MageArmor = 0;
                }
                else
                {
                    Armor.ArmorAttributes.MageArmor = 1;
                }
                Armor.InvalidateProperties();

                From.SendLocalizedMessage(1154118); // Your armor has been converted.
            }
Пример #2
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (m_CraftSystem.CanCraft(from, m_Tool, targeted.GetType()) == 1044267)
                {
                    number = 1044282;                     // You must be near a forge and and anvil to repair items. * Yes, there are two and's *
                }
                else if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon   = (BaseWeapon)targeted;
                    SkillName  skill    = m_CraftSystem.MainSkill;
                    int        toWeaken = 0;

                    if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon))
                    {
                        number = 1061136;                     // That item cannot be repaired.
                    }
                    else if (!weapon.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (weapon.PoisonCharges != 0)
                    {
                        number = 1005012;                         // You cannot repair an item while a caustic substance is on it.
                    }
                    else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (weapon.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            weapon.MaxHitPoints -= toWeaken;
                            weapon.HitPoints     = Math.Max(0, weapon.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            weapon.HitPoints = weapon.MaxHitPoints;
                        }
                        else
                        {
                            number = 1061137;                         // You fail to repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                        }
                    }
                }
                else if (targeted is BaseArmor)
                {
                    BaseArmor armor    = (BaseArmor)targeted;
                    SkillName skill    = m_CraftSystem.MainSkill;
                    int       toWeaken = 0;

                    if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null)
                    {
                        number = 1061136;                     // That item cannot be repaired.
                    }
                    else if (!armor.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (armor.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            armor.MaxHitPoints -= toWeaken;
                            armor.HitPoints     = Math.Max(0, armor.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            armor.HitPoints = armor.MaxHitPoints;
                        }
                        else
                        {
                            number = 1061137;                             // You fail to repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                        }
                    }
                }
                else if (targeted is BaseClothing)
                {
                    BaseClothing clothing = (BaseClothing)targeted;
                    SkillName    skill    = m_CraftSystem.MainSkill;
                    int          toWeaken = 0;

                    if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !IsSpecialClothing(clothing) && !((targeted is TribalMask) || (targeted is HornedTribalMask)))
                    {
                        number = 1061136;                         // That item cannot be repaired.
                    }
                    else if (!clothing.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (clothing.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            clothing.MaxHitPoints -= toWeaken;
                            clothing.HitPoints     = Math.Max(0, clothing.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            clothing.HitPoints = clothing.MaxHitPoints;
                        }
                        else
                        {
                            number = 1061137;                             // You fail to repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                        }
                    }
                }
                else if (targeted is Item)
                {
                    number = 1061136;                     // That item cannot be repaired.
                }
                else
                {
                    number = 500426;                     // You can't repair that.
                }

                from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
            }
Пример #3
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (!this.CheckDeed(from))
                {
                    return;
                }

                bool usingDeed = (this.m_Deed != null);
                bool toDelete  = false;

                // TODO: Make an IRepairable

                if (this.m_CraftSystem.CanCraft(from, this.m_Tool, targeted.GetType()) == 1044267)
                {
                    number = 1044282; // You must be near a forge and and anvil to repair items. * Yes, there are two and's *
                }
                else if (this.m_CraftSystem is DefTinkering && targeted is Golem)
                {
                    Golem g      = (Golem)targeted;
                    int   damage = g.HitsMax - g.Hits;

                    if (g.IsDeadBondedPet)
                    {
                        number = 500426; // You can't repair that.
                    }
                    else if (damage <= 0)
                    {
                        number = 500423; // That is already in full repair.
                    }
                    else
                    {
                        double skillValue = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[SkillName.Tinkering].Value;

                        if (skillValue < 60.0)
                        {
                            number = 1044153; // You don't have the required skills to attempt this item.	//TODO: How does OSI handle this with deeds with golems?
                        }
                        else if (!from.CanBeginAction(typeof(Golem)))
                        {
                            number = 501789; // You must wait before trying again.
                        }
                        else
                        {
                            if (damage > (int)(skillValue * 0.3))
                            {
                                damage = (int)(skillValue * 0.3);
                            }

                            damage += 30;

                            if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0))
                            {
                                damage /= 2;
                            }

                            Container pack = from.Backpack;

                            if (pack != null)
                            {
                                int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5);

                                if (v > 0)
                                {
                                    g.Hits += v * 5;

                                    number   = 1044279; // You repair the item.
                                    toDelete = true;

                                    from.BeginAction(typeof(Golem));
                                    Timer.DelayCall(TimeSpan.FromSeconds(12.0), new TimerStateCallback(EndGolemRepair), from);
                                }
                                else
                                {
                                    number = 1044037; // You do not have sufficient metal to make that.
                                }
                            }
                            else
                            {
                                number = 1044037; // You do not have sufficient metal to make that.
                            }
                        }
                    }
                }
                else if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon   = (BaseWeapon)targeted;
                    SkillName  skill    = this.m_CraftSystem.MainSkill;
                    int        toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (this.m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !this.IsSpecialWeapon(weapon))
                    {
                        number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!weapon.IsChildOf(from.Backpack) && (!Core.ML || weapon.Parent != from))
                    {
                        number = 1044275; // The item must be in your backpack to repair it.
                    }
                    else if (!Core.AOS && weapon.PoisonCharges != 0)
                    {
                        number = 1005012; // You cannot repair an item while a caustic substance is on it.
                    }
                    else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                    {
                        number = 1044281; // That item is in full repair
                    }
                    else if (weapon.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                                                                    // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else if (targeted is DragonsEnd || targeted is KatrinasCrook || targeted is JaanasStaff) // Quick fix
                    {
                        number = 1044277;                                                                    // That item cannot be repaired.
                    }
                    else
                    {
                        if (this.CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            weapon.MaxHitPoints -= toWeaken;
                            weapon.HitPoints     = Math.Max(0, weapon.HitPoints - toWeaken);
                        }

                        if (this.CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            number = 1044279; // You repair the item.
                            this.m_CraftSystem.PlayCraftEffect(from);
                            weapon.HitPoints = weapon.MaxHitPoints;
                            //daat99 OWLTR start - tokens on repairs
                            if (OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.CRAFT_GIVE_TOKENS))
                            {
                                TokenSystem.GiveTokensToPlayer(from as PlayerMobile, Utility.Random(5));
                            }
                            //daat99 OWLTR end - tokens on repairs
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                            this.m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (targeted is BaseArmor)
                {
                    BaseArmor armor    = (BaseArmor)targeted;
                    SkillName skill    = this.m_CraftSystem.MainSkill;
                    int       toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (this.m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null && !this.IsSpecialArmor(armor))
                    {
                        number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!armor.IsChildOf(from.Backpack) && (!Core.ML || armor.Parent != from))
                    {
                        number = 1044275; // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281; // That item is in full repair
                    }
                    else if (armor.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                                                 // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else if (armor is LordBlackthornsExemplar || armor is SentinelsGuard) // quick fix
                    {
                        number = 1044277;                                                 // That item cannot be repaired.
                    }
                    else
                    {
                        if (this.CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            armor.MaxHitPoints -= toWeaken;
                            armor.HitPoints     = Math.Max(0, armor.HitPoints - toWeaken);
                        }

                        if (this.CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            number = 1044279; // You repair the item.
                            this.m_CraftSystem.PlayCraftEffect(from);
                            armor.HitPoints = armor.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                            this.m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (targeted is BaseClothing)
                {
                    BaseClothing clothing = (BaseClothing)targeted;
                    SkillName    skill    = this.m_CraftSystem.MainSkill;
                    int          toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (this.m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !this.IsSpecialClothing(clothing) && !((targeted is TribalMask) || (targeted is HornedTribalMask)))
                    {
                        number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!clothing.IsChildOf(from.Backpack) && (!Core.ML || clothing.Parent != from))
                    {
                        number = 1044275; // The item must be in your backpack to repair it.
                    }
                    else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints)
                    {
                        number = 1044281; // That item is in full repair
                    }
                    else if (clothing.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (this.CheckWeaken(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            clothing.MaxHitPoints -= toWeaken;
                            clothing.HitPoints     = Math.Max(0, clothing.HitPoints - toWeaken);
                        }

                        if (this.CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            number = 1044279; // You repair the item.
                            this.m_CraftSystem.PlayCraftEffect(from);
                            clothing.HitPoints = clothing.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                            this.m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (!usingDeed && targeted is BlankScroll)
                {
                    SkillName skill = this.m_CraftSystem.MainSkill;

                    if (from.Skills[skill].Value >= 50.0)
                    {
                        ((BlankScroll)targeted).Consume(1);
                        RepairDeed deed = new RepairDeed(RepairDeed.GetTypeFor(this.m_CraftSystem), from.Skills[skill].Value, from);
                        from.AddToBackpack(deed);

                        number = 500442; // You create the item and put it in your backpack.
                    }
                    else
                    {
                        number = 1047005; // You must be at least apprentice level to create a repair service contract.
                    }
                }
                else if (targeted is Item)
                {
                    number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                }
                else
                {
                    number = 500426; // You can't repair that.
                }

                if (!usingDeed)
                {
                    CraftContext context = this.m_CraftSystem.GetContext(from);
                    from.SendGump(new CraftGump(from, this.m_CraftSystem, this.m_Tool, number));
                }
                else
                {
                    from.SendLocalizedMessage(number);

                    if (toDelete)
                    {
                        this.m_Deed.Delete();
                    }
                }
            }
Пример #4
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (!CheckDeed(from))
                {
                    return;
                }


                bool usingDeed = (m_Deed != null);
                bool toDelete  = false;

                //TODO: Make a IRepairable

                if (m_CraftSystem is DefTinkering && targeted is Golem)
                {
                    Golem g      = (Golem)targeted;
                    int   damage = g.HitsMax - g.Hits;

                    if (g.IsDeadBondedPet)
                    {
                        number = 500426; // You can't repair that.
                    }
                    else if (damage <= 0)
                    {
                        number = 500423; // That is already in full repair.
                    }
                    else
                    {
                        double skillValue = (usingDeed) ? m_Deed.SkillLevel : from.Skills[SkillName.Tinkering].Value;

                        if (skillValue < 60.0)
                        {
                            number = 1044153; // You don't have the required skills to attempt this item.	//TODO: How does OSI handle this with deeds with golems?
                        }
                        else if (!from.CanBeginAction(typeof(Golem)))
                        {
                            number = 501789; // You must wait before trying again.
                        }
                        else
                        {
                            if (damage > (int)(skillValue * 0.3))
                            {
                                damage = (int)(skillValue * 0.3);
                            }

                            damage += 30;

                            if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0))
                            {
                                damage /= 2;
                            }

                            Container pack = from.Backpack;

                            if (pack != null)
                            {
                                int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5);

                                if (v > 0)
                                {
                                    g.Hits += v * 5;

                                    number   = 1044279; // You repair the item.
                                    toDelete = true;

                                    from.BeginAction(typeof(Golem));
                                    Timer.DelayCall(TimeSpan.FromSeconds(12.0), new TimerStateCallback(EndGolemRepair), from);
                                }
                                else
                                {
                                    number = 1044037; // You do not have sufficient metal to make that.
                                }
                            }
                            else
                            {
                                number = 1044037; // You do not have sufficient metal to make that.
                            }
                        }
                    }
                }
                else if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon   = (BaseWeapon)targeted;
                    SkillName  skill    = m_CraftSystem.MainSkill;
                    int        toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon))
                    {
                        number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!weapon.IsChildOf(from.Backpack))
                    {
                        number = 1044275; // The item must be in your backpack to repair it.
                    }
                    else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                    {
                        number = 1044281; // That item is in full repair
                    }
                    else if (weapon.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            weapon.MaxHitPoints -= toWeaken;
                            weapon.HitPoints     = Math.Max(0, weapon.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            number = 1044279; // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            weapon.HitPoints = weapon.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (targeted is BaseArmor)
                {
                    BaseArmor armor    = (BaseArmor)targeted;
                    SkillName skill    = m_CraftSystem.MainSkill;
                    int       toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null)
                    {
                        number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!armor.IsChildOf(from.Backpack))
                    {
                        number = 1044275; // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281; // That item is in full repair
                    }
                    else if (armor.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            armor.MaxHitPoints -= toWeaken;
                            armor.HitPoints     = Math.Max(0, armor.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            number = 1044279; // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            armor.HitPoints = armor.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (targeted is BaseClothing)
                {
                    BaseClothing clothing = (BaseClothing)targeted;
                    SkillName    skill    = m_CraftSystem.MainSkill;
                    int          toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null)
                    {
                        number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!clothing.IsChildOf(from.Backpack))
                    {
                        number = 1044275; // The item must be in your backpack to repair it.
                    }
                    else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints)
                    {
                        number = 1044281; // That item is in full repair
                    }
                    else if (clothing.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            clothing.MaxHitPoints -= (short)toWeaken;
                            clothing.HitPoints     = (short)Math.Max(0, clothing.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            number = 1044279; // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            clothing.HitPoints = clothing.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }

                /*else if (!usingDeed && targeted is BlankScroll)
                 * {
                 *  SkillName skill = m_CraftSystem.MainSkill;
                 *
                 *  if (from.Skills[skill].Value >= 50.0)
                 *  {
                 *      ((BlankScroll)targeted).Consume(1);
                 *      RepairDeed deed = new RepairDeed(RepairDeed.GetTypeFor(m_CraftSystem), from.Skills[skill].Value, from);
                 *      from.AddToBackpack(deed);
                 *
                 *      number = 500442; // You create the item and put it in your backpack.
                 *  }
                 *  else
                 *      number = 1047005; // You must be at least apprentice level to create a repair service contract.
                 * }*/
                else if (targeted is Item)
                {
                    number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                }
                else
                {
                    number = 500426; // You can't repair that.
                }

                if (!usingDeed)
                {
                    CraftContext context = m_CraftSystem.GetContext(from);
                    from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
                }
                else if (toDelete)
                {
                    m_Deed.Delete();
                }
            }
Пример #5
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (m_CraftSystem is DefTinkering && targeted is Golem)
                {
                    Golem g      = (Golem)targeted;
                    int   damage = g.HitsMax - g.Hits;

                    if (g.IsDeadBondedPet)
                    {
                        number = 500426;                         // You can't repair that.
                    }
                    else if (damage <= 0)
                    {
                        number = 500423;                         // That is already in full repair.
                    }
                    else
                    {
                        double skillValue = from.Skills[SkillName.Tinkering].Value;

                        if (skillValue < 60.0)
                        {
                            number = 1044153;                             // You don't have the required skills to attempt this item.
                        }
                        else if (!from.CanBeginAction(typeof(Golem)))
                        {
                            number = 501789;                             // You must wait before trying again.
                        }
                        else
                        {
                            if (damage > (int)(skillValue * 0.3))
                            {
                                damage = (int)(skillValue * 0.3);
                            }

                            damage += 30;

                            if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0))
                            {
                                damage /= 2;
                            }

                            Container pack = from.Backpack;

                            if (pack != null)
                            {
                                int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5);

                                if (v > 0)
                                {
                                    g.Hits += v * 5;

                                    number = 1044279;                                     // You repair the item.

                                    from.BeginAction(typeof(Golem));
                                    Timer.DelayCall(TimeSpan.FromSeconds(12.0), new TimerStateCallback(EndGolemRepair), from);
                                }
                                else
                                {
                                    number = 1044037;                                     // You do not have sufficient metal to make that.
                                }
                            }
                            else
                            {
                                number = 1044037;                                 // You do not have sufficient metal to make that.
                            }
                        }
                    }
                }
                else if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon   = (BaseWeapon)targeted;
                    SkillName  skill    = m_CraftSystem.MainSkill;
                    int        toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon))
                    {
                        number = 1044277;                         // That item cannot be repaired.
                    }
                    else if (!weapon.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (weapon.MaxHits <= 0 || weapon.Hits == weapon.MaxHits)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (weapon.MaxHits <= toWeaken)
                    {
                        number = 500424;                         // You destroyed the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        weapon.Delete();
                    }
                    else if (from.CheckSkill(skill, -285.0, 100.0))
                    {
                        number = 1044279;                         // You repair the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        weapon.MaxHits -= toWeaken;
                        weapon.Hits     = weapon.MaxHits;
                    }
                    else
                    {
                        number = 1044280;                         // You fail to repair the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        weapon.MaxHits -= toWeaken;

                        if (weapon.Hits - toWeaken < 0)
                        {
                            weapon.Hits = 0;
                        }
                        else
                        {
                            weapon.Hits -= toWeaken;
                        }
                    }

                    if (weapon.MaxHits <= toWeaken)
                    {
                        from.SendLocalizedMessage(1044278);                           // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                }
                else if (targeted is BaseArmor)
                {
                    BaseArmor armor    = (BaseArmor)targeted;
                    SkillName skill    = m_CraftSystem.MainSkill;
                    int       toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null && !IsSpecialArmor(armor))
                    {
                        number = 1044277;                         // That item cannot be repaired.
                    }
                    else if (!armor.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (armor.MaxHitPoints <= toWeaken)
                    {
                        number = 500424;                         // You destroyed the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        armor.Delete();
                    }
                    else if (from.CheckSkill(skill, -285.0, 100.0))
                    {
                        number = 1044279;                         // You repair the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        armor.MaxHitPoints -= toWeaken;
                        armor.HitPoints     = armor.MaxHitPoints;
                    }
                    else
                    {
                        number = 1044280;                         // You fail to repair the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        armor.MaxHitPoints -= toWeaken;

                        if (armor.HitPoints - toWeaken < 0)
                        {
                            armor.HitPoints = 0;
                        }
                        else
                        {
                            armor.HitPoints -= toWeaken;
                        }
                    }

                    if (armor.MaxHitPoints <= toWeaken)
                    {
                        from.SendLocalizedMessage(1044278);                           // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                }
                else if (targeted is Item)
                {
                    SkillName skill = m_CraftSystem.MainSkill;
                    if (targeted is BlankScroll)
                    {
                        if (skill == SkillName.Blacksmith && from.Skills[SkillName.Blacksmith].Value >= 55.0)
                        {
                            BlackSmithRepair r1 = new BlackSmithRepair();
                            r1.SkillLevel = from.Skills[SkillName.Blacksmith].Value;
                            r1.Maker      = from.Name;
                            r1.Uses       = 8;
                            from.AddToBackpack(r1);
                            number = 1044154;
                            BlankScroll i_blank = targeted as BlankScroll;
                            if (i_blank.Amount >= 2)
                            {
                                i_blank.Amount -= 1;
                            }
                            else
                            {
                                i_blank.Delete();
                            }
                        }
                        else if (skill == SkillName.Tailoring && from.Skills[SkillName.Tailoring].Value >= 55.0)
                        {
                            TailorRepair r1 = new TailorRepair();
                            r1.SkillLevel = from.Skills[SkillName.Tailoring].Value;
                            r1.Maker      = from.Name;
                            r1.Uses       = 8;
                            from.AddToBackpack(r1);
                            number = 1044154;
                            BlankScroll i_blank = targeted as BlankScroll;
                            if (i_blank.Amount >= 2)
                            {
                                i_blank.Amount -= 1;
                            }
                            else
                            {
                                i_blank.Delete();
                            }
                        }
                        else
                        {
                            number = 1044277;                     // That item cannot be repaired.
                        }
                    }
                    else
                    {
                        number = 1044277;                 // That item cannot be repaired.
                    }
                }
                else
                {
                    number = 500426;                     // You can't repair that.
                }

                CraftContext context = m_CraftSystem.GetContext(from);

                from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
            }
Пример #6
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                bool usingDeed = (m_Deed != null);
                bool toDelete  = false;
                int  number;

                if (m_CraftSystem is DefTinkering && targeted is IRepairableMobile)
                {
                    if (TryRepairMobile(from, (IRepairableMobile)targeted, usingDeed, out toDelete))
                    {
                        number = 1044279; // You repair the item.
                    }
                    else
                    {
                        number = 500426; // You can't repair that.
                    }
                }
                else if (targeted is Item)
                {
                    if (from.InRange(((Item)targeted).GetWorldLocation(), 2))
                    {
                        if (!CheckDeed(from))
                        {
                            return;
                        }

                        if (!AllowsRepair(targeted, m_CraftSystem))
                        {
                            from.SendLocalizedMessage(500426); // You can't repair that.
                            return;
                        }

                        if (m_CraftSystem.CanCraft(from, m_Tool, targeted.GetType()) == 1044267)
                        {
                            number = 1044282; // You must be near a forge and and anvil to repair items. * Yes, there are two and's *
                        }
                        else if (!usingDeed && m_CraftSystem is DefTinkering && targeted is BrokenAutomatonHead)
                        {
                            if (((BrokenAutomatonHead)targeted).TryRepair(from))
                            {
                                number = 1044279; // You repair the item.
                            }
                            else
                            {
                                number = 1044280; // You fail to repair the item.
                            }
                        }
                        else if (targeted is BaseWeapon)
                        {
                            BaseWeapon weapon   = (BaseWeapon)targeted;
                            SkillName  skill    = m_CraftSystem.MainSkill;
                            int        toWeaken = 0;

                            if (Core.AOS)
                            {
                                toWeaken = 1;
                            }
                            else if (skill != SkillName.Tailoring)
                            {
                                double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base;

                                if (skillLevel >= 90.0)
                                {
                                    toWeaken = 1;
                                }
                                else if (skillLevel >= 70.0)
                                {
                                    toWeaken = 2;
                                }
                                else
                                {
                                    toWeaken = 3;
                                }
                            }

                            if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !CheckSpecial(weapon))
                            {
                                number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                            }
                            else if (!weapon.IsChildOf(from.Backpack) && (!Core.ML || weapon.Parent != from))
                            {
                                number = 1044275; // The item must be in your backpack to repair it.
                            }
                            else if (!Core.AOS && weapon.PoisonCharges != 0)
                            {
                                number = 1005012; // You cannot repair an item while a caustic substance is on it.
                            }
                            else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                            {
                                number = 1044281; // That item is in full repair
                            }
                            else if (weapon.MaxHitPoints <= toWeaken)
                            {
                                number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                            }
                            else if (weapon.BlockRepair || weapon.NegativeAttributes.NoRepair > 0)
                            {
                                number = 1044277; // That item cannot be repaired.
                            }
                            else
                            {
                                if (CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                                {
                                    weapon.MaxHitPoints -= toWeaken;
                                    weapon.HitPoints     = Math.Max(0, weapon.HitPoints - toWeaken);
                                }

                                if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                                {
                                    number = 1044279; // You repair the item.
                                    m_CraftSystem.PlayCraftEffect(from);
                                    weapon.HitPoints = weapon.MaxHitPoints;
                                }
                                else
                                {
                                    number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                                    m_CraftSystem.PlayCraftEffect(from);
                                }

                                toDelete = true;
                            }
                        }
                        else if (targeted is BaseArmor)
                        {
                            BaseArmor armor    = (BaseArmor)targeted;
                            SkillName skill    = m_CraftSystem.MainSkill;
                            int       toWeaken = 0;

                            if (Core.AOS)
                            {
                                toWeaken = 1;
                            }
                            else if (skill != SkillName.Tailoring)
                            {
                                double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base;

                                if (skillLevel >= 90.0)
                                {
                                    toWeaken = 1;
                                }
                                else if (skillLevel >= 70.0)
                                {
                                    toWeaken = 2;
                                }
                                else
                                {
                                    toWeaken = 3;
                                }
                            }

                            if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null && !CheckSpecial(armor))
                            {
                                number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                            }
                            else if (!armor.IsChildOf(from.Backpack) && (!Core.ML || armor.Parent != from))
                            {
                                number = 1044275; // The item must be in your backpack to repair it.
                            }
                            else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                            {
                                number = 1044281; // That item is in full repair
                            }
                            else if (armor.MaxHitPoints <= toWeaken)
                            {
                                number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                            }
                            else if (armor.BlockRepair || armor.NegativeAttributes.NoRepair > 0)
                            {
                                number = 1044277; // That item cannot be repaired.
                            }
                            else
                            {
                                if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints))
                                {
                                    armor.MaxHitPoints -= toWeaken;
                                    armor.HitPoints     = Math.Max(0, armor.HitPoints - toWeaken);
                                }

                                if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
                                {
                                    number = 1044279; // You repair the item.
                                    m_CraftSystem.PlayCraftEffect(from);
                                    armor.HitPoints = armor.MaxHitPoints;
                                }
                                else
                                {
                                    number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                                    m_CraftSystem.PlayCraftEffect(from);
                                }

                                toDelete = true;
                            }
                        }
                        else if (targeted is BaseJewel)
                        {
                            BaseJewel jewel    = (BaseJewel)targeted;
                            SkillName skill    = m_CraftSystem.MainSkill;
                            int       toWeaken = 0;

                            if (Core.AOS)
                            {
                                toWeaken = 1;
                            }
                            else if (skill != SkillName.Tailoring)
                            {
                                double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base;

                                if (skillLevel >= 90.0)
                                {
                                    toWeaken = 1;
                                }
                                else if (skillLevel >= 70.0)
                                {
                                    toWeaken = 2;
                                }
                                else
                                {
                                    toWeaken = 3;
                                }
                            }

                            if (m_CraftSystem.CraftItems.SearchForSubclass(jewel.GetType()) == null && !CheckSpecial(jewel))
                            {
                                number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                            }
                            else if (!jewel.IsChildOf(from.Backpack))
                            {
                                number = 1044275; // The item must be in your backpack to repair it.
                            }
                            else if (jewel.MaxHitPoints <= 0 || jewel.HitPoints == jewel.MaxHitPoints)
                            {
                                number = 1044281; // That item is in full repair
                            }
                            else if (jewel.MaxHitPoints <= toWeaken)
                            {
                                number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                            }
                            else if (jewel.BlockRepair || jewel.NegativeAttributes.NoRepair > 0)
                            {
                                number = 1044277; // That item cannot be repaired.
                            }
                            else
                            {
                                if (CheckWeaken(from, skill, jewel.HitPoints, jewel.MaxHitPoints))
                                {
                                    jewel.MaxHitPoints -= toWeaken;
                                    jewel.HitPoints     = Math.Max(0, jewel.HitPoints - toWeaken);
                                }

                                if (CheckRepairDifficulty(from, skill, jewel.HitPoints, jewel.MaxHitPoints))
                                {
                                    number = 1044279; // You repair the item.
                                    m_CraftSystem.PlayCraftEffect(from);
                                    jewel.HitPoints = jewel.MaxHitPoints;
                                }
                                else
                                {
                                    number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                                    m_CraftSystem.PlayCraftEffect(from);
                                }

                                toDelete = true;
                            }
                        }
                        else if (targeted is BaseClothing)
                        {
                            BaseClothing clothing = (BaseClothing)targeted;
                            SkillName    skill    = m_CraftSystem.MainSkill;
                            int          toWeaken = 0;

                            if (Core.AOS)
                            {
                                toWeaken = 1;
                            }
                            else if (skill != SkillName.Tailoring)
                            {
                                double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base;

                                if (skillLevel >= 90.0)
                                {
                                    toWeaken = 1;
                                }
                                else if (skillLevel >= 70.0)
                                {
                                    toWeaken = 2;
                                }
                                else
                                {
                                    toWeaken = 3;
                                }
                            }

                            if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !CheckSpecial(clothing))
                            {
                                number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                            }
                            else if (!clothing.IsChildOf(from.Backpack) && (!Core.ML || clothing.Parent != from))
                            {
                                number = 1044275; // The item must be in your backpack to repair it.
                            }
                            else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints)
                            {
                                number = 1044281; // That item is in full repair
                            }
                            else if (clothing.MaxHitPoints <= toWeaken)
                            {
                                number = 1044278;                                                      // That item has been repaired many times, and will break if repairs are attempted again.
                            }
                            else if (clothing.BlockRepair || clothing.NegativeAttributes.NoRepair > 0) // quick fix
                            {
                                number = 1044277;                                                      // That item cannot be repaired.
                            }
                            else
                            {
                                if (CheckWeaken(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                                {
                                    clothing.MaxHitPoints -= toWeaken;
                                    clothing.HitPoints     = Math.Max(0, clothing.HitPoints - toWeaken);
                                }

                                if (CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                                {
                                    number = 1044279; // You repair the item.
                                    m_CraftSystem.PlayCraftEffect(from);
                                    clothing.HitPoints = clothing.MaxHitPoints;
                                }
                                else
                                {
                                    number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                                    m_CraftSystem.PlayCraftEffect(from);
                                }

                                toDelete = true;
                            }
                        }
                        else if (targeted is BaseTalisman)
                        {
                            BaseTalisman talisman = (BaseTalisman)targeted;
                            SkillName    skill    = m_CraftSystem.MainSkill;
                            int          toWeaken = 0;

                            if (Core.AOS)
                            {
                                toWeaken = 1;
                            }
                            else if (skill != SkillName.Tailoring)
                            {
                                double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base;

                                if (skillLevel >= 90.0)
                                {
                                    toWeaken = 1;
                                }
                                else if (skillLevel >= 70.0)
                                {
                                    toWeaken = 2;
                                }
                                else
                                {
                                    toWeaken = 3;
                                }
                            }

                            if (!(m_CraftSystem is DefTinkering))
                            {
                                number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                            }
                            else if (!talisman.IsChildOf(from.Backpack) && (!Core.ML || talisman.Parent != from))
                            {
                                number = 1044275; // The item must be in your backpack to repair it.
                            }
                            else if (talisman.MaxHitPoints <= 0 || talisman.HitPoints == talisman.MaxHitPoints)
                            {
                                number = 1044281; // That item is in full repair
                            }
                            else if (talisman.MaxHitPoints <= toWeaken)
                            {
                                number = 1044278;         // That item has been repaired many times, and will break if repairs are attempted again.
                            }
                            else if (!talisman.CanRepair) // quick fix
                            {
                                number = 1044277;         // That item cannot be repaired.
                            }
                            else
                            {
                                if (CheckWeaken(from, skill, talisman.HitPoints, talisman.MaxHitPoints))
                                {
                                    talisman.MaxHitPoints -= toWeaken;
                                    talisman.HitPoints     = Math.Max(0, talisman.HitPoints - toWeaken);
                                }

                                if (CheckRepairDifficulty(from, skill, talisman.HitPoints, talisman.MaxHitPoints))
                                {
                                    number = 1044279; // You repair the item.
                                    m_CraftSystem.PlayCraftEffect(from);
                                    talisman.HitPoints = talisman.MaxHitPoints;
                                }
                                else
                                {
                                    number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                                    m_CraftSystem.PlayCraftEffect(from);
                                }

                                toDelete = true;
                            }
                        }
                        else if (!usingDeed && targeted is BlankScroll)
                        {
                            SkillName skill = m_CraftSystem.MainSkill;

                            if (from.Skills[skill].Value >= 50.0)
                            {
                                ((BlankScroll)targeted).Consume(1);
                                RepairDeed deed = new RepairDeed(RepairDeed.GetTypeFor(m_CraftSystem), from.Skills[skill].Value, from);
                                from.AddToBackpack(deed);

                                number = 500442; // You create the item and put it in your backpack.
                            }
                            else
                            {
                                number = 1047005; // You must be at least apprentice level to create a repair service contract.
                            }
                        }
                        else
                        {
                            number = 500426; // You can't repair that.
                        }
                    }
                    else
                    {
                        number = 500446; // That is too far away.
                    }
                }
                else
                {
                    number = 500426; // You can't repair that.
                }

                if (!usingDeed)
                {
                    CraftContext context = m_CraftSystem.GetContext(from);
                    from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
                }
                else
                {
                    from.SendLocalizedMessage(number);

                    if (toDelete)
                    {
                        m_Deed.Delete();
                    }
                }
            }
Пример #7
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (m_CraftSystem is DefBlacksmithy)
                {
                    bool anvil, forge;
                    DefBlacksmithy.CheckAnvilAndForge(from, 2, out anvil, out forge);

                    if (anvil && forge)
                    {
                        // You must be near a forge and and anvil to repair items.
                        number = 1044282;
                    }
                }

                if (m_CraftSystem is DefTinkering && targeted is Golem)
                {
                    Golem g      = (Golem)targeted;
                    int   damage = g.HitsMax - g.Hits;

                    if (g.IsDeadBondedPet)
                    {
                        number = 500426;                         // You can't repair that.
                    }
                    else if (damage <= 0)
                    {
                        number = 500423;                         // That is already in full repair.
                    }
                    else
                    {
                        double skillValue = from.Skills[SkillName.Tinkering].Value;

                        if (skillValue < 60.0)
                        {
                            number = 1044153;                             // You don't have the required skills to attempt this item.
                        }
                        else if (!from.CanBeginAction(typeof(Golem)))
                        {
                            number = 501789;                             // You must wait before trying again.
                        }
                        else
                        {
                            if (damage > (int)(skillValue * 0.3))
                            {
                                damage = (int)(skillValue * 0.3);
                            }

                            damage += 30;

                            if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0))
                            {
                                damage /= 2;
                            }

                            Container pack = from.Backpack;

                            if (pack != null)
                            {
                                int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5);

                                if (v > 0)
                                {
                                    g.Hits += v * 5;

                                    number = 1044279;                                     // You repair the item.

                                    from.BeginAction(typeof(Golem));
                                    Timer.DelayCall(TimeSpan.FromSeconds(12.0), new TimerStateCallback(EndGolemRepair), from);

                                    if (m_Contract != null)
                                    {
                                        m_Contract.Delete();
                                    }
                                }
                                else
                                {
                                    number = 1044037;                                     // You do not have sufficient metal to make that.
                                }
                            }
                            else
                            {
                                number = 1044037;                                 // You do not have sufficient metal to make that.
                            }
                        }
                    }
                }
                else if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon   = (BaseWeapon)targeted;
                    SkillName  skill    = m_CraftSystem.MainSkill;
                    int        toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (m_Tool == null)
                        {
                            skillLevel = m_SkillLevel;
                        }

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon))
                    {
                        if (m_Contract != null)
                        {
                            // You cannot repair that item with this type of repair contract.
                            number = 1061136;
                        }
                        else
                        {
                            // You cannot repair that using this type of tool.
                            number = 1061139;
                        }
                    }
                    else if (!weapon.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (weapon.MaxHits <= 0 || weapon.Hits == weapon.MaxHits)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (weapon.MaxHits <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, weapon.Hits, weapon.MaxHits))
                        {
                            weapon.MaxHits -= toWeaken;
                            weapon.Hits     = Math.Max(0, weapon.Hits - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, weapon.Hits, weapon.MaxHits))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            weapon.Hits = weapon.MaxHits;

                            if (from.AccessLevel > AccessLevel.Player)
                            {
                                weapon.Cheater_Name = String.Format("This item repaired by GM {0}", from.Name);
                            }
                        }
                        else
                        {
                            if (m_Contract != null)
                            {
                                // You fail to repair the item and the repair contract is destroyed.
                                number = 1061137;
                            }
                            else
                            {
                                // You fail to repair the item.
                                number = 1044280;
                            }

                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        if (m_Contract != null)
                        {
                            m_Contract.Delete();
                        }
                    }
                }
                else if (targeted is BaseArmor)
                {
                    BaseArmor armor    = (BaseArmor)targeted;
                    SkillName skill    = m_CraftSystem.MainSkill;
                    int       toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (m_Tool == null)
                        {
                            skillLevel = m_SkillLevel;
                        }

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null)
                    {
                        if (m_Contract != null)
                        {
                            // You cannot repair that item with this type of repair contract.
                            number = 1061136;
                        }
                        else
                        {
                            // You cannot repair that using this type of tool.
                            number = 1061139;
                        }
                    }
                    else if (!armor.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (armor.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            armor.MaxHitPoints -= toWeaken;
                            armor.HitPoints     = Math.Max(0, armor.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            armor.HitPoints = armor.MaxHitPoints;

                            if (from.AccessLevel > AccessLevel.Player)
                            {
                                armor.Cheater_Name = String.Format("This item repaired by GM {0}", from.Name);
                            }
                        }
                        else
                        {
                            if (m_Contract != null)
                            {
                                // You fail to repair the item and the repair contract is destroyed.
                                number = 1061137;
                            }
                            else
                            {
                                // You fail to repair the item.
                                number = 1044280;
                            }

                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        if (m_Contract != null)
                        {
                            m_Contract.Delete();
                        }
                    }
                }
                else if (targeted is Item)
                {
                    number = 1044283;                     // You cannot repair that.

                    SkillName skill = m_CraftSystem.MainSkill;

                    double value = from.Skills[skill].Value;

                    if (targeted is BlankScroll)
                    {
                        Item contract = null;

                        if (value < 50.0)
                        {
                            // You must be at least apprentice level to create a repair service contract.
                            number = 1047005;
                        }
                        else
                        {
                            if (skill == SkillName.Blacksmith)
                            {
                                contract = new RepairContract(ContractType.Blacksmith, value, from.Name);
                            }
                            else if (skill == SkillName.Carpentry)
                            {
                                contract = new RepairContract(ContractType.Carpenter, value, from.Name);
                            }
                            else if (skill == SkillName.Fletching)
                            {
                                contract = new RepairContract(ContractType.Fletcher, value, from.Name);
                            }
                            else if (skill == SkillName.Tailoring)
                            {
                                contract = new RepairContract(ContractType.Tailor, value, from.Name);
                            }
                            else if (skill == SkillName.Tinkering)
                            {
                                contract = new RepairContract(ContractType.Tinker, value, from.Name);
                            }
                        }

                        if (contract != null)
                        {
                            if (from.AccessLevel > AccessLevel.Player)
                            {
                                contract.Cheater_Name = String.Format("This item crafted by GM {0}", from.Name);
                            }

                            from.AddToBackpack(contract);

                            number = 1044154;                             // You create the item.

                            BlankScroll scroll = targeted as BlankScroll;

                            if (scroll.Amount >= 2)
                            {
                                scroll.Amount -= 1;
                            }
                            else
                            {
                                scroll.Delete();
                            }
                        }
                    }
                }
                else
                {
                    number = 500426;                     // You can't repair that.
                }

                if (m_Tool != null)
                {
                    CraftContext context = m_CraftSystem.GetContext(from);

                    from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
                }
                else
                {
                    from.SendLocalizedMessage(number);
                }
            }
Пример #8
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (!CheckDeed(from))
                {
                    return;
                }

                bool usingDeed = (m_Deed != null);
                bool toDelete  = false;

                // TODO: Make an IRepairable

                if (m_CraftSystem.CanCraft(from, m_Tool, targeted.GetType()) == 1044267)
                {
                    number = 1044282;                     // You must be near a forge and and anvil to repair items. * Yes, there are two and's *
                }
                else if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon   = (BaseWeapon)targeted;
                    SkillName  skill    = m_CraftSystem.MainSkill;
                    int        toWeaken = 0;

                    if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed)? m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon))
                    {
                        number = (usingDeed)? 1061136 : 1044277;                         // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!weapon.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (weapon.PoisonCharges != 0)
                    {
                        number = 1005012;                         // You cannot repair an item while a caustic substance is on it.
                    }
                    else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (weapon.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            weapon.MaxHitPoints -= toWeaken;
                            weapon.HitPoints     = Math.Max(0, weapon.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            weapon.HitPoints = weapon.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed)? 1061137 : 1044280;                             // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (targeted is BaseArmor)
                {
                    BaseArmor armor    = (BaseArmor)targeted;
                    SkillName skill    = m_CraftSystem.MainSkill;
                    int       toWeaken = 0;

                    if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed)? m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null)
                    {
                        number = (usingDeed)? 1061136 : 1044277;                         // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!armor.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (armor.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            armor.MaxHitPoints -= toWeaken;
                            armor.HitPoints     = Math.Max(0, armor.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            armor.HitPoints = armor.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed)? 1061137 : 1044280;                             // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (targeted is BaseClothing)
                {
                    BaseClothing clothing = (BaseClothing)targeted;
                    SkillName    skill    = m_CraftSystem.MainSkill;
                    int          toWeaken = 0;

                    if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !IsSpecialClothing(clothing) && !((targeted is TribalMask) || (targeted is HornedTribalMask)))
                    {
                        number = (usingDeed) ? 1061136 : 1044277;                         // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!clothing.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (clothing.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            clothing.MaxHitPoints -= toWeaken;
                            clothing.HitPoints     = Math.Max(0, clothing.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            clothing.HitPoints = clothing.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280;                             // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (!usingDeed && targeted is BlankScroll)
                {
                    SkillName skill = m_CraftSystem.MainSkill;

                    if (from.Skills[skill].Value >= 50.0)
                    {
                        ((BlankScroll)targeted).Consume(1);
                        RepairDeed deed = new RepairDeed(RepairDeed.GetTypeFor(m_CraftSystem), from.Skills[skill].Value, from);
                        from.AddToBackpack(deed);

                        number = 500442;                         // You create the item and put it in your backpack.
                    }
                    else
                    {
                        number = 1047005;                         // You must be at least apprentice level to create a repair service contract.
                    }
                }
                else if (targeted is Item)
                {
                    number = (usingDeed)? 1061136 : 1044277;                     // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                }
                else
                {
                    number = 500426;                     // You can't repair that.
                }

                if (!usingDeed)
                {
                    CraftContext context = m_CraftSystem.GetContext(from);
                    from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
                }
                else
                {
                    from.SendLocalizedMessage(number);

                    if (toDelete)
                    {
                        m_Deed.Delete();
                    }
                }
            }
Пример #9
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (m_CraftSystem.CanCraft(from, m_Tool, targeted.GetType()) == 1044267)
                {
                    number = 1044282;                     // You must be near a forge and and anvil to repair items.
                }
                else if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon = (BaseWeapon)targeted;
                    SkillName  skill  = m_CraftSystem.MainSkill;

                    double repairChance = (from.Skills[skill].Value / 100);

                    double missingHitPointsScalar = ((double)weapon.MaxHitPoints - (double)weapon.HitPoints) / (double)weapon.MaxHitPoints;

                    int repairDurabilityDamage = (int)(Math.Round((missingHitPointsScalar * .1) * (double)weapon.MaxHitPoints));

                    if (repairDurabilityDamage < 1)
                    {
                        repairDurabilityDamage = 1;
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null)
                    {
                        number = 1044277;                         // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!weapon.IsChildOf(from.Backpack) && (!Core.ML || weapon.Parent != from))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (weapon.PoisonCharges != 0)
                    {
                        number = 1005012;                         // You cannot repair an item while a caustic substance is on it.
                    }
                    else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (weapon.MaxHitPoints < 10)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (Utility.RandomDouble() <= repairChance)
                        {
                            number = 1044279; // You repair the item.

                            if (ReduceDurabilityOnSuccess(weapon))
                            {
                                weapon.MaxHitPoints -= repairDurabilityDamage;
                            }

                            weapon.HitPoints = weapon.MaxHitPoints;

                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        else
                        {
                            number = 044280; // You fail to repair the item. [And the contract is destroyed]

                            m_CraftSystem.PlayCraftEffect(from);
                        }
                    }
                }

                else if (targeted is BaseArmor)
                {
                    BaseArmor armor = (BaseArmor)targeted;
                    SkillName skill = m_CraftSystem.MainSkill;

                    double repairChance = (from.Skills[skill].Value / 100);

                    double missingHitPointsScalar = ((double)armor.MaxHitPoints - (double)armor.HitPoints) / (double)armor.MaxHitPoints;

                    int repairDurabilityDamage = (int)(Math.Round((missingHitPointsScalar * .1) * (double)armor.MaxHitPoints));

                    if (repairDurabilityDamage < 1)
                    {
                        repairDurabilityDamage = 1;
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null)
                    {
                        number = 1044277;                         // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!armor.IsChildOf(from.Backpack) && (armor.Parent != from))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (armor.MaxHitPoints < 10)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (Utility.RandomDouble() <= repairChance)
                        {
                            number = 1044279; // You repair the item.

                            if (ReduceDurabilityOnSuccess(armor))
                            {
                                armor.MaxHitPoints -= repairDurabilityDamage;
                            }

                            armor.HitPoints = armor.MaxHitPoints;

                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        else
                        {
                            number = 044280; // You fail to repair the item. [And the contract is destroyed]

                            m_CraftSystem.PlayCraftEffect(from);
                        }
                    }
                }

                /*
                 *              else if ( targeted is BaseClothing )
                 *              {
                 *                      BaseClothing clothing = (BaseClothing)targeted;
                 *                      SkillName skill = m_CraftSystem.MainSkill;
                 *                      int toWeaken = 0;
                 *
                 *                      if ( Core.AOS )
                 *                      {
                 *                              toWeaken = 1;
                 *                      }
                 *
                 *                      else if ( skill != SkillName.Tailoring )
                 *                      {
                 *                              double skillLevel = from.Skills[skill].Base;
                 *
                 *                              if ( skillLevel >= 90.0 )
                 *                                      toWeaken = 1;
                 *                              else if ( skillLevel >= 70.0 )
                 *                                      toWeaken = 2;
                 *                              else
                 *                                      toWeaken = 3;
                 *                      }
                 *
                 *                      if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !((targeted is TribalMask) || (targeted is HornedTribalMask)) )
                 *                      {
                 *                              number = 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                 *                      }
                 *
                 *                      else if ( !clothing.IsChildOf( from.Backpack ) && ( !Core.ML || clothing.Parent != from ) )
                 *                      {
                 *                              number = 1044275; // The item must be in your backpack to repair it.
                 *                      }
                 *
                 *                      else if ( clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints )
                 *                      {
                 *                              number = 1044281; // That item is in full repair
                 *                      }
                 *
                 *                      else if ( clothing.MaxHitPoints <= toWeaken )
                 *                      {
                 *                              number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                 *                      }
                 *
                 *                      else
                 *                      {
                 *                              if ( CheckWeaken( from, skill, clothing.HitPoints, clothing.MaxHitPoints ) )
                 *                              {
                 *                                      clothing.MaxHitPoints -= toWeaken;
                 *                                      clothing.HitPoints = Math.Max( 0, clothing.HitPoints - toWeaken );
                 *                              }
                 *
                 *                              if ( CheckRepairDifficulty( from, skill, clothing.HitPoints, clothing.MaxHitPoints ) )
                 *                              {
                 *                                      number = 1044279; // You repair the item.
                 *                                      m_CraftSystem.PlayCraftEffect( from );
                 *                                      clothing.HitPoints = clothing.MaxHitPoints;
                 *                              }
                 *
                 *                              else
                 *                              {
                 *                                      number = 1044280; // You fail to repair the item. [And the contract is destroyed]
                 *                                      m_CraftSystem.PlayCraftEffect( from );
                 *                              }
                 *                      }
                 *              }
                 */

                else if (targeted is Item)
                {
                    number = 1044277;                     // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                }
                else
                {
                    number = 500426;                     // You can't repair that.
                }
                CraftContext context = m_CraftSystem.GetContext(from);

                from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
            }
Пример #10
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Item == null || m_Item.Deleted)
                {
                    return;
                }

                if (targeted is BaseArmor)
                {
                    BaseArmor armor = targeted as BaseArmor;

                    if (!armor.IsChildOf(from.Backpack))
                    {
                        from.SendLocalizedMessage(1054107); // This item must be in your backpack.
                    }
                    else if (armor.ArmorAttributes.MageArmor > 0)
                    {
                        from.SendLocalizedMessage(1153986); // You cannot refine this piece of armor!
                    }
                    else if (!RefinementGump.CanApplyToArmor(from, armor, m_Item))
                    {
                        from.SendLocalizedMessage(1153987); // The type of armor you have selected is not compatible with this Refinement Tool.
                    }
                    else if (RefinementItem.CheckForVendor(from, m_Item))
                    {
                        //Resets old refinement if it exists
                        armor.RefinedPhysical = 0;
                        armor.RefinedFire     = 0;
                        armor.RefinedCold     = 0;
                        armor.RefinedPoison   = 0;
                        armor.RefinedEnergy   = 0;

                        for (int i = 0; i < m_Item.ModAmount; i++)
                        {
                            if (i < 0 || i >= m_Entry.Resists.Length)
                            {
                                continue;
                            }

                            int value = i < m_Entry.Values.Length ? m_Entry.Values[i] : 0;

                            switch (m_Entry.Resists[i])
                            {
                            case ResistanceType.Physical: armor.RefinedPhysical += value; break;

                            case ResistanceType.Fire: armor.RefinedFire += value; break;

                            case ResistanceType.Cold: armor.RefinedCold += value; break;

                            case ResistanceType.Poison: armor.RefinedPoison += value; break;

                            case ResistanceType.Energy: armor.RefinedEnergy += value; break;
                            }
                        }

                        from.PrivateOverheadMessage(MessageType.Regular, 0, 1153980, from.NetState); // *You carefully apply the Refinement to the armor*
                        m_Item.Delete();
                        return;
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1153991); // You can only refine non-medable armor.
                }
                from.SendGump(new RefinementGump(m_Item));
            }
Пример #11
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (m_CraftSystem.CanCraft(from, m_Tool, targeted.GetType()) == 1044267)
                {
                    number = 1044282;                     // You must be near a forge and and anvil to repair items. * Yes, there are two and's *
                }
                else if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon   = (BaseWeapon)targeted;
                    SkillName  skill    = m_CraftSystem.MainSkill;
                    int        toWeaken = weapon.MaxHitPoints / 2;

                    if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon))
                    {
                        number = 1044277;                         // That item cannot be repaired.
                    }
                    else if (!weapon.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (weapon.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else if (weapon.Slayer != SlayerName.None || weapon.Slayer2 != SlayerName.None)
                    {
                        number = 1044277;                         // That item cannot be repaired.
                    }
                    else if (weapon.LootType == LootType.Cursed)
                    {
                        number = 1044277;                         // That item cannot be repaired.
                    }
                    else
                    {
                        weapon.MaxHitPoints -= toWeaken;
                        weapon.HitPoints     = Math.Max(0, weapon.HitPoints - toWeaken);

                        if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            weapon.HitPoints = weapon.MaxHitPoints;
                        }
                        else
                        {
                            number = 1044280;                             // You fail to repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                        }
                    }
                }
                else if (targeted is BaseArmor)
                {
                    BaseArmor armor    = (BaseArmor)targeted;
                    SkillName skill    = m_CraftSystem.MainSkill;
                    int       toWeaken = armor.MaxHitPoints / 2;

                    if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null)
                    {
                        number = 1044277;                         // That item cannot be repaired.
                    }
                    else if (!armor.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (armor.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        armor.MaxHitPoints -= toWeaken;
                        armor.HitPoints     = Math.Max(0, armor.HitPoints - toWeaken);

                        if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            armor.HitPoints = armor.MaxHitPoints;
                        }
                        else
                        {
                            number = 1044280;                             // You fail to repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                        }
                    }
                }
                else if (targeted is BaseClothing)
                {
                    BaseClothing clothing = (BaseClothing)targeted;
                    SkillName    skill    = m_CraftSystem.MainSkill;
                    int          toWeaken = clothing.MaxHitPoints / 2;

                    if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !IsSpecialClothing(clothing) && !((targeted is TribalMask) || (targeted is HornedTribalMask)))
                    {
                        number = 1044277;                         // That item cannot be repaired.
                    }
                    else if (!clothing.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (clothing.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        clothing.MaxHitPoints -= toWeaken;
                        clothing.HitPoints     = Math.Max(0, clothing.HitPoints - toWeaken);

                        if (CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            clothing.HitPoints = clothing.MaxHitPoints;
                        }
                        else
                        {
                            number = 1044280;                             // You fail to repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                        }
                    }
                }
                else if (targeted is Item)
                {
                    number = 1044277;                     // That item cannot be repaired.
                }
                else
                {
                    number = 500426;                     // You can't repair that.
                }

                CraftContext context = m_CraftSystem.GetContext(from);

                from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
            }
Пример #12
0
        private void DoRepair(object targeted)
        {
            int    number    = 0;
            bool   usingDeed = false;
            bool   toDelete  = false;
            Mobile from      = m_from;

            if (targeted is BaseWeapon)
            {
                BaseWeapon weapon   = (BaseWeapon)targeted;
                SkillName  skill    = m_craftSystem.MainSkill;
                int        toWeaken = 0;

                if (Core.AOS)
                {
                    toWeaken = 1;
                }
                else if (skill != SkillName.Tailoring)
                {
                    double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base;

                    if (skillLevel >= 90.0)
                    {
                        toWeaken = 1;
                    }
                    else if (skillLevel >= 70.0)
                    {
                        toWeaken = 2;
                    }
                    else
                    {
                        toWeaken = 3;
                    }
                }

                if (m_craftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon))
                {
                    number = (usingDeed) ? 1061136 : 1044277;                     // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                }
                else if (!weapon.IsChildOf(from.Backpack))
                {
                    number = 1044275;                     // The item must be in your backpack to repair it.
                }
                else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                {
                    number = 500423;                     // That is already in full repair.
                }
                else if (weapon.MaxHitPoints <= toWeaken)
                {
                    number = 1044278;                     // That item has been repaired many times, and will break if repairs are attempted again.
                }
                else
                {
                    if (CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                    {
                        weapon.MaxHitPoints -= toWeaken;
                        weapon.HitPoints     = Math.Max(0, weapon.HitPoints - toWeaken);
                    }

                    if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                    {
                        number = 1044279;                         // You repair the item.
                        m_craftSystem.PlayCraftEffect(from);
                        weapon.HitPoints = weapon.MaxHitPoints;
                    }
                    else
                    {
                        number = (usingDeed) ? 1061137 : 1044280;                         // You fail to repair the item. [And the contract is destroyed]
                        m_craftSystem.PlayCraftEffect(from);
                    }

                    toDelete = true;
                }
            }
            else if (targeted is BaseArmor)
            {
                BaseArmor armor    = (BaseArmor)targeted;
                SkillName skill    = m_craftSystem.MainSkill;
                int       toWeaken = 0;

                if (Core.AOS)
                {
                    toWeaken = 1;
                }
                else if (skill != SkillName.Tailoring)
                {
                    double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base;

                    if (skillLevel >= 90.0)
                    {
                        toWeaken = 1;
                    }
                    else if (skillLevel >= 70.0)
                    {
                        toWeaken = 2;
                    }
                    else
                    {
                        toWeaken = 3;
                    }
                }

                if (m_craftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null)
                {
                    number = (usingDeed) ? 1061136 : 1044277;                     // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                }
                else if (!armor.IsChildOf(from.Backpack))
                {
                    number = 1044275;                     // The item must be in your backpack to repair it.
                }
                else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                {
                    number = 500423;                     // That is already in full repair.
                }
                else if (armor.MaxHitPoints <= toWeaken)
                {
                    number = 1044278;                     // That item has been repaired many times, and will break if repairs are attempted again.
                }
                else
                {
                    if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints))
                    {
                        armor.MaxHitPoints -= toWeaken;
                        armor.HitPoints     = Math.Max(0, armor.HitPoints - toWeaken);
                    }

                    if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
                    {
                        number = 1044279;                         // You repair the item.
                        m_craftSystem.PlayCraftEffect(from);
                        armor.HitPoints = armor.MaxHitPoints;
                    }
                    else
                    {
                        number = (usingDeed) ? 1061137 : 1044280;                         // You fail to repair the item. [And the contract is destroyed]
                        m_craftSystem.PlayCraftEffect(from);
                    }

                    toDelete = true;
                }
            }

            // tell the user what happened
            if (number != 0)
            {
                Craft.From.SendLocalizedMessage(number);
            }
        }
Пример #13
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (m_CraftSystem is DefTinkering)
                {
                    if (targeted is Golem)
                    {
                        Golem g      = (Golem)targeted;
                        int   damage = g.HitsMax - g.Hits;
                        if (g.IsDeadBondedPet)
                        {
                            if (from.Skills[SkillName.Tinkering].Value > 79.9)
                            {
                                if (!g.Map.CanFit(g.Location, 16, false, false))
                                {
                                    number = 501042;                                     // Target can not be resurrected at that location.
                                }
                                else
                                {
                                    double chance = ((from.Skills[SkillName.Tinkering].Value - 68.0) / 50.0);
                                    if (chance > Utility.RandomDouble())
                                    {
                                        Mobile master = g.ControlMaster;
                                        if (master != null && master.InRange(g, 3))
                                        {
                                            number = 503255;                                             // You are able to resurrect the creature.
                                            master.SendGump(new PetResurrectGump(from, g));
                                        }
                                        else
                                        {
                                            number = 1049670;                                             // The pet's owner must be nearby to attempt resurrection.
                                        }
                                    }
                                    else
                                    {
                                        number = 503256;                                         // You fail to resurrect the creature.
                                    }
                                }
                            }
                            else
                            {
                                number = 503256;                                 // You fail to resurrect the creature.
                            }
                        }

                        else if (damage <= 0)
                        {
                            number = 500423;                             // That is already in full repair.
                        }
                        else
                        {
                            double skillValue = from.Skills[SkillName.Tinkering].Value;

                            if (skillValue < 60.0)
                            {
                                number = 1044153;                                 // You don't have the required skills to attempt this item.
                            }
                            else if (!from.CanBeginAction(typeof(Golem)))
                            {
                                number = 501789;                                 // You must wait before trying again.
                            }
                            else
                            {
                                if (damage > (int)(skillValue * 0.3))
                                {
                                    damage = (int)(skillValue * 0.3);                                    //max 33
                                }
                                damage += 30;

                                if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0))
                                {
                                    damage /= 2;
                                }

                                Container pack = from.Backpack;

                                if (pack != null)
                                {
                                    int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5);

                                    if (v > 0)
                                    {
                                        g.Hits += (v * 5 + (int)(from.Skills[SkillName.Blacksmith].Value / 5)); //max 36.8 w/o ancient hammer
                                        g.Hits += (int)(from.Skills[SkillName.Tailoring].Value / 5);            //max24
                                        g.Hits += (int)(from.Skills[SkillName.ArmsLore].Value / 5);             //max24

                                        number = 1044279;                                                       // You repair the item.

                                        from.BeginAction(typeof(Golem));
                                        Timer.DelayCall(TimeSpan.FromSeconds(5.0), new TimerStateCallback(EndGolemRepair), from);
                                    }
                                    else
                                    {
                                        number = 1044037;                                         // You do not have sufficient metal to make that.
                                    }
                                }
                                else
                                {
                                    number = 1044037;                                     // You do not have sufficient metal to make that.
                                }
                            }
                        }
                    }
                    else
                    {
                        number = 500426;                         // You can't repair that.
                    }
                }
                else if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon   = (BaseWeapon)targeted;
                    SkillName  skill    = m_CraftSystem.MainSkill;
                    int        toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null)
                    {
                        number = 1044277;                         // That item cannot be repaired.
                    }
                    else if (!weapon.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (weapon.MaxHitPoints <= toWeaken)
                    {
                        number = 500424;                         // You destroyed the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        weapon.Delete();
                    }
                    else if (from.CheckSkill(skill, -285.0, 100.0))
                    {
                        number = 1044279;                         // You repair the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        weapon.MaxHitPoints -= toWeaken;
                        weapon.HitPoints     = weapon.MaxHitPoints;
                    }
                    else
                    {
                        number = 1044280;                         // You fail to repair the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        weapon.MaxHitPoints -= toWeaken;
                        weapon.HitPoints    -= toWeaken;
                    }

                    if (weapon.MaxHitPoints <= toWeaken)
                    {
                        from.SendLocalizedMessage(1044278);                           // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                }
                else if (targeted is BaseArmor)
                {
                    BaseArmor armor    = (BaseArmor)targeted;
                    SkillName skill    = m_CraftSystem.MainSkill;
                    int       toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null)
                    {
                        number = 1044277;                         // That item cannot be repaired.
                    }
                    else if (!armor.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (armor.MaxHitPoints <= toWeaken)
                    {
                        number = 500424;                         // You destroyed the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        armor.Delete();
                    }
                    else if (from.CheckSkill(skill, -285.0, 100.0))
                    {
                        number = 1044279;                         // You repair the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        armor.MaxHitPoints -= toWeaken;
                        armor.HitPoints     = armor.MaxHitPoints;
                    }
                    else
                    {
                        number = 1044280;                         // You fail to repair the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        armor.MaxHitPoints -= toWeaken;
                        armor.HitPoints    -= toWeaken;
                    }

                    if (armor.MaxHitPoints <= toWeaken)
                    {
                        from.SendLocalizedMessage(1044278);                           // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                }
                else if (targeted is Item)
                {
                    number = 1044277;                     // That item cannot be repaired.
                }
                else
                {
                    number = 500426;                     // You can't repair that.
                }

                CraftContext context = m_CraftSystem.GetContext(from);

                from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
            }