public override bool CheckSpells(eCheckSpellType type) { if (Body == null || ((TurretPet)Body).TurretSpell == null) { return(false); } if (Body.IsCasting) { return(true); } Spell spell = ((TurretPet)Body).TurretSpell; switch (type) { case eCheckSpellType.Defensive: return(CheckDefensiveSpells(spell)); case eCheckSpellType.Offensive: return(CheckOffensiveSpells(spell)); } return(false); }
public bool TrustCast(Spell spell, eCheckSpellType type) { if (AggressionState == eAggressionState.Passive) { return(false); } if (Body.GetSkillDisabledDuration(spell) != 0) { return(false); } if (spell.Radius == 0 && spell.Range > 0) { GameLiving target; if (type == eCheckSpellType.Defensive) { target = GetDefensiveTarget(spell); } else { CheckPlayerAggro(); CheckNPCAggro(); target = CalculateNextAttackTarget(); } if (target != null && Body.IsWithinRadius(target, spell.Range)) { if (!Body.IsAttacking || target != Body.TargetObject) { Body.TargetObject = target; if (spell.CastTime > 0) { Body.TurnTo(Body.TargetObject); } Body.CastSpell(spell, m_mobSpellLine); } } else { if (Body.IsAttacking) { Body.StopAttack(); } if (Body.SpellTimer != null && Body.SpellTimer.IsAlive) { Body.SpellTimer.Stop(); } return(false); } } else //Radius spell don't need target { Body.CastSpell(spell, m_mobSpellLine); } return(true); }
public override bool CheckSpells(eCheckSpellType type) { if (Body == null || Body.Spells == null || Body.Spells.Count < 1) { return(false); } if (Body.IsCasting) { return(true); } bool casted = false; if (type == eCheckSpellType.Defensive) { foreach (Spell spell in Body.Spells) { if (!Body.IsBeingInterrupted && Body.GetSkillDisabledDuration(spell) == 0 && CheckDefensiveSpells(spell)) { casted = true; break; } } } else { foreach (Spell spell in Body.Spells) { if (Body.GetSkillDisabledDuration(spell) == 0) { if (spell.CastTime > 0) { if (!Body.IsBeingInterrupted && CheckOffensiveSpells(spell)) { casted = true; break; } } else { CheckInstantSpells(spell); } } } } if (!Body.AttackState && Owner != null) { Follow(Owner); } return(casted); }
public override bool CheckSpells(eCheckSpellType type) { if(Body == null || ((TurretPet) Body).TurretSpell == null) { return false; } if(Body.IsCasting) { return true; } Spell spell = ((TurretPet) Body).TurretSpell; switch (type) { case eCheckSpellType.Defensive: return CheckDefensiveSpells(spell); case eCheckSpellType.Offensive: return CheckOffensiveSpells(spell); } return false; }
public override bool CheckSpells(eCheckSpellType type) { if (Body == null || Body.Spells == null || Body.Spells.Count < 1 || m_melee) return false; if (Body.IsCasting) return true; bool casted = false; if (type == eCheckSpellType.Defensive) { foreach (Spell spell in Body.Spells) { if (!Body.IsBeingInterrupted && Body.GetSkillDisabledDuration(spell) == 0 && CheckDefensiveSpells(spell)) { casted = true; break; } } } else { foreach (Spell spell in Body.Spells) { if (Body.GetSkillDisabledDuration(spell) == 0) { if (spell.CastTime > 0) { if (!Body.IsBeingInterrupted && CheckOffensiveSpells(spell)) { casted = true; break; } } else { CheckInstantSpells(spell); } } } } if (this is IControlledBrain && !Body.AttackState) ((IControlledBrain)this).Follow(((IControlledBrain)this).Owner); return casted; }
public override bool CheckSpells(eCheckSpellType type) { if (Body == null || Body.Spells == null || Body.Spells.Count < 1) return false; if (Body.IsCasting) return true; bool casted = false; if (type == eCheckSpellType.Defensive) { foreach (Spell spell in Body.Spells) { if (!Body.IsBeingInterrupted && Body.GetSkillDisabledDuration(spell) == 0 && CheckDefensiveSpells(spell)) { casted = true; break; } } } else { foreach (Spell spell in Body.Spells) { if (Body.GetSkillDisabledDuration(spell) == 0) { if (spell.CastTime > 0) { if (!Body.IsBeingInterrupted && CheckOffensiveSpells(spell)) { casted = true; break; } } else CheckInstantSpells(spell); } } } // WHRIA // if (!Body.AttackState && Owner != null) if (!Body.AttackState && Owner != null && WalkState == eWalkState.Follow) { Follow(Owner); } return casted; }
public bool TrustCast(Spell spell, eCheckSpellType type) { if(AggressionState == eAggressionState.Passive) return false; if(Body.GetSkillDisabledDuration(spell) != 0) { return false; } if(spell.Radius == 0 && spell.Range > 0) { GameLiving target; if(type == eCheckSpellType.Defensive) { target = GetDefensiveTarget(spell); } else { CheckPlayerAggro(); CheckNPCAggro(); target = CalculateNextAttackTarget(); } if ( target != null && Body.IsWithinRadius( target, spell.Range ) ) { if(!Body.IsAttacking || target != Body.TargetObject) { Body.TargetObject = target; if(spell.CastTime > 0) { Body.TurnTo(Body.TargetObject); } Body.CastSpell(spell, m_mobSpellLine); } } else { if(Body.IsAttacking) { Body.StopAttack(); } if(Body.SpellTimer != null && Body.SpellTimer.IsAlive) { Body.SpellTimer.Stop(); } return false; } } else //Radius spell don't need target { Body.CastSpell(spell, m_mobSpellLine); } return true; }
/// <summary> /// Checks if any spells need casting /// </summary> /// <param name="type">Which type should we go through and check for?</param> /// <returns></returns> public virtual bool CheckSpells(eCheckSpellType type) { if (Body.IsCasting) return true; bool casted = false; if (Body != null && Body.Spells != null && Body.Spells.Count > 0) { ArrayList spell_rec = new ArrayList(); Spell spellToCast = null; bool needpet = false; bool needheal = false; if (type == eCheckSpellType.Defensive) { foreach (Spell spell in Body.Spells) { if (Body.GetSkillDisabledDuration(spell) > 0) continue; if (spell.Target.ToLower() == "enemy" || spell.Target.ToLower() == "area" || spell.Target.ToLower() == "cone") continue; // If we have no pets if (Body.ControlledBrain == null) { if (spell.SpellType.ToLower() == "pet") continue; if (spell.SpellType.ToLower().Contains("summon")) { spell_rec.Add(spell); needpet = true; } } if (Body.ControlledBrain != null && Body.ControlledBrain.Body != null) { if (Util.Chance(30) && Body.ControlledBrain != null && spell.SpellType.ToLower() == "heal" && Body.GetDistanceTo(Body.ControlledBrain.Body) <= spell.Range && Body.ControlledBrain.Body.HealthPercent < 60 && spell.Target.ToLower() != "self") { spell_rec.Add(spell); needheal = true; } if (LivingHasEffect(Body.ControlledBrain.Body, spell) && (spell.Target.ToLower() != "self")) continue; } if (!needpet && !needheal) spell_rec.Add(spell); } if (spell_rec.Count > 0) { spellToCast = (Spell)spell_rec[Util.Random((spell_rec.Count - 1))]; if (!Body.IsReturningToSpawnPoint) { if (spellToCast.Uninterruptible && CheckDefensiveSpells(spellToCast)) casted = true; else if (!Body.IsBeingInterrupted && CheckDefensiveSpells(spellToCast)) casted = true; } } } else if (type == eCheckSpellType.Offensive) { foreach (Spell spell in Body.Spells) { if (Body.GetSkillDisabledDuration(spell) == 0) { if (spell.CastTime > 0) { if (spell.Target.ToLower() == "enemy" || spell.Target.ToLower() == "area" || spell.Target.ToLower() == "cone") spell_rec.Add(spell); } } } if (spell_rec.Count > 0) { spellToCast = (Spell)spell_rec[Util.Random((spell_rec.Count - 1))]; if (spellToCast.Uninterruptible && CheckOffensiveSpells(spellToCast)) casted = true; else if (!Body.IsBeingInterrupted && CheckOffensiveSpells(spellToCast)) casted = true; } } return casted; } return casted; }
/// <summary> /// Checks if any spells need casting /// </summary> /// <param name="type">Which type should we go through and check for?</param> /// <returns>True if we are begin to cast or are already casting</returns> public override bool CheckSpells(eCheckSpellType type) { if (Body == null || Body.Spells == null || Body.Spells.Count < 1) { return(false); } bool casted = false; if (type == eCheckSpellType.Defensive) { // Check instant spells, but only cast one of each type to prevent spamming if (Body.CanCastInstantHealSpells) { foreach (Spell spell in Body.InstantHealSpells) { if (CheckDefensiveSpells(spell)) { break; } } } if (Body.CanCastInstantMiscSpells) { foreach (Spell spell in Body.InstantMiscSpells) { if (CheckDefensiveSpells(spell)) { break; } } } if (!Body.IsCasting) { // Check spell lists, prioritizing healing if (Body.CanCastHealSpells) { foreach (Spell spell in Body.HealSpells) { if (CheckDefensiveSpells(spell)) { casted = true; break; } } } if (!casted && Body.CanCastMiscSpells) { foreach (Spell spell in Body.MiscSpells) { if (CheckDefensiveSpells(spell)) { casted = true; break; } } } } } else if (Body.TargetObject is GameLiving living && living.IsAlive) { // Check instant spells, but only cast one to prevent spamming if (Body.CanCastInstantHarmfulSpells) { foreach (Spell spell in Body.InstantHarmfulSpells) { if (CheckOffensiveSpells(spell)) { break; } } } if (!Body.IsCasting && Body.CanCastHarmfulSpells) { foreach (Spell spell in Body.HarmfulSpells) { if (CheckOffensiveSpells(spell)) { casted = true; break; } } } } return(casted || Body.IsCasting); }
/// <summary> /// Checks if any spells need casting /// </summary> /// <param name="type">Which type should we go through and check for?</param> /// <returns></returns> public virtual bool CheckSpells(eCheckSpellType type) { if (this.Body != null && this.Body.Spells != null && this.Body.Spells.Count > 0 && !Body.IsCasting) { bool casted = false; if (type == eCheckSpellType.Defensive) { foreach (Spell spell in Body.Spells) { if (!Body.IsBeingInterrupted && Body.GetSkillDisabledDuration(spell) == 0 && CheckDefensiveSpells(spell)) { casted = true; break; } } } else { foreach (Spell spell in Body.Spells) { if (Body.GetSkillDisabledDuration(spell) == 0) { if (spell.CastTime > 0) { if (!Body.IsBeingInterrupted && Body.CurrentRegion.Time - Body.LastAttackedByEnemyTick > 10 * 1000 && Util.Chance(50) && CheckOffensiveSpells(spell)) { casted = true; break; } } else { CheckInstantSpells(spell); } } } } if (this is IControlledBrain && !Body.AttackState) ((IControlledBrain)this).Follow(((IControlledBrain)this).Owner); return casted; } return false; }
/// <summary> /// Checks if any spells need casting /// </summary> /// <param name="type">Which type should we go through and check for?</param> /// <returns></returns> public override bool CheckSpells(eCheckSpellType type) { bool casted = false; if (type == eCheckSpellType.Offensive && Body is CommanderPet pet && pet.PreferredSpell != CommanderPet.eCommanderPreferredSpell.None && !pet.IsCasting && !pet.IsBeingInterrupted && pet.TargetObject is GameLiving living && living.IsAlive) { Spell spellDamage = pet.CommSpellDamage; Spell spellDamageDebuff = pet.CommSpellDamageDebuff; Spell spellDot = pet.CommSpellDot; Spell spellDebuff = pet.CommSpellDebuff; Spell spellOther = pet.CommSpellOther; Spell cast = null; switch (pet.PreferredSpell) { case CommanderPet.eCommanderPreferredSpell.Debuff: if (spellDebuff != null && !living.HasEffect(spellDebuff)) { cast = spellDebuff; } break; case CommanderPet.eCommanderPreferredSpell.Other: cast = spellOther; break; } if (cast == null) { // Pick a damage spell if (spellDot != null && !living.HasEffect(spellDot)) { cast = spellDot; } else if (spellDamageDebuff != null && (!living.HasEffect(spellDamageDebuff) || spellDamage == null)) { cast = spellDamageDebuff; } else if (spellDamage != null) { cast = spellDamage; } } if (cast != null) { casted = CheckOffensiveSpells(cast); } } if (casted) { // Check instant spells, but only cast one to prevent spamming if (Body.CanCastInstantHarmfulSpells) { foreach (Spell spell in Body.InstantHarmfulSpells) { if (CheckOffensiveSpells(spell)) { break; } } } } else { // Only call base method if we didn't cast anything, // otherwise it tries to cast a second offensive spell casted = base.CheckSpells(type); } return(casted); }