Esempio n. 1
0
        public override bool DoEffect(Mobile from, Mobile target)
        {
            if (from.CanSee(target) && from.CanBeHarmful(target) && from.InLOS(target) && target.Alive)
            {
                ManaDrainSpell.DoEffect(from, target, (int)SpellCircle.Fifth);

                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        public virtual Spell ChooseSpell(Mobile c)
        {
            Spell spell = this.CheckCastHealingSpell();

            if (spell != null)
            {
                return(spell);
            }

            double damage = ((this.m_Mobile.Skills[SkillName.SpiritSpeak].Value - c.Skills[SkillName.MagicResist].Value) / 10) + (c.Player ? 18 : 30);

            if (damage > c.Hits)
            {
                spell = new ManaDrainSpell(this.m_Mobile, null);
            }

            switch (Utility.Random(16))
            {
            case 0:
            case 1:
            case 2:     // Poison them
            {
                this.m_Mobile.DebugSay("Attempting to BloodOath");

                if (!c.Poisoned)
                {
                    spell = new BloodOathSpell(this.m_Mobile, null);
                }

                break;
            }

            case 3:     // Bless ourselves.
            {
                this.m_Mobile.DebugSay("Blessing myself");

                spell = new BlessSpell(this.m_Mobile, null);
                break;
            }

            case 4:
            case 5:
            case 6:     // Curse them.
            {
                this.m_Mobile.DebugSay("Attempting to curse");

                spell = this.GetRandomCurseSpell();
                break;
            }

            case 7:     // Paralyze them.
            {
                this.m_Mobile.DebugSay("Attempting to paralyze");

                if (this.m_Mobile.Skills[SkillName.Magery].Value > 50.0)
                {
                    spell = new ParalyzeSpell(this.m_Mobile, null);
                }

                break;
            }

            case 8:     // Drain mana
            {
                this.m_Mobile.DebugSay("Attempting to drain mana");

                spell = this.GetRandomManaDrainSpell();
                break;
            }

            case 9:     // Blood oath them
            {
                this.m_Mobile.DebugSay("Attempting to blood oath");

                if (this.m_Mobile.Skills[SkillName.Necromancy].Value > 30 && BloodOathSpell.GetBloodOath(c) != this.m_Mobile)
                {
                    spell = new BloodOathSpell(this.m_Mobile, null);
                }

                break;
            }
            }

            return(spell);
        }
Esempio n. 3
0
        public Spell GetMagerySpell()
        {
            Spell spell = null;

            // always check for bless, per OSI
            spell = this.CheckBless();

            if (spell != null)
            {
                if (this.m_Mobile.Debug)
                {
                    this.m_Mobile.Say(1156, "Blessing my self");
                }

                return(spell);
            }

            // always check for curse, per OSI
            spell = this.CheckCurse();

            if (spell != null)
            {
                if (this.m_Mobile.Debug)
                {
                    this.m_Mobile.Say(1156, "Cursing my opponent");
                }

                return(spell);
            }

            // 25% chance to cast poison if needed
            if (this.m_Mobile.Combatant is Mobile && !((Mobile)m_Mobile.Combatant).Poisoned && Utility.RandomDouble() > 0.75)
            {
                if (this.m_Mobile.Debug)
                {
                    this.m_Mobile.Say(1156, "Casting Poison");
                }

                spell = new PoisonSpell(this.m_Mobile, null);
            }

            // scaling chance to drain mana based on how much of a caster the opponent is
            if (this.CheckManaDrain() > 0.75)
            {
                if (this.m_Mobile.Skills[SkillName.Magery].Value > 80.0)
                {
                    spell = new ManaVampireSpell(this.m_Mobile, null);
                }
                else if (this.m_Mobile.Skills[SkillName.Magery].Value > 40.0)
                {
                    spell = new ManaDrainSpell(this.m_Mobile, null);
                }

                if (spell != null)
                {
                    if (this.m_Mobile.Debug)
                    {
                        this.m_Mobile.Say(1156, "Draining mana");
                    }

                    return(spell);
                }
            }

            // 10% chance to summon help
            if (this.m_CanUseMagerySummon && Utility.RandomDouble() > 0.90)
            {
                spell = this.CheckMagerySummon();

                if (spell != null)
                {
                    if (this.m_Mobile.Debug)
                    {
                        this.m_Mobile.Say(1156, "Summoning help");
                    }
                    return(spell);
                }
            }

            // Let's just blast the hell out of them.
            return(this.GetRandomMageryDamageSpell());
        }
Esempio n. 4
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);
        }