Exemple #1
0
        public override Spell GetRandomHealingSpell()
        {
            Spell spell = null;

            if (m_Mobile.Hits < (m_Mobile.HitsMax - 50))
            {
                if (m_Mobile.Skills[SkillName.Mysticism].Value >= 70.0)
                {
                    spell = new CleansingWindsSpell(m_Mobile, null);
                }
                else
                {
                    spell = new GreaterHealSpell(m_Mobile, null);
                }

                if (spell == null)
                {
                    spell = new HealSpell(m_Mobile, null);
                }
            }
            else if (m_Mobile.Hits < (m_Mobile.HitsMax - 10))
            {
                spell = new HealSpell(m_Mobile, null);
            }

            return(spell);
        }
Exemple #2
0
        private Spell CheckCastHealingSpell()
        {
            // If I'm poisoned, always attempt to cure.
            if (this.m_Mobile.Poisoned)
            {
                return(new CureSpell(this.m_Mobile, null));
            }

            // Summoned creatures never heal themselves.
            if (this.m_Mobile.Summoned)
            {
                return(null);
            }

            if (this.m_Mobile.Controlled)
            {
                if (DateTime.Now < this.m_NextHealTime)
                {
                    return(null);
                }
            }

            if (this.ScaleByMagery(HealChance) < Utility.RandomDouble())
            {
                return(null);
            }

            Spell spell = null;

            if (this.m_Mobile.Hits < (this.m_Mobile.HitsMax - 50))
            {
                spell = new GreaterHealSpell(this.m_Mobile, null);

                if (spell == null)
                {
                    spell = new HealSpell(this.m_Mobile, null);
                }
            }
            else if (this.m_Mobile.Hits < (this.m_Mobile.HitsMax - 10))
            {
                spell = new HealSpell(this.m_Mobile, null);
            }

            double delay;

            if (this.m_Mobile.Int >= 500)
            {
                delay = Utility.RandomMinMax(7, 10);
            }
            else
            {
                delay = Math.Sqrt(600 - this.m_Mobile.Int);
            }

            this.m_Mobile.UseSkill(SkillName.SpiritSpeak);

            this.m_NextHealTime = DateTime.Now + TimeSpan.FromSeconds(delay);

            return(spell);
        }
Exemple #3
0
        public static void DoHeal()
        {
            var heal     = ssMenu.GetCheckbox("Heal");
            var hp       = ssMenu.GetSlider("ssheal");
            var healSlot = ObjectManager.Player.Spellbook.Spells.FirstOrDefault(x => x.SpellData.Name.ToLower().Contains("heal"));

            if (healSlot == null)
            {
                return;
            }

            if (healSlot != null)
            {
                HealSpell = new Spell(healSlot.Slot, 850);
            }
            if (heal && ObjectManager.Player.HealthPercent < hp && HealSpell.IsReady())
            {
                HealSpell.Cast();
            }

            /*var hally = ssMenu.GetCheckbox("HealA");
             * var ahp = ssMenu.GetSlider("aHP");
             * if (healSlot != null)
             * {
             *  HealSpell = new Spell(healSlot.Slot, 850);
             * }
             * if (hally &&  ally < ahp && HealSpell.IsReady())
             * {
             *  HealSpell.Cast();
             * }*/
        }
Exemple #4
0
        public virtual Spell DoDispel(Mobile toDispel)
        {
            Spell spell = null;

            if (!m_Mobile.Summoned && Utility.Random(0, 4 + (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : (m_Mobile.HitsMax / m_Mobile.Hits))) >= 3)
            {
                if (m_Mobile.Hits < (m_Mobile.HitsMax - 50))
                {
                    spell = new GreaterHealSpell(m_Mobile, null);
                }
                else if (m_Mobile.Hits < (m_Mobile.HitsMax - 20))
                {
                    spell = new HealSpell(m_Mobile, null);
                }
            }

            if (spell == null)
            {
                if (!m_Mobile.DisallowAllMoves && Utility.Random((int)m_Mobile.GetDistanceToSqrt(toDispel)) == 0)
                {
                    spell = new TeleportSpell(m_Mobile, null);
                }
                else if (Utility.Random(3) == 0 && !m_Mobile.InRange(toDispel, 3) && !toDispel.Paralyzed && !toDispel.Frozen)
                {
                    spell = new ParalyzeSpell(m_Mobile, null);
                }
                else
                {
                    spell = new DispelSpell(m_Mobile, null);
                }
            }

            return(spell);
        }
Exemple #5
0
    public void Heal()
    {
        if (Time.time > (fireRate + lastShot) && stamina > healCost)
        {
            stamina          -= healCost;
            stamRechargeTimer = 0;


            animator.SetBool("isHealing", true);

            HealSpell h = Instantiate(healspell, transform.position, transform.rotation);
            h.transform.parent = transform;
            h.setPlayerNo(playerNum);

            hp += healAmt;
            if (hp > maxHp)
            {
                hp = maxHp;
            }

            AudioManager.instance.PlaySound("heal", h.transform.position);
            lastShot = Time.time;
        }
        else
        {
            //stamRechargeTimer = 0;
            return;
        }
    }
Exemple #6
0
    private Spell CheckCastHealingSpell()
    {
        // If I'm poisoned, always attempt to cure.
        if (m_Mobile.Poisoned)
        {
            return(new CureSpell(m_Mobile));
        }

        // Summoned creatures never heal themselves.
        if (m_Mobile.Summoned)
        {
            return(null);
        }

        if (m_Mobile.Controlled)
        {
            if (Core.TickCount - m_NextHealTime < 0)
            {
                return(null);
            }
        }

        if (!SmartAI)
        {
            if (ScaleBySkill(HealChance, SkillName.Magery) < Utility.RandomDouble())
            {
                return(null);
            }
        }
        else if (Utility.Random(0, 4 + (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : m_Mobile.HitsMax / m_Mobile.Hits)) < 3)
        {
            return(null);
        }

        Spell spell = null;

        if (m_Mobile.Hits < m_Mobile.HitsMax - 50)
        {
            if (UseNecromancy())
            {
                m_Mobile.UseSkill(SkillName.SpiritSpeak);
            }
            else
            {
                spell = new GreaterHealSpell(m_Mobile);
            }
        }
        else if (m_Mobile.Hits < m_Mobile.HitsMax - 10)
        {
            spell = new HealSpell(m_Mobile);
        }

        var delay = m_Mobile.Int >= 500 ? Utility.RandomMinMax(7, 10) : Math.Sqrt(600 - m_Mobile.Int);

        m_NextHealTime = Core.TickCount + (int)TimeSpan.FromSeconds(delay).TotalMilliseconds;

        return(spell);
    }
Exemple #7
0
        public virtual Spell DoDispel(Mobile toDispel)
        {
            if (!SmartAI)
            {
                if (ScaleByMagery(DispelChance) > Utility.RandomDouble())
                {
                    if (toDispel is Daemon)
                    {
                        return(new MassDispelSpell(m_Mobile, null));
                    }
                    else
                    {
                        return(new DispelSpell(m_Mobile, null));
                    }
                }

                return(ChooseSpell(toDispel));
            }

            Spell spell = null;

            if (!m_Mobile.Summoned && Utility.Random(0, 4 + (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : (m_Mobile.HitsMax / m_Mobile.Hits))) >= 3)
            {
                if (m_Mobile.Hits < (m_Mobile.HitsMax - 50))
                {
                    spell = new GreaterHealSpell(m_Mobile, null);
                }
                else if (m_Mobile.Hits < (m_Mobile.HitsMax - 20))
                {
                    spell = new HealSpell(m_Mobile, null);
                }
            }

            if (spell == null)
            {
                if (!m_Mobile.DisallowAllMoves && Utility.Random((int)m_Mobile.GetDistanceToSqrt(toDispel)) == 0)
                {
                    spell = new TeleportSpell(m_Mobile, null);
                }
                else if (Utility.Random(3) == 0 && !m_Mobile.InRange(toDispel, 3) && !toDispel.Paralyzed && !toDispel.Frozen)
                {
                    spell = new ParalyzeSpell(m_Mobile, null);
                }
                else
                {
                    if (toDispel is Daemon)
                    {
                        return(new MassDispelSpell(m_Mobile, null));
                    }
                    else
                    {
                        return(new DispelSpell(m_Mobile, null));
                    }
                }
            }

            return(spell);
        }
Exemple #8
0
        public override Spell ChooseSpell(Mobile c)
        {
            Mobile com   = m_Mobile.Combatant;
            Spell  spell = null;

            int healChance = (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : (m_Mobile.HitsMax / m_Mobile.Hits));

            switch (Utility.Random(1 + healChance))
            {
            default:
            case 0:                     // Heal ourself
            {
                if (!m_Mobile.Summoned)
                {
                    m_Mobile.DebugSay("I am going to heal myself");
                    if (m_Mobile.Hits < (m_Mobile.HitsMax - 50))
                    {
                        spell = new GreaterHealSpell(m_Mobile, null);
                    }
                    else if (m_Mobile.Hits < (m_Mobile.HitsMax - 10))
                    {
                        spell = new HealSpell(m_Mobile, null);
                    }
                }

                break;
            }

            case 1:                     // Set up a combo
            {
                if (m_Mobile.Mana < 40 && m_Mobile.Mana > 15)
                {
                    if (c.Paralyzed)
                    {
                        m_Mobile.DebugSay("I am going to meditate");

                        m_Mobile.UseSkill(SkillName.Meditation);
                    }
                }
                else if (m_Mobile.Mana > 60)
                {
                    Combo = 0;
                    m_Mobile.DebugSay("I am going to combo and paralyze");
                    if (!c.Paralyzed)
                    {
                        spell = new ParalyzeSpell(m_Mobile, null);
                    }
                }

                break;
            }
            }

            return(spell);
        }
Exemple #9
0
        public virtual Spell GetRandomHealingSpell()
        {
            Spell spell = null;

            if (m_Mobile.Hits < (m_Mobile.HitsMax - 50))
            {
                spell = new GreaterHealSpell(m_Mobile, null);

                if (spell == null)
                {
                    spell = new HealSpell(m_Mobile, null);
                }
            }
            else if (m_Mobile.Hits < (m_Mobile.HitsMax - 10))
            {
                spell = new HealSpell(m_Mobile, null);
            }

            return(spell);
        }
Exemple #10
0
    void Start()
    {
        fireball   = FindObjectOfType <SingleTargetSpell>();
        aoeSpell   = FindObjectOfType <Spell>();
        fireShield = FindObjectOfType <FireShield>();
        healSpell  = FindObjectOfType <HealSpell>();

        // fireball.addSpell(1);
        // aoeSpell.addSpell(2);
        // fireShield.addSpell(3);
        // healSpell.addSpell(4);

        FireballLvl          = 0;
        HealLvl              = 0;
        BurstballLvl         = 0;
        FirewalkLvl          = 0;
        FirearmorLvl         = 0;
        FirespikeLvl         = 0;
        MayaS                = GetComponent <MayaMove>();
        SpellsCanvas.enabled = false;
    }
            public HealSpellManager()
            {
                spells = new List <HealSpell>();

                int Heal_HW  = 0;
                int Heal_GHW = 0;
                int Heal_RT  = 0;
                int Heal_UE  = 0;
                int Heal_CH  = 0;
                int Heal_HR  = 0;
                int Heal_HS  = 0;
                int Heal_OS  = 0;

                if (IsRAF())
                {
                    Heal_HW        = cfg.RAF_Heal.HealingWave;
                    Heal_GHW       = cfg.RAF_Heal.GreaterHealingWave;
                    Heal_RT        = cfg.RAF_Heal.Riptide;
                    Heal_UE        = cfg.RAF_Heal.UnleashElements;
                    Heal_CH        = cfg.RAF_Heal.ChainHeal;
                    Heal_HR        = cfg.RAF_Heal.HealingRain;
                    Heal_HS        = cfg.RAF_Heal.HealingSurge;
                    Heal_OS        = cfg.RAF_Heal.OhShoot;
                    BuffTidalWaves = cfg.RAF_Heal.TidalWaves;
                    HealPets       = cfg.RAF_Heal.Pets;
                }
                else if (IsPVP())
                {
                    Heal_HW        = cfg.PVP_Heal.HealingWave;
                    Heal_GHW       = cfg.PVP_Heal.GreaterHealingWave;
                    Heal_RT        = cfg.PVP_Heal.Riptide;
                    Heal_UE        = cfg.PVP_Heal.UnleashElements;
                    Heal_CH        = cfg.PVP_Heal.ChainHeal;
                    Heal_HR        = cfg.PVP_Heal.HealingRain;
                    Heal_HS        = cfg.PVP_Heal.HealingSurge;
                    Heal_OS        = cfg.PVP_Heal.OhShoot;
                    BuffTidalWaves = cfg.PVP_Heal.TidalWaves;
                    HealPets       = cfg.PVP_Heal.Pets;
                }

                spells.Add(new HealSpell(Heal_HW, "Healing Wave", "Healing Wave", HealSpellManager.HealingWave));
                spells.Add(new HealSpell(Heal_GHW, "Greater Healing Wave", "Greater Healing Wave", HealSpellManager.GreaterHealingWave));
                spells.Add(new HealSpell(Heal_RT, "Riptide", "Riptide", HealSpellManager.Riptide));
                spells.Add(new HealSpell(Heal_UE, "Unleash Elements", "Unleash Elements", HealSpellManager.UnleashElements));
                spells.Add(new HealSpell(Heal_CH, "Chain Heal", "Chain Heal", HealSpellManager.ChainHeal));
                spells.Add(new HealSpell(Heal_HR, "Healing Rain", "Healing Rain", HealSpellManager.HealingRain));
                spells.Add(new HealSpell(Heal_HS, "Healing Surge", "Healing Surge", HealSpellManager.HealingSurge));
                spells.Add(new HealSpell(Heal_OS, "Oh Shoot Heal", "Nature's Swiftness", HealSpellManager.OhShoot));

                spells.Sort(HealSpellManager.Compare);
                Dlog("### HealSpellManager Dump BEFORE PRUNE");
                Dump();

                // remove those with 0 health values
                while (spells.Any() && spells[0].Health == 0)
                {
                    spells.RemoveAt(0);
                }

                Dlog("### HealSpellManager Dump AFTER PRUNE");
                Dump();

                // find maximum to use as NeedHeal value
                HealSpell hs = spells.LastOrDefault();

                if (hs != null)
                {
                    NeedHeal = hs.Health;
                    Dlog("HealSpellManager:  NeedHeal set to {0}", NeedHeal);
                }
                else
                {
                    if (_me.IsInParty || _me.IsInRaid)
                    {
                        Elog("HealSpellManager:  NOT CURRENTLY IN A GROUP, group healing will activate when you join");
                    }
                    NeedHeal = 0;
                }
            }
Exemple #12
0
        public virtual Spell ChooseSpell(Mobile c)
        {
            if (!SmartAI)
            {
                if (ScaleByMagery(HealChance) > Utility.RandomDouble())
                {
                    if (m_Mobile.Hits < (m_Mobile.HitsMax - 50))
                    {
                        return(new GreaterHealSpell(m_Mobile, null));
                    }
                    else if (m_Mobile.Hits < (m_Mobile.HitsMax - 10))
                    {
                        return(new HealSpell(m_Mobile, null));
                    }
                }

                return(GetRandomDamageSpell());
            }

            Spell spell = null;

            int healChance = (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : (m_Mobile.HitsMax / m_Mobile.Hits));

            switch (Utility.Random(4 + healChance))
            {
            default:
            case 0:                     // Heal ourself
            {
                if (m_Mobile.Hits < (m_Mobile.HitsMax - 50))
                {
                    spell = new GreaterHealSpell(m_Mobile, null);
                }
                else if (m_Mobile.Hits < (m_Mobile.HitsMax - 10))
                {
                    spell = new HealSpell(m_Mobile, null);
                }
                break;
            }

            case 1:                     // Poison them
            {
                if (!c.Poisoned)
                {
                    spell = new PoisonSpell(m_Mobile, null);
                }

                break;
            }

            case 2:                     // Deal some damage
            {
                spell = GetRandomDamageSpell();

                break;
            }

            case 3:                     // Set up a combo
            {
                if (m_Mobile.Mana < 40 && m_Mobile.Mana > 15)
                {
                    if (c.Paralyzed && !c.Poisoned)
                    {
                        m_Mobile.DebugSay("I am going to meditate");

                        m_Mobile.UseSkill(SkillName.Meditation);
                    }
                    else if (!c.Poisoned)
                    {
                        spell = new ParalyzeSpell(m_Mobile, null);
                    }
                }
                else if (m_Mobile.Mana > 60)
                {
                    if (Utility.Random(2) == 0 && !c.Paralyzed && !c.Frozen && !c.Poisoned)
                    {
                        m_Combo = 0;
                        spell   = new ParalyzeSpell(m_Mobile, null);
                    }
                    else
                    {
                        m_Combo = 1;
                        spell   = new ExplosionSpell(m_Mobile, null);
                    }
                }

                break;
            }
            }

            return(spell);
        }
Exemple #13
0
        private Spell CheckCastHealingSpell()
        {
            // If I'm poisoned, always attempt to cure.
            if (m_Mobile.Poisoned)
            {
                return(new CureSpell(m_Mobile, null));
            }

            // Summoned creatures never heal themselves.
            if (m_Mobile.Summoned)
            {
                return(null);
            }

            if (m_Mobile.Controlled)
            {
                if (DateTime.Now < m_NextHealTime)
                {
                    return(null);
                }
            }

            if (!SmartAI)
            {
                if (ScaleBySkill(HealChance, SkillName.Magery) < Utility.RandomDouble())
                {
                    return(null);
                }
            }
            else
            {
                if (Utility.Random(0, 4 + (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : (m_Mobile.HitsMax / m_Mobile.Hits))) < 3)
                {
                    return(null);
                }
            }

            Spell spell = null;

            if (m_Mobile.Hits < (m_Mobile.HitsMax - 50))
            {
                if (UseNecromancy())
                {
                    m_Mobile.UseSkill(SkillName.SpiritSpeak);
                }
                else
                {
                    spell = new GreaterHealSpell(m_Mobile, null);

                    if (spell == null)
                    {
                        spell = new HealSpell(m_Mobile, null);
                    }
                }
            }
            else if (m_Mobile.Hits < (m_Mobile.HitsMax - 10))
            {
                spell = new HealSpell(m_Mobile, null);
            }

            double delay;

            if (m_Mobile.Int >= 500)
            {
                delay = Utility.RandomMinMax(7, 10);
            }
            else
            {
                delay = Math.Sqrt(600 - m_Mobile.Int);
            }

            m_NextHealTime = DateTime.Now + TimeSpan.FromSeconds(delay);

            return(spell);
        }
Exemple #14
0
        public virtual Spell ChooseSpell(Mobile c)
        {
            if (!SmartAI)
            {
                if (!m_Mobile.Summoned && ScaleByMagery(HealChance) > Utility.RandomDouble())
                {
                    if (m_Mobile.Hits < (m_Mobile.HitsMax - 50))
                    {
                        return(new GreaterHealSpell(m_Mobile, null));
                    }
                    else if (m_Mobile.Hits < (m_Mobile.HitsMax - 10))
                    {
                        return(new HealSpell(m_Mobile, null));
                    }
                }

                return(GetRandomDamageSpell());
            }

            if (c.Int > 70 && m_Mobile.CanBeginAction(typeof(DefensiveSpell)))
            {
                return(new MagicReflectSpell(m_Mobile, null));
            }

            if (c.Dex > 60 && m_Mobile.CanBeginAction(typeof(DefensiveSpell)))
            {
                return(new ReactiveArmorSpell(m_Mobile, null));
            }


            Spell spell = null;

            int healChance = (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : (m_Mobile.HitsMax / m_Mobile.Hits));

            if (m_Mobile.Summoned)
            {
                healChance = 0;
            }

            switch (Utility.Random(1 + healChance))
            {
            default:
            case 0:                     // Heal ourself
            {
                if (!m_Mobile.Summoned)
                {
                    if (m_Mobile.Hits < (m_Mobile.HitsMax - 50))
                    {
                        spell = new GreaterHealSpell(m_Mobile, null);
                    }
                    else if (m_Mobile.Hits < (m_Mobile.HitsMax - 10))
                    {
                        spell = new HealSpell(m_Mobile, null);
                    }
                }

                break;
            }

            //case 1: // Poison them
            //{
            //	if ( !c.Poisoned )
            //		spell = new PoisonSpell( m_Mobile, null );
            //
            //	break;
            //	}
            //case 2: // Deal some damage
            //	{
            //		spell = GetRandomDamageSpell();
            //
            //		break;
            //	}
            case 1:                     // Set up a combo
            {
                if (m_Mobile.Mana < 50 && m_Mobile.Mana > 15)
                {
                    if (c.Paralyzed && !c.Poisoned)
                    {
                        if (c.Hits < 45)
                        {
                            spell = new ExplosionSpell(m_Mobile, null);
                        }

                        if (c.Hits < 30)
                        {
                            spell = new EnergyBoltSpell(m_Mobile, null);
                        }

                        m_Mobile.DebugSay("I am going to meditate");

                        m_Mobile.UseSkill(SkillName.Meditation);
                    }
                    else if (!c.Poisoned)
                    {
                        spell = new ParalyzeSpell(m_Mobile, null);
                    }
                }
                else if (m_Mobile.Mana > 80)
                {
                    m_Combo = 1;
                    spell   = new ExplosionSpell(m_Mobile, null);
                }

                break;
            }
            }

            return(spell);
        }
Exemple #15
0
        public override Spell ChooseSpell(Mobile c)
        {
            if (c is PlayerMobile && SmartAI && (c.Spell is MagicTrapSpell || c.Spell is MagicArrowSpell))
            {
                EnemyCountersPara = true;
            }

            if (c.Int > 70 && m_Mobile.MagicDamageAbsorb <= 0 && m_Mobile.Mana > 20 && m_Mobile.Hits > 60 && m_Mobile.CanBeginAction(typeof(DefensiveSpell)))
            {
                Spell temp = c.Spell as Spell;

                if (temp == null || (temp != null && temp.IsCasting && (int)temp.Circle <= (int)SpellCircle.Fourth))
                {
                    return(new MagicReflectSpell(m_Mobile, null));
                }
            }

            if (c.Dex > 60 && m_Mobile.MeleeDamageAbsorb <= 0 && m_Mobile.Mana > 20 && m_Mobile.Hits > 30 && m_Mobile.CanBeginAction(typeof(DefensiveSpell)))
            {
                return(new ReactiveArmorSpell(m_Mobile, null));
            }

            Spell spell = null;

            int healChance = (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : (m_Mobile.HitsMax / m_Mobile.Hits));

            switch (Utility.Random(1 + healChance))
            {
            default:
            case 0:                     // Heal ourself
            {
                if (UsesPotions && HealPotCount >= 1 && m_Mobile.Hits < (m_Mobile.HitsMax - 30))
                {
                    DrinkHeal(m_Mobile);
                }
                else if (m_Mobile.Hits < (m_Mobile.HitsMax - 35) && m_Mobile.Hits >= 45)
                {
                    spell = new GreaterHealSpell(m_Mobile, null);
                }
                else if (m_Mobile.Hits < (m_Mobile.HitsMax - 10))
                {
                    spell = new HealSpell(m_Mobile, null);
                }
                break;
            }

            case 1:                     // Set up a combo
            {
                //para them and med up until we have mana for a dump
                if (m_Mobile.Mana < 85 && m_Mobile.Mana > 2)
                {
                    RegainingMana = true;
                    //if there low on life and we have the mana try an finish them
                    if (m_Mobile.Mana > 20 && c.Hits < 28)
                    {
                        spell = new EnergyBoltSpell(m_Mobile, null);
                    }

                    if (m_Mobile.Mana > 12 && c.Hits < 15)
                    {
                        spell = new LightningSpell(m_Mobile, null);
                    }

                    if (c.Paralyzed && !c.Poisoned)
                    {
                        if (c.Hits < 45 && m_Mobile.Mana > 40)
                        {
                            spell = new ExplosionSpell(m_Mobile, null);
                        }

                        if (c.Hits < 30)
                        {
                            spell = new EnergyBoltSpell(m_Mobile, null);
                        }

                        m_Mobile.DebugSay("I am going to meditate");

                        m_Mobile.UseSkill(SkillName.Meditation);
                    }
                    else if (!c.Poisoned && EnemyCountersPara == false && m_Mobile.Mana > 40)
                    {
                        spell = new ParalyzeSpell(m_Mobile, null);
                    }
                }

                if (m_Mobile.Mana > 85)
                {
                    RegainingMana = false;
                    Combo         = 0;
                }

                break;
            }
            }

            return(spell);
        }
Exemple #16
0
        public override bool Think()
        {
            Mobile combatant = m_Guard.Combatant;

            if (combatant == null || combatant.Deleted || !combatant.Alive || combatant.IsDeadBondedPet || !m_Mobile.CanSee(combatant) || !m_Mobile.CanBeHarmful(combatant, false) || combatant.Map != m_Mobile.Map)
            {
                // Our combatant is deleted, dead, hidden, or we cannot hurt them
                // Try to find another combatant

                if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
                {
                    m_Mobile.Combatant = combatant = m_Mobile.FocusMob;
                    m_Mobile.FocusMob  = null;
                }
                else
                {
                    m_Mobile.Combatant = combatant = null;
                }
            }

            if (combatant != null && (!m_Mobile.InLOS(combatant) || !m_Mobile.InRange(combatant, 12)))
            {
                if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
                {
                    m_Mobile.Combatant = combatant = m_Mobile.FocusMob;
                    m_Mobile.FocusMob  = null;
                }
                else if (!m_Mobile.InRange(combatant, 36))
                {
                    m_Mobile.Combatant = combatant = null;
                }
            }

            Mobile dispelTarget = FindDispelTarget(true);

            if (m_Guard.Target != null && m_ReleaseTarget == DateTime.MinValue)
            {
                m_ReleaseTarget = DateTime.Now + TimeSpan.FromSeconds(10.0);
            }

            if (m_Guard.Target != null && DateTime.Now > m_ReleaseTarget)
            {
                Target targ = m_Guard.Target;

                Mobile toHarm = (dispelTarget == null ? combatant : dispelTarget);

                if ((targ.Flags & TargetFlags.Harmful) != 0 && toHarm != null)
                {
                    if (m_Guard.Map == toHarm.Map && (targ.Range < 0 || m_Guard.InRange(toHarm, targ.Range)) && m_Guard.CanSee(toHarm) && m_Guard.InLOS(toHarm))
                    {
                        targ.Invoke(m_Guard, toHarm);
                    }
                    else if (targ is DispelSpell.InternalTarget)
                    {
                        targ.Cancel(m_Guard, TargetCancelType.Canceled);
                    }
                }
                else if ((targ.Flags & TargetFlags.Beneficial) != 0)
                {
                    targ.Invoke(m_Guard, m_Guard);
                }
                else
                {
                    targ.Cancel(m_Guard, TargetCancelType.Canceled);
                }

                m_ReleaseTarget = DateTime.MinValue;
            }

            if (dispelTarget != null)
            {
                if (Action != ActionType.Combat)
                {
                    Action = ActionType.Combat;
                }

                m_Guard.Warmode = true;

                RunFrom(dispelTarget);
            }
            else if (combatant != null)
            {
                if (Action != ActionType.Combat)
                {
                    Action = ActionType.Combat;
                }

                m_Guard.Warmode = true;

                RunTo(combatant);
            }
            else if (m_Guard.Orders.Movement != MovementType.Stand)
            {
                Mobile toFollow = null;

                if (m_Guard.Town != null && m_Guard.Orders.Movement == MovementType.Follow)
                {
                    toFollow = m_Guard.Orders.Follow;

                    if (toFollow == null)
                    {
                        toFollow = m_Guard.Town.Sheriff;
                    }
                }

                if (toFollow != null && toFollow.Map == m_Guard.Map && toFollow.InRange(m_Guard, m_Guard.RangePerception * 3) && Town.FromRegion(toFollow.Region) == m_Guard.Town)
                {
                    if (Action != ActionType.Combat)
                    {
                        Action = ActionType.Combat;
                    }

                    if (m_Mobile.CurrentSpeed != m_Mobile.ActiveSpeed)
                    {
                        m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
                    }

                    m_Guard.Warmode = true;

                    RunTo(toFollow);
                }
                else
                {
                    if (Action != ActionType.Wander)
                    {
                        Action = ActionType.Wander;
                    }

                    if (m_Mobile.CurrentSpeed != m_Mobile.PassiveSpeed)
                    {
                        m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
                    }

                    m_Guard.Warmode = false;

                    WalkRandomInHome(2, 2, 1);
                }
            }
            else
            {
                if (Action != ActionType.Wander)
                {
                    Action = ActionType.Wander;
                }

                m_Guard.Warmode = false;
            }

            if ((IsDamaged || IsPoisoned) && m_Guard.Skills.Healing.Base > 20.0)
            {
                TimeSpan ts = TimeUntilBandage;

                if (ts == TimeSpan.MaxValue)
                {
                    StartBandage();
                }
            }

            if (m_Mobile.Spell == null && DateTime.Now >= m_Mobile.NextSpellTime)
            {
                Spell spell = null;

                DateTime toRelease = DateTime.MinValue;

                if (IsPoisoned)
                {
                    Poison p = m_Guard.Poison;

                    TimeSpan ts = TimeUntilBandage;

                    if (p != Poison.Lesser || ts == TimeSpan.MaxValue || TimeUntilBandage < TimeSpan.FromSeconds(1.5) || (m_Guard.HitsMax - m_Guard.Hits) > Utility.Random(250))
                    {
                        if (IsAllowed(GuardAI.Bless))
                        {
                            spell = new CureSpell(m_Guard, null);
                        }
                        else
                        {
                            UseItemByType(typeof(BaseCurePotion));
                        }
                    }
                }
                else if (IsDamaged && (m_Guard.HitsMax - m_Guard.Hits) > Utility.Random(200))
                {
                    if (IsAllowed(GuardAI.Magic) && ((m_Guard.Hits * 100) / Math.Max(m_Guard.HitsMax, 1)) < 10 && m_Guard.Home != Point3D.Zero && !m_Guard.InRange(m_Guard.Home, 15) && m_Guard.Mana >= 11)
                    {
                        spell = new RecallSpell(m_Guard, null, new RunebookEntry(m_Guard.Home, m_Guard.Map, "Guard's Home", null, 0), null);
                    }
                    else if (IsAllowed(GuardAI.Bless))
                    {
                        if (m_Guard.Mana >= 11 && (m_Guard.Hits + 30) < m_Guard.HitsMax)
                        {
                            spell = new GreaterHealSpell(m_Guard, null);
                        }
                        else if ((m_Guard.Hits + 10) < m_Guard.HitsMax && (m_Guard.Mana < 11 || (m_Guard.NextCombatTime - DateTime.Now) > TimeSpan.FromSeconds(2.0)))
                        {
                            spell = new HealSpell(m_Guard, null);
                        }
                    }
                    else if (m_Guard.CanBeginAction(typeof(BaseHealPotion)))
                    {
                        UseItemByType(typeof(BaseHealPotion));
                    }
                }
                else if (dispelTarget != null && (IsAllowed(GuardAI.Magic) || IsAllowed(GuardAI.Bless) || IsAllowed(GuardAI.Curse)))
                {
                    if (!dispelTarget.Paralyzed && m_Guard.Mana > (ManaReserve + 20) && 40 > Utility.Random(100))
                    {
                        spell = new ParalyzeSpell(m_Guard, null);
                    }
                    else
                    {
                        spell = new DispelSpell(m_Guard, null);
                    }
                }

                if (combatant != null)
                {
                    if (m_Combo != null)
                    {
                        if (spell == null)
                        {
                            spell = SpellCombo.Process(m_Guard, combatant, ref m_Combo, ref m_ComboIndex, ref toRelease);
                        }
                        else
                        {
                            m_Combo      = null;
                            m_ComboIndex = -1;
                        }
                    }
                    else if (20 > Utility.Random(100) && IsAllowed(GuardAI.Magic))
                    {
                        if (80 > Utility.Random(100))
                        {
                            m_Combo      = (IsAllowed(GuardAI.Smart) ? SpellCombo.Simple : SpellCombo.Strong);
                            m_ComboIndex = -1;

                            if (m_Guard.Mana >= (ManaReserve + m_Combo.Mana))
                            {
                                spell = SpellCombo.Process(m_Guard, combatant, ref m_Combo, ref m_ComboIndex, ref toRelease);
                            }
                            else
                            {
                                m_Combo = null;

                                if (m_Guard.Mana >= (ManaReserve + 40))
                                {
                                    spell = RandomOffenseSpell();
                                }
                            }
                        }
                        else if (m_Guard.Mana >= (ManaReserve + 40))
                        {
                            spell = RandomOffenseSpell();
                        }
                    }

                    if (spell == null && 2 > Utility.Random(100) && m_Guard.Mana >= (ManaReserve + 10))
                    {
                        int strMod = GetStatMod(m_Guard, StatType.Str);
                        int dexMod = GetStatMod(m_Guard, StatType.Dex);
                        int intMod = GetStatMod(m_Guard, StatType.Int);

                        List <Type> types = new List <Type>();

                        if (strMod <= 0)
                        {
                            types.Add(typeof(StrengthSpell));
                        }

                        if (dexMod <= 0 && IsAllowed(GuardAI.Melee))
                        {
                            types.Add(typeof(AgilitySpell));
                        }

                        if (intMod <= 0 && IsAllowed(GuardAI.Magic))
                        {
                            types.Add(typeof(CunningSpell));
                        }

                        if (IsAllowed(GuardAI.Bless))
                        {
                            if (types.Count > 1)
                            {
                                spell = new BlessSpell(m_Guard, null);
                            }
                            else if (types.Count == 1)
                            {
                                spell = (Spell)Activator.CreateInstance(types[0], new object[] { m_Guard, null });
                            }
                        }
                        else if (types.Count > 0)
                        {
                            if (types[0] == typeof(StrengthSpell))
                            {
                                UseItemByType(typeof(BaseStrengthPotion));
                            }
                            else if (types[0] == typeof(AgilitySpell))
                            {
                                UseItemByType(typeof(BaseAgilityPotion));
                            }
                        }
                    }

                    if (spell == null && 2 > Utility.Random(100) && m_Guard.Mana >= (ManaReserve + 10) && IsAllowed(GuardAI.Curse))
                    {
                        if (!combatant.Poisoned && 40 > Utility.Random(100))
                        {
                            spell = new PoisonSpell(m_Guard, null);
                        }
                        else
                        {
                            int strMod = GetStatMod(combatant, StatType.Str);
                            int dexMod = GetStatMod(combatant, StatType.Dex);
                            int intMod = GetStatMod(combatant, StatType.Int);

                            ArrayList types = new ArrayList();

                            if (strMod >= 0)
                            {
                                types.Add(typeof(WeakenSpell));
                            }

                            if (dexMod >= 0 && IsAllowed(GuardAI.Melee))
                            {
                                types.Add(typeof(ClumsySpell));
                            }

                            if (intMod >= 0 && IsAllowed(GuardAI.Magic))
                            {
                                types.Add(typeof(FeeblemindSpell));
                            }

                            if (types.Count > 1)
                            {
                                spell = new CurseSpell(m_Guard, null);
                            }
                            else if (types.Count == 1)
                            {
                                spell = (Spell)Activator.CreateInstance((Type)types[0], new object[] { m_Guard, null });
                            }
                        }
                    }
                }

                if (spell != null && (m_Guard.HitsMax - m_Guard.Hits + 10) > Utility.Random(100))
                {
                    Type type = null;

                    if (spell is GreaterHealSpell)
                    {
                        type = typeof(BaseHealPotion);
                    }
                    else if (spell is CureSpell)
                    {
                        type = typeof(BaseCurePotion);
                    }
                    else if (spell is StrengthSpell)
                    {
                        type = typeof(BaseStrengthPotion);
                    }
                    else if (spell is AgilitySpell)
                    {
                        type = typeof(BaseAgilityPotion);
                    }

                    if (type == typeof(BaseHealPotion) && !m_Guard.CanBeginAction(type))
                    {
                        type = null;
                    }

                    if (type != null && m_Guard.Target == null && UseItemByType(type))
                    {
                        if (spell is GreaterHealSpell)
                        {
                            if ((m_Guard.Hits + 30) > m_Guard.HitsMax && (m_Guard.Hits + 10) < m_Guard.HitsMax)
                            {
                                spell = new HealSpell(m_Guard, null);
                            }
                        }
                        else
                        {
                            spell = null;
                        }
                    }
                }
                else if (spell == null && m_Guard.Stam < (m_Guard.StamMax / 3) && IsAllowed(GuardAI.Melee))
                {
                    UseItemByType(typeof(BaseRefreshPotion));
                }

                if (spell == null || !spell.Cast())
                {
                    EquipWeapon();
                }
            }
            else if (m_Mobile.Spell is Spell && ((Spell)m_Mobile.Spell).State == SpellState.Sequencing)
            {
                EquipWeapon();
            }

            return(true);
        }
Exemple #17
0
        private Spell CheckCastHealingSpell()
        {
            // If I'm poisoned, always attempt to cure.
            if (m_Mobile.Poisoned)
            {
                return(new CureSpell(m_Mobile, null));
            }

            // Summoned creatures never heal themselves.
            if (m_Mobile.Summoned)
            {
                return(null);
            }

            if (m_Mobile.Controlled && !(m_Mobile is HenchmanMonster) && !(m_Mobile is HenchmanArcher) && !(m_Mobile is HenchmanWizard) && !(m_Mobile is HenchmanFighter))              // WIZARD ADDED FOR HENCHMAN
            {
                if (DateTime.UtcNow < m_NextHealTime)
                {
                    return(null);
                }
            }

            if (!SmartAI)
            {
                if (ScaleByMagery(HealChance) < Utility.RandomDouble())
                {
                    return(null);
                }
            }
            else
            {
                if (Utility.Random(0, 4 + (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : (m_Mobile.HitsMax / m_Mobile.Hits))) < 3)
                {
                    return(null);
                }
            }

            Spell spell = null;

            if (m_Mobile.Hits < (m_Mobile.HitsMax - 50))
            {
                spell = new GreaterHealSpell(m_Mobile, null);

                if (spell == null)
                {
                    spell = new HealSpell(m_Mobile, null);
                }
            }
            else if (m_Mobile.Hits < (m_Mobile.HitsMax - 10))
            {
                spell = new HealSpell(m_Mobile, null);
            }

            double delay;

            if (m_Mobile.Int >= 500)
            {
                delay = Utility.RandomMinMax(7, 10);
            }
            else
            {
                delay = Math.Sqrt(600 - m_Mobile.Int);
            }

            m_NextHealTime = DateTime.UtcNow + TimeSpan.FromSeconds(delay);

            return(spell);
        }
Exemple #18
0
        public virtual Spell ChooseSpell(Mobile c)
        {
            Spell spell = null;

            int    healChance = (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : (m_Mobile.HitsMax / m_Mobile.Hits));
            int    spellResult;
            double witherChance = .05; //05% chance to wither per enemy in range

            m_Mobile.DebugSay("Choosing a Spell");
            spellResult = Utility.Random(4 + healChance);
            m_Mobile.DebugSay("Chose " + spellResult);
            switch (spellResult)
            {
            case 0:                     // Heal  myself
            {
                m_Mobile.DebugSay("0. Heal");
                if (m_Mobile.Hits < (m_Mobile.HitsMax - 50))
                {
                    spell = new GreaterHealSpell(m_Mobile, null);
                }
                else if (m_Mobile.Hits < (m_Mobile.HitsMax - 20))
                {
                    spell = new HealSpell(m_Mobile, null);
                }

                break;
            }

            case 1:                     // PoisonStrike them
            {
                if (!c.Poisoned && (!(c is BaseCreature) ||
                                    (((BaseCreature)c).PoisonImmune != null && ((BaseCreature)m_Mobile).HitPoison != null &&
                                     ((BaseCreature)c).PoisonImmune.Level < ((BaseCreature)m_Mobile).HitPoison.Level) ||
                                    ((BaseCreature)c).PoisonImmune == null))
                {
                    spell = new PoisonFieldSpell(m_Mobile, null);
                }
                else
                if (Utility.RandomDouble() > .5)
                {
                    spell = new FlameStrikeSpell(m_Mobile, null);
                }
                else
                {
                    spell = new FireFieldSpell(m_Mobile, null);
                }



                break;
            }

            case 2:                     // Deal some damage
            {
                List <Mobile> targets = new List <Mobile>();

                BaseCreature cbc       = m_Mobile as BaseCreature;
                bool         isMonster = (cbc != null && !cbc.Controlled && !cbc.Summoned);
                //check if enough Earthquake targets.
                if (m_Mobile.Map != null)
                {
                    foreach (Mobile m in m_Mobile.GetMobilesInRange(1 + (int)(m_Mobile.Skills[SkillName.Magery].Value / 15.0)))
                    {
                        if (m_Mobile != m && SpellHelper.ValidIndirectTarget(m_Mobile, m) && m_Mobile.CanBeHarmful(m, false) && (!Core.AOS || m_Mobile.InLOS(m)))
                        {
                            targets.Add(m);
                        }
                    }
                }

                if (targets.Count * witherChance > Utility.RandomDouble())
                {
                    m_Mobile.DebugSay("2. Earthquake");
                    spell = new EarthquakeSpell(m_Mobile, null);
                }
                else
                {
                    spell = GetRandomDamageSpell();
                    m_Mobile.DebugSay("2. Random Spell");
                }


                break;
            }

            case 3:                     // Set up a combo of attacks
            {
                if (m_Mobile.Mana < 30 && m_Mobile.Mana > 15)
                {
                    if (c.Paralyzed && !c.Poisoned)
                    {
                        m_Mobile.DebugSay("I am going to meditate");

                        m_Mobile.UseSkill(SkillName.Meditation);
                    }
                    else if (!c.Poisoned && (!(c is BaseCreature) ||
                                             (((BaseCreature)c).PoisonImmune != null && ((BaseCreature)m_Mobile).HitPoison != null &&
                                              ((BaseCreature)c).PoisonImmune.Level < ((BaseCreature)m_Mobile).HitPoison.Level) ||
                                             ((BaseCreature)c).PoisonImmune == null))
                    {
                        m_Mobile.DebugSay("3. Casting Poison");
                        spell = new PoisonSpell(m_Mobile, null);
                    }
                }
                else if (m_Mobile.Mana > 30 && m_Mobile.Mana < 80)
                {
                    if (Utility.Random(2) == 0 && !c.Paralyzed && !c.Frozen && !c.Poisoned)
                    {
                        m_Mobile.DebugSay("3. Curse (Explo)");
                        m_Combo = 0;
                        spell   = new CurseSpell(m_Mobile, null);
                    }
                    else
                    {
                        m_Mobile.DebugSay("3. Curse (FS)");
                        m_Combo = 1;
                        spell   = new CurseSpell(m_Mobile, null);
                    }
                }
                else
                {
                    if (Utility.Random(2) == 0 && !c.Paralyzed && !c.Frozen && !c.Poisoned)
                    {
                        m_Mobile.DebugSay("4. Mana Vampire (Explo)");
                        m_Combo = 0;
                        spell   = new ManaVampireSpell(m_Mobile, null);
                    }
                    else
                    {
                        m_Mobile.DebugSay("4. Mana Vampire (FS)");
                        m_Combo = 1;
                        spell   = new ManaVampireSpell(m_Mobile, null);
                    }
                }
                break;
            }
            }

            return(spell);
        }
Exemple #19
0
        public bool TryToHeal()
        {
            if (this.m_Mobile.Summoned)
            {
                return(false);
            }
            else if (DateTime.UtcNow < this.m_NextHealTime)
            {
                return(false);
            }

            int diff = this.m_Mobile.HitsMax - this.m_Mobile.Hits;

            diff = ((this.m_Mobile.HitsMax * (100 - diff)) / 100);
            diff = 100 - diff;

            if ((int)(Utility.RandomDouble() * 100.0) > diff)
            {
                return(false);
            }

            Spell spell = null;

            this.m_NextHealTime = DateTime.UtcNow + TimeSpan.FromSeconds(20);

            if (this.m_CanUseMagery)
            {
                if (this.m_Mobile.Poisoned)
                {
                    spell = new CureSpell(this.m_Mobile, null);
                }

                spell = new GreaterHealSpell(this.m_Mobile, null);

                if (spell == null)
                {
                    spell = new HealSpell(this.m_Mobile, null);
                }
            }
            else if (this.m_CanUseNecromancy)
            {
                this.m_Mobile.UseSkill(SkillName.SpiritSpeak);
                this.m_NextHealTime = DateTime.UtcNow + TimeSpan.FromSeconds(10);
            }
            else if (this.m_CanUseChivalry)
            {
                if (this.m_Mobile.Poisoned)
                {
                    spell = new CleanseByFireSpell(this.m_Mobile, null);
                }
                else
                {
                    spell = new CloseWoundsSpell(this.m_Mobile, null);
                }
            }
            else if (this.m_CanUseMystic)
            {
                spell = new CleansingWindsSpell(this.m_Mobile, null);
            }
            else if (this.m_Mobile.Skills[SkillName.Healing].Value > 10.0)
            {
                int delay = (int)(5.0 + (0.5 * ((120 - this.m_Mobile.Dex) / 10)));
                new BandageContext(this.m_Mobile, this.m_Mobile, TimeSpan.FromSeconds(delay), false);
                this.m_NextHealTime = DateTime.UtcNow + TimeSpan.FromSeconds(delay + 1);
                return(true);
            }

            if (spell != null)
            {
                spell.Cast();
            }

            return(true);
        }
Exemple #20
0
        public virtual Spell ChooseSpell(Mobile c)
        {
            // tamable solution ---------------
            Mobile com   = m_Mobile.Combatant;
            Spell  spell = null;

            if (com != null && com is BaseCreature && DateTime.Now >= m_NextCouncilSpell)
            {
                if (CastRevelationWave())
                {
                    m_Mobile.DebugSay("I'm gunna cast Revelation Wave!");
                    m_NextCouncilSpell = DateTime.Now + TimeBetweenCouncilSpell;
                    return(new RevelationWaveSpell(m_Mobile, null));
                }

                if (CastPoisonWave())
                {
                    m_Mobile.DebugSay("I'm gunna cast Poison Wave!");
                    m_NextCouncilSpell = DateTime.Now + TimeBetweenCouncilSpell;
                    return(new PoisonWaveSpell(m_Mobile, null));
                }
            }
            // end tamable solution ---------------

            if (!SmartAI)
            {
                if (!m_Mobile.Summoned && ScaleByMagery(HealChance) > Utility.RandomDouble())
                {
                    if (m_Mobile.Hits < (m_Mobile.HitsMax - 50))
                    {
                        return(new GreaterHealSpell(m_Mobile, null));
                    }
                    else if (m_Mobile.Hits < (m_Mobile.HitsMax - 10))
                    {
                        return(new HealSpell(m_Mobile, null));
                    }
                }

                return(GetRandomDamageSpell());
            }

            int healChance = (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : (m_Mobile.HitsMax / m_Mobile.Hits));

            if (m_Mobile.Summoned)
            {
                healChance = 0;
            }

            switch (Utility.Random(4 + healChance))
            {
            default:
            case 0:                     // Heal ourself
            {
                if (!m_Mobile.Summoned)
                {
                    if (m_Mobile.Hits < (m_Mobile.HitsMax - 50))
                    {
                        spell = new GreaterHealSpell(m_Mobile, null);
                    }
                    else if (m_Mobile.Hits < (m_Mobile.HitsMax - 10))
                    {
                        spell = new HealSpell(m_Mobile, null);
                    }
                }

                break;
            }

            case 1:                     // Poison them
            {
                if (!c.Poisoned)
                {
                    spell = new PoisonSpell(m_Mobile, null);
                }

                break;
            }

            case 2:                     // Deal some damage
            {
                spell = GetRandomDamageSpell();

                break;
            }

            case 3:                     // Set up a combo
            {
                if (m_Mobile.Mana < 40 && m_Mobile.Mana > 15)
                {
                    if (c.Paralyzed && !c.Poisoned)
                    {
                        m_Mobile.DebugSay("I am going to meditate");

                        m_Mobile.UseSkill(SkillName.Meditation);
                    }
                    else if (!c.Poisoned)
                    {
                        spell = new ParalyzeSpell(m_Mobile, null);
                    }
                }
                else if (m_Mobile.Mana > 60)
                {
                    if (Utility.Random(2) == 0 && !c.Paralyzed && !c.Frozen && !c.Poisoned)
                    {
                        m_Combo = 0;
                        spell   = new ParalyzeSpell(m_Mobile, null);
                    }
                    else
                    {
                        m_Combo = 1;
                        spell   = new ExplosionSpell(m_Mobile, null);
                    }
                }

                break;
            }
            }

            return(spell);
        }
Exemple #21
0
        public override bool DoActionCombat()
        {
            m_Mobile.DebugSay("doing DoActionCombat");
            Mobile c = m_Mobile.Combatant;

            m_Mobile.Warmode = true;

            // check to see if our attack priority has changed
            Mobile newTarget = null;

            if (PriorityTarget(c, out newTarget) == true)
            {
                m_Mobile.DebugSay("Higher priority target found switching targets");
                m_Mobile.Combatant = c = newTarget;
                m_Mobile.FocusMob  = null;
            }

            if (m_Mobile.CanReveal)
            {
                if (c == null)
                {
                    //	If we can Recall() a player via FindHiddenTarget, make them our new Combatant.
                    //	Keep in mind, CombatTimer.OnTick() will set the Combatant to null if it sees that the mobile is hidden,
                    //	for this reason, we make this check in DoActionGuard and again in DoActionCombat if the Combatant is null.
                    Mobile mx = FindHiddenTarget();
                    if (mx != null)
                    {
                        m_Mobile.DebugSay("C: Ah, I remembered {0}!", mx.Name);
                        c = m_Mobile.Combatant = mx;
                    }
                }

                // if we can reveal and our target just hid and we Recall them, lets try to reveal
                if (c != null && c.Hidden && ShortTermMemory.Recall(c) && c.Alive && !c.IsDeadBondedPet && m_Mobile.CanBeHarmful(c, false) && !m_Mobile.Controlled)
                {                       // we will keep retrying the reveal
                    if (DoProcessReveal(c))
                    {
                        return(true);
                    }
                    else
                    {
                        m_Mobile.DebugSay("Failed reveal attempt");
                    }
                }
            }

            if (c == null || c.Deleted || !c.Alive || c.IsDeadBondedPet || !m_Mobile.CanSee(c) || !m_Mobile.CanBeHarmful(c, false) || c.Map != m_Mobile.Map)
            {
                // Our combatant is deleted, dead, hidden, or we cannot hurt them
                // Try to find another combatant
                if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
                {
                    if (m_Mobile.Debug)
                    {
                        m_Mobile.DebugSay("Something happened to my combatant, so I am going to fight {0}", m_Mobile.FocusMob.Name);
                    }

                    m_Mobile.Combatant = c = m_Mobile.FocusMob;
                    m_Mobile.FocusMob  = null;
                }
                else
                {
                    m_Mobile.DebugSay("Something happened to my combatant, and nothing is around. I am on guard.");
                    Action = ActionType.Guard;
                    return(true);
                }

                if (!m_Mobile.InRange(c, m_Mobile.RangePerception))
                {
                    // They are somewhat far away, can we find something else?

                    if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
                    {
                        m_Mobile.Combatant = m_Mobile.FocusMob;
                        m_Mobile.FocusMob  = null;
                    }
                    else if (!m_Mobile.InRange(c, m_Mobile.RangePerception * 3))
                    {
                        m_Mobile.Combatant = null;
                    }

                    c = m_Mobile.Combatant;

                    if (c == null)
                    {
                        m_Mobile.DebugSay("My combatant has fled, so I am on guard");
                        Action = ActionType.Guard;
                        return(true);
                    }
                }
            }

            if (!m_Mobile.InLOS(c))
            {
                if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
                {
                    m_Mobile.Combatant = c = m_Mobile.FocusMob;
                    m_Mobile.FocusMob  = null;
                }
            }

            if (c != null)
            {
                int    strMod   = GetStatMod(c, StatType.Str);
                Mobile toDispel = null;

                //dont worry about creatures/pets useing these spells, only players.
                if (c is PlayerMobile && SmartAI && (c.Spell is MagicTrapSpell || c.Spell is MagicArrowSpell))
                {
                    EnemyCountersPara = true;
                }

                if (UsesPotions && RefreshPotCount >= 1 && m_Mobile.Stam < 20)
                {
                    DrinkRefresh(m_Mobile);
                }

                if (m_Mobile.Paralyzed)
                {
                    UseTrapPouch(m_Mobile);
                }

                TrapPouch(m_Mobile);

                if ((c.Paralyzed || c.Frozen) && PreferMagic() == true)
                {
                    if (m_Mobile.InRange(c, 3))
                    {
                        RunAround(c);
                    }
                }

                if (PreferMagic() == true)
                {
                    if (SmartAI && !m_Mobile.StunReady && m_Mobile.Skills[SkillName.Wrestling].Value >= 80.0 && m_Mobile.Skills[SkillName.Anatomy].Value >= 80.0)
                    {
                        EventSink.InvokeStunRequest(new StunRequestEventArgs(m_Mobile));
                    }
                }

                if (UsesBandages && (IsDamaged || IsPoisoned) && m_Mobile.Skills.Healing.Base > 20.0)
                {
                    TimeSpan ts = TimeUntilBandage;

                    if (ts == TimeSpan.MaxValue)
                    {
                        StartBandage(m_Mobile, m_Mobile);
                    }
                }

                if (IsPoisoned && UsesPotions && CurePotCount >= 1)
                {
                    if (m_Mobile.Poison.Level >= 3 || Combo != -1 || m_Mobile.Mana < 30)
                    {
                        DrinkCure(m_Mobile);
                    }
                }

                if (IsDamaged && UsesPotions && HealPotCount >= 1)
                {
                    if (Utility.Random(0, 4 + (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : (m_Mobile.HitsMax / m_Mobile.Hits))) >= 3)
                    {
                        if (m_Mobile.Hits < (m_Mobile.HitsMax * .25) || m_Mobile.Mana < (m_Mobile.ManaMax * .25))
                        {
                            DrinkHeal(m_Mobile);
                        }
                    }
                }

                if (m_Mobile.Skills[SkillName.Magery].Value >= 50.0 && m_Mobile.Spell == null && DateTime.Now >= m_Mobile.NextSpellTime)
                {
                    m_Mobile.DebugSay("Doing spell selection");
                    // We are ready to cast a spell
                    Spell spell = null;
                    toDispel = FindDispelTarget(true);

                    //woot weaken block up to lightening!
                    ISpell i = c.Spell;
                    if (i != null && i.IsCasting)
                    {
                        Spell s = (Spell)i;
                        if (m_Mobile.Hits <= 40 && (s.MaxDamage >= 12 || (s is PoisonSpell && !IsPoisoned && CurePotCount == 0)))
                        {
                            m_Mobile.DebugSay("Damage is {0}", s.MaxDamage);
                            spell = new WeakenSpell(m_Mobile, null);
                        }
                    }
                    // Top cast priority is cure - may override the previous assignment
                    else if (IsPoisoned)
                    {
                        spell = new CureSpell(m_Mobile, null);
                        int level = (m_Mobile.Poison.Level + 1);
                        if (level > 0 && (((m_Mobile.Skills[SkillName.Magery].Value / level) - 20) * 7.5) > 50)
                        {
                            spell = new CureSpell(m_Mobile, null);
                        }
                        else
                        {
                            spell = new ArchCureSpell(m_Mobile, null);
                        }
                    }
                    //were hurt they have atleast half life and were to low on mana to finish them start healing
                    else if (m_Mobile.Hits < 70 && c.Hits > 50 && m_Mobile.Mana < 30)
                    {
                        spell = new HealSpell(m_Mobile, null);
                    }
                    // Something dispellable is attacking us
                    else if (toDispel != null)
                    {
                        if (Utility.Random(0, 4 + (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : (m_Mobile.HitsMax / m_Mobile.Hits))) >= 3)
                        {
                            if (UsesPotions && HealPotCount >= 1 && m_Mobile.Hits < (m_Mobile.HitsMax - 20))
                            {
                                DrinkHeal(m_Mobile);
                            }
                            else if (m_Mobile.Hits < (m_Mobile.HitsMax - 20))
                            {
                                spell = new HealSpell(m_Mobile, null);
                            }
                        }

                        spell = DoDispel(toDispel);
                    }
                    // a friend needs healed
                    else if (CrossHeals && FindHealTarget(true) != null)
                    {
                        spell = new GreaterHealSpell(m_Mobile, null);
                    }
                    //target has reflect up hit is with ManaDrain till down
                    else if (c.MagicDamageAbsorb > 5)
                    {
                        spell = new ManaDrainSpell(m_Mobile, null);
                    }
                    // We are doing a spell combo
                    else if (Combo != -1)
                    {
                        spell = DoCombo(c);
                    }
                    //keep them weakened.
                    else if (m_Mobile.Mana >= 40 && strMod >= 0 && !c.Paralyzed)
                    {
                        spell = new WeakenSpell(m_Mobile, null);
                    }
                    else
                    {
                        spell = ChooseSpell(c);
                    }

                    if (spell != null && m_Mobile.InRange(c, 12))
                    {
                        spell.Cast();
                    }
                }


                if (SmartAI && toDispel != null)
                {
                    if (m_Mobile.InRange(toDispel, 8) && !toDispel.Paralyzed)
                    {
                        RunFrom(toDispel);
                    }
                }
                else if (HoldingWeapon() == true && PreferMagic() == false)
                {
                    m_Mobile.DebugSay("I will prefer my weapon over magic");
                    RunTo(c, CanRun);
                }
                else
                {
                    if (c is BaseCreature && ((BaseCreature)c).Controlled && !((BaseCreature)c).Summoned && !c.Paralyzed && m_Mobile.InRange(c, 6))
                    {
                        RunFrom(c);
                    }

                    if (c is BaseCreature && (((BaseCreature)c).Controlled && !((BaseCreature)c).Summoned) && !m_Mobile.InRange(c, 10))
                    {
                        RunTo(c, CanRun);
                    }

                    if (RegainingMana == false)
                    {
                        if (c is PlayerMobile || (c is BaseCreature && !((BaseCreature)c).Controlled && !((BaseCreature)c).Summoned))
                        {
                            RunTo(c, CanRun);
                        }
                    }
                    else
                    {
                        if (c is PlayerMobile || (c is BaseCreature && !((BaseCreature)c).Controlled && !((BaseCreature)c).Summoned))
                        {
                            if (m_Mobile.InRange(c, 4))
                            {
                                RunAround(c);
                            }

                            if (!m_Mobile.InRange(c, 6))
                            {
                                RunTo(c, CanRun);
                            }
                        }

                        m_Mobile.UseSkill(SkillName.Meditation);
                    }
                }

                return(true);
            }
            return(true);
        }
            public bool CastHeal(WoWUnit unit)
            {
                if (!unit.IsAlive)
                {
                    Dlog("CastHeal: Heal target is dead");
                    return(false);
                }

                if (!unit.IsMe && !IsUnitInRange(unit, 39))
                {
                    Dlog("CastHeal:  moving to heal target who is {0} yds away", unit.Distance);
                    MoveToHealTarget(unit, 35);
                    if (!IsUnitInRange(unit, 39))
                    {
                        Dlog("CastHeal:  not within healing range, Heal Target {0} is {1:F1} yds away", Safe_UnitName(unit), unit.Distance);
                        return(false);
                    }

                    Dlog("CastHeal:  stopping now that Heal Target {0} is {1:F1} yds away", Safe_UnitName(unit), unit.Distance);
                }

                if (BuffTidalWaves && SpellManager.HasSpell("Riptide"))
                {
                    WoWUnit tank = GroupTank;
                    if (IsRAF() && tank != null && tank.HealthPercent < NeedHeal && !tank.Auras.ContainsKey("Riptide"))
                    {
                        if (Riptide(tank))
                        {
                            return(true);
                        }
                    }

                    if (Riptide(unit))
                    {
                        return(true);
                    }
                }

                Safe_StopMoving();

                // wait here to try and cut down on Safe_SpellCast() having to wait which provides sqewed log output
                // .. indicating we cast a higher power heal (HealingSurge) while unit had higher health %

                double    currHealth = unit.HealthPercent;
                HealSpell spell      = spells.FirstOrDefault(s => currHealth < s.Health);
                HealSpell baseSpell  = spell;

                // FIND FIRST CHOICE SPELL
                // nav up: find the correct spell in the list or next higher health % spell
                while (!IsGameUnstable() && _me.IsAlive && spell != null)
                {
                    Dlog("CastHeal:  {0} {1}% for unit with health {2:F1}%", spell.DisplayName, spell.Health, currHealth);

                    WoWSpell wowSpell = SpellManager.Spells[spell.TestSpell];
                    if (wowSpell.Cooldown)
                    {
                        Dlog("CastHeal: spell '{0}' is on cooldown", wowSpell.Name);
                    }
                    else if (spell.Cast(unit))
                    {
                        if (!_me.Combat && !unit.Combat)
                        {
                            WaitForCurrentHeal(unit, NeedHeal);
                        }
                        return(true);
                    }

                    // on CD, so move to next higher health % in list
                    spell = spells.FirstOrDefault(s => spell.Health < s.Health);
                }

#if ALLOW_NEXT_LOWER_HEALTH_SPELL
                // FIND SECOND CHOICE SPELL
                // nav dn: find next lower health % spell
                if (baseSpell != null)
                {
                    spell = spells.LastOrDefault(s => baseSpell.Health > s.Health);
                }

                while (!IsGameUnstable() && _me.IsAlive && spell != null)
                {
                    Dlog("CastHeal:  2nd choice {0} {1}% for unit with health {2:F1}%", spell.DisplayName, spell.Health, currHealth);
                    if (spell.Cast(unit))
                    {
                        WaitForCurrentHeal(unit, NeedHeal);
                        return(true);
                    }

                    // on CD, so find next lower health % in list
                    spell = spells.LastOrDefault(s => spell.Health > s.Health);
                }
#endif
                Dlog("CastHeal:  failed to find usable healing spell for unit with health {0:F1}%", currHealth);
                return(false);
            }
 private static int Compare(HealSpell a, HealSpell b)
 {
     return(a.Health - b.Health);
 }
 private static int Compare(HealSpell a, HealSpell b)
 {
     return a.Health - b.Health;
 }
Exemple #25
0
        public virtual Spell ChooseSpell(Mobile c)
        {
            Spell spell = null;

            int    healChance = (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : (m_Mobile.HitsMax / m_Mobile.Hits));
            int    spellResult;
            double witherChance = .10; //05% chance to wither per enemy in range

            m_Mobile.DebugSay("Choosing a Spell");
            spellResult = Utility.Random(4 + healChance);
            m_Mobile.DebugSay("Chose " + spellResult);
            switch (spellResult)
            {
            case 0:                     // Heal  myself
            {
                m_Mobile.DebugSay("0. Heal");
                if (m_Mobile.Hits < (m_Mobile.HitsMax - 50))
                {
                    spell = new GreaterHealSpell(m_Mobile, null);
                }
                else if (m_Mobile.Hits < (m_Mobile.HitsMax - 20))
                {
                    spell = new HealSpell(m_Mobile, null);
                }

                break;
            }

            case 1:                     // PoisonStrike them
            {
                m_Mobile.DebugSay("1. Poison Strike or Pfield or Ffield");
                if (!c.Poisoned && (!(c is BaseCreature) ||
                                    (((BaseCreature)c).PoisonImmune != null && ((BaseCreature)m_Mobile).HitPoison != null &&
                                     ((BaseCreature)c).PoisonImmune.Level < ((BaseCreature)m_Mobile).HitPoison.Level) ||
                                    ((BaseCreature)c).PoisonImmune == null))
                {
                    if (Utility.RandomDouble() > .5)
                    {
                        spell = new PoisonStrikeSpell(m_Mobile, null);
                    }
                    else
                    {
                        spell = new PoisonFieldSpell(m_Mobile, null);      //need to do targeting on fields
                    }
                }
                else
                if (Utility.RandomDouble() > .5)
                {
                    spell = new FireFieldSpell(m_Mobile, null);
                }
                else
                {
                    spell = new FlameStrikeSpell(m_Mobile, null);
                }

                break;
            }

            case 2:                     // Deal some damage
            {
                List <Mobile> targets = new List <Mobile>();

                BaseCreature cbc       = m_Mobile as BaseCreature;
                bool         isMonster = (cbc != null && !cbc.Controlled && !cbc.Summoned);
                //check if enough wither targets.
                foreach (Mobile m in m_Mobile.GetMobilesInRange(Core.ML ? 4 : 5))
                {
                    if (m_Mobile != m && m_Mobile.InLOS(m) && (isMonster || SpellHelper.ValidIndirectTarget(m_Mobile, m)) && m_Mobile.CanBeHarmful(m, false))
                    {
                        /*
                         * if (isMonster)
                         * {
                         * if (m is BaseCreature)
                         * {
                         *  BaseCreature bc = (BaseCreature)m;
                         *
                         *  if (!bc.Controlled && !bc.Summoned && bc.Team == cbc.Team)
                         *      continue;
                         * }
                         * else if (!m.Player)
                         * {
                         *  continue;
                         * }
                         * }
                         */
                        targets.Add(m);
                    }
                }

                if (targets.Count * witherChance > Utility.RandomDouble())
                {
                    m_Mobile.DebugSay("2. Wither");
                    spell = new WitherSpell(m_Mobile, null);
                }
                else
                {
                    spell = GetRandomDamageSpell();
                    m_Mobile.DebugSay("2. Random Spell");
                }


                break;
            }

            case 3:                     // Set up a combo of attacks
            {
                if (m_Mobile.Mana < 30 && m_Mobile.Mana > 15)
                {
                    if (c.Paralyzed && !c.Poisoned)
                    {
                        m_Mobile.DebugSay("I am going to meditate");

                        m_Mobile.UseSkill(SkillName.Meditation);
                    }
                    else if (!c.Poisoned && (!(c is BaseCreature) ||
                                             (((BaseCreature)c).PoisonImmune != null && ((BaseCreature)m_Mobile).HitPoison != null &&
                                              ((BaseCreature)c).PoisonImmune.Level < ((BaseCreature)m_Mobile).HitPoison.Level) ||
                                             ((BaseCreature)c).PoisonImmune == null))
                    {
                        m_Mobile.DebugSay("3. Casting Poison");
                        spell = new PoisonSpell(m_Mobile, null);
                    }
                }
                else if (m_Mobile.Mana > 30 && m_Mobile.Mana < 80)
                {
                    if (Utility.Random(2) == 0 && !c.Paralyzed && !c.Frozen && !c.Poisoned)
                    {
                        m_Mobile.DebugSay("3. Pain Spike (Explo)");
                        m_Combo = 0;
                        spell   = new PainSpikeSpell(m_Mobile, null);
                    }
                    else
                    {
                        m_Mobile.DebugSay("3. Mind Rot or Curse (FS)");
                        m_Combo = 1;
                        if (Utility.RandomBool())
                        {
                            spell = new CurseSpell(m_Mobile, null);
                        }
                        else
                        {
                            spell = new MindRotSpell(m_Mobile, null);
                        }
                    }
                }
                else
                {
                    if (Utility.Random(2) == 0 && !c.Paralyzed && !c.Frozen && !c.Poisoned)
                    {
                        m_Mobile.DebugSay("4. Vengeful Spirit (Explo)");
                        m_Combo = 0;
                        spell   = new VengefulSpiritSpell(m_Mobile, null);
                    }
                    else
                    {
                        m_Mobile.DebugSay("4. Poison Strike (FS)");
                        m_Combo = 1;
                        spell   = new PoisonStrikeSpell(m_Mobile, null);
                    }
                }
                break;
            }
            }

            return(spell);
        }
        public override bool DoActionCombat()
        {
            m_Mobile.DebugSay("doing HumanMageAI combat action");
            Mobile c = m_Mobile.Combatant;

            m_Mobile.Warmode = true;


            if (c == null || c.Deleted || !c.Alive || c.IsDeadBondedPet || !m_Mobile.CanSee(c) || !m_Mobile.CanBeHarmful(c, false) || c.Map != m_Mobile.Map)
            {
                // Our combatant is deleted, dead, hidden, or we cannot hurt them
                // Try to find another combatant

                if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
                {
                    if (m_Mobile.Debug)
                    {
                        m_Mobile.DebugSay("Something happened to my combatant, so I am going to fight {0}", m_Mobile.FocusMob.Name);
                    }

                    m_Mobile.Combatant = c = m_Mobile.FocusMob;
                    m_Mobile.FocusMob  = null;
                }
                else
                {
                    m_Mobile.DebugSay("Something happened to my combatant, and nothing is around. I am on guard.");
                    Action = ActionType.Guard;
                    return(true);
                }
            }

            if (!m_Mobile.InLOS(c))
            {
                if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
                {
                    m_Mobile.Combatant = c = m_Mobile.FocusMob;
                    m_Mobile.FocusMob  = null;
                }
            }

            if (c is PlayerMobile && SmartAI && (c.Spell is MagicTrapSpell || c.Spell is MagicArrowSpell))
            {
                m_EnemyCountersPara = true;
            }

            if (c.Paralyzed || c.Frozen)
            {
                if (m_Mobile.InRange(c, 1))
                {
                    RunFrom(c);
                }
            }

            if (m_Mobile.Paralyzed)
            {
                UseTrapPouch(m_Mobile);
            }
            TrapPouch(m_Mobile);

            if (SmartAI && !m_Mobile.StunReady && m_Mobile.Skills[SkillName.Wrestling].Value >= 80.0 && m_Mobile.Skills[SkillName.Anatomy].Value >= 80.0)
            {
                EventSink.InvokeStunRequest(new StunRequestEventArgs(m_Mobile));
            }

            if (!m_Mobile.InRange(c, m_Mobile.RangePerception))
            {
                // They are somewhat far away, can we find something else?

                if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
                {
                    m_Mobile.Combatant = m_Mobile.FocusMob;
                    m_Mobile.FocusMob  = null;
                }
                else if (!m_Mobile.InRange(c, m_Mobile.RangePerception * 3))
                {
                    m_Mobile.Combatant = null;
                }

                c = m_Mobile.Combatant;

                if (c == null)
                {
                    m_Mobile.DebugSay("My combatant has fled, so I am on guard");
                    Action = ActionType.Guard;

                    return(true);
                }
            }

            if (m_Mobile.Hits < m_Mobile.HitsMax * 20 / 100)
            {
                // We are low on health, should we flee?

                bool flee = false;

                if (m_Mobile.Hits < c.Hits)
                {
                    // We are more hurt than them

                    int diff = c.Hits - m_Mobile.Hits;

                    flee = (Utility.Random(0, 100) > (10 + diff));                     // (10 + diff)% chance to flee
                }
                else
                {
                    flee = Utility.Random(0, 100) > 10;                     // 10% chance to flee
                }

                if (flee)
                {
                    if (m_Mobile.Debug)
                    {
                        m_Mobile.DebugSay("I am going to flee from {0}", c.Name);
                    }

                    Action = ActionType.Flee;
                    return(true);
                }
            }


            if (m_Mobile.Spell == null && DateTime.Now > m_NextCastTime && m_Mobile.InRange(c, 12))
            {
                // We are ready to cast a spell
                Spell  spell    = null;
                Mobile toDispel = FindDispelTarget(true);

                //try an cure with a pot first if the poison is serious or where in the middle of dumping
                if (UsesPotions && (m_Mobile.Poisoned && m_Mobile.Poison.Level >= 3) || m_Mobile.Poisoned && Combo != -1)
                {
                    DrinkCure(m_Mobile);
                }

                if (m_Mobile.Poisoned)                 // Top cast priority is cure
                {
                    spell = new CureSpell(m_Mobile, null);
                    try
                    {
                        if ((((m_Mobile.Skills[SkillName.Magery].Value / (m_Mobile.Poison.Level + 1)) - 20) * 7.5) > 50)
                        {
                            spell = new CureSpell(m_Mobile, null);
                        }
                        else
                        {
                            spell = new ArchCureSpell(m_Mobile, null);
                        }
                    }
                    catch
                    {
                        spell = new CureSpell(m_Mobile, null);
                    }
                }

                //were hurt they have atleast half life and were to low on mana to finish them start healing
                else if (m_Mobile.Hits < 70 && c.Hits > 50 && m_Mobile.Mana < 30)
                {
                    spell = new HealSpell(m_Mobile, null);
                }

                else if (toDispel != null)                 // Something dispellable is attacking us
                {
                    spell = DoDispel(toDispel);
                }
                //take down reflect on are enemy if its up
                else if (c.MagicDamageAbsorb > 5)
                {
                    m_Mobile.DebugSay("Takeing Down Reflect");
                    spell = new FireballSpell(m_Mobile, null);
                }
                else if (Combo != -1)                 // We are doing a spell combo
                {
                    spell = DoCombo(c);
                }
                else
                {
                    spell = ChooseSpell(c);
                }

                if (SmartAI && toDispel != null)
                {
                    if (m_Mobile.InRange(toDispel, 10))
                    {
                        RunFrom(toDispel);
                    }
                    else if (!m_Mobile.InRange(toDispel, 12))
                    {
                        RunTo(toDispel, CanRun);
                    }
                }
                else
                {
                    if (m_RegainingMana == false)
                    {
                        RunTo(c, CanRun);
                    }
                }

                if (spell != null && spell.Cast())
                {
                    TimeSpan delay;
                    //spell cast time is equal to the delay for the spells.
                    delay = spell.GetCastDelay() + spell.GetCastRecovery();

                    m_NextCastTime = DateTime.Now + delay;
                }
            }
            else if ((m_Mobile.Spell == null || !m_Mobile.Spell.IsCasting) && m_RegainingMana == false)
            {
                RunTo(c, CanRun);
            }

            return(true);
        }