/// <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;
if (Body is TheurgistPet == false)
//By elcotek monsters cast only if spell not active on Target
if (Body.TargetObject != null)
{
living = Body.TargetObject as GameLiving;
}
bool casted = false;
//Find an active effect
GameSpellEffect DamageOverTime = SpellHandler.FindEffectOnTarget(living, "DamageOverTime");
GameSpellEffect Nearsight = SpellHandler.FindEffectOnTarget(living, "Nearsight");
GameSpellEffect Mesmerize = SpellHandler.FindEffectOnTarget(living, "Mesmerize");
GameSpellEffect Disease = SpellHandler.FindEffectOnTarget(living, "Disease");
GameSpellAndImmunityEffect MesmerizeImmunity = SpellHandler.FindImmunityEffectOnTarget(living, typeof(MesmerizeSpellHandler));
GameSpellAndImmunityEffect PoisonImmunity = SpellHandler.FindImmunityEffectOnTarget(living, typeof(DirectDamagePoisoneSpellHandler));
GameSpellAndImmunityEffect DamageOverTimeImmunity = SpellHandler.FindImmunityEffectOnTarget(living, typeof(DirectDamageSpellHandler));
GameSpellAndImmunityEffect DiseaseImmunity = SpellHandler.FindImmunityEffectOnTarget(living, typeof(DiseaseSpellHandler));
GameSpellAndImmunityEffect NearsightImmunity = SpellHandler.FindImmunityEffectOnTarget(living, typeof(NearsightSpellHandler));
if (PoisonImmunity == null && Nearsight == null && NearsightImmunity == null && Disease == null && DiseaseImmunity == null && DamageOverTime == null && DamageOverTimeImmunity == null && MesmerizeImmunity == null && Body != null && Body.Spells != null && Body.Spells.Count > 0 && !Body.IsBeingInterrupted && Mesmerize == null
|| Nearsight == null && NearsightImmunity == null && PoisonImmunity == null && Disease == null && DiseaseImmunity == null && DamageOverTime == null && DamageOverTimeImmunity == null && MesmerizeImmunity == null && Mesmerize == null && Body != null && Body.Spells != null && Body.Spells.Count > 0 && Body.IsWithinRadius(Body.TargetObject, 400))
{
ArrayList spell_rec = new ArrayList();
Spell tire = null;
bool needpet = false;
bool needheal = false;
if (type == eCheckSpellType.Defensive)
{
foreach (Spell spell in Body.Spells)
{
if (spell == null) continue;//bugfix
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;
//pets
if (spell.SpellType.ToLower().Contains("summon") || spell.SpellType.ToLower().Contains("SummonMobPet") || spell.SpellType.ToLower().Contains("SummobFollowerPets"))
{
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)
{
tire = (Spell)spell_rec[Util.Random((spell_rec.Count - 1))];
if (!Body.IsReturningToSpawnPoint)
{
if (tire.Uninterruptible && CheckDefensiveSpells(tire))
casted = true;
else
if (!Body.IsBeingInterrupted && CheckDefensiveSpells(tire))
casted = true;
}
}
}
/// <summary>
/// Checks if any Ovensive spells need casting near the Body
/// </summary>
/// <param name="type">New Intelligence for Casting mobs by Elcotek</param>
/// <returns></returns>
else if (type == eCheckSpellType.Offensive)
{
if (Body is TheurgistPet == false)
foreach (Spell spell in Body.Spells)
{
//We allow casting only if there is not already the same type of spell and immunity active on target
if (Body.GetSkillDisabledDuration(spell) == 0 && SpellHandler.FindEffectAndImmunityOnTarget(living, spell.SpellType) == null)
{
if (spell.CastTime > 0 && (!Body.IsBeingInterrupted && Body is NecromancerPet == false) && Body.IsWithinRadius(Body.TargetObject, spell.Range)// (!Body.IsBeingInterrupted && Body is NecromancerPet == false) neu
|| spell.CastTime == 0 && Body.TargetObject != null && (Body.InCombat && Body is NecromancerPet == false))
{
int Cast = Util.Random(1, 6);
if (spell.CastTime == 0 && Cast != 3) continue;
if (spell.Target.ToLower() == "enemy" || spell.Target.ToLower() == "area" || spell.Target.ToLower() == "cone")
spell_rec.Add(spell);
}
}
}
if (spell_rec.Count > 0)
{
tire = (Spell)spell_rec[Util.Random((spell_rec.Count - 1))];
if (tire.Uninterruptible && CheckOffensiveSpells(tire))
casted = true;
else
if ((Body.IsWithinRadius(Body.TargetObject, 400) && CheckOffensiveSpells(tire)
|| !Body.IsWithinRadius(Body.TargetObject, 400) && !Body.IsBeingInterrupted) && CheckOffensiveSpells(tire))
casted = true;
}
}
}
return casted;
}
//We allow casting only if there is not already the same type of spell or immunity active on target
if (Body.GetSkillDisabledDuration(spell) == 0 && SpellHandler.FindEffectAndImmunityOnTarget(living, spell.SpellType) == null)
/// <summary>
/// Find effect and immunity by spell type
/// </summary>
/// <param name="target"></param>
/// <param name="spellType"></param>
/// <returns>first occurance of effect in target's effect list or null</returns>
public static GameSpellEffect FindEffectAndImmunityOnTarget(GameLiving target, string spellType)
{
if (target == null)
return null;
lock (target.EffectList)
{
foreach (IGameEffect fx in target.EffectList)
{
if (!(fx is GameSpellEffect))
continue;
GameSpellEffect effect = (GameSpellEffect)fx;
if (fx is GameSpellAndImmunityEffect && ((GameSpellAndImmunityEffect)fx).ImmunityState)
{
// we dont ignore immunity effects
if (effect.SpellHandler.Spell != null && (effect.SpellHandler.Spell.SpellType == spellType))
{
return effect;
}
}
else if (effect.SpellHandler.Spell != null && (effect.SpellHandler.Spell.SpellType == spellType))
{
return effect;
}
}
}
return null;
}
Hmm nice job Elcotec but if i see that right this fix only applies on spells with an effect on opponent and dont do anything against lifedrain/dd spamm?
And if i see that right that script dont do diffrences between diffrent kinds of spells that can be active same time (like effect groups)?
(its not critic its just for me if i understood the script correct)
Body.TempProperties.removeProperty
Body.TempProperties.getProperty
Body.TempProperties.setProperty
Users browsing this forum: No registered users and 1 guest