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) { m_pss = new PoisonSpell(this, null); // get your spell if (m_pss.Cast()) // if it casts the spell { TimeSpan castDelay = m_pss.GetCastDelay(); m_CastTimer = new PSCastTimer(m_pss, from, castDelay); m_CastTimer.Start(); } } } }
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); }
public override bool DoActionCombat() { Mobile c = m_Mobile.Combatant; m_Mobile.Warmode = true; if (c == null || c.Deleted || !c.Alive || !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 (AquireFocusMob(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 (MobileOnDoomShip(m_Mobile)) { if (PlayersOnDoomShip() == 0) { if (Utility.RandomMinMax(0, 1) == 0) { m_Mobile.Location = new Point3D(424, 328, -1); } else { m_Mobile.Location = new Point3D(432, 331, -2); } Action = ActionType.Guard; return(true); } } else if (NeedJumpToDoomShip()) { m_Mobile.Location = new Point3D(428, 327, 2); Action = ActionType.Guard; return(true); } if (!m_Mobile.InLOS(c)) { if (AquireFocusMob(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 (AquireFocusMob(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 (ChanceToDetectHidden >= Utility.RandomDouble()) { m_Mobile.DebugSay("Detecting hidden...", c.Name); DetectHiden(); } if (!m_Mobile.Controled && !m_Mobile.Summoned) { m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed + m_Mobile.ActiveSpeed * (1 + 1 - (m_Mobile.Hits / m_Mobile.HitsMax)); 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 && 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); } else if (toDispel != null) // Something dispellable is attacking us { 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 (false && 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); } else { double del = ScaleByMagery(3.0); 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); }
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); }
public virtual Spell ChooseSpell(Mobile c) { Spell spell = null; if (!SmartAI) { spell = CheckCastHealingSpell(); if (spell != null) { return(spell); } if (IsNecromancer) { double psDamage = ((m_Mobile.Skills[SkillName.SpiritSpeak].Value - c.Skills[SkillName.MagicResist].Value) / 10) + (c.Player ? 18 : 30); if (psDamage > c.Hits) { return(new PainSpikeSpell(m_Mobile, null)); } } switch (Utility.Random(16)) { case 0: case 1: // Poison them { if (c.Poisoned) { goto default; } m_Mobile.DebugSay("Attempting to poison"); spell = new PoisonSpell(m_Mobile, null); break; } case 2: // Bless ourselves { m_Mobile.DebugSay("Blessing myself"); spell = new BlessSpell(m_Mobile, null); break; } case 3: case 4: // Curse them { m_Mobile.DebugSay("Attempting to curse"); spell = GetRandomCurseSpell(); break; } case 5: // Paralyze them { if (c.Paralyzed || m_Mobile.Skills[SkillName.Magery].Value <= 50.0) { goto default; } m_Mobile.DebugSay("Attempting to paralyze"); spell = new ParalyzeSpell(m_Mobile, null); break; } case 6: // Drain mana { m_Mobile.DebugSay("Attempting to drain mana"); spell = GetRandomManaDrainSpell(); break; } case 7: // Invis ourselves { if (Utility.RandomBool()) { goto default; } m_Mobile.DebugSay("Attempting to invis myself"); spell = new InvisibilitySpell(m_Mobile, null); break; } default: // Damage them { m_Mobile.DebugSay("Just doing damage"); spell = GetRandomDamageSpell(); break; } } return(spell); } spell = CheckCastHealingSpell(); if (spell != null) { return(spell); } switch (Utility.Random(3)) { case 0: // Poison them { if (c.Poisoned) { goto case 1; } spell = new PoisonSpell(m_Mobile, null); break; } case 1: // Deal some damage { spell = GetRandomDamageSpell(); break; } default: // Set up a combo { if (m_Mobile.Mana > 15 && m_Mobile.Mana < 40) { if (c.Paralyzed && !c.Poisoned && !m_Mobile.Meditating) { 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.RandomBool() && !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); }
public virtual Spell ChooseSpell(Mobile c) { Spell spell = null; spell = GetRandomBlessSpell(); if (spell != null) { return(spell); } spell = CheckCastHealingSpell(); if (spell != null) { return(spell); } switch (Utility.Random(10)) { default: case 0: case 1: // Curse them. { spell = GetRandomCurseSpell(c); break; } case 2: // Poison them { if (!c.Poisoned) { spell = new PoisonSpell(m_Mobile, null); } break; } case 3: // Drain some mana { spell = GetRandomManaDrainSpell(c); break; } case 4: case 5: case 6: // Deal some damage { spell = GetRandomDamageSpell(c); break; } case 7: case 8: case 9: // 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); }
public virtual Spell ChooseSpell(Mobile c) { Spell spell = null; if (!SmartAI) { spell = CheckCastHealingSpell(); if (spell != null) { return(spell); } switch (Utility.Random(16)) { case 0: case 1: // Poison them { //m_Mobile.DebugSay( "Attempting to poison" ); if (!c.Poisoned) { spell = new PoisonSpell(m_Mobile, null); } break; } case 2: // Bless ourselves. { //m_Mobile.DebugSay( "Blessing myself" ); spell = new BlessSpell(m_Mobile, null); break; } case 3: case 4: // Curse them. { //m_Mobile.DebugSay( "Attempting to curse" ); spell = GetRandomCurse(); break; } case 5: // 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 6: // Drain mana { //m_Mobile.DebugSay( "Attempting to drain mana" ); spell = GetRandomManaDrainSpell(); break; } case 7: { //m_Mobile.DebugSay( "Attempting to Invis" ); if (spell == null) { spell = new InvisibilitySpell(m_Mobile, null); } break; } default: // Damage them. { //m_Mobile.DebugSay( "Just doing damage" ); spell = GetRandomDamage(); break; } } return(spell); } spell = CheckCastHealingSpell(); if (spell != null) { return(spell); } switch (Utility.Random(2)) // Removido COMBO Utility.Random( 3 ) { default: case 0: // Poison them { if (!c.Poisoned) { spell = new PoisonSpell(m_Mobile, null); } break; } case 1: // Deal some damage { spell = GetRandomDamageSpell(); 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; } } return(spell); }
public void Target(Mobile m) { if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); /* Creates a blast of poisonous energy centered on the target. * The main target is inflicted with a large amount of Poison damage, and all valid targets in a radius of 2 tiles around the main target are inflicted with a lesser effect. * One tile from main target receives 50% damage, two tiles from target receives 33% damage. */ Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x36B0, 1, 14, 63, 7, 9915, 0); Effects.PlaySound(m.Location, m.Map, 0x229); double damage = Utility.RandomMinMax(32, 40) * ((300 + (GetDamageSkill(Caster) * 9)) / 1000); damage += damage * (SpellHelper.GetSpellDamage(Caster, m.Player) / 100.0); Map map = m.Map; if (map != null) { ArrayList targets = new ArrayList(); foreach (Mobile targ in m.GetMobilesInRange(2)) { if ((Caster == targ || SpellHelper.ValidIndirectTarget(Caster, targ)) && Caster.CanBeHarmful(targ, false)) { targets.Add(targ); } } for (int i = 0; i < targets.Count; ++i) { Mobile targ = (Mobile)targets[i]; int num; if (targ.InRange(m.Location, 0)) { num = 1; } else if (targ.InRange(m.Location, 1)) { num = 2; } else { num = 3; } Caster.DoHarmful(targ); SpellHelper.Damage(this, targ, damage / num, 0, 0, 0, 100, 0); } } // Necromancers with greater than 60 poisoning skill will have a 3% to 9% chance // (Scales with poison skill) to poison their target. double poisoning = Caster.Skills.Poisoning.Value; if (poisoning >= 60.0) { double chance = (3.0 + (poisoning - 60.0) * 0.15) / 100.0; if (chance > Utility.RandomDouble()) { int level = PoisonSpell.GetPoisonLevel(Caster, m, SkillName.Poisoning, SkillName.Necromancy); m.ApplyPoison(Caster, Poison.GetPoison(level)); } } } FinishSequence(); }
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()); }
public virtual Spell DoCombo(Mobile c) { Spell spell = null; m_Mobile.DebugSay("Doing Combo"); if (m_Combo == 0) { m_Mobile.DebugSay(" Casting Explosion and moving to the next spell "); spell = new ExplosionSpell(m_Mobile, null); ++m_Combo; // Move to next spell } else if (m_Combo == 1) { if (m_Mobile.Skills[SkillName.Magery].Value * Utility.RandomDouble() > m_Mobile.Skills[SkillName.Necromancy].Value * Utility.RandomDouble()) { spell = new FlameStrikeSpell(m_Mobile, null); m_Mobile.DebugSay("Casting Flamestrike and moving to the next spell "); } else { spell = new PoisonStrikeSpell(m_Mobile, null); m_Mobile.DebugSay("Casting Poison Strike and moving to the next spell "); } ++m_Combo; // Move to next spell } else if (m_Combo == 2) { m_Mobile.DebugSay("Casting maybe poison and moving to next spell"); 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 PoisonSpell(m_Mobile, null); } else { spell = new PainSpikeSpell(m_Mobile, null); } ++m_Combo; // Move to next spell } else if (m_Combo == 3 && spell == null) { switch (Utility.Random(3)) { default: case 0: { m_Mobile.DebugSay("Casting small spell"); spell = GetSmallDamageSpell(); m_Mobile.DebugSay("Moving to next spell"); ++m_Combo; // Move to next spell break; } case 1: { m_Mobile.DebugSay("Casting Strangle and resetting combo"); spell = new StrangleSpell(m_Mobile, null); m_Combo = -1; // Reset combo state break; } case 2: { m_Mobile.DebugSay("Casting small spell"); spell = GetSmallDamageSpell(); break; } } } else if (m_Combo == 4 && spell == null) { m_Mobile.DebugSay("Casting Vengeful Spirit and resetting combo"); spell = new VengefulSpiritSpell(m_Mobile, null); m_Combo = -1; } return(spell); }
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); }
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 override Spell DoCombo(Mobile c) { Spell spell = null; if (m_NecroComboType == NecroComboType.None) { m_NecroComboType = (NecroComboType)Utility.RandomMinMax(1, 7); m_Combo = 0; m_Mobile.DebugSay("Doing {0} Combo", m_NecroComboType); } if (m_Combo == 0) { switch (m_NecroComboType) { case NecroComboType.Exp_FS_Omen_Poison_PS: case NecroComboType.Exp_MB_Omen_Poison_PS: case NecroComboType.Exp_EB_Omen_Poison_PS: case NecroComboType.Exp_FB_MA_Poison_PS: case NecroComboType.Exp_FB_Poison_PS: case NecroComboType.Exp_FB_MA_PS: case NecroComboType.Exp_Poison_FB_PS: spell = new ExplosionSpell(m_Mobile, null); break; } ++m_Combo; } else if (m_Combo == 1) { switch (m_NecroComboType) { case NecroComboType.Exp_FS_Omen_Poison_PS: spell = new FlameStrikeSpell(m_Mobile, null); break; case NecroComboType.Exp_MB_Omen_Poison_PS: spell = new MindBlastSpell(m_Mobile, null); break; case NecroComboType.Exp_EB_Omen_Poison_PS: spell = new EnergyBoltSpell(m_Mobile, null); break; case NecroComboType.Exp_FB_MA_Poison_PS: case NecroComboType.Exp_FB_Poison_PS: case NecroComboType.Exp_FB_MA_PS: spell = new FireballSpell(m_Mobile, null); break; case NecroComboType.Exp_Poison_FB_PS: spell = new PoisonSpell(m_Mobile, null); break; } ++m_Combo; } else if (m_Combo == 2) { switch (m_NecroComboType) { case NecroComboType.Exp_FS_Omen_Poison_PS: case NecroComboType.Exp_MB_Omen_Poison_PS: case NecroComboType.Exp_EB_Omen_Poison_PS: spell = new EvilOmenSpell(m_Mobile, null); break; case NecroComboType.Exp_FB_MA_Poison_PS: spell = new MagicArrowSpell(m_Mobile, null); break; case NecroComboType.Exp_FB_Poison_PS: spell = new PoisonSpell(m_Mobile, null); break; case NecroComboType.Exp_FB_MA_PS: spell = new MagicArrowSpell(m_Mobile, null); break; case NecroComboType.Exp_Poison_FB_PS: spell = new FireballSpell(m_Mobile, null); break; } ++m_Combo; } else if (m_Combo == 3) { switch (m_NecroComboType) { case NecroComboType.Exp_FS_Omen_Poison_PS: case NecroComboType.Exp_MB_Omen_Poison_PS: case NecroComboType.Exp_EB_Omen_Poison_PS: case NecroComboType.Exp_FB_MA_Poison_PS: case NecroComboType.Exp_FB_Poison_PS: spell = new PoisonSpell(m_Mobile, null); break; case NecroComboType.Exp_FB_MA_PS: case NecroComboType.Exp_Poison_FB_PS: if (Utility.RandomBool()) { spell = new PoisonStrikeSpell(m_Mobile, null); } else { spell = new PainSpikeSpell(m_Mobile, null); } EndCombo(); return(spell); } ++m_Combo; } else if (m_Combo == 4) { switch (m_NecroComboType) { case NecroComboType.Exp_FS_Omen_Poison_PS: case NecroComboType.Exp_MB_Omen_Poison_PS: case NecroComboType.Exp_EB_Omen_Poison_PS: case NecroComboType.Exp_FB_MA_Poison_PS: case NecroComboType.Exp_FB_Poison_PS: case NecroComboType.Exp_FB_MA_PS: case NecroComboType.Exp_Poison_FB_PS: if (Utility.RandomBool()) { spell = new PoisonStrikeSpell(m_Mobile, null); } else { spell = new PainSpikeSpell(m_Mobile, null); } EndCombo(); return(spell); } } return(spell); }
public virtual Spell DoCombo(Mobile c) { Spell spell = null; m_Mobile.DebugSay("Doing Combo"); if (m_Combo == 0) { m_Mobile.DebugSay(" Casting Explosion and moving to the next spell "); spell = new ExplosionSpell(m_Mobile, null); ++m_Combo; // Move to next spell } else if (m_Combo == 1) { spell = new FlameStrikeSpell(m_Mobile, null); m_Mobile.DebugSay("Casting Flamestrike and moving to the next spell "); ++m_Combo; // Move to next spell } else if (m_Combo == 2) { m_Mobile.DebugSay("Casting maybe poison and moving to next spell"); 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 PoisonSpell(m_Mobile, null); } else { spell = new HarmSpell(m_Mobile, null); } ++m_Combo; // Move to next spell } else if (m_Combo == 3 && spell == null) { switch (Utility.Random(3)) { default: case 0: { m_Mobile.DebugSay("Random small Spell and next spell"); spell = GetSmallDamageSpell(); ++m_Combo; // Move to next spell break; } case 1: { m_Mobile.DebugSay("Random small spell and resetting combo"); spell = GetSmallDamageSpell(); m_Combo = -1; // Reset combo state break; } case 2: { m_Mobile.DebugSay("Random small spell and same state"); spell = GetSmallDamageSpell(); break; } } } else if (m_Combo == 4 && spell == null) { m_Mobile.DebugSay("Casting Flamestrike and resetting combo"); spell = new FlameStrikeSpell(m_Mobile, null); m_Combo = -1; } 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) { 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()); } 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(5 + healChance)) { case 0: // Heal myself { if (!m_Mobile.Summoned) { if (m_Mobile.Hits < (m_Mobile.HitsMax - 50)) { m_Mobile.UseSkill(SkillName.SpiritSpeak); } else if (m_Mobile.Hits < (m_Mobile.HitsMax - 10)) { m_Mobile.UseSkill(SkillName.SpiritSpeak); } } break; } case 1: // PoisonStrike them { if (!c.Poisoned) { spell = new PoisonStrikeSpell(m_Mobile, null); } break; } case 2: // Deal some damage { spell = GetRandomDamageSpell(); 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) { 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_Combo = 0; spell = new PainSpikeSpell(m_Mobile, null); } else { m_Combo = 1; spell = new MindRotSpell(m_Mobile, null); } } break; } case 4: //Combo to soften our enemies with a powerful attack while we have max mana amounts { if (m_Mobile.Mana > 80) { if (Utility.Random(2) == 0 && !c.Paralyzed && !c.Frozen && !c.Poisoned) { m_Combo = 0; spell = new VengefulSpiritSpell(m_Mobile, null); } else { m_Combo = 1; spell = new PoisonStrikeSpell(m_Mobile, null); } } break; } } return(spell); }
public virtual Spell DoCombo(Mobile c) { Spell spell = null; if (m_Combo == 0) { //m_Mobile.Say( "combo phase 0" ); spell = new ExplosionSpell(m_Mobile, null); ++m_Combo; // Move to next spell } else if (m_Combo == 1) { //m_Mobile.Say( "combo phase 1" ); spell = new ExplosionSpell(m_Mobile, null); ++m_Combo; // Move to next spell } else if (m_Combo == 2) { //m_Mobile.Say( "combo phase 2" ); if (!c.Poisoned) { spell = new PoisonSpell(m_Mobile, null); } ++m_Combo; // Move to next spell } else if (m_Combo == 3) { //m_Mobile.Say( "combo phase 3" ); if (c.Poisoned) { spell = new WeakenSpell(m_Mobile, null); } if (!c.Poisoned) { spell = new PoisonSpell(m_Mobile, null); } ++m_Combo; // Move to next spell } else if (m_Combo == 4) { // m_Mobile.Say( "combo phase 4 ebolt" ); spell = new EnergyBoltSpell(m_Mobile, null); ++m_Combo; // Move to next spell } else if (m_Combo == 5) { //m_Mobile.Say( "combo phase 5" ); if (c.Poisoned && c.Alive) { spell = new HarmSpell(m_Mobile, null); m_Combo = 5; // Move to next spell } if (!c.Poisoned) { if (m_Mobile.Mana > 20) { spell = new EnergyBoltSpell(m_Mobile, null); } if (m_Mobile.Mana < 19) { spell = new LightningSpell(m_Mobile, null); } m_Combo = -1; // Reset combo state } } return(spell); }
public virtual Spell DoCombo(Mobile c) { Spell spell = null; if (m_Combo == 0) { spell = new FlameStrikeSpell(m_Mobile, null); ++m_Combo; // Move to next spell } else if (m_Combo == 1) { spell = new WitherSpell(m_Mobile, null); ++m_Combo; // Move to next spell } else if (m_Combo == 2) { if (!c.Poisoned) { spell = new PoisonSpell(m_Mobile, null); } ++m_Combo; // Move to next spell } if (m_Combo == 3 && spell == null) { switch (Utility.Random(3)) { default: case 0: { if (c.Int < c.Dex) { spell = new MindRotSpell(m_Mobile, null); } else { spell = new WitherSpell(m_Mobile, null); } ++m_Combo; // Move to next spell break; } case 1: { spell = new StrangleSpell(m_Mobile, null); m_Combo = -1; // Reset combo state break; } case 2: { spell = new WitherSpell(m_Mobile, null); m_Combo = -1; // Reset combo state break; } } } else if (m_Combo == 4 && spell == null) { spell = new VengefulSpiritSpell(m_Mobile, null); m_Combo = -1; } return(spell); }
public virtual Spell ChooseSpell(Mobile c) { Spell spell = null; if (!SmartAI) { spell = CheckCastHealingSpell(); if (spell != null) { return(spell); } switch (Utility.Random(15)) { case 0: case 1: // Poison them { if (c.Poisoned) { goto default; } m_Mobile.DebugSay("Attempting to poison"); spell = new PoisonSpell(m_Mobile, null); break; } case 2: // Bless ourselves { m_Mobile.DebugSay("Blessing myself"); spell = GetRandomBuffSpell(); //new BlessSpell(this.m_Mobile, null); break; } case 3: case 4: // Curse them { m_Mobile.DebugSay("Attempting to curse"); spell = GetRandomCurseSpell(); break; } case 5: // Paralyze them { if (c.Paralyzed || m_Mobile.Skills[SkillName.Magery].Value <= 50.0) { goto default; } m_Mobile.DebugSay("Attempting to paralyze"); spell = new ParalyzeSpell(m_Mobile, null); break; } case 6: // 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); } switch (Utility.Random(3)) { case 0: // Poison them { if (c.Poisoned) { goto case 1; } spell = new PoisonSpell(m_Mobile, null); break; } case 1: // Deal some damage { spell = GetRandomDamageSpell(); break; } default: // Set up a combo { if (m_Mobile.Mana > 15 && m_Mobile.Mana < 40) { if (c.Paralyzed && !c.Poisoned && !m_Mobile.Meditating) { 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.RandomBool() && !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); }
public override Spell ChooseSpell(Mobile c) { Spell spell = CheckCastHealingSpell(); if (spell != null) { return(spell); } switch (Utility.Random(16)) { case 0: case 1: 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"); if (Utility.RandomBool() && !ArcaneEmpowermentSpell.IsBuffed(m_Mobile)) { spell = new ArcaneEmpowermentSpell(m_Mobile, null); } else { spell = new BlessSpell(m_Mobile, null); } break; } case 4: // Wildfire { m_Mobile.DebugSay("Incendio!"); spell = new WildfireSpell(m_Mobile, null); break; } case 5: // Reduce their cast speed { if (c.InRange(m_Mobile.Location, 6)) { if (m_Mobile.Skills[SkillName.Spellweaving].Value >= 90.0) { spell = new EssenceOfWindSpell(m_Mobile, null); } else if (c.InRange(m_Mobile.Location, 2)) { spell = new ThunderstormSpell(m_Mobile, null); } } m_Mobile.DebugSay("Attempting to reduce their cast speed"); break; } case 6: // Curse them. { m_Mobile.DebugSay("Attempting to curse"); spell = GetRandomCurseSpell(c); 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(c); break; } default: // Damage them. { m_Mobile.DebugSay("Just doing damage"); spell = GetRandomDamageSpell(c); break; } } return(spell); }
public PSCastTimer(PoisonSpell spell, Mobile target, TimeSpan castDelay) : base(castDelay) { m_Spell = spell; m_Target = target; Priority = TimerPriority.OneSecond; }
public virtual Spell ChooseSpell(Mobile c) { Spell spell = CheckCastHealingSpell(); if (spell != null) { return(spell); } double damage = ((m_Mobile.Skills[SkillName.SpiritSpeak].Value - c.Skills[SkillName.MagicResist].Value) / 10) + (c.Player ? 18 : 30); if (damage > c.Hits) { return(new PainSpikeSpell(m_Mobile, null)); } switch (Utility.Random(20)) { case 0: case 1: 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: 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; } case 9: case 10: // Blood oath them { m_Mobile.DebugSay("Attempting to blood oath"); if (m_Mobile.Skills[SkillName.Necromancy].Value > 30 && BloodOathSpell.GetBloodOath(c) != m_Mobile) { spell = new BloodOathSpell(m_Mobile, null); } break; } case 11: case 12: // Animate dead { m_Mobile.DebugSay("Attempting to animate dead"); if ((m_Animated == null || !m_Animated.Alive) && m_Mobile.Skills[SkillName.Necromancy].Value > 40) { spell = new AnimateDeadSpell(m_Mobile, null); } break; } case 13: case 14: { m_Mobile.DebugSay("Attempting to cast vengeful spirit"); if (m_Mobile.Skills[SkillName.Necromancy].Value > 80 && (m_Mobile.Followers + 3) < m_Mobile.FollowersMax) { spell = new VengefulSpiritSpell(m_Mobile, null); } break; } default: // Damage them. { m_Mobile.DebugSay("Just doing damage"); spell = GetRandomDamageSpell(); break; } } return(spell); }
public override bool DoActionCombat() { Mobile c = m_Mobile.Combatant; m_Mobile.Warmode = true; if (m_Mobile.ChangeCombatantChance > Utility.RandomDouble()) { if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { if (m_Mobile.Debug) { m_Mobile.DebugSay("Changing my combatant, now I am going to fight {0}", m_Mobile.FocusMob.Name); } m_Mobile.Combatant = c = m_Mobile.FocusMob; m_Mobile.FocusMob = null; } } 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)) { m_Mobile.DebugSay("I can't see my target"); if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { m_Mobile.DebugSay("Nobody else is around"); m_Mobile.Combatant = c = m_Mobile.FocusMob; m_Mobile.FocusMob = null; } } 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) { 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.UtcNow > 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 { m_Mobile.DebugSay("I am going to cure myself"); spell = new CureSpell(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 (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 RunTo(c); TimeSpan delay = TimeSpan.FromSeconds(m_Mobile.ActiveSpeed); if (spell != null) { spell.Cast(); delay += spell.GetCastRecovery(); } if (m_Mobile.Mana < 20) { m_NextCastTime = DateTime.UtcNow + TimeSpan.FromSeconds(10.0); // Let mana raise... } else { m_NextCastTime = DateTime.UtcNow + delay; } } else if (m_Mobile.Spell == null || !m_Mobile.Spell.IsCasting) { RunTo(c); } return(true); }
public virtual Spell ChooseSpell(IDamageable d) { if (!(d is Mobile)) { m_Mobile.DebugSay("Just doing damage"); return(GetRandomDamageSpell()); } Mobile c = d as Mobile; Spell spell = null; if (!SmartAI) { spell = CheckCastHealingSpell(); if (spell != null) { return(spell); } if (spell == null && m_Mobile.RawInt >= 80) { spell = CheckCastDispelField(); } switch (Utility.Random(15)) { case 0: case 1: // Poison them { if (c.Poisoned || !CheckCast(3)) { goto default; } m_Mobile.DebugSay("Attempting to poison"); spell = new PoisonSpell(m_Mobile, null); break; } case 2: // Bless ourselves { if (BlessSpell.IsBlessed(m_Mobile) || !CheckCast(3)) { goto default; } m_Mobile.DebugSay("Blessing myself"); spell = GetRandomBuffSpell(); //new BlessSpell(m_Mobile, null); break; } case 3: case 4: // Curse them { m_Mobile.DebugSay("Attempting to curse"); spell = GetRandomCurseSpell(); if (spell == null) { goto default; } break; } case 5: // Paralyze them { m_Mobile.DebugSay("Attempting to paralyze"); if (CheckCast(5)) { spell = new ParalyzeSpell(m_Mobile, null); } else { spell = GetRandomCurseSpell(); } if (spell == null) { goto default; } break; } case 6: // Drain mana { m_Mobile.DebugSay("Attempting to drain mana"); spell = GetRandomManaDrainSpell(); if (spell == null) { goto default; } break; } default: // Damage them { m_Mobile.DebugSay("Just doing damage"); spell = GetRandomDamageSpell(); break; } } return(spell); } if (m_Mobile.Hidden) { return(null); } spell = CheckCastDispelField(); if (spell == null) { spell = CheckCastHealingSpell(); } if (spell == null && 0.05 >= Utility.RandomDouble()) { spell = GetRandomBuffSpell(); } else if (spell == null && m_Mobile.Followers + 1 < m_Mobile.FollowersMax && 0.05 >= Utility.RandomDouble()) { spell = GetRandomSummonSpell(); } else if (spell == null && 0.05 >= Utility.RandomDouble()) { spell = GetRandomFieldSpell(); } else if (spell == null && 0.05 >= Utility.RandomDouble()) { spell = GetRandomManaDrainSpell(); } if (spell != null) { return(spell); } switch (Utility.Random(3)) { case 0: // Poison them { if (c.Poisoned) { goto case 1; } spell = new PoisonSpell(m_Mobile, null); break; } case 1: // Deal some damage { spell = GetRandomDamageSpell(); break; } default: // Set up a combo { if (m_Mobile.Mana > 15 && m_Mobile.Mana < 40) { if (c.Paralyzed && !c.Poisoned && !m_Mobile.Meditating) { 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.RandomBool() && !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); }
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 && DateTime.Now > m_NextCastTime && 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 CureSpell(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 = DateTime.Now + GetDelay(spell); } else if (m_Mobile.Spell == null || !m_Mobile.Spell.IsCasting) { RunTo(c); } m_LastTarget = c; m_LastTargetLoc = c.Location; return(true); }
public virtual Spell DoCombo(Mobile c) { Spell spell = null; if (m_ComboType == ComboType.None) { m_ComboType = (ComboType)Utility.RandomMinMax(1, 7); } if (m_Combo == 1) { switch (m_ComboType) { case ComboType.Exp_FS_Poison: case ComboType.Exp_MB_Poison: case ComboType.Exp_EB_Poison: case ComboType.Exp_FB_MA_Poison: case ComboType.Exp_FB_Poison_Light: case ComboType.Exp_FB_MA_Light: case ComboType.Exp_Poison_FB_Light: spell = new ExplosionSpell(m_Mobile, null); break; } } else if (m_Combo == 2) { switch (m_ComboType) { case ComboType.Exp_FS_Poison: spell = new FlameStrikeSpell(m_Mobile, null); break; case ComboType.Exp_MB_Poison: spell = new MindBlastSpell(m_Mobile, null); break; case ComboType.Exp_EB_Poison: spell = new EnergyBoltSpell(m_Mobile, null); break; case ComboType.Exp_FB_MA_Poison: spell = new FireballSpell(m_Mobile, null); break; case ComboType.Exp_FB_Poison_Light: spell = new FireballSpell(m_Mobile, null); break; case ComboType.Exp_FB_MA_Light: spell = new FireballSpell(m_Mobile, null); break; case ComboType.Exp_Poison_FB_Light: spell = new PoisonSpell(m_Mobile, null); break; } } else if (m_Combo == 3) { switch (m_ComboType) { case ComboType.Exp_FS_Poison: case ComboType.Exp_MB_Poison: case ComboType.Exp_EB_Poison: spell = new PoisonSpell(m_Mobile, null); EndCombo(); return(spell); case ComboType.Exp_FB_MA_Poison: spell = new MagicArrowSpell(m_Mobile, null); break; case ComboType.Exp_FB_Poison_Light: spell = new PoisonSpell(m_Mobile, null); break; case ComboType.Exp_FB_MA_Light: spell = new MagicArrowSpell(m_Mobile, null); break; case ComboType.Exp_Poison_FB_Light: spell = new FireballSpell(m_Mobile, null); break; } } else if (m_Combo == 4) { switch (m_ComboType) { case ComboType.Exp_FS_Poison: case ComboType.Exp_MB_Poison: case ComboType.Exp_EB_Poison: spell = new LightningSpell(m_Mobile, null); EndCombo(); return(spell); case ComboType.Exp_FB_MA_Poison: spell = new PoisonSpell(m_Mobile, null); break; case ComboType.Exp_FB_Poison_Light: case ComboType.Exp_FB_MA_Light: case ComboType.Exp_Poison_FB_Light: spell = new LightningSpell(m_Mobile, null); EndCombo(); return(spell); } } else if (m_Combo == 5) { switch (m_ComboType) { case ComboType.Exp_FS_Poison: case ComboType.Exp_MB_Poison: case ComboType.Exp_EB_Poison: case ComboType.Exp_FB_MA_Poison: case ComboType.Exp_FB_Poison_Light: case ComboType.Exp_FB_MA_Light: case ComboType.Exp_Poison_FB_Light: spell = new LightningSpell(m_Mobile, null); EndCombo(); return(spell); } } m_Combo++; // Move to next spell if (spell == null) { spell = new PoisonSpell(m_Mobile, null); } return(spell); }
public virtual Spell DoCombo(Mobile c) { Spell spell = null; if (m_Combo == 0) { spell = new ExplosionSpell(m_Mobile, null); ++m_Combo; // Move to next spell } else if (m_Combo == 1) { spell = new WeakenSpell(m_Mobile, null); ++m_Combo; // Move to next spell } else if (m_Combo == 2) { if (!c.Poisoned) { spell = new PoisonSpell(m_Mobile, null); } ++m_Combo; // Move to next spell } if (m_Combo == 3 && spell == null) { switch (Utility.Random(3)) { default: case 0: { if (c.Int < c.Dex) { spell = new FeeblemindSpell(m_Mobile, null); } else { spell = new ClumsySpell(m_Mobile, null); } ++m_Combo; // Move to next spell break; } case 1: { spell = new EnergyBoltSpell(m_Mobile, null); m_Combo = -1; // Reset combo state break; } case 2: { spell = new FlameStrikeSpell(m_Mobile, null); m_Combo = -1; // Reset combo state break; } } } else if (m_Combo == 4 && spell == null) { spell = new MindBlastSpell(m_Mobile, null); m_Combo = -1; } return(spell); }
public override bool DoActionCombat() { IDamageable c = m_Mobile.Combatant; m_Mobile.Warmode = true; if (m_Mobile.Target != null) { ProcessTarget(); } if (c == null || c.Deleted || !c.Alive || (c is Mobile && ((Mobile)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 as Mobile; 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? if (Utility.Random(100) <= Math.Max(10, 10 + c.Hits - m_Mobile.Hits)) { m_Mobile.DebugSay("I am going to flee from {0}", c.Name); Action = ActionType.Flee; return(true); } } } if (m_Mobile.Spell == null && DateTime.UtcNow > m_NextCastTime && 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 = CheckCastCureSpell(); } else if (toDispel != null) // Something dispellable is attacking us { m_Mobile.DebugSay("I am going to dispel {0}", toDispel); spell = DoDispel(toDispel); } else if (c is Mobile && SmartAI && m_Combo != -1) // We are doing a spell combo { spell = DoCombo((Mobile)c); } else if (c is Mobile && SmartAI && (((Mobile)c).Spell is HealSpell || ((Mobile)c).Spell is GreaterHealSpell) && !((Mobile)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 TimeSpan ts = !SmartAI && !(spell is DispelSpell) ? TimeSpan.FromSeconds(1) : m_Combo > -1 ? TimeSpan.FromSeconds(.5) : TimeSpan.FromSeconds(1.5); TimeSpan delay = spell == null?TimeSpan.FromSeconds(m_Mobile.ActiveSpeed) : spell.GetCastDelay() + spell.GetCastRecovery() + ts; RunTo(c); if (spell != null) { spell.Cast(); } m_NextCastTime = DateTime.UtcNow + delay; } else { RunTo(c); } m_LastTarget = c as Mobile; m_LastTargetLoc = c.Location; return(true); }
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); }
public override Spell DoCombo(Mobile c) { //m_Mobile.Say("doing human AI combo"); if (c is PlayerMobile && SmartAI && (c.Spell is MagicTrapSpell || c.Spell is MagicArrowSpell)) { m_EnemyCountersPara = true; } Spell spell = null; if (Combo == 0) { //m_Mobile.Say( "combo phase 1" ); spell = new ExplosionSpell(m_Mobile, null); ++Combo; // Move to next spell } if (Combo == 1) { //m_Mobile.Say( "combo phase 1" ); spell = new ExplosionSpell(m_Mobile, null); ++Combo; // Move to next spell } else if (Combo == 2) { //m_Mobile.Say( "combo phase 2" ); if (!c.Poisoned && (CheckCanPoison(c))) { spell = new PoisonSpell(m_Mobile, null); } ++Combo; // Move to next spell } else if (Combo == 3) { //m_Mobile.Say( "combo phase 3" ); if (c.Poisoned || !CheckCanPoison(c)) { spell = new WeakenSpell(m_Mobile, null); } if (!c.Poisoned && (CheckCanPoison(c))) { spell = new PoisonSpell(m_Mobile, null); } ++Combo; // Move to next spell } else if (Combo == 4) { // m_Mobile.Say( "combo phase 4 ebolt" ); if (!c.Poisoned && (CheckCanPoison(c))) { spell = new PoisonSpell(m_Mobile, null); Combo = 4; } else { spell = new EnergyBoltSpell(m_Mobile, null); } ++Combo; // Move to next spell } else if (Combo == 5) { //m_Mobile.Say( "combo phase 5" ); if (c.Poisoned) { if (c.Hits < 20 && m_Mobile.Mana >= 20) { spell = new EnergyBoltSpell(m_Mobile, null); } else { spell = new HarmSpell(m_Mobile, null); } Combo = 5; // Move to next spell } if (!c.Poisoned) { if (m_Mobile.Mana > 20) { spell = new EnergyBoltSpell(m_Mobile, null); } if (m_Mobile.Mana < 19) { spell = new LightningSpell(m_Mobile, null); } Combo = -1; // Reset combo state } } return(spell); }