Beispiel #1
0
        protected override async Task KillStealAsync(CancellationToken token)
        {
            if (Game.IsPaused || !this.Owner.IsAlive || !AbilityExtensions.CanBeCasted(this.Blast))
            {
                await Task.Delay(125, token);

                return;
            }

            var damageBlast = Blast.GetAbilitySpecialData("blast_damage");

            damageBlast *= Ensage.SDK.Extensions.UnitExtensions.GetSpellAmplification(this.Owner);

            bool comboMana = Blast.GetManaCost(Blast.Level - 1) + Decrepify.GetManaCost(Decrepify.Level - 1) <
                             Owner.Mana;

            var decrepifyKillable =
                EntityManager <Hero> .Entities.FirstOrDefault(
                    x =>
                    x.IsAlive && x.Team != this.Owner.Team && !x.IsIllusion &&
                    x.Health < damageBlast *(1 - x.MagicDamageResist) &&
                    Blast != null && Blast.IsValid && x.Distance2D(this.Owner) <= 900 &&
                    Ensage.Common.Extensions.AbilityExtensions.CanBeCasted(Decrepify, x) && Ensage.Common.Extensions.AbilityExtensions.CanBeCasted(Blast, x) &&
                    !UnitExtensions.IsMagicImmune(x) && comboMana);

            var blastKillable =
                EntityManager <Hero> .Entities.FirstOrDefault(
                    x =>
                    x.IsAlive && x.Team != this.Owner.Team && !x.IsIllusion &&
                    x.Health < damageBlast *(1 - x.MagicDamageResist) &&
                    Ensage.Common.Extensions.AbilityExtensions.CanBeCasted(Blast, x) && !UnitExtensions.IsMagicImmune(x) && Blast.CanHit(x) &&
                    Ensage.SDK.Extensions.EntityExtensions.Distance2D(Owner, x.NetworkPosition) <= 800);

            if (!UnitExtensions.IsChanneling(this.Owner))
            {
                if (decrepifyKillable != null)
                {
                    if (Decrepify.UseAbility(decrepifyKillable))
                    {
                        await this.AwaitKillstealDelay((int)AbilityExtensions.GetCastDelay(this.Decrepify, this.Owner, decrepifyKillable, true), token); // decrepify
                    }

                    if (Blast.CanHit(decrepifyKillable))
                    {
                        if (Blast.UseAbility(decrepifyKillable))
                        {
                            await this.AwaitKillstealDelay((int)AbilityExtensions.GetCastDelay(this.Blast, this.Owner, decrepifyKillable, true), token);
                        }
                    }
                }

                if (blastKillable != null)
                {
                    if (Blast.UseAbility(blastKillable.NetworkPosition))
                    {
                        await this.AwaitKillstealDelay((int)AbilityExtensions.GetCastDelay(this.Blast, this.Owner, blastKillable, true), token);
                    }
                }
            }
        }