public static bool DoSpellCure(BaseCreature creature, Mobile target) { Spell spell = new CureSpell(creature, null); if (target != null) { creature.SpellTarget = target; spell.Cast(); return(true); } else { return(false); } }
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 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 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 override bool DoActionWander() { if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { if (m_Mobile.Debug) { m_Mobile.DebugSay("I am going to attack {0}", m_Mobile.FocusMob.Name); } m_Mobile.Combatant = m_Mobile.FocusMob; Action = ActionType.Combat; m_NextCastTime = DateTime.Now; } else if (SmartAI && m_Mobile.Mana < m_Mobile.ManaMax) { m_Mobile.DebugSay("I am going to meditate"); m_Mobile.UseSkill(SkillName.Meditation); } else { m_Mobile.DebugSay("I am wandering"); m_Mobile.Warmode = false; base.DoActionWander(); if (m_Mobile.Poisoned) { if (m_Mobile.Poison != null) { Spell curespell; if ((((m_Mobile.Skills[SkillName.Magery].Value / (m_Mobile.Poison.Level + 1)) - 20) * 7.5) > 50) { curespell = new CureSpell(m_Mobile, null); } else { curespell = new ArchCureSpell(m_Mobile, null); } curespell.Cast(); } else { new CureSpell(m_Mobile, null).Cast(); } } else if (!m_Mobile.Summoned && (SmartAI || (ScaleByMagery(HealChance) > Utility.RandomDouble()))) { if (m_Mobile.Hits < (m_Mobile.HitsMax - 50)) { if (!new GreaterHealSpell(m_Mobile, null).Cast()) { new HealSpell(m_Mobile, null).Cast(); } } else if (m_Mobile.Hits < (m_Mobile.HitsMax - 10)) { new HealSpell(m_Mobile, null).Cast(); } } } return(true); }
public override bool DoActionCombat() { IDamageable c = m_Mobile.Combatant; m_Mobile.Warmode = true; 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)) { 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 && 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, 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 (c is Mobile && (((Mobile)c).Spell is HealSpell || ((Mobile)c).Spell is GreaterHealSpell) && !((Mobile)c).Poisoned) // They have a heal spell out { spell = new BloodOathSpell(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 if (c is Mobile) { RunTo((Mobile)c); } if (spell != null) { spell.Cast(); } TimeSpan delay; if (spell is DispelSpell) { delay = TimeSpan.FromSeconds(m_Mobile.ActiveSpeed); } else { delay = GetDelay(); } m_NextCastTime = DateTime.UtcNow + delay; } else if (c is Mobile && (m_Mobile.Spell == null || !m_Mobile.Spell.IsCasting)) { RunTo((Mobile)c); } return(true); }
public override bool DoActionCombat() { IDamageable c = this.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) || !this.m_Mobile.CanSee(c) || !this.m_Mobile.CanBeHarmful(c, false) || c.Map != this.m_Mobile.Map) { // Our combatant is deleted, dead, hidden, or we cannot hurt them // Try to find another combatant if (this.AcquireFocusMob(this.m_Mobile.RangePerception, this.m_Mobile.FightMode, false, false, true)) { this.m_Mobile.DebugSay("Something happened to my combatant, so I am going to fight {0}", this.m_Mobile.FocusMob.Name); this.m_Mobile.Combatant = c = this.m_Mobile.FocusMob; this.m_Mobile.FocusMob = null; } else { this.m_Mobile.DebugSay("Something happened to my combatant, and nothing is around. I am on guard."); this.Action = ActionType.Guard; return(true); } } if (!this.m_Mobile.InLOS(c)) { this.m_Mobile.DebugSay("I can't see my target"); if (this.AcquireFocusMob(this.m_Mobile.RangePerception, this.m_Mobile.FightMode, false, false, true)) { this.m_Mobile.DebugSay("I will switch to {0}", this.m_Mobile.FocusMob.Name); this.m_Mobile.Combatant = c = this.m_Mobile.FocusMob; this.m_Mobile.FocusMob = null; } } if (!Core.AOS && this.SmartAI && !this.m_Mobile.StunReady && this.m_Mobile.Skills[SkillName.Wrestling].Value >= 80.0 && this.m_Mobile.Skills[SkillName.Anatomy].Value >= 80.0) { EventSink.InvokeStunRequest(new StunRequestEventArgs(this.m_Mobile)); } if (!this.m_Mobile.InRange(c, this.m_Mobile.RangePerception)) { // They are somewhat far away, can we find something else? if (this.AcquireFocusMob(this.m_Mobile.RangePerception, this.m_Mobile.FightMode, false, false, true)) { this.m_Mobile.Combatant = this.m_Mobile.FocusMob; this.m_Mobile.FocusMob = null; } else if (!this.m_Mobile.InRange(c, this.m_Mobile.RangePerception * 3)) { this.m_Mobile.Combatant = null; } c = this.m_Mobile.Combatant as Mobile; if (c == null) { this.m_Mobile.DebugSay("My combatant has fled, so I am on guard"); this.Action = ActionType.Guard; return(true); } } if (!this.m_Mobile.Controlled && !this.m_Mobile.Summoned && this.m_Mobile.CanFlee) { if (this.m_Mobile.Hits < this.m_Mobile.HitsMax * 20 / 100) { // We are low on health, should we flee? bool flee = false; if (this.m_Mobile.Hits < c.Hits) { // We are more hurt than them int diff = c.Hits - this.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) { this.m_Mobile.DebugSay("I am going to flee from {0}", c.Name); this.Action = ActionType.Flee; return(true); } } } if (this.m_Mobile.Spell == null && DateTime.UtcNow > this.m_NextCastTime && this.m_Mobile.InRange(c, Core.ML ? 10 : 12)) { // We are ready to cast a spell Spell spell = null; Mobile toDispel = this.FindDispelTarget(true); if (this.m_Mobile.Poisoned) // Top cast priority is cure { this.m_Mobile.DebugSay("I am going to cure myself"); spell = new CureSpell(this.m_Mobile, null); } else if (toDispel != null) // Something dispellable is attacking us { this.m_Mobile.DebugSay("I am going to dispel {0}", toDispel); spell = this.DoDispel(toDispel); } else if (c is Mobile && this.SmartAI && this.m_Combo != -1) // We are doing a spell combo { spell = this.DoCombo((Mobile)c); } else if (c is Mobile && this.SmartAI && (((Mobile)c).Spell is HealSpell || ((Mobile)c).Spell is GreaterHealSpell) && !((Mobile)c).Poisoned) // They have a heal spell out { spell = new PoisonSpell(this.m_Mobile, null); } else { spell = this.ChooseSpell(c); } // Now we have a spell picked // Move first before casting TimeSpan ts = !SmartAI && !(spell is DispelSpell) ? TimeSpan.FromSeconds(1.5) : 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(); } this.m_NextCastTime = DateTime.UtcNow + delay; } else/* if (this.m_Mobile.Spell == null || !this.m_Mobile.Spell.IsCasting)*/ { this.RunTo(c); } this.m_LastTarget = c as Mobile; this.m_LastTargetLoc = c.Location; return(true); }
public override bool DoActionCombat() { m_Mobile.DebugSay("doing MageAI base DoActionCombat()"); Mobile c = m_Mobile.Combatant; m_Mobile.Warmode = true; // if we can reveal and our target just hid and we Recall them, lets try to reveal if (c != null && m_Mobile.CanReveal && 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); } } 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) { 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.Controlled && !m_Mobile.Summoned) { if (m_Mobile.Hits < m_Mobile.HitsMax * 20 / 100) { // We are low on health, should we flee? bool flee = false; if (m_Mobile.Hits < c.Hits) { // We are more hurt than them int diff = c.Hits - m_Mobile.Hits; flee = (Utility.Random(0, 100) > (10 + diff)); // (10 + diff)% chance to flee } else { flee = Utility.Random(0, 100) > 10; // 10% chance to flee } if (flee) { if (m_Mobile.Debug) { m_Mobile.DebugSay("I am going to flee from {0}", c.Name); } Action = ActionType.Flee; return(true); } } } if (m_Mobile.Spell == null && DateTime.Now > m_NextCastTime && m_Mobile.InRange(c, 12)) { // We are ready to cast a spell Spell spell = null; Mobile toDispel = FindDispelTarget(true); if (m_Mobile.Poisoned) // Top cast priority is cure { spell = new CureSpell(m_Mobile, null); try { if ((((m_Mobile.Skills[SkillName.Magery].Value / (m_Mobile.Poison.Level + 1)) - 20) * 7.5) > 50) { spell = new CureSpell(m_Mobile, null); } else { spell = new ArchCureSpell(m_Mobile, null); } } catch { spell = new CureSpell(m_Mobile, null); } } else if (toDispel != null) // Something dispellable is attacking us { spell = DoDispel(toDispel); } else if (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, 12)) { RunTo(toDispel, CanRun); } } else { RunTo(c, CanRun); } 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, CanRun); } return(true); } return(true); }
public override bool DoActionCombat() { Mobile c = m_Mobile.Combatant; m_Mobile.Warmode = true; if (c == null || c.Deleted || !c.Alive || c.IsDeadBondedPet || !m_Mobile.CanSee(c) || !m_Mobile.CanBeHarmful(c, false) || c.Map != m_Mobile.Map) { // Our combatant is deleted, dead, hidden, or we cannot hurt them // Try to find another combatant if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { if (m_Mobile.Debug) { m_Mobile.DebugSay("Something happened to my combatant, so I am going to fight {0}", m_Mobile.FocusMob.Name); } m_Mobile.Combatant = c = m_Mobile.FocusMob; m_Mobile.FocusMob = null; } else { m_Mobile.DebugSay("Something happened to my combatant, and nothing is around. I am on guard."); Action = ActionType.Guard; return(true); } } if (!m_Mobile.InLOS(c)) { if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { m_Mobile.Combatant = c = m_Mobile.FocusMob; m_Mobile.FocusMob = null; } } if (SmartAI && (c.Spell is MagicTrapSpell || c.Spell is MagicArrowSpell)) { EnemyCountersPara = true; } if (m_Mobile.Paralyzed) { UseTrapPouch(m_Mobile); } TrapPouch(m_Mobile); if (SmartAI && !m_Mobile.StunReady && m_Mobile.Skills[SkillName.Wrestling].Value >= 80.0 && m_Mobile.Skills[SkillName.Anatomy].Value >= 80.0) { EventSink.InvokeStunRequest(new StunRequestEventArgs(m_Mobile)); } if (!m_Mobile.InRange(c, m_Mobile.RangePerception)) { // They are somewhat far away, can we find something else? if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { m_Mobile.Combatant = m_Mobile.FocusMob; m_Mobile.FocusMob = null; } else if (!m_Mobile.InRange(c, m_Mobile.RangePerception * 3)) { m_Mobile.Combatant = null; } c = m_Mobile.Combatant; if (c == null) { m_Mobile.DebugSay("My combatant has fled, so I am on guard"); Action = ActionType.Guard; return(true); } } if (m_Mobile.Hits < m_Mobile.HitsMax * 20 / 100) { // We are low on health, should we flee? bool flee = false; if (m_Mobile.Hits < c.Hits) { // We are more hurt than them int diff = c.Hits - m_Mobile.Hits; flee = (Utility.Random(0, 100) > (10 + diff)); // (10 + diff)% chance to flee } else { flee = Utility.Random(0, 100) > 10; // 10% chance to flee } if (flee) { if (m_Mobile.Debug) { m_Mobile.DebugSay("I am going to flee from {0}", c.Name); } Action = ActionType.Flee; return(true); } } if (m_Mobile.Spell == null && DateTime.Now > m_NextCastTime && m_Mobile.InRange(c, 12)) { // We are ready to cast a spell Spell spell = null; Mobile toDispel = FindDispelTarget(true); Mobile toParalyze = FindParalyzeTarget(true); //try an cure with a pot first if the poison is serious or where in the middle of dumping if (UsesPotions && (m_Mobile.Poisoned && m_Mobile.Poison.Level >= 3) || m_Mobile.Poisoned && Combo != -1) { DrinkCure(m_Mobile); } if (m_Mobile.Poisoned) // Top cast priority is cure { spell = new CureSpell(m_Mobile, null); try { if ((((m_Mobile.Skills[SkillName.Magery].Value / (m_Mobile.Poison.Level + 1)) - 20) * 7.5) > 50) { spell = new CureSpell(m_Mobile, null); } else { spell = new ArchCureSpell(m_Mobile, null); } } catch { spell = new CureSpell(m_Mobile, null); } } else if (toDispel != null) // Something dispellable is attacking us { spell = DoDispel(toDispel); } else if (toParalyze != null) // Something dispellable is attacking us { spell = DoParalyze(toParalyze); } //take down reflect on are enemy if its up else if (c.MagicDamageAbsorb > 5) { m_Mobile.DebugSay("Takeing Down Reflect"); spell = new LightningSpell(m_Mobile, null); } else if (Combo != -1 && !m_Mobile.Paralyzed) // We are doing a spell combo { spell = DoCombo(c); } else { spell = ChooseSpell(c); } if (SmartAI && toDispel != null) { if (m_Mobile.InRange(toDispel, 10)) { RunFrom(toDispel); } else if (!m_Mobile.InRange(toDispel, 12)) { RunTo(toDispel, CanRun); } } if (toParalyze != null) { if (m_Mobile.InRange((BaseCreature)toParalyze, 10)) { RunFrom(toParalyze); } else if (!m_Mobile.InRange((BaseCreature)toParalyze, 12)) { RunTo(toParalyze, CanRun); } } else { if (RegainingMana == false) { RunTo(c, CanRun); } } if (spell != null && spell.Cast()) { TimeSpan delay; //spell cast time is equal to the delay for the spells. delay = spell.GetCastDelay() + spell.GetCastRecovery(); m_NextCastTime = DateTime.Now + delay; } } else if ((m_Mobile.Spell == null || !m_Mobile.Spell.IsCasting) && RegainingMana == false) { RunTo(c, CanRun); } return(true); }
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 CureSpell(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 { 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 bool TryToHeal() { if (this.m_Mobile.Summoned) { return(false); } else if (DateTime.UtcNow < this.m_NextHealTime) { return(false); } int diff = this.m_Mobile.HitsMax - this.m_Mobile.Hits; diff = ((this.m_Mobile.HitsMax * (100 - diff)) / 100); diff = 100 - diff; if ((int)(Utility.RandomDouble() * 100.0) > diff) { return(false); } Spell spell = null; this.m_NextHealTime = DateTime.UtcNow + TimeSpan.FromSeconds(20); if (this.m_CanUseMagery) { if (this.m_Mobile.Poisoned) { spell = new CureSpell(this.m_Mobile, null); } spell = new GreaterHealSpell(this.m_Mobile, null); if (spell == null) { spell = new HealSpell(this.m_Mobile, null); } } else if (this.m_CanUseNecromancy) { this.m_Mobile.UseSkill(SkillName.SpiritSpeak); this.m_NextHealTime = DateTime.UtcNow + TimeSpan.FromSeconds(10); } else if (this.m_CanUseChivalry) { if (this.m_Mobile.Poisoned) { spell = new CleanseByFireSpell(this.m_Mobile, null); } else { spell = new CloseWoundsSpell(this.m_Mobile, null); } } else if (this.m_CanUseMystic) { spell = new CleansingWindsSpell(this.m_Mobile, null); } else if (this.m_Mobile.Skills[SkillName.Healing].Value > 10.0) { int delay = (int)(5.0 + (0.5 * ((120 - this.m_Mobile.Dex) / 10))); new BandageContext(this.m_Mobile, this.m_Mobile, TimeSpan.FromSeconds(delay), false); this.m_NextHealTime = DateTime.UtcNow + TimeSpan.FromSeconds(delay + 1); return(true); } if (spell != null) { spell.Cast(); } return(true); }
public override bool DoActionCombat() { IDamageable c = m_Mobile.Combatant; m_Mobile.Warmode = true; if (c == null || c.Deleted || !c.Alive || c is Mobile mobile && mobile.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)) { 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)) { 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)) { 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.CheckCanFlee()) { 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; 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 (c is Mobile hMobile && (hMobile.Spell is HealSpell || hMobile.Spell is GreaterHealSpell) && !hMobile.Poisoned) // They have a heal spell out { spell = new BloodOathSpell(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 if (c is Mobile m) { RunTo(m); } spell?.Cast(); TimeSpan delay; delay = spell is DispelSpell?TimeSpan.FromSeconds(m_Mobile.ActiveSpeed) : GetDelay(); m_NextCastTime = DateTime.UtcNow + delay; }
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); }
public override bool Think() { if (m_Mobile.Deleted) { return(false); } if (m_Mobile.Target is AsyncSpellTarget target) { switch (target.Spell) { case CureSpell: ProcessTarget(target, ACure); break; case GreaterHealSpell: ProcessTarget(target, AgHeal); break; case HealSpell: ProcessTarget(target, AlHeal); break; default: m_Mobile.Target.Cancel(m_Mobile, TargetCancelType.Canceled); break; } } else { Mobile toHelp = Find(All); if (toHelp != null) { if (NeedCure(toHelp)) { if (m_Mobile.Debug) { m_Mobile.DebugSay("{0} needs a cure", toHelp.Name); } var spell = new CureSpell(m_Mobile, null); if (spell.CanCast()) { spell.Cast(); } } else if (NeedGHeal(toHelp)) { if (m_Mobile.Debug) { m_Mobile.DebugSay("{0} needs a greater heal", toHelp.Name); } var spell = new GreaterHealSpell(m_Mobile, null); if (spell.CanCast()) { spell.Cast(); } } else if (NeedLHeal(toHelp)) { if (m_Mobile.Debug) { m_Mobile.DebugSay("{0} needs a lesser heal", toHelp.Name); } new HealSpell(m_Mobile, null).Cast(); } } else { if (AcquireFocusMob(m_Mobile.RangePerception, FightMode.Weakest, false, true, false)) { WalkMobileRange(m_Mobile.FocusMob, 1, false, 4, 7); } else { WalkRandomInHome(3, 2, 1); } } } 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 bool DoActionCombat() { Mobile c = this.m_Mobile.Combatant; this.m_Mobile.Warmode = true; if (c == null || c.Deleted || !c.Alive || c.IsDeadBondedPet || !this.m_Mobile.CanSee(c) || !this.m_Mobile.CanBeHarmful(c, false) || c.Map != this.m_Mobile.Map) { // Our combatant is deleted, dead, hidden, or we cannot hurt them // Try to find another combatant if (this.AcquireFocusMob(this.m_Mobile.RangePerception, this.m_Mobile.FightMode, false, false, true)) { if (this.m_Mobile.Debug) { this.m_Mobile.DebugSay("Something happened to my combatant, so I am going to fight {0}", this.m_Mobile.FocusMob.Name); } this.m_Mobile.Combatant = c = this.m_Mobile.FocusMob; this.m_Mobile.FocusMob = null; } else { this.m_Mobile.DebugSay("Something happened to my combatant, and nothing is around. I am on guard."); this.Action = ActionType.Guard; return(true); } } if (!this.m_Mobile.InLOS(c)) { if (this.AcquireFocusMob(this.m_Mobile.RangePerception, this.m_Mobile.FightMode, false, false, true)) { this.m_Mobile.Combatant = c = this.m_Mobile.FocusMob; this.m_Mobile.FocusMob = null; } } if (!this.m_Mobile.StunReady && this.m_Mobile.Skills[SkillName.Wrestling].Value >= 80.0 && this.m_Mobile.Skills[SkillName.Anatomy].Value >= 80.0) { EventSink.InvokeStunRequest(new StunRequestEventArgs(this.m_Mobile)); } if (!this.m_Mobile.InRange(c, this.m_Mobile.RangePerception)) { // They are somewhat far away, can we find something else? if (this.AcquireFocusMob(this.m_Mobile.RangePerception, this.m_Mobile.FightMode, false, false, true)) { this.m_Mobile.Combatant = this.m_Mobile.FocusMob; this.m_Mobile.FocusMob = null; } else if (!this.m_Mobile.InRange(c, this.m_Mobile.RangePerception * 3)) { this.m_Mobile.Combatant = null; } c = this.m_Mobile.Combatant; if (c == null) { this.m_Mobile.DebugSay("My combatant has fled, so I am on guard"); this.Action = ActionType.Guard; return(true); } } if (!this.m_Mobile.Controlled && !this.m_Mobile.Summoned && !this.m_Mobile.IsParagon) { if (this.m_Mobile.Hits < this.m_Mobile.HitsMax * 20 / 100) { // We are low on health, should we flee? bool flee = false; if (this.m_Mobile.Hits < c.Hits) { // We are more hurt than them int diff = c.Hits - this.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 (this.m_Mobile.Debug) { this.m_Mobile.DebugSay("I am going to flee from {0}", c.Name); } this.Action = ActionType.Flee; return(true); } } } if (this.m_Mobile.Spell == null && DateTime.Now > this.m_NextCastTime && this.m_Mobile.InRange(c, 12)) { // We are ready to cast a spell Spell spell = null; Mobile toDispel = this.FindDispelTarget(true); if (this.m_Mobile.Poisoned) // Top cast priority is cure { this.m_Mobile.DebugSay("I am going to cure myself"); spell = new CureSpell(this.m_Mobile, null); } else if (toDispel != null) // Something dispellable is attacking us { this.m_Mobile.DebugSay("I am going to dispel {0}", toDispel); spell = this.DoDispel(toDispel); } else if ((c.Spell is HealSpell || c.Spell is GreaterHealSpell) && !c.Poisoned) // They have a heal spell out { spell = new BloodOathSpell(this.m_Mobile, null); } else { spell = this.ChooseSpell(c); } // Now we have a spell picked // Move first before casting if (toDispel != null) { if (this.m_Mobile.InRange(toDispel, 10)) { this.RunFrom(toDispel); } else if (!this.m_Mobile.InRange(toDispel, 12)) { this.RunTo(toDispel); } } else { this.RunTo(c); } if (spell != null) { spell.Cast(); } TimeSpan delay; if (spell is DispelSpell) { delay = TimeSpan.FromSeconds(this.m_Mobile.ActiveSpeed); } else { delay = this.GetDelay(); } this.m_NextCastTime = DateTime.Now + delay; } else if (this.m_Mobile.Spell == null || !this.m_Mobile.Spell.IsCasting) { this.RunTo(c); } return(true); }
public override bool DoActionCombat() { Mobile c = m_Mobile.Combatant; m_Mobile.Warmode = true; if (c == null || c.Deleted || !c.Alive || c.IsDeadBondedPet || !m_Mobile.CanSee(c) || !m_Mobile.CanBeHarmful(c, false) || c.Map != m_Mobile.Map) { // Our combatant is deleted, dead, hidden, or we cannot hurt them // Try to find another combatant if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { if (m_Mobile.Debug) { m_Mobile.DebugSay("Something happened to my combatant, so I am going to fight {0}", m_Mobile.FocusMob.Name); } m_Mobile.Combatant = c = m_Mobile.FocusMob; m_Mobile.FocusMob = null; } else { m_Mobile.DebugSay("Something happened to my combatant, and nothing is around. I am on guard."); Action = ActionType.Guard; return(true); } } if (!m_Mobile.InLOS(c)) { if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { m_Mobile.Combatant = c = m_Mobile.FocusMob; m_Mobile.FocusMob = null; } } if (SmartAI && !m_Mobile.StunReady && m_Mobile.Skills[SkillName.Wrestling].Value >= 80.0 && m_Mobile.Skills[SkillName.Anatomy].Value >= 80.0) { EventSink.InvokeStunRequest(new StunRequestEventArgs(m_Mobile)); } if (!m_Mobile.InRange(c, m_Mobile.RangePerception)) { // They are somewhat far away, can we find something else? if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { m_Mobile.Combatant = m_Mobile.FocusMob; m_Mobile.FocusMob = null; } else if (!m_Mobile.InRange(c, m_Mobile.RangePerception * 3)) { m_Mobile.Combatant = null; } c = m_Mobile.Combatant; if (c == null) { m_Mobile.DebugSay("My combatant has fled, so I am on guard"); Action = ActionType.Guard; return(true); } } if (m_Mobile.Spell == null && DateTime.Now > m_NextCastTime && m_Mobile.InRange(c, 12)) { // We are ready to cast a spell Spell spell = null; if (m_Mobile.Poisoned) // Top cast priority is cure { spell = new CureSpell(m_Mobile, null); } else { spell = ChooseSpell(c); } // Now we have a spell picked // Move first before casting 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); }