//Try to stun or interrupt an enemy per the given strategy
        //Potential targets are sorted by the amount of time left before their spell goes off. The one with the smallest amount of time left
        //that's still enough for the stun or interrupt to go off is chosen.
        public static async Task <bool> StunOrInterrupt(IEnumerable <SpellData> stuns, IEnumerable <SpellData> interrupts, InterruptStrategy strategy)
        {
            IEnumerable <BattleCharacter> castingEnemies;

            switch (strategy)
            {
            case InterruptStrategy.Never:
                castingEnemies = new List <BattleCharacter>();
                break;

            case InterruptStrategy.BossesOnly:
                castingEnemies = Combat.Enemies;
                castingEnemies = castingEnemies.Where(e => e.IsBoss());
                break;

            case InterruptStrategy.ExceptBoss:
                castingEnemies = Combat.Enemies;
                castingEnemies = castingEnemies.Where(r => r.InView() && r.IsCasting && !r.IsBoss())
                                 .OrderBy(r => r.SpellCastInfo.RemainingCastTime);
                break;

            case InterruptStrategy.CurrentTargetOnly:
                castingEnemies = Combat.Enemies;
                castingEnemies = castingEnemies.Where(e => e == Core.Me.CurrentTarget);
                break;

            case InterruptStrategy.AnyEnemy:
                castingEnemies = Combat.Enemies;
                castingEnemies = castingEnemies.Where(r => r.InView() && r.IsCasting)
                                 .OrderBy(r => r.SpellCastInfo.RemainingCastTime);
                break;

            default:
                castingEnemies = new List <BattleCharacter>();
                break;
            }

            if (await DoStuns(castingEnemies, stuns))
            {
                return(true);
            }
            return(await DoInterrupts(castingEnemies, interrupts));
        }
Beispiel #2
0
        //Try to stun or interrupt an enemy per the given strategy
        //Potential targets are sorted by the amount of time left before their spell goes off. The one with the smallest amount of time left
        //that's still enough for the stun or interrupt to go off is chosen.
        public static async Task <bool> StunOrInterrupt(IEnumerable <SpellData> stuns, IEnumerable <SpellData> interrupts, InterruptStrategy strategy)
        {
            IEnumerable <BattleCharacter> castingEnemies;

            if (strategy == InterruptStrategy.Never)
            {
                castingEnemies = new List <BattleCharacter>();
            }
            else
            {
                castingEnemies = Combat.Enemies;
                if (strategy == InterruptStrategy.BossesOnly)
                {
                    castingEnemies = castingEnemies.Where(e => e.IsBoss());
                }
                else if (strategy == InterruptStrategy.CurrentTargetOnly)
                {
                    castingEnemies = castingEnemies.Where(e => e == Core.Me.CurrentTarget);
                }

                castingEnemies = castingEnemies.Where(r => r.InView() && r.IsCasting)
                                 .OrderBy(r => r.SpellCastInfo.RemainingCastTime);
            }

            if (await DoStuns(castingEnemies, stuns))
            {
                return(true);
            }
            return(await DoInterrupts(castingEnemies, interrupts));
        }