public virtual bool CombatLogic()
{
//Check if we can cast any combat buff-type abilities while channeling
if (FunkyGame.Hero.Class.LastUsedAbility.IsChanneling && FunkyGame.Targeting.Cache.CurrentUnitTarget!=null)
{
Skill buff;
if (FunkyGame.Hero.Class.FindCombatBuffPower(FunkyGame.Targeting.Cache.CurrentUnitTarget, out buff))
{
Skill.UsePower(ref buff);
buff.OnSuccessfullyUsed(false);
}
}
// Find a valid skill
#region AbilityPick
if (Cache.bPickNewAbilities && !Cache.bWaitingForPower && !Cache.bWaitingForPotion)
{
Cache.bPickNewAbilities = false;
if (Cache.CurrentTarget.targetType.Value == TargetType.Unit && Cache.CurrentTarget.AcdGuid.HasValue)
{
// Pick an Ability
Skill nextAbility = FunkyGame.Hero.Class.AbilitySelector(Cache.CurrentUnitTarget);
// Did we get default attack?
if (nextAbility.Equals(FunkyGame.Hero.Class.DefaultAttack) && !FunkyGame.Hero.Class.CanUseDefaultAttack && !FunkyBaseExtension.Settings.Combat.AllowDefaultAttackAlways)
{//TODO:: Fix issue when nothing keeps returning (possibly due to bad ability setup)
Helpers.Logger.Write(Helpers.LogLevel.Ability, "Default Attack not usable -- Failed to find a valid Ability to use -- Target: {0}", Cache.CurrentTarget.InternalName);
Cache.bForceTargetUpdate = true;
CurrentState = RunStatus.Running;
Cache.CurrentTarget.BlacklistLoops = 10;
return false;
}
FunkyGame.Hero.Class.PowerPrime = nextAbility;
}
// Select an Ability for destroying a destructible with in advance
if (Cache.CurrentTarget.targetType.Value == TargetType.Destructible || Cache.CurrentTarget.targetType == TargetType.Barricade)
{
Skill nextAbility = FunkyGame.Hero.Class.DestructibleAbility();
if (nextAbility.Equals(FunkyGame.Hero.Class.DefaultAttack) && !FunkyGame.Hero.Class.CanUseDefaultAttack && !FunkyBaseExtension.Settings.Combat.AllowDefaultAttackAlways)
{
Helpers.Logger.Write(Helpers.LogLevel.Ability, "Default Attack not usable -- Failed to find a valid Ability to use -- Target: {0}", Cache.CurrentTarget.InternalName);
Cache.bForceTargetUpdate = true;
CurrentState = RunStatus.Running;
Cache.CurrentTarget.BlacklistLoops = 10;
return false;
}
FunkyGame.Hero.Class.PowerPrime = FunkyGame.Hero.Class.DestructibleAbility();
}
//Interactables (for pre and post waits)
//if (ObjectCache.CheckFlag(Cache.CurrentTarget.targetType.Value, TargetType.Item | TargetType.Interactables | TargetType.Interaction))
//{
// Skill.SetupAbilityForUse(ref Cache.InteractionSkill);
// FunkyGame.Hero.Class.PowerPrime = Cache.InteractionSkill;
// Cache.bWaitingAfterPower = false;
//}
}
#endregion
#region PotionCheck
if (FunkyGame.Hero.dCurrentHealthPct <= FunkyBaseExtension.Settings.Combat.PotionHealthPercent
&& !Cache.bWaitingForPower
&& !Cache.bWaitingForPotion
&& !FunkyGame.Hero.bIsIncapacitated
&& FunkyGame.Hero.Class.HealthPotionAbility.AbilityUseTimer())
{
Cache.bWaitingForPotion = true;
CurrentState = RunStatus.Running;
return false;
}
if (Cache.bWaitingForPotion)
{
Cache.bWaitingForPotion = false;
if (FunkyGame.Hero.Class.HealthPotionAbility.CheckCustomCombatMethod(null))
{
FunkyGame.Hero.Class.HealthPotionAbility.AttemptToUseHealthPotion();
CurrentState = RunStatus.Running;
return false;
}
}
#endregion
// See if we can use any special buffs etc. while in avoidance
if (ObjectCache.CheckFlag(Cache.CurrentTarget.targetType.Value, TargetType.Globe | TargetType.AvoidanceMovements))
{
Skill buff;
if (FunkyGame.Hero.Class.FindBuffPower(out buff))
{
Skill.UsePower(ref buff);
buff.OnSuccessfullyUsed();
}
}
return true;
}