Exemplo n.º 1
0
        public async Task <bool> DecideNextSkill()
        {
            Log.Info("Deciding Next Skill");
            Log.Debug("Actor count (for refresh)" + GameManager.Actors.ToList().Count);
            breakCC = false;


            //Log.InfoFormat("Current Player Stance {0}", GameManager.LocalPlayer.Stance);

            List <Effect> targetEffects = new List <Effect>();
            List <Effect> selfEffects   = new List <Effect>();

            Actor target = null;

            try
            {
                Log.Info("Checking current target...");
                target = GameManager.LocalPlayer.CurrentTarget;

                if (CombatUtils.ValidateTarget(target))
                {
                }
                else
                {
                    return(false);
                }

                Log.Info("Killing " + target.Name + " Dis:" + (target.Distance / 50));
                Log.InfoFormat("Creature Type: " + target.CreatureType);
            }
            catch (Exception ex)
            {
                //Log.Error("NO TARGET FOUND (combat) = "+ex.Message);
                _nextSkill    = null;
                _currentChain = null;
                chainPosition = 0;
                return(false);
            }

            try
            {
                selfEffects = GameManager.LocalPlayer.Effects.ToList();

                Log.DebugFormat("Self Effect count: " + selfEffects.Count);

                breakCC = CombatUtils.EffectInList(GameManager.LocalPlayer, cclist);
                Log.Info("Lets Break CC =" + breakCC);

                foreach (Effect effect in selfEffects.ToList())
                {
                    Log.DebugFormat("Self Effect==> {0} Stack {1}", effect.Name, effect.StackCount);


                    // Log.Info(effect.Dump());
                }
            }
            catch (Exception ex)
            {
                Log.Error("PROBLEM GETTING EFECTS = " + ex.Message);
            }

            if (CombatUtils.KeepBlock(target, profile.skillList.Where(i => i.type.Equals(SkillType.BLOCK))) && GameManager.LocalPlayer.IsCasting)
            {
                inBlock = true;
            }
            else
            {
                inBlock = false;
            }

            if (_currentChain != null && _currentChain.channeledSkill && CombatUtils.KeepChannel(_currentChain.skillName))
            {
                return(false);
            }

            try
            {
                Log.Info("Evaluating EVADE");
                foreach (SkillInfo skill in profile.skillList.Where(i => i.type.Equals(SkillType.EVADE)))
                {
                    if (await CombatUtils.ValidateConditions(skill, target, inBlock))
                    {
                        _nextSkill = skill;
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("Problem Performing EVADE");
            }

            try
            {
                Log.Info("Evaluating Block");

                foreach (SkillInfo skill in profile.skillList.Where(i => i.type.Equals(SkillType.BLOCK)))
                {
                    if (CombatUtils.CanBlock(target, skill.skillName) && await CombatUtils.ValidateConditions(skill, target, inBlock))
                    {
                        Log.Info("Can Cast Block...");
                        _nextSkill = skill;
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("Problem Performing Block");
            }

            try
            {
                //CC BREAK
                if (breakCC)
                {
                    Log.Info("Evaluating Break CC");
                    foreach (SkillInfo skill in profile.skillList.Where(i => i.type.Equals(SkillType.CCBREAK)))
                    {
                        if (await CombatUtils.ValidateConditions(skill, target, inBlock))
                        {
                            _nextSkill = skill;
                            return(true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("Problem Performing BreakCC");
            }

            //Chain?

            if (_currentChain != null)
            {
                Log.InfoFormat("Evaluating Chain for skill {0} in pos {1}", _currentChain.skillName, chainPosition);
                //should chain

                try
                {
                    Log.InfoFormat("Chains {0} for skill {1}", _currentChain.skillName, _currentChain.chainSkill.Count);
                    if (_currentChain.chainSkill.Count > chainPosition)
                    {
                        if (await CombatUtils.ValidateConditions(_currentChain.chainSkill.ElementAt(chainPosition), target, inBlock))
                        {
                            _nextSkill = _currentChain.chainSkill.ElementAt(chainPosition);
                            chainPosition++;
                            return(true);
                        }
                    }
                    else
                    {
                        _nextSkill    = null;
                        _currentChain = null;
                        chainPosition = 0;
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("Problem Performing Chain (prolly no chain)");
                }
            }

            try
            {
                Log.Info("Evaluating Regular DPS");
                foreach (SkillInfo skill in profile.skillList.Where(i => i.type.Equals(SkillType.DPS)))
                {
                    if (await CombatUtils.ValidateConditions(skill, target, inBlock))
                    {
                        _nextSkill = skill;
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("Problem Performing Regular DPS");
            }

            //DEFAULT

            try
            {
                Log.Info("Evaluating DEFAULT DPS");
                foreach (SkillInfo skill in profile.skillList.Where(i => i.type.Equals(SkillType.DEFAULT)))
                {
                    if (await CombatUtils.ValidateConditions(skill, target, inBlock))
                    {
                        _nextSkill = skill;
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("Problem Performing Defautl");
            }

            return(false);
        }