The unit extensions.
예제 #1
0
        private async Task OnUpdate(CancellationToken token)
        {
            if (Game.IsPaused || !this.Owner.IsAlive || !PortalLocations.Any())
            {
                await Task.Delay(250, token);

                return;
            }

            if (Ensage.SDK.Extensions.UnitExtensions.HasModifier(this.Owner, "modifier_void_spirit_dissimilate_phase"))
            {
                if (UnitExtensions.FindModifier(this.Owner, "modifier_void_spirit_dissimilate_phase").RemainingTime >= 0.2f && this.VoidSpirit.RandomlyJump)
                {
                    foreach (var portalLocation in PortalLocations.ToList())
                    {
                        this.Owner.Move(portalLocation);
                        await Task.Delay(50, token);

                        if (UnitExtensions.FindModifier(this.Owner, "modifier_void_spirit_dissimilate_phase")
                            .RemainingTime <= 0.2f)
                        {
                            break;
                        }
                    }
                }
                else if (this.CurrentTarget != null)
                {
                    var closestPortal = this.PortalLocations
                                        .OrderBy(x => VectorExtensions.Distance2D(x, this.CurrentTarget)).FirstOrDefault();
                    if (this.Owner.Move(closestPortal))
                    {
                        await Task.Delay(50, token);
                    }
                }
                else
                {
                    var closestToMouse = this.PortalLocations.OrderBy(x => x.Distance2D(Game.MousePosition))
                                         .FirstOrDefault();
                    if (this.Owner.Move(closestToMouse))
                    {
                        await Task.Delay(50, token);
                    }
                }
            }
        }
예제 #2
0
        public override async Task ExecuteAsync(CancellationToken token)
        {
            if (!await this.ShouldExecute(token))
            {
                return;
            }

            this.MaxTargetRange = Math.Max(this.MaxTargetRange, Snapfire.Kiss.CastRange * 1.1f);

            if ((this.CurrentTarget == null) || !this.CurrentTarget.IsVisible)
            {
                this.Snapfire.Context.Orbwalker.Active.OrbwalkTo(null);
                return;
            }

            if (this.CurrentTarget.IsIllusion)
            {
                this.OrbwalkToTarget();
                return;
            }

            try
            {
                if (!Ensage.SDK.Extensions.UnitExtensions.HasModifier(this.Owner, "modifier_snapfire_mortimer_kisses"))
                {
                    var linkens = UnitExtensions.IsLinkensProtected(this.CurrentTarget);
                    await BreakLinken(token);

                    var veil = this.Snapfire.VeilOfDiscord;
                    if (veil != null && veil.CanBeCasted && veil.CanHit(CurrentTarget))
                    {
                        veil.UseAbility(CurrentTarget.Position);
                        await Task.Delay(veil.GetCastDelay(), token);
                    }

                    var hex = this.Snapfire.Sheepstick;
                    if (hex != null && hex.CanBeCasted && hex.CanHit(CurrentTarget) && !linkens &&
                        this.Snapfire.HexHeroes.Value.IsEnabled(CurrentTarget.Name))
                    {
                        hex.UseAbility(CurrentTarget);
                        await Task.Delay(hex.GetCastDelay(this.CurrentTarget), token);
                    }

                    var atos = this.Snapfire.RodOfAtos;
                    if (atos != null && atos.CanBeCasted && atos.CanHit(CurrentTarget) && !linkens)
                    {
                        atos.UseAbility(CurrentTarget);
                        await Task.Delay(atos.GetCastDelay(CurrentTarget), token);
                    }

                    var bloodthorn = this.Snapfire.BloodThorn;
                    if (bloodthorn != null && bloodthorn.CanBeCasted && bloodthorn.CanHit(CurrentTarget) && !linkens && this.Snapfire.OrchidHeroes.Value.IsEnabled(this.CurrentTarget.Name))
                    {
                        bloodthorn.UseAbility(CurrentTarget);
                        await Task.Delay(bloodthorn.GetCastDelay(CurrentTarget), token);
                    }

                    var orchid = this.Snapfire.Orchid;
                    if (orchid != null && orchid.CanBeCasted && orchid.CanHit(CurrentTarget) && !linkens && this.Snapfire.OrchidHeroes.Value.IsEnabled(this.CurrentTarget.Name))
                    {
                        orchid.UseAbility(CurrentTarget);
                        await Task.Delay(orchid.GetCastDelay(CurrentTarget), token);
                    }

                    var scatterblast = this.Snapfire.Scatterblast;
                    if (scatterblast.CanBeCasted && EntityExtensions.Distance2D(this.Owner, this.CurrentTarget) <= scatterblast.CastRange)
                    {
                        var input  = scatterblast.GetPredictionInput(this.CurrentTarget);
                        var output = this.Snapfire.Context.Prediction.GetPrediction(input);

                        if (output.HitChance >= HitChance.Medium)
                        {
                            scatterblast.UseAbility(output.CastPosition);
                            await Task.Delay(scatterblast.GetCastDelay(output.CastPosition), token);
                        }
                    }

                    var cookie = this.Snapfire.Cookie;
                    if (cookie.CanBeCasted)
                    {
                        var allies = EntityManager <Unit> .Entities.Where(x =>
                                                                          x.IsValid && cookie.CanHit(x) && x.Team == this.Owner.Team && x.Distance2D(this.Owner) <= cookie.CastRange &&
                                                                          x.Distance2D(this.CurrentTarget) <= 600 && x.Distance2D(this.CurrentTarget) >= 150).OrderBy(x => x.Distance2D(this.Owner)).ToList();

                        foreach (var ally in allies)
                        {
                            if (Ensage.Common.Extensions.UnitExtensions.InFront(ally, 450).Distance2D(this.CurrentTarget) >= 200)
                            {
                                continue;
                            }

                            var input  = new PredictionInput(this.Owner, ally, ally == this.Owner ? 0.3f : this.Owner.Distance2D(ally) / 1000, 1000, 450, 350);
                            var output = this.Snapfire.Context.Prediction.GetPrediction(input);

                            if (output.HitChance >= HitChance.Medium)
                            {
                                if (cookie.UseAbility(ally))
                                {
                                    await Task.Delay(cookie.GetCastDelay(ally), token);

                                    break;
                                }
                            }
                        }
                    }

                    var E = this.Snapfire.Shredder;
                    if (E.CanBeCasted && this.CurrentTarget.Distance2D(this.Owner) <=
                        (this.Owner.AttackRange + this.Snapfire.Shredder.Ability.GetAbilitySpecialData("attack_range_bonus")) - 150)
                    {
                        if (E.UseAbility())
                        {
                            await Task.Delay(E.GetCastDelay(), token);
                        }
                    }

                    var nullifier = this.Snapfire.Nullifier;
                    if (nullifier != null && nullifier.CanBeCasted && nullifier.CanHit(CurrentTarget) && !linkens &&
                        this.Snapfire.NullifierHeroes.Value.IsEnabled(CurrentTarget.Name))
                    {
                        nullifier.UseAbility(CurrentTarget);
                        await Task.Delay(nullifier.GetCastDelay(), token);
                    }

                    var solarCrest = this.Snapfire.SolarCrest;
                    if (solarCrest != null && solarCrest.CanBeCasted && solarCrest.CanHit(CurrentTarget) && !linkens)
                    {
                        nullifier.UseAbility(CurrentTarget);
                        await Task.Delay(nullifier.GetCastDelay(), token);
                    }

                    //if (Ensage.SDK.Extensions.UnitExtensions.HasModifier(this.Owner, "modifier_snapfire_lil_shredder_buff"))
                    //{
                    //    this.Snapfire.Context.Orbwalker.Attack(this.CurrentTarget);
                    //    return;
                    //}
                }
            }
            catch (TaskCanceledException)
            {
                // ignore
            }
            catch (Exception e)
            {
                Log.Debug($"{e}");
            }

            //if (!Ensage.SDK.Extensions.UnitExtensions.HasModifier(this.Owner, "modifier_snapfire_lil_shredder_buff"))
            //{
            this.OrbwalkToTarget();
            //}
        }
예제 #3
0
        protected async Task BreakLinken(CancellationToken token)
        {
            if (this.CurrentTarget != null && this.CurrentTarget.IsValid)
            {
                try
                {
                    List <KeyValuePair <string, uint> > breakerChanger = new List <KeyValuePair <string, uint> >();

                    if (UnitExtensions.IsLinkensProtected(this.CurrentTarget))
                    {
                        breakerChanger = this.Snapfire.Config.Hero.LinkenBreakerPriorityMenu.Value.Dictionary.Where(
                            x => this.Snapfire.Config.Hero.LinkenBreakerTogglerMenu.Value.IsEnabled(x.Key))
                                         .OrderByDescending(x => x.Value)
                                         .ToList();
                    }

                    foreach (var order in breakerChanger)
                    {
                        var euls = this.Snapfire.Euls;
                        if (euls != null &&
                            euls.ToString() == order.Key &&
                            euls.CanBeCasted && euls.CanHit(this.CurrentTarget))
                        {
                            euls.UseAbility(this.CurrentTarget);
                            await Task.Delay(euls.GetCastDelay(this.CurrentTarget), token);

                            return;
                        }

                        var force = this.Snapfire.ForceStaff;
                        if (force != null &&
                            force.ToString() == order.Key &&
                            force.CanBeCasted && force.CanHit(this.CurrentTarget))
                        {
                            force.UseAbility(this.CurrentTarget);
                            await Task.Delay(force.GetCastDelay(this.CurrentTarget), token);

                            return;
                        }

                        var orchid = this.Snapfire.Orchid;
                        if (orchid != null &&
                            orchid.ToString() == order.Key &&
                            orchid.CanBeCasted && orchid.CanHit(this.CurrentTarget))
                        {
                            orchid.UseAbility(this.CurrentTarget);
                            await Task.Delay(orchid.GetCastDelay(this.CurrentTarget), token);

                            return;
                        }

                        var bloodthorn = this.Snapfire.BloodThorn;
                        if (bloodthorn != null &&
                            bloodthorn.ToString() == order.Key &&
                            bloodthorn.CanBeCasted && bloodthorn.CanHit(this.CurrentTarget))
                        {
                            bloodthorn.UseAbility(this.CurrentTarget);
                            await Task.Delay(bloodthorn.GetCastDelay(this.CurrentTarget), token);

                            return;
                        }

                        var nullifier = this.Snapfire.Nullifier;
                        if (nullifier != null &&
                            nullifier.ToString() == order.Key &&
                            nullifier.CanBeCasted && nullifier.CanHit(this.CurrentTarget))
                        {
                            nullifier.UseAbility(this.CurrentTarget);
                            await Task.Delay(nullifier.GetCastDelay(this.CurrentTarget) + nullifier.GetHitTime(this.CurrentTarget), token);

                            return;
                        }

                        var atos = this.Snapfire.RodOfAtos;
                        if (atos != null &&
                            atos.ToString() == order.Key &&
                            atos.CanBeCasted && atos.CanHit(this.CurrentTarget))
                        {
                            atos.UseAbility(this.CurrentTarget);
                            await Task.Delay(atos.GetCastDelay(this.CurrentTarget) + atos.GetHitTime(this.CurrentTarget), token);

                            return;
                        }

                        var hex = this.Snapfire.Sheepstick;
                        if (hex != null &&
                            hex.ToString() == order.Key &&
                            hex.CanBeCasted && hex.CanHit(this.CurrentTarget))
                        {
                            hex.UseAbility(this.CurrentTarget);
                            await Task.Delay(hex.GetCastDelay(this.CurrentTarget), token);

                            return;
                        }

                        var diff = this.Snapfire.DiffusalBlade;
                        if (diff != null &&
                            diff.ToString() == order.Key &&
                            diff.CanBeCasted && diff.CanHit(this.CurrentTarget))
                        {
                            diff.UseAbility(this.CurrentTarget);
                            await Task.Delay(diff.GetCastDelay(this.CurrentTarget), token);

                            return;
                        }
                    }
                }
                catch (TaskCanceledException)
                {
                    // ignore
                }
                catch (Exception e)
                {
                    Log.Error("Linken break error: " + e);
                }
            }
        }
예제 #4
0
        public override async Task ExecuteAsync(CancellationToken token)
        {
            if (!await this.ShouldExecute(token))
            {
                return;
            }

            this.MaxTargetRange = Math.Max(this.MaxTargetRange, VoidSpirit.Ulti.CastRange * 1.1f);

            if ((this.CurrentTarget == null) || !this.CurrentTarget.IsVisible)
            {
                this.VoidSpirit.Context.Orbwalker.Active.OrbwalkTo(null);
                return;
            }

            if (this.CurrentTarget.IsIllusion)
            {
                this.OrbwalkToTarget();
                return;
            }

            try
            {
                if (!Ensage.SDK.Extensions.UnitExtensions.HasModifier(this.Owner, "modifier_void_spirit_dissimilate_phase"))
                {
                    var linkens = UnitExtensions.IsLinkensProtected(this.CurrentTarget);
                    await BreakLinken(token);

                    var veil = this.VoidSpirit.VeilOfDiscord;
                    if (veil != null && veil.CanBeCasted && veil.CanHit(CurrentTarget))
                    {
                        veil.UseAbility(CurrentTarget.Position);
                        await Task.Delay(veil.GetCastDelay(), token);
                    }

                    var hex = this.VoidSpirit.Sheepstick;
                    if (hex != null && hex.CanBeCasted && hex.CanHit(CurrentTarget) && !linkens &&
                        this.VoidSpirit.HexHeroes.Value.IsEnabled(CurrentTarget.Name))
                    {
                        hex.UseAbility(CurrentTarget);
                        await Task.Delay(hex.GetCastDelay(this.CurrentTarget), token);
                    }

                    var etherealBlade = this.VoidSpirit.EtherealBlade;
                    if (etherealBlade != null && etherealBlade.CanBeCasted && etherealBlade.CanHit(CurrentTarget) && !linkens)
                    {
                        etherealBlade.UseAbility(CurrentTarget);
                        await Task.Delay(etherealBlade.GetCastDelay(this.CurrentTarget), token);
                    }

                    var mjollnir = this.VoidSpirit.Mjollnir;
                    if (mjollnir != null && mjollnir.CanBeCasted)
                    {
                        mjollnir.UseAbility(this.Owner);
                        await Task.Delay(mjollnir.GetCastDelay(), token);
                    }

                    var bloodthorn = this.VoidSpirit.BloodThorn;
                    if (bloodthorn != null && bloodthorn.CanBeCasted && bloodthorn.CanHit(CurrentTarget) && !linkens && this.VoidSpirit.OrchidHeroes.Value.IsEnabled(this.CurrentTarget.Name))
                    {
                        bloodthorn.UseAbility(CurrentTarget);
                        await Task.Delay(bloodthorn.GetCastDelay(), token);
                    }

                    var orchid = this.VoidSpirit.Orchid;
                    if (orchid != null && orchid.CanBeCasted && orchid.CanHit(CurrentTarget) && !linkens && this.VoidSpirit.OrchidHeroes.Value.IsEnabled(this.CurrentTarget.Name))
                    {
                        orchid.UseAbility(CurrentTarget);
                        await Task.Delay(orchid.GetCastDelay(), token);
                    }

                    var remnant = this.VoidSpirit.Remnant;
                    if (remnant.CanBeCasted && EntityExtensions.Distance2D(this.Owner, this.CurrentTarget) <= remnant.CastRange)
                    {
                        var input  = remnant.GetPredictionInput(this.CurrentTarget);
                        var output = this.VoidSpirit.Context.Prediction.GetPrediction(input);

                        if (output.HitChance >= HitChance.Medium)
                        {
                            remnant.UseAbility(Vector3Extensions.Extend(output.CastPosition, Ensage.SDK.Extensions.UnitExtensions.InFront(output.Unit, 50), 50));
                            await Task.Delay(remnant.GetCastDelay(), token);
                        }
                    }

                    var mod    = this.Owner.FindModifier("modifier_void_spirit_astral_step_charge_counter");
                    var stacks = mod?.StackCount;
                    var ulti   = this.VoidSpirit.Ulti;
                    if (ulti.CanBeCasted)
                    {
                        if (this.Owner.Distance2D(this.CurrentTarget) <= ulti.Ability.GetAbilitySpecialData("max_travel_distance") && stacks > 1)
                        {
                            var input = new PredictionInput(this.Owner, this.CurrentTarget, ulti.GetCastDelay() / 1000f, float.MaxValue, ulti.Ability.GetAbilitySpecialData("max_travel_distance")
                                                            , ulti.Radius);
                            var output = this.VoidSpirit.Context.Prediction.GetPrediction(input);
                            if (output.HitChance >= HitChance.Medium)
                            {
                                for (int i = 0; i < 1; i++)
                                {
                                    if (ulti.UseAbility(output.CastPosition))
                                    {
                                        await Task.Delay(ulti.GetCastDelay(output.CastPosition), token);
                                    }
                                }
                            }
                        }
                        else if (this.Owner.Distance2D(this.CurrentTarget) <=
                                 ulti.Ability.GetAbilitySpecialData("max_travel_distance") &&
                                 this.Owner.Distance2D(this.CurrentTarget) > 400)
                        {
                            var input = new PredictionInput(this.Owner, this.CurrentTarget, ulti.GetCastDelay() / 1000f, float.MaxValue, ulti.Ability.GetAbilitySpecialData("max_travel_distance")
                                                            , ulti.Radius);
                            var output = this.VoidSpirit.Context.Prediction.GetPrediction(input);
                            if (output.HitChance >= HitChance.Medium)
                            {
                                if (ulti.UseAbility(output.CastPosition))
                                {
                                    await Task.Delay(ulti.GetCastDelay(output.CastPosition), token);
                                }
                            }
                        }
                    }

                    var targets =
                        EntityManager <Hero> .Entities.Where(
                            x =>
                            x.IsValid && x.Team != this.Owner.Team && !x.IsIllusion && !Ensage.SDK.Extensions.UnitExtensions.IsMagicImmune(x) &&
                            x.Distance2D(this.Owner) <= this.VoidSpirit.E.Radius)
                        .ToList();

                    var E = this.VoidSpirit.E;
                    if (E.CanBeCasted && this.CurrentTarget.Distance2D(this.Owner) <= E.Radius &&
                        targets.Count >= this.VoidSpirit.ResonantPulseCount.Value.Value)
                    {
                        if (E.UseAbility())
                        {
                            await Task.Delay(E.GetCastDelay(), token);
                        }
                    }

                    var W = this.VoidSpirit.W;
                    if (W.CanBeCasted && this.CurrentTarget.Distance2D(this.Owner) <= 400)
                    {
                        if (W.UseAbility())
                        {
                            await Task.Delay(W.GetCastDelay(), token);
                        }
                    }

                    var abyssal = this.VoidSpirit.AbyssalBlade;
                    if (abyssal != null && abyssal.CanBeCasted && abyssal.CanHit(CurrentTarget) && !linkens &&
                        this.VoidSpirit.AbyssalBladeHeroes.Value.IsEnabled(CurrentTarget.Name))
                    {
                        abyssal.UseAbility(CurrentTarget);
                        await Task.Delay(abyssal.GetCastDelay(), token);
                    }

                    var shivas = this.VoidSpirit.ShivasGuard;
                    if (shivas != null && shivas.CanBeCasted && shivas.CanHit(this.CurrentTarget))
                    {
                        if (shivas.UseAbility())
                        {
                            await Task.Delay(10, token);
                        }
                    }

                    var nullifier = this.VoidSpirit.Nullifier;
                    if (nullifier != null && nullifier.CanBeCasted && nullifier.CanHit(CurrentTarget) && !linkens &&
                        this.VoidSpirit.NullifierHeroes.Value.IsEnabled(CurrentTarget.Name))
                    {
                        nullifier.UseAbility(CurrentTarget);
                        await Task.Delay(nullifier.GetCastDelay(), token);
                    }

                    if (this.VoidSpirit.Dagon != null &&
                        this.VoidSpirit.Dagon.Item.IsValid &&
                        this.CurrentTarget != null &&
                        this.VoidSpirit.Dagon.Item.CanBeCasted(this.CurrentTarget))
                    {
                        this.VoidSpirit.Dagon.UseAbility(this.CurrentTarget);
                        await Task.Delay(this.VoidSpirit.Dagon.GetCastDelay(this.CurrentTarget), token);
                    }
                }
            }
            catch (TaskCanceledException)
            {
                // ignore
            }
            catch (Exception e)
            {
                Log.Debug($"{e}");
            }

            if (!Ensage.SDK.Extensions.UnitExtensions.HasModifier(this.Owner, "modifier_void_spirit_dissimilate_phase"))
            {
                this.OrbwalkToTarget();
            }
        }