コード例 #1
0
        public override bool DoActionCombat()
        {
            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 (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.Controlled && !m_Mobile.Summoned)
            {
                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);

                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);
                    }
                }
                else if (toDispel != null)                 // Something dispellable is attacking us
                {
                    spell = DoDispel(toDispel);
                }
                else if (m_Combo != -1)                 // We are doing a spell combo
                {
                    spell = DoCombo(c);
                }
                else if ((c.Spell is HealSpell || c.Spell is GreaterHealSpell) && !c.Poisoned)                 // They have a heal spell out
                {
                    spell = new PoisonSpell(m_Mobile, null);
                }
                else
                {
                    spell = ChooseSpell(c);
                }

                // Now we have a spell picked
                // Move first before casting

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

                if (spell != null && spell.Cast())
                {
                    TimeSpan delay;

                    if (SmartAI || (spell is DispelSpell))
                    {
                        delay = TimeSpan.FromSeconds(m_Mobile.ActiveSpeed);
                    }
                    if (spell is HarmSpell)
                    {
                        delay = TimeSpan.FromSeconds(m_Mobile.ActiveSpeed);
                    }

                    else
                    {
                        double del = ScaleByMagery(4.3);
                        double min = 6.0 - (del * 0.75);
                        double max = 6.0 - (del * 1.25);

                        delay = TimeSpan.FromSeconds(min + ((max - min) * Utility.RandomDouble()));
                    }

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

            return(true);
        }
コード例 #2
0
        public override bool DoActionWander()
        {
            if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
            {
                if (m_Mobile.Debug)
                {
                    m_Mobile.DebugSay("I am going to attack {0}", m_Mobile.FocusMob.Name);
                }

                m_Mobile.Combatant = m_Mobile.FocusMob;
                Action             = ActionType.Combat;
                m_NextCastTime     = DateTime.Now;
            }
            else if (SmartAI && m_Mobile.Mana < m_Mobile.ManaMax)
            {
                m_Mobile.DebugSay("I am going to meditate");

                m_Mobile.UseSkill(SkillName.Meditation);
            }
            else
            {
                m_Mobile.DebugSay("I am wandering");

                m_Mobile.Warmode = false;

                base.DoActionWander();

                if (m_Mobile.Poisoned)
                {
                    if (m_Mobile.Poison != null)
                    {
                        Spell curespell;

                        if ((((m_Mobile.Skills[SkillName.Magery].Value / (m_Mobile.Poison.Level + 1)) - 20) * 7.5) > 50)
                        {
                            curespell = new CureSpell(m_Mobile, null);
                        }
                        else
                        {
                            curespell = new ArchCureSpell(m_Mobile, null);
                        }

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

            return(true);
        }
コード例 #3
0
ファイル: NecromageEpicAI.cs プロジェクト: KairiL/runuo
        public override bool DoActionCombat()
        {
            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 (!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.Controlled && !m_Mobile.Summoned)
            {
                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);

                if (m_Mobile.Poisoned)                   // Top cast priority is cure
                {
                    IPooledEnumerable eable = (IPooledEnumerable)m_Mobile.Map.GetItemsInRange(m_Mobile.Location, 1);

                    foreach (object o in eable)
                    {
                        if (o is PoisonFieldSpell.InternalItem)
                        {
                            m_Mobile.Move(m_Mobile.Direction);
                            break;
                        }
                    }
                    spell = new ArchCureSpell(m_Mobile, null);
                }
                else if (toDispel != null && Utility.RandomDouble() < DispelChance)                   // Something dispellable is attacking us
                {
                    spell = DoDispel(toDispel);
                }
                else if (m_Combo != -1)                   // We are doing a spell combo
                {
                    spell = DoCombo(c);
                }
                else if ((c.Spell is HealSpell || c.Spell is GreaterHealSpell) && !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)) // They have a heal spell out and can be poisoned
                {
                    spell = new PoisonSpell(m_Mobile, null);
                }
                else
                {
                    spell = ChooseSpell(c);
                }

                // Now we have a spell picked
                // Move first before casting

                /*
                 *              if ( toDispel != null )
                 *              {
                 *                      if ( m_Mobile.InRange( toDispel, 10 ) )
                 *                              RunFrom( toDispel );
                 *                      else if ( !m_Mobile.InRange( toDispel, 12 ) )
                 *                              RunTo( toDispel );
                 *              }
                 *              else
                 */
                {
                    RunTo(c);
                }

                if (spell != null && spell.Cast())
                {
                    TimeSpan delay;

                    delay          = spell.GetCastDelay();
                    m_NextCastTime = DateTime.Now + delay;
                    m_Mobile.DebugSay("Spell Delay is " + delay);
                }
            }
            else if (m_Mobile.Spell == null || !m_Mobile.Spell.IsCasting)
            {
                RunTo(c);
            }

            return(true);
        }
コード例 #4
0
        public override bool DoActionCombat()
        {
            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 (SmartAI && (c.Spell is MagicTrapSpell || c.Spell is MagicArrowSpell))
            {
                EnemyCountersPara = true;
            }

            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);
                Mobile toParalyze = FindParalyzeTarget(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);
                    }
                }


                else if (toDispel != null)                 // Something dispellable is attacking us
                {
                    spell = DoDispel(toDispel);
                }
                else if (toParalyze != null)                 // Something dispellable is attacking us
                {
                    spell = DoParalyze(toParalyze);
                }
                //take down reflect on are enemy if its up
                else if (c.MagicDamageAbsorb > 5)
                {
                    m_Mobile.DebugSay("Takeing Down Reflect");
                    spell = new LightningSpell(m_Mobile, null);
                }
                else if (Combo != -1 && !m_Mobile.Paralyzed)                 // 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);
                    }
                }

                if (toParalyze != null)
                {
                    if (m_Mobile.InRange((BaseCreature)toParalyze, 10))
                    {
                        RunFrom(toParalyze);
                    }
                    else if (!m_Mobile.InRange((BaseCreature)toParalyze, 12))
                    {
                        RunTo(toParalyze, CanRun);
                    }
                }

                else
                {
                    if (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) && RegainingMana == false)
            {
                RunTo(c, CanRun);
            }

            return(true);
        }
コード例 #5
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);
        }
コード例 #6
0
        public override bool DoActionCombat()
        {
            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))
                {
                    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))
            {
                m_Mobile.DebugSay("I can't see my target");

                if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
                {
                    m_Mobile.DebugSay("I will switch to {0}", m_Mobile.FocusMob.Name);
                    m_Mobile.Combatant = c = m_Mobile.FocusMob;
                    m_Mobile.FocusMob  = null;
                }
            }

            if (!Core.AOS && 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.Controlled && !m_Mobile.Summoned && m_Mobile.CanFlee)
            {
                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)
                    {
                        m_Mobile.DebugSay("I am going to flee from {0}", c.Name);

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

            if (m_Mobile.Spell == null && Core.TickCount - m_NextCastTime >= 0 && m_Mobile.InRange(c, Core.ML ? 10 : 12))
            {
                // We are ready to cast a spell

                Spell  spell    = null;
                Mobile toDispel = FindDispelTarget(true);

                if (m_Mobile.Poisoned)                  // Top cast priority is cure
                {
                    m_Mobile.DebugSay("I am going to cure myself");

                    spell = new ArchCureSpell(m_Mobile, null);
                }
                else if (toDispel != null)                  // Something dispellable is attacking us
                {
                    m_Mobile.DebugSay("I am going to dispel {0}", toDispel);

                    spell = DoDispel(toDispel);
                }
                else if (SmartAI && m_Combo != -1)                  // We are doing a spell combo
                {
                    spell = DoCombo(c);
                }
                else if (SmartAI && (c.Spell is HealSpell || c.Spell is GreaterHealSpell) && !c.Poisoned)                    // They have a heal spell out
                {
                    spell = new PoisonSpell(m_Mobile, null);
                }
                else
                {
                    spell = ChooseSpell(c);
                }

                // Now we have a spell picked
                // Move first before casting

                if (SmartAI && toDispel != null)
                {
                    if (m_Mobile.InRange(toDispel, 10))
                    {
                        RunFrom(toDispel);
                    }
                    else if (!m_Mobile.InRange(toDispel, Core.ML ? 10 : 12))
                    {
                        RunTo(toDispel);
                    }
                }
                else
                {
                    RunTo(c);
                }

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

                m_NextCastTime = Core.TickCount + (int)GetDelay(spell).TotalMilliseconds;
            }
            else if (m_Mobile.Spell == null || !m_Mobile.Spell.IsCasting)
            {
                RunTo(c);
            }

            m_LastTarget    = c;
            m_LastTargetLoc = c.Location;

            return(true);
        }