Hello. I'm trying to edit rejuvinate to work more like cleansing winds, but every time i cast it in game the client crashes. Can anyone figure out why and/or help me to fix it? Thanks.

Code:
using System;
using System.Globalization;
using Server;
using Server.Spells;
using Server.Network;
using Server.Mobiles;
using Server.Spells.Necromancy;
using Server.Spells.First;
using Server.Spells.Fourth;
using Server.Spells.Mysticism;
using Server.Items;
using System.Collections.Generic;

namespace Server.Spells.SkillMasteries
{
    public class RejuvinateSpell : SkillMasterySpell
    {
        private static SpellInfo m_Info = new SpellInfo(
                "Rejuvinate", "In Vas Ort Grav Mani",
                204,
                9061
            );

        public override double RequiredSkill { get { return 90; } }
        public override double UpKeep { get { return 0; } }
        public override int RequiredMana { get { return 40; } } //default 20
        public override TimeSpan CastDelayBase { get { return TimeSpan.FromSeconds(3.25); } }
        public int RequiredTithing { get { return 100; } }

        public override SkillName CastSkill { get { return SkillName.Chivalry; } }
        public override SkillName DamageSkill { get { return SkillName.Chivalry; } }

        public RejuvinateSpell(Mobile caster, Item scroll)
            : base(caster, scroll, m_Info)
        {
        }

        public override void SendCastEffect()
        {
            Caster.FixedEffect(0x37C4, 87, (int)(GetCastDelay().TotalSeconds * 28), 4, 3);
        }

        public override bool CheckCast()
        {
            if (Caster is PlayerMobile && Caster.TithingPoints < RequiredTithing)
            {
                Caster.SendLocalizedMessage(1060173, RequiredTithing.ToString()); // You must have at least ~1_TITHE_REQUIREMENT~ Tithing Points to use this ability,
                return false;
            }

            BaseWeapon weapon = GetWeapon();

            if (weapon == null)
            {
                Caster.SendLocalizedMessage(1156006); // You must have a swordsmanship weapon equipped to use this ability.
                return false;
            }

            return base.CheckCast();
        }

        public override void OnCast()
        {
            Caster.Target = new MasteryTarget(this);
        }

        protected override void OnTarget(object o)
        {

            Mobile m = o as Mobile;

            if (m != null)
            {
                if (m.IsDeadBondedPet)
                {
                    Caster.SendLocalizedMessage(1046439); // That is not a valid target.
                }
                else if (m is BaseCreature && ((BaseCreature)m).IsAnimatedDead)
                {
                    Caster.SendLocalizedMessage(1046439); // That is not a valid target.
                }
                else if (m is Golem)
                {
                    Caster.SendLocalizedMessage(1046439); // That is not a valid target.
                }
                else if (m.Hits > m.HitsMax && m.Stam >= m.StamMax && m.Mana >= m.ManaMax)
                {
                    Caster.SendLocalizedMessage(1155788); // Your target is already at full health, mana and stamina!
                }
                else if (CheckBSequence(m))
                {
                    double primarySkill = Caster.Skills[CastSkill].Value;
                    double secondarySkill = Caster.Skills[DamageSkill].Value;

                    int toHeal = (int)((primarySkill) / 1.5) + Utility.RandomMinMax(-5, 5);

                    double rejuv = ((double)GetMasteryLevel() * 33.3) / 100;

                    if (rejuv > 1.0) rejuv = 1.0;

                    if (Caster.Karma > Utility.Random(10000)) //default 5000
                    {
                        Caster.DoBeneficial(Target);
                        m.FixedParticles(0x3709, 1, 30, 9963, 1150, 3, EffectLayer.Head);

                        IEntity from = new Entity(Serial.Zero, new Point3D(m.X, m.Y, m.Z - 10), this.Caster.Map);
                        IEntity to = new Entity(Serial.Zero, new Point3D(m.X, m.Y, m.Z + 50), this.Caster.Map);
                        Effects.SendMovingParticles(from, to, 0x2255, 1, 0, false, false, 1150, 3, 9501, 1, 0, EffectLayer.Head, 0x100);

                        int toHealMod = toHeal;

                        int curseLevel = RemoveCurses(Target);

                        if (toHealMod > 0 && curseLevel > 0)
                        {
                            toHealMod = toHealMod - (curseLevel * 5);
                        }

                        if (toHealMod > 0)
                            SpellHelper.Heal(toHealMod, Target, Caster);

                        Caster.PlaySound(0x102);

                        m.SendLocalizedMessage(1155789); // You feel completely rejuvenated!

                        if (Caster != m)
                        {
                            m.PlaySound(0x102);
                            Caster.SendLocalizedMessage(1155790); // Your target has been rejuvenated!
                        }

                        if (m.Poison != null)
                            m.CurePoison(Caster);
                    }
                }
            }
            else
                Caster.SendLocalizedMessage(1046439); // That is not a valid target.
        }

        public override bool CheckSequence()
        {
            int requiredTithing = this.RequiredTithing;

            if (Caster is PlayerMobile && Caster.TithingPoints < requiredTithing)
            {
                Caster.SendLocalizedMessage(1060173, RequiredTithing.ToString()); // You must have at least ~1_TITHE_REQUIREMENT~ Tithing Points to use this ability,
                return false;
            }

            if (AosAttributes.GetValue(Caster, AosAttribute.LowerRegCost) > Utility.Random(100))
                requiredTithing = 0;

            if (requiredTithing > 0 && Caster is PlayerMobile)
                Caster.TithingPoints -= requiredTithing;

            return base.CheckSequence();
        }
        public static int RemoveCurses(Mobile m)
        {
            int curseLevel = 0;

            if (SleepSpell.IsUnderSleepEffects(m))
            {
                SleepSpell.EndSleep(m);
                curseLevel += 2;
            }

            if (EvilOmenSpell.TryEndEffect(m))
            {
                curseLevel += 1;
            }

            if (StrangleSpell.RemoveCurse(m))
            {
                curseLevel += 5;
            }

            if (CorpseSkinSpell.RemoveCurse(m))
            {
                curseLevel += 4;
            }

            if (CurseSpell.UnderEffect(m))
            {
                CurseSpell.RemoveEffect(m);
                curseLevel += 4;
            }

            if (BloodOathSpell.RemoveCurse(m))
            {
                curseLevel += 4;
            }

            if (MindRotSpell.HasMindRotScalar(m))
            {
                MindRotSpell.ClearMindRotScalar(m);
                curseLevel += 2;
            }

            if (SpellPlagueSpell.HasSpellPlague(m))
            {
                SpellPlagueSpell.RemoveFromList(m);
                curseLevel += 5;
            }

            if (FeeblemindSpell.IsUnderEffects(m))
            {
                FeeblemindSpell.RemoveEffects(m);
                curseLevel += 1;
            }

            if (ClumsySpell.IsUnderEffects(m))
            {
                ClumsySpell.RemoveEffects(m);
                curseLevel += 1;
            }

            if (WeakenSpell.IsUnderEffects(m))
            {
                WeakenSpell.RemoveEffects(m);
                curseLevel += 1;
            }

            if (MortalStrike.IsWounded(m))
            {
                MortalStrike.EndWound(m);
                curseLevel += 8;
            }

            if (m.NetState != null)
            {
                m.SendSpeedControl(SpeedControlType.Disable);
            }

            BuffInfo.RemoveBuff(m, BuffIcon.Weaken);
            BuffInfo.RemoveBuff(m, BuffIcon.Clumsy);
            BuffInfo.RemoveBuff(m, BuffIcon.FeebleMind);
            BuffInfo.RemoveBuff(m, BuffIcon.Curse);
            BuffInfo.RemoveBuff(m, BuffIcon.MassCurse);
            BuffInfo.RemoveBuff(m, BuffIcon.MortalStrike);

            return curseLevel;
        }
    }
}
 
Back