Esempio n. 1
0
        protected override void OnTarget(Mobile from, object o)
        {
            int number = -1;

            Item origItem = o as Item;
            SkillName skill = m_System.MainSkill;
            double value = from.Skills[skill].Value;

            var alterInfo = GetAlterableAttribute(o, false);

            if (alterInfo == null)
                alterInfo = GetAlterableAttribute(o, true);

            if (origItem == null || !origItem.IsChildOf(from.Backpack))
            {
                number = 1094729; // The item must be in your backpack for you to alter it.
            }
            else if (origItem is BlankScroll)
            {
                if (m_Contract == null)
                {
                    if (value >= 100.0)
                    {
                        Item contract = null;

                        if (skill == SkillName.Blacksmith)
                            contract = new AlterContract(RepairDeed.RepairSkillType.Smithing, from);
                        else if (skill == SkillName.Carpentry)
                            contract = new AlterContract(RepairDeed.RepairSkillType.Carpentry, from);
                        else if (skill == SkillName.Tailoring)
                            contract = new AlterContract(RepairDeed.RepairSkillType.Tailoring, from);
                        else if (skill == SkillName.Tinkering)
                            contract = new AlterContract(RepairDeed.RepairSkillType.Tinkering, from);

                        if (contract != null)
                        {
                            from.AddToBackpack(contract);

                            number = 1044154; // You create the item.

                            // Consume a blank scroll
                            origItem.Consume();
                        }
                    }
                    else
                    {
                        number = 1111869; // You must be at least grandmaster level to create an alter service contract.
                    }
                }
                else
                {
                    number = 1094728; // You may not alter that item.
                }
            }
            else if (alterInfo == null)
            {
                // You may not alter that item.
                number = 1094728;
            }
            else if (!IsAlterable(origItem))
            {
                number = 1094728; // You may not alter that item.
            }
            else if (alterInfo.CraftSystem != m_System.GetType())
            {
                if (m_Tool != null)
                {
                    // You may not alter that item.
                    number = 1094728;
                }
                else
                {
                    // You cannot alter that item with this type of alter contract.
                    number = 1094793;
                }
            }
            else if (!Server.SkillHandlers.Imbuing.CheckSoulForge(from, 2, false))
            {
                number = 1111867; // You must be near a soulforge to alter an item.
            }
            else if (!Server.SkillHandlers.Imbuing.CheckQueen(from))
            {
                number = 1113736; // You must rise to the rank of noble in the eyes of the Gargoyle Queen before her majesty will allow you to use this soulforge.
            }
            else if (m_Contract == null && value < 100.0)
            {
                number = 1111870; // You must be at least grandmaster level to alter an item.
            }
            else if (origItem is BaseWeapon && ((BaseWeapon)origItem).EnchantedWeilder != null)
            {
                number = 1111849; // You cannot alter an item that is currently enchanted.
            }
            else
            {
                Item newitem = Activator.CreateInstance(alterInfo.AlteredType) as Item;

                if (newitem == null)
                    return;

                if (origItem is BaseWeapon && newitem is BaseWeapon)
                {
                    BaseWeapon oldweapon = (BaseWeapon)origItem;
                    BaseWeapon newweapon = (BaseWeapon)newitem;

                    newweapon.Attributes = new AosAttributes(oldweapon, newweapon.Attributes);
                    //newweapon.ElementDamages = new AosElementAttributes( oldweapon, newweapon.ElementDamages ); To Do
                    newweapon.SkillBonuses = new AosSkillBonuses(oldweapon, newweapon.SkillBonuses);
                    newweapon.WeaponAttributes = new AosWeaponAttributes(oldweapon, newweapon.WeaponAttributes);
                    newweapon.AbsorptionAttributes = new SAAbsorptionAttributes(oldweapon, newweapon.AbsorptionAttributes);
                    newweapon.Altered = true;
                }
                else if (origItem is BaseArmor && newitem is BaseArmor)
                {
                    BaseArmor oldarmor = (BaseArmor)origItem;
                    BaseArmor newarmor = (BaseArmor)newitem;

                    newarmor.Attributes = new AosAttributes(oldarmor, newarmor.Attributes);
                    newarmor.ArmorAttributes = new AosArmorAttributes(oldarmor, newarmor.ArmorAttributes);
                    newarmor.SkillBonuses = new AosSkillBonuses(oldarmor, newarmor.SkillBonuses);
                    newarmor.AbsorptionAttributes = new SAAbsorptionAttributes(oldarmor, newarmor.AbsorptionAttributes);
                    newarmor.Altered = true;
                }
                else if (origItem is BaseClothing && newitem is BaseClothing)
                {
                    BaseClothing oldcloth = (BaseClothing)origItem;
                    BaseClothing newcloth = (BaseClothing)newitem;

                    newcloth.Attributes = new AosAttributes(oldcloth, newcloth.Attributes);
                    newcloth.SkillBonuses = new AosSkillBonuses(oldcloth, newcloth.SkillBonuses);
                    newcloth.SAAbsorptionAttributes = new SAAbsorptionAttributes(oldcloth, newcloth.SAAbsorptionAttributes);
                    newcloth.Altered = true;
                }
                else if (origItem is BaseClothing && newitem is BaseArmor)
                {
                    BaseClothing oldcloth = (BaseClothing)origItem;
                    BaseArmor newarmor = (BaseArmor)newitem;

                    newarmor.Attributes = new AosAttributes(oldcloth, newarmor.Attributes);
                    newarmor.ArmorAttributes = new AosArmorAttributes(oldcloth, newarmor.ArmorAttributes);
                    newarmor.SkillBonuses = new AosSkillBonuses(oldcloth, newarmor.SkillBonuses);
                    newarmor.AbsorptionAttributes = new SAAbsorptionAttributes(oldcloth, newarmor.AbsorptionAttributes);
                    newarmor.Altered = true;
                }
                else if (origItem is BaseQuiver && newitem is BaseArmor)
                {
                    BaseQuiver oldquiver = (BaseQuiver)origItem;
                    BaseArmor newarmor = (BaseArmor)newitem;

                    newarmor.Attributes = new AosAttributes(oldquiver, newarmor.Attributes);
                    newarmor.ArmorAttributes = new AosArmorAttributes(oldquiver, newarmor.ArmorAttributes);
                    newarmor.SkillBonuses = new AosSkillBonuses(oldquiver, newarmor.SkillBonuses);
                    newarmor.AbsorptionAttributes = new SAAbsorptionAttributes(oldquiver, newarmor.AbsorptionAttributes);
                    newarmor.Altered = true;
                }
                else
                {
                    return;
                }

                newitem.Name = origItem.Name;
                newitem.Hue = origItem.Hue;

                newitem.LootType = origItem.LootType;

                origItem.Delete();
                origItem.OnAfterDuped(newitem);
                newitem.Parent = null;

                if (from.Backpack == null)
                    newitem.MoveToWorld(from.Location, from.Map);
                else
                    from.Backpack.DropItem(newitem);

                newitem.InvalidateProperties();

                if (m_Contract != null)
                    m_Contract.Delete();

                number = 1094727; // You have altered the item.
            }

            if (m_Tool != null)
                from.SendGump(new CraftGump(from, m_System, m_Tool, number));
            else
                from.SendLocalizedMessage(number);
        }
Esempio n. 2
0
            protected override void OnTarget( Mobile from, object targeted )
            {
                int number = -1;
                Item origItem = targeted as Item;
                SkillName skill = m_CraftSystem.MainSkill;
                double value = from.Skills[skill].Value;

                var alterInfo = GetAlterableAttribute( targeted, false );

                if ( alterInfo == null )
                    alterInfo = GetAlterableAttribute( targeted, true );

                if ( origItem == null || !origItem.IsChildOf( from.Backpack ) )
                {
                    // The item must be in your backpack for you to alter it.
                    number = 1094729;
                }
                else if ( origItem is BlankScroll )
                {
                    if ( m_Contract == null )
                    {
                        if ( value >= 100.0 )
                        {
                            Item contract = null;

                            if ( skill == SkillName.Blacksmith )
                                contract = new AlterContract( ContractType.Blacksmith, from );
                            else if ( skill == SkillName.Carpentry )
                                contract = new AlterContract( ContractType.Carpenter, from );
                            else if ( skill == SkillName.Tailoring )
                                contract = new AlterContract( ContractType.Tailor, from );
                            else if ( skill == SkillName.Tinkering )
                                contract = new AlterContract( ContractType.Tinker, from );

                            if ( contract != null )
                            {
                                from.AddToBackpack( contract );

                                number = 1044154; // You create the item.

                                // Consume a blank scroll
                                origItem.Consume();
                            }
                        }
                        else
                        {
                            // You must be at least grandmaster level to create an alter service contract.
                            number = 1111869;
                        }
                    }
                    else
                    {
                        // You may not alter that item.
                        number = 1094728;
                    }
                }
                else if ( alterInfo == null )
                {
                    // You may not alter that item.
                    number = 1094728;
                }
                else if ( !IsAlterable( origItem ) )
                {
                    // You may not alter that item.
                    number = 1094728;
                }
                else if ( alterInfo.CraftSystem != m_CraftSystem.GetType() )
                {
                    if ( m_Tool != null )
                    {
                        // You may not alter that item.
                        number = 1094728;
                    }
                    else
                    {
                        // You cannot alter that item with this type of alter contract.
                        number = 1094793;
                    }
                }
                else if ( !Imbuing.Soulforge.CheckProximity( from, 2 ) )
                {
                    // You must be near a soulforge to alter an item.
                    number = 1111867;
                }
                else if ( !Imbuing.Soulforge.CheckQueen( from ) )
                {
                    // You must rise to the rank of noble in the eyes of the Gargoyle Queen before her majesty will allow you to use this soulforge.
                    number = 1113736;
                }
                else if ( origItem is BaseWeapon && ( (BaseWeapon) origItem ).Enchanted )
                {
                    // You cannot alter an item that is currently enchanted.
                    number = 1111849;
                }
                else if ( m_Contract == null && value < 100.0 )
                {
                    // You must be at least grandmaster level to alter an item.
                    number = 1111870;
                }
                else
                {
                    Item alteredItem = Activator.CreateInstance( alterInfo.AlteredType ) as Item;

                    alteredItem.Hue = origItem.Hue;
                    alteredItem.Insured = origItem.Insured;
                    alteredItem.PayedInsurance = origItem.PayedInsurance;
                    alteredItem.Label1 = origItem.Label1;
                    alteredItem.Label2 = origItem.Label2;
                    alteredItem.Label3 = origItem.Label3;
                    alteredItem.LootType = origItem.LootType;

                    if ( origItem.LabelNumber != origItem.DefaultLabelNumber )
                        alteredItem.LabelNumber = origItem.LabelNumber;

                    AlterFrom( origItem, alteredItem );

                    alteredItem.Hue = origItem.PrivateHue;

                    from.PlaceInBackpack( alteredItem );
                    alteredItem.Location = origItem.Location;
                    origItem.Delete();

                    if ( m_Contract != null )
                        m_Contract.Delete();

                    // You have altered the item.
                    number = 1094727;
                }

                if ( m_Tool != null )
                    from.SendGump( new CraftGump( from, m_CraftSystem, m_Tool, number ) );
                else
                    from.SendLocalizedMessage( number );
            }