Ejemplo n.º 1
0
        public static bool TryUnravel(Mobile from, Item item, bool warnIfSpecial)
        {
            IImbuable unravel = item as IImbuable;

            if (unravel == null)
            {
                from.SendLocalizedMessage(1080425);                   // You cannot magically unravel this item.
                return(false);
            }
            else if (item is IFactionArtifact)
            {
                from.SendLocalizedMessage(1112408);                   // You cannot magically unravel a faction reward item.
                return(false);
            }
            else if (item is ICollectionItem)
            {
                from.SendLocalizedMessage(1080425);                   // You cannot magically unravel this item.
                return(false);
            }
            else if (item.LootType == LootType.Blessed)
            {
                from.SendLocalizedMessage(1080421);                   // You cannot unravel the magic of a blessed item.
                return(false);
            }
            else if (warnIfSpecial && unravel.IsSpecialMaterial)
            {
                from.BeginAction(typeof(Imbuing));
                from.SendGump(new ConfirmUnravelGump(item));
                return(false);
            }
            else
            {
                return(Unravel(from, item));
            }
        }
Ejemplo n.º 2
0
        public PropCollection(Item item, bool validateFlags)
        {
            if (item is IImbuable)
            {
                IImbuable imbuable = item as IImbuable;

                foreach (BaseAttrInfo prop in Imbuing.Properties)
                {
                    if (prop.CanHold(item) && (!validateFlags || Imbuing.ValidateFlags(imbuable.ImbuingFlags, prop.Flags)) && prop.Validate(item))
                    {
                        int intensity = Imbuing.ComputeIntensity(item, prop, false);

                        if (intensity != 0)
                        {
                            PropEntry entry = new PropEntry(prop, intensity);

                            m_Properties.Add(entry);

                            m_Intensity         += entry.Intensity;
                            m_WeightedIntensity += entry.WeightedIntensity;
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        protected override void OnTarget(Mobile from, object targeted)
        {
            Item item = targeted as Item;

            if (Imbuing.Check(from, item))
            {
                IImbuable imbuable = item as IImbuable;

                if (imbuable != null && m_Attribute.CanHold(item) && Imbuing.ValidateFlags(imbuable.ImbuingFlags, m_Attribute.Flags) && m_Attribute.Validate(item))
                {
                    Gump confirm = SelectPropGump.SelectProp(from, item, m_Attribute);

                    if (confirm != null)
                    {
                        from.SendGump(confirm);
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1114291);                       // You cannot imbue the last property on that item.
                    from.EndAction(typeof(Imbuing));
                }
            }
            else
            {
                from.EndAction(typeof(Imbuing));
            }
        }
Ejemplo n.º 4
0
        private static bool HasSpecialMaterialItem(Container c)
        {
            for (int i = 0; i < c.Items.Count; i++)
            {
                IImbuable item = c.Items[i] as IImbuable;

                if (item != null && item.IsSpecialMaterial)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns a list of properties that can be imbued to the given item.
        /// </summary>
        public static List <BaseAttrInfo> GetValidProperties(Item item)
        {
            List <BaseAttrInfo> props    = new List <BaseAttrInfo>();
            IImbuable           imbuable = item as IImbuable;

            if (imbuable != null)
            {
                foreach (BaseAttrInfo prop in m_Properties)
                {
                    if (prop.CanHold(item) && ValidateFlags(imbuable.ImbuingFlags, prop.Flags) && prop.Validate(item))
                    {
                        props.Add(prop);
                    }
                }
            }

            return(props);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Performs the pre-imbue checks for the given Mobile and Item.
        /// </summary>
        public static bool Check(Mobile from, Item item)
        {
            IImbuable  imbuable = item as IImbuable;
            BaseWeapon weapon   = item as BaseWeapon;

            /*
             * Additional checks that OSI performs but aren't needed on X-RunUO:
             * - Focus Attack effect: 1080444 "You cannot imbue an item that is under the effects of the ninjitsu focus attack ability."
             */

            if (!Soulforge.CheckProximity(from, 2))
            {
                from.SendLocalizedMessage(1079787);                   // You must be near a soulforge to imbue an item.
            }
            else if (!Soulforge.CheckQueen(from))
            {
                from.SendLocalizedMessage(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 (item == null || !item.IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1079575);                   // The item must be in your backpack to imbue it.
            }
            else if (imbuable == null || !imbuable.CanImbue || item is ISetItem || item is ICollectionItem)
            {
                from.SendLocalizedMessage(1079576);                   // You cannot imbue this item.
            }
            else if (item.LootType == LootType.Blessed)
            {
                from.SendLocalizedMessage(1080438);                   // You cannot imbue a blessed item.
            }
            else if (weapon != null && weapon.Enchanted)
            {
                from.SendLocalizedMessage(1080130);                   // You cannot imbue an item that is currently enchanted.
            }
            else
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 7
0
        protected override void OnTarget(Mobile from, object targeted)
        {
            Item      item      = targeted as Item;
            IImbuable toUnravel = targeted as IImbuable;

            from.EndAction(typeof(Imbuing));

            if (!Soulforge.CheckProximity(from, 2))
            {
                from.SendLocalizedMessage(1080433);                   // You must be near a soulforge to magically unravel an item.
            }
            else if (!Soulforge.CheckQueen(from))
            {
                from.SendLocalizedMessage(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 (item == null || !item.IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1080424);                   // The item must be in your backpack to magically unravel it.
            }
            else
            {
                Unraveling.TryUnravel(from, item, true);
            }
        }
Ejemplo n.º 8
0
        public ConfirmationGump(Mobile from, Item itemToImbue, PropCollection itemProperties, BaseAttrInfo propToImbue, BaseAttrInfo propToReplace, int intensityStep, int totalSteps)
            : base(50, 50)
        {
            // Var declarations
            int    intensity;                   // intensity of the prop we are imbuing
            int    wIntensity;                  // weighted intensity of the prop we are imbuing
            int    totalIntensity;              // total intensity of all props, weighted
            int    wTotalIntensity;             // total intensity of all props, weighted
            int    totalProperties;             // total number of properties the item will possess when imbued
            string newValueString;              // the new value of the prop we are imbuing

            // Save the parameters.
            m_ItemToImbue         = itemToImbue;
            m_Imbuable            = m_ItemToImbue as IImbuable;
            m_ItemProperties      = itemProperties;
            m_PropToImbue         = propToImbue;
            m_PropToReplace       = propToReplace;
            m_IntensityStep       = intensityStep;
            m_TotalIntensitySteps = totalSteps;

            // Make sure we don't perverse the intensities.
            Utility.FixMinMax(ref m_IntensityStep, 1, m_TotalIntensitySteps);

            // Gets info about the prop that we are going to imbue.
            intensity       = (int)(100 * ((double)m_IntensityStep / m_TotalIntensitySteps));
            wIntensity      = (int)(intensity * m_PropToImbue.Weight);
            totalIntensity  = m_ItemProperties.Intensity + intensity;
            wTotalIntensity = m_ItemProperties.WeightedIntensity + wIntensity;
            totalProperties = m_ItemProperties.Count;

            m_ValueToImbue = ComputeValue(m_IntensityStep, m_TotalIntensitySteps, m_PropToImbue.MinIntensity, m_PropToImbue.MaxIntensity);
            newValueString = FormatValue(m_PropToImbue.Modify(m_ItemToImbue, m_ValueToImbue), m_PropToImbue);

            // **********************
            // Gump Structure
            // **********************
            AddPage(0);

            AddBackground(0, 0, 520, 440, 0x13BE);
            AddImageTiled(10, 10, 500, 20, 0xA40);
            AddImageTiled(10, 40, 245, 140, 0xA40);
            AddImageTiled(265, 40, 245, 140, 0xA40);
            AddImageTiled(10, 190, 245, 140, 0xA40);
            AddImageTiled(265, 190, 245, 140, 0xA40);
            AddImageTiled(10, 340, 500, 60, 0xA40);
            AddImageTiled(10, 410, 500, 20, 0xA40);
            AddAlphaRegion(10, 10, 500, 420);

            AddHtmlLocalized(10, 12, 500, 20, 1079717, 0x7FFF, false, false);               // <CENTER>IMBUING CONFIRMATION</CENTER>

            // **********************
            // Property Info
            // **********************

            AddHtmlLocalized(50, 50, 250, 20, 1114269, 0x7FFF, false, false);               // PROPERTY INFORMATION

            AddHtmlLocalized(25, 80, 390, 20, 1114270, 0x7FFF, false, false);               // Property:
            AddHtmlLocalized(95, 80, 150, 20, m_PropToImbue.Name, 0x7FFF, false, false);

            AddHtmlLocalized(25, 100, 390, 20, 1114271, 0x7FFF, false, false);               // Replaces:
            if (m_PropToReplace != null)
            {
                m_ValueToReplace = m_PropToReplace.GetValue(m_ItemToImbue);

                AddHtmlLocalized(95, 100, 150, 20, m_PropToReplace.Name, 0x7FFF, false, false);

                // The intensity of the property replaced may not count in the total.
                int replaceIntensity = Imbuing.ComputeIntensity(m_ItemToImbue, m_PropToReplace);
                totalIntensity  -= replaceIntensity;
                wTotalIntensity -= (int)(m_PropToReplace.Weight * replaceIntensity);
            }
            else
            {
                // Since we are not replacing any prop, it means we are adding one ^^u
                totalProperties++;
            }

            m_WTotalIntensity = wTotalIntensity;

            AddHtmlLocalized(25, 120, 200, 20, 1114272, 0x7FFF, false, false);               // Weight:
            AddLabel(95, 120, 0x481, String.Format("{0:0.0}x", m_PropToImbue.Weight));

            AddHtmlLocalized(25, 140, 200, 20, 1114273, 0x7FFF, false, false);               // Intensity:
            AddLabel(95, 140, 0x481, String.Format("{0}%", wIntensity));

            AddHtmlLocalized(280, 55, 205, 115, m_PropToImbue.Description, 0x7FFF, false, false);

            // **********************
            // Material Info
            // **********************
            AddHtmlLocalized(100, 200, 80, 20, 1044055, 0x7FFF, false, false);               // <CENTER>MATERIALS</CENTER>

            m_Resources1 = Math.Max(1, (int)(intensity / 20));
            m_Resources2 = Math.Max(1, (int)(intensity / 10));
            m_Resources3 = Math.Max(0, (intensity - 90));

            AddHtmlLocalized(40, 220, 390, 20, (int)m_PropToImbue.PrimaryResource, 0x7FFF, false, false);
            AddLabel(210, 220, 0x481, m_Resources1.ToString());

            AddHtmlLocalized(40, 240, 390, 20, (int)m_PropToImbue.SecondaryResource, 0x7FFF, false, false);
            AddLabel(210, 240, 0x481, m_Resources2.ToString());

            if (m_Resources3 > 0)
            {
                AddHtmlLocalized(40, 260, 390, 20, (int)m_PropToImbue.FullResource, 0x7FFF, false, false);
                AddLabel(210, 260, 0x481, m_Resources3.ToString());
            }

            // **********************
            // Results
            // **********************
            AddHtmlLocalized(350, 200, 65, 20, 1113650, 0x7FFF, false, false);               // RESULTS

            AddHtmlLocalized(280, 220, 140, 20, 1113645, 0x7FFF, false, false);              // Properties:
            AddFractionLabel(430, 220, totalProperties, 5);

            AddHtmlLocalized(280, 240, 260, 20, 1113646, 0x7FFF, false, false);               // Total Property Weight:
            AddFractionLabel(430, 240, wTotalIntensity, m_Imbuable.MaxIntensity);

            AddHtmlLocalized(280, 260, 200, 20, 1113647, 0x7FFF, false, false);               // Times Imbued:
            AddFractionLabel(430, 260, m_Imbuable.TimesImbued, 20);

            // **********************
            // Choose Intensity
            // **********************
            if (m_PropToImbue.MinIntensity != m_PropToImbue.MaxIntensity)
            {
                AddHtmlLocalized(235, 350, 200, 20, 1062300, 0x7FFF, false, false);                   // New Value:
                AddLabel(256, 370, 0x481, newValueString);

                AddButton(179, 372, 0x1464, 0x1464, 310, GumpButtonType.Reply, 0);
                AddButton(187, 372, 0x1466, 0x1466, 310, GumpButtonType.Reply, 0);
                AddLabel(181, 370, 0x0, "<");
                AddLabel(185, 370, 0x0, "<");
                AddLabel(189, 370, 0x0, "<");
                AddButton(199, 372, 0x1464, 0x1464, 314, GumpButtonType.Reply, 0);
                AddButton(207, 372, 0x1466, 0x1466, 314, GumpButtonType.Reply, 0);
                AddLabel(202, 370, 0x0, "<");
                AddLabel(207, 370, 0x0, "<");
                AddButton(221, 372, 0x1464, 0x1464, 311, GumpButtonType.Reply, 0);
                AddButton(229, 372, 0x1466, 0x1466, 311, GumpButtonType.Reply, 0);
                AddLabel(224, 370, 0x0, "<");
                AddButton(280, 372, 0x1464, 0x1464, 312, GumpButtonType.Reply, 0);
                AddButton(288, 372, 0x1466, 0x1466, 312, GumpButtonType.Reply, 0);
                AddLabel(286, 370, 0x0, ">");
                AddButton(300, 372, 0x1464, 0x1464, 315, GumpButtonType.Reply, 0);
                AddButton(308, 372, 0x1466, 0x1466, 315, GumpButtonType.Reply, 0);
                AddLabel(304, 370, 0x0, ">");
                AddLabel(308, 370, 0x0, ">");
                AddButton(320, 372, 0x1464, 0x1464, 313, GumpButtonType.Reply, 0);
                AddButton(328, 372, 0x1466, 0x1466, 313, GumpButtonType.Reply, 0);
                AddLabel(322, 370, 0x0, ">");
                AddLabel(326, 370, 0x0, ">");
                AddLabel(330, 370, 0x0, ">");
            }

            // **********************
            // Self Repair Warning
            // **********************

            bool selfRepair = (m_ItemToImbue is IArmor && ((IArmor)m_ItemToImbue).ArmorAttributes.SelfRepair != 0) ||
                              (m_ItemToImbue is ICloth && ((ICloth)m_ItemToImbue).ClothingAttributes.SelfRepair != 0) ||
                              (m_ItemToImbue is IWeapon && ((IWeapon)m_ItemToImbue).WeaponAttributes.SelfRepair != 0);

            if (selfRepair)
            {
                AddHtmlLocalized(20, 330, 390, 20, 1080417, 0x7FFF, false, false);                   // WARNING! Imbuing will remove Self Repair from this item.
            }
            // **********************
            // Success Chance
            // **********************
            m_SuccessChance = Imbuing.GetSuccessChance(from, m_ItemToImbue, totalIntensity);

            AddHtmlLocalized(300, 300, 250, 20, 1044057, 0x7FFF, false, false);               // Success Chance:
            AddLabel(420, 300, GetSuccessChanceHue(), String.Format("{0:0.0}%", Math.Max(0, (m_SuccessChance * 100))));

            // **********************
            // Are we ready to rock?
            // **********************
            AddButton(15, 410, 0xFA5, 0xFA6, 301, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 412, 100, 20, 1114268, 0x7FFF, false, false);               // Back

            AddButton(390, 410, 0xFA5, 0xFA6, 302, GumpButtonType.Reply, 0);
            AddHtmlLocalized(425, 412, 100, 20, 1114267, 0x7FFF, false, false);               // Imbue Item
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Do the imbuing stuff.
        /// </summary>
        public static void Do(Mobile from, Item item, BaseAttrInfo propToImbue, BaseAttrInfo propToReplace, int value, int wTotalIntensity, int r1, int r2, int r3, double successChance)
        {
            IImbuable imbuable = item as IImbuable;
            int       curValue = propToImbue.GetValue(item);

            if (curValue == value)
            {
                from.SendLocalizedMessage(1113473);                   // The item already has that property imbued at that intensity.
            }
            else if (wTotalIntensity > imbuable.MaxIntensity)
            {
                from.SendLocalizedMessage(1113364);                   // You can not imbue this property on this item at the selected intensity because it will make the item unstable.
            }
            else if (!Check(from, item))
            {
            }
            else if (!Resources.ConsumeResources(from, propToImbue, r1, r2, r3))
            {
                from.SendLocalizedMessage(1079773);                   // You do not have enough resources to imbue this item.
            }
            else
            {
                bool success;

                if (imbuable.TimesImbued >= 20)
                {
                    from.SendLocalizedMessage(1113377);                       // Your chance to learn while imbuing this item is diminished, as it has been imbued many times before.
                    success = successChance > Utility.RandomDouble();
                }
                else
                {
                    success = from.CheckSkill(SkillName.Imbuing, successChance);
                }

                Effects.SendPacket(from, from.Map, new GraphicalEffect(EffectType.FixedFrom, from.Serial, Server.Serial.Zero, 0x375A, from.Location, from.Location, 1, 17, true, false));
                Effects.SendTargetParticles(from, 0, 1, 0, 0x1593, EffectLayer.Waist);

                if (success)
                {
                    if (propToReplace != null)
                    {
                        propToReplace.SetValue(item, 0);
                    }

                    propToImbue.SetValue(item, value);

                    if (item is IArmor)
                    {
                        ((IArmor)item).ArmorAttributes.SelfRepair = 0;
                    }
                    else if (item is ICloth)
                    {
                        ((ICloth)item).ClothingAttributes.SelfRepair = 0;
                    }
                    else if (item is IWeapon)
                    {
                        ((IWeapon)item).WeaponAttributes.SelfRepair = 0;
                    }

                    imbuable.OnImbued();
                    imbuable.TimesImbued++;

                    from.SendLocalizedMessage(1079775);                       // You successfully imbue the item!
                    from.PlaySound(0x1EB);
                }
                else
                {
                    from.SendLocalizedMessage(1079774);                       // You attempt to imbue the item, but fail.
                    from.PlaySound(0x1E4);
                }

                Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerCallback(
                                    delegate
                {
                    from.SendGump(new ImbuingMainGump());
                }
                                    ));

                return;
            }

            from.EndAction(typeof(Imbuing));
        }