Exemple #1
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());
        }
Exemple #2
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);
        }