Example #1
0
        public override bool CheckCast()
        {
            if (Weapon == null)
            {
                BaseWeapon wep = Caster.Weapon as BaseWeapon;

                if (wep == null)
                {
                    Caster.SendLocalizedMessage(501078); // You must be holding a weapon.
                }
                else
                {
                    if (Caster.HasGump(typeof(EnchantSpellGump)))
                    {
                        Caster.CloseGump(typeof(EnchantSpellGump));
                    }

                    var gump   = new EnchantSpellGump(Caster, Scroll, wep);
                    int serial = gump.Serial;

                    Caster.SendGump(gump);

                    Timer.DelayCall(TimeSpan.FromSeconds(30), () =>
                    {
                        var current = Caster.FindGump(typeof(EnchantSpellGump));

                        if (current != null && current.Serial == serial)
                        {
                            Caster.CloseGump(typeof(EnchantSpellGump));
                            FinishSequence();
                        }
                    });
                }

                return(false);
            }
            else if (IsUnderSpellEffects(Caster, Weapon))
            {
                Caster.SendLocalizedMessage(501775); // This spell is already in effect.
                return(false);
            }
            else if (ImmolatingWeaponSpell.IsImmolating(Caster, Weapon) || Weapon.ConsecratedContext != null)
            {
                Caster.SendLocalizedMessage(1080128); //You cannot use this ability while your weapon is enchanted.
                return(false);
            }
            else if (Weapon.FocusWeilder != null)
            {
                Caster.SendLocalizedMessage(1080446); // You cannot enchant an item that is under the effects of the ninjitsu focus attack ability.
                return(false);
            }
            else if (Weapon.WeaponAttributes.HitLightning > 0 || Weapon.WeaponAttributes.HitFireball > 0 || Weapon.WeaponAttributes.HitHarm > 0 || Weapon.WeaponAttributes.HitMagicArrow > 0 || Weapon.WeaponAttributes.HitDispel > 0)
            {
                Caster.SendLocalizedMessage(1080127); // This weapon already has a hit spell effect and cannot be enchanted.
                return(false);
            }

            return(true);
        }
Example #2
0
        public override Spell GetRandomBuffSpell()
        {
            if (UsesMagery && 0.5 > Utility.RandomDouble())
            {
                return(base.GetRandomBuffSpell());
            }

            int        mana = m_Mobile.Mana;
            BaseWeapon wep  = m_Mobile.Weapon as BaseWeapon;

            if (mana >= 50 && !ArcaneEmpowermentSpell.IsUnderEffects(m_Mobile) && 0.5 >= Utility.RandomDouble())
            {
                return(new ArcaneEmpowermentSpell(m_Mobile, null));
            }
            if (mana >= 32 && wep != null && !ImmolatingWeaponSpell.IsImmolating(m_Mobile, wep))
            {
                return(new ImmolatingWeaponSpell(m_Mobile, null));
            }

            return(null);
        }
Example #3
0
        public override void OnCast()
        {
            BaseWeapon wep = Caster.Weapon as BaseWeapon;

            if (wep == null || wep != Weapon)
            {
                Caster.SendLocalizedMessage(501078); // You must be holding a weapon.
            }
            else if (IsUnderSpellEffects(Caster, Weapon))
            {
                Caster.SendLocalizedMessage(501775); // This spell is already in effect.
            }
            else if (ImmolatingWeaponSpell.IsImmolating(Caster, Weapon) || Weapon.ConsecratedContext != null)
            {
                Caster.SendLocalizedMessage(1080128); //You cannot use this ability while your weapon is enchanted.
            }
            else if (Weapon.FocusWeilder != null)
            {
                Caster.SendLocalizedMessage(1080446); // You cannot enchant an item that is under the effects of the ninjitsu focus attack ability.
            }
            else if (Weapon.WeaponAttributes.HitLightning > 0 || Weapon.WeaponAttributes.HitFireball > 0 || Weapon.WeaponAttributes.HitHarm > 0 || Weapon.WeaponAttributes.HitMagicArrow > 0 || Weapon.WeaponAttributes.HitDispel > 0)
            {
                Caster.SendLocalizedMessage(1080127); // This weapon already has a hit spell effect and cannot be enchanted.
            }
            else if (CheckSequence() && Caster.Weapon == Weapon)
            {
                Caster.PlaySound(0x64E);
                Caster.FixedEffect(0x36CB, 1, 9, 1915, 0);

                int prim = (int)Caster.Skills[CastSkill].Value;
                int sec  = (int)Caster.Skills[DamageSkill].Value;

                int    value    = (60 * (prim + sec)) / 240;
                double duration = ((double)(prim + sec) / 2.0) + 30.0;
                int    malus    = 0;

                if (Table == null)
                {
                    Table = new Dictionary <Mobile, EnchantmentTimer>();
                }

                Enhancement.SetValue(Caster, this.Attribute, value, ModName);

                if (prim >= 80 && sec >= 80 && Weapon.Attributes.SpellChanneling == 0)
                {
                    Enhancement.SetValue(Caster, AosAttribute.SpellChanneling, 1, ModName);
                    Enhancement.SetValue(Caster, AosAttribute.CastSpeed, -1, ModName);
                    malus = 1;
                }

                Table[Caster] = new EnchantmentTimer(Caster, Weapon, this.Attribute, value, malus, duration);

                int loc;

                switch (this.Attribute)
                {
                default:
                case AosWeaponAttribute.HitLightning: loc = 1060423; break;

                case AosWeaponAttribute.HitFireball: loc = 1060420; break;

                case AosWeaponAttribute.HitHarm: loc = 1060421; break;

                case AosWeaponAttribute.HitMagicArrow: loc = 1060426; break;

                case AosWeaponAttribute.HitDispel: loc = 1060417; break;
                }

                BuffInfo.AddBuff(Caster, new BuffInfo(BuffIcon.Enchant, 1080126, loc, TimeSpan.FromSeconds(duration), Caster, value.ToString()));

                Weapon.EnchantedWeilder = Caster;
                Weapon.InvalidateProperties();
            }

            FinishSequence();
        }