Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
    }
Esempio n. 6
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);
        }
Esempio n. 7
0
        public static bool DoSpellHeal(BaseCreature creature, Mobile target)
        {
            Spell spell = new GreaterHealSpell(creature, null);

            if (target != null)
            {
                creature.SpellTarget = target;
                spell.Cast();

                return(true);
            }

            else
            {
                return(false);
            }
        }
Esempio n. 8
0
        public override void OnSpeech(SpeechEventArgs e)
        {
            base.OnSpeech(e);
            Mobile from = e.Mobile;

            if (from.FindItemOnLayer(Layer.Helm) is NecromaticMask)
            {
                if (e.Speech.IndexOf("nwapslleh") >= 0)
                {
                    GreaterHealSpell gheal = new GreaterHealSpell(this, null); // get your spell
                    if (gheal.Cast())                                          // if it casts the spell
                    {
                        m_CastTimer = new GHCastTimer(gheal, from, gheal.GetCastDelay());
                        m_CastTimer.Start();
                    }
                }
            }
        }
Esempio n. 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);
        }
Esempio n. 10
0
        public override void OnSpeech(SpeechEventArgs e)
        {
            if (XmlScript.HasTrigger(this, TriggerName.onSpeech) && UberScriptTriggers.Trigger(this, e.Mobile, TriggerName.onSpeech, null, e.Speech))
            {
                return;
            }
            base.OnSpeech(e);
            Mobile from = e.Mobile;

            if (from.FindItemOnLayer(Layer.Helm) is NecromaticMask)
            {
                if (e.Speech.IndexOf("nwapslleh") >= 0)
                {
                    GreaterHealSpell gheal = new GreaterHealSpell(this, null); // get your spell
                    if (gheal.Cast())                                          // if it casts the spell
                    {
                        m_CastTimer = new GHCastTimer(gheal, from, gheal.GetCastDelay());
                        m_CastTimer.Start();
                    }
                }
            }
        }
Esempio n. 11
0
        public override void OnSpeech(SpeechEventArgs e)
        {
            base.OnSpeech(e);
            Mobile from = e.Mobile;

//if( e.Layer.Helm is NecromaticMask )
            if (from.FindItemOnLayer(Layer.Helm) is NecromaticMask)
            {
                if (e.Speech.IndexOf("nwapslleh") >= 0)
                //if (e.Speech.ToLower().IndexOf( "nwapslleh" ) >= 0  )
                {
                    // if ( e.Hits < (e.HitsMax - 50) && from.Poisoned == false )
                    //{
                    m_ghs = new GreaterHealSpell(this, null); // get your spell
                    if (m_ghs.Cast())                         // if it casts the spell
                    {
                        TimeSpan castDelay = m_ghs.GetCastDelay();
                        m_CastTimer = new GHCastTimer(m_ghs, from, castDelay);
                        m_CastTimer.Start();
                    }
                }
            }
            //}
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 15
0
 public GHCastTimer(GreaterHealSpell spell, Mobile target, TimeSpan castDelay) : base(castDelay)
 {
     m_Spell  = spell;
     m_Target = target;
     Priority = TimerPriority.TwentyFiveMS;
 }
Esempio n. 16
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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 22
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);
        }
Esempio n. 23
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);
        }
Esempio n. 24
0
        public override bool Think()
        {
            if (m_Mobile.Deleted)
            {
                return(false);
            }

            if (m_Mobile.Target is AsyncSpellTarget target)
            {
                switch (target.Spell)
                {
                case CureSpell:
                    ProcessTarget(target, ACure);
                    break;

                case GreaterHealSpell:
                    ProcessTarget(target, AgHeal);
                    break;

                case HealSpell:
                    ProcessTarget(target, AlHeal);
                    break;

                default:
                    m_Mobile.Target.Cancel(m_Mobile, TargetCancelType.Canceled);
                    break;
                }
            }
            else
            {
                Mobile toHelp = Find(All);

                if (toHelp != null)
                {
                    if (NeedCure(toHelp))
                    {
                        if (m_Mobile.Debug)
                        {
                            m_Mobile.DebugSay("{0} needs a cure", toHelp.Name);
                        }

                        var spell = new CureSpell(m_Mobile, null);
                        if (spell.CanCast())
                        {
                            spell.Cast();
                        }
                    }
                    else if (NeedGHeal(toHelp))
                    {
                        if (m_Mobile.Debug)
                        {
                            m_Mobile.DebugSay("{0} needs a greater heal", toHelp.Name);
                        }

                        var spell = new GreaterHealSpell(m_Mobile, null);
                        if (spell.CanCast())
                        {
                            spell.Cast();
                        }
                    }
                    else if (NeedLHeal(toHelp))
                    {
                        if (m_Mobile.Debug)
                        {
                            m_Mobile.DebugSay("{0} needs a lesser heal", toHelp.Name);
                        }

                        new HealSpell(m_Mobile, null).Cast();
                    }
                }
                else
                {
                    if (AcquireFocusMob(m_Mobile.RangePerception, FightMode.Weakest, false, true, false))
                    {
                        WalkMobileRange(m_Mobile.FocusMob, 1, false, 4, 7);
                    }
                    else
                    {
                        WalkRandomInHome(3, 2, 1);
                    }
                }
            }

            return(true);
        }