public virtual Spell ChooseSpell(Mobile c) { Spell spell = null; int healChance = (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : (m_Mobile.HitsMax / m_Mobile.Hits)); int spellResult; double witherChance = .10; //05% chance to wither per enemy in range m_Mobile.DebugSay("Choosing a Spell"); spellResult = Utility.Random(4 + healChance); m_Mobile.DebugSay("Chose " + spellResult); switch (spellResult) { case 0: // Heal myself { m_Mobile.DebugSay("0. Heal"); if (m_Mobile.Hits < (m_Mobile.HitsMax - 50)) { spell = new GreaterHealSpell(m_Mobile, null); } else if (m_Mobile.Hits < (m_Mobile.HitsMax - 20)) { spell = new HealSpell(m_Mobile, null); } break; } case 1: // PoisonStrike them { m_Mobile.DebugSay("1. Poison Strike or Pfield or Ffield"); if (!c.Poisoned && (!(c is BaseCreature) || (((BaseCreature)c).PoisonImmune != null && ((BaseCreature)m_Mobile).HitPoison != null && ((BaseCreature)c).PoisonImmune.Level < ((BaseCreature)m_Mobile).HitPoison.Level) || ((BaseCreature)c).PoisonImmune == null)) { if (Utility.RandomDouble() > .5) { spell = new PoisonStrikeSpell(m_Mobile, null); } else { spell = new PoisonFieldSpell(m_Mobile, null); //need to do targeting on fields } } else if (Utility.RandomDouble() > .5) { spell = new FireFieldSpell(m_Mobile, null); } else { spell = new FlameStrikeSpell(m_Mobile, null); } break; } case 2: // Deal some damage { List <Mobile> targets = new List <Mobile>(); BaseCreature cbc = m_Mobile as BaseCreature; bool isMonster = (cbc != null && !cbc.Controlled && !cbc.Summoned); //check if enough wither targets. foreach (Mobile m in m_Mobile.GetMobilesInRange(Core.ML ? 4 : 5)) { if (m_Mobile != m && m_Mobile.InLOS(m) && (isMonster || SpellHelper.ValidIndirectTarget(m_Mobile, m)) && m_Mobile.CanBeHarmful(m, false)) { /* * if (isMonster) * { * if (m is BaseCreature) * { * BaseCreature bc = (BaseCreature)m; * * if (!bc.Controlled && !bc.Summoned && bc.Team == cbc.Team) * continue; * } * else if (!m.Player) * { * continue; * } * } */ targets.Add(m); } } if (targets.Count * witherChance > Utility.RandomDouble()) { m_Mobile.DebugSay("2. Wither"); spell = new WitherSpell(m_Mobile, null); } else { spell = GetRandomDamageSpell(); m_Mobile.DebugSay("2. Random Spell"); } break; } case 3: // Set up a combo of attacks { if (m_Mobile.Mana < 30 && m_Mobile.Mana > 15) { if (c.Paralyzed && !c.Poisoned) { m_Mobile.DebugSay("I am going to meditate"); m_Mobile.UseSkill(SkillName.Meditation); } else if (!c.Poisoned && (!(c is BaseCreature) || (((BaseCreature)c).PoisonImmune != null && ((BaseCreature)m_Mobile).HitPoison != null && ((BaseCreature)c).PoisonImmune.Level < ((BaseCreature)m_Mobile).HitPoison.Level) || ((BaseCreature)c).PoisonImmune == null)) { m_Mobile.DebugSay("3. Casting Poison"); spell = new PoisonSpell(m_Mobile, null); } } else if (m_Mobile.Mana > 30 && m_Mobile.Mana < 80) { if (Utility.Random(2) == 0 && !c.Paralyzed && !c.Frozen && !c.Poisoned) { m_Mobile.DebugSay("3. Pain Spike (Explo)"); m_Combo = 0; spell = new PainSpikeSpell(m_Mobile, null); } else { m_Mobile.DebugSay("3. Mind Rot or Curse (FS)"); m_Combo = 1; if (Utility.RandomBool()) { spell = new CurseSpell(m_Mobile, null); } else { spell = new MindRotSpell(m_Mobile, null); } } } else { if (Utility.Random(2) == 0 && !c.Paralyzed && !c.Frozen && !c.Poisoned) { m_Mobile.DebugSay("4. Vengeful Spirit (Explo)"); m_Combo = 0; spell = new VengefulSpiritSpell(m_Mobile, null); } else { m_Mobile.DebugSay("4. Poison Strike (FS)"); m_Combo = 1; spell = new PoisonStrikeSpell(m_Mobile, null); } } break; } } return(spell); }
public virtual Spell ChooseSpell(Mobile c) { Spell spell = null; if (!SmartAI) { spell = CheckCastHealingSpell(); if (spell != null) { return(spell); } switch (Utility.Random(16)) { case 0: { spell = new FireballSpell(m_Mobile, null); break; } case 1: { m_Mobile.DebugSay("Protecting myself"); spell = new ProtectionSpell(m_Mobile, null); break; } case 2: // Poison them { m_Mobile.DebugSay("Attempting to poison"); if (!c.Poisoned) { spell = new PoisonSpell(m_Mobile, null); } break; } case 3: // Bless ourselves. { m_Mobile.DebugSay("Blessing myself"); spell = new BlessSpell(m_Mobile, null); break; } case 4: { m_Mobile.DebugSay("Summoning FIRE FIELD!!!"); spell = new FireFieldSpell(m_Mobile, null); break; } case 5: case 6: // Curse them. { m_Mobile.DebugSay("Attempting to curse"); spell = GetRandomCurseSpell(); break; } case 7: // Paralyze them. { m_Mobile.DebugSay("Attempting to paralyze"); if (m_Mobile.Skills[SkillName.Magery].Value > 50.0) { spell = new ParalyzeSpell(m_Mobile, null); } break; } case 8: // Drain mana { m_Mobile.DebugSay("Attempting to drain mana"); spell = GetRandomManaDrainSpell(); break; } default: // Damage them. { m_Mobile.DebugSay("Just doing damage"); spell = GetRandomDamageSpell(); break; } } return(spell); } spell = CheckCastHealingSpell(); if (spell != null) { return(spell); } if (!c.Poisoned && c.Spell != null && c.Mana > (c.ManaMax / 2)) { return(GetRandomManaDrainSpell()); } if (m_Mobile.Hits < (m_Mobile.HitsMax / 2) && 0.30 > Utility.RandomDouble()) { spell = new ProtectionSpell(m_Mobile, null); if (spell == null) { spell = new BlessSpell(m_Mobile, null); } if (spell != null) { return(spell); } } if (c.Hits < (c.HitsMax * 0.30)) //They're dying, set up a kill combo { m_Combo = 0; if (!c.Poisoned) { spell = new PoisonSpell(m_Mobile, null); } else { spell = new ParalyzeSpell(m_Mobile, null); } } switch (Utility.Random(10)) { default: case 0: // Deal some damage { spell = GetRandomDamageSpell(); break; } case 1: // Poison them { if (!c.Poisoned) { spell = new PoisonSpell(m_Mobile, null); } break; } case 2: // 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; } case 3: { spell = GetRandomCurseSpell(); break; } } return(spell); }
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); }