Distance2D() public static method

Distance between two entities
public static Distance2D ( this entity1, System.Entity entity2 ) : float
entity1 this /// The entity 1. ///
entity2 System.Entity /// The entity 2. ///
return float
Exemplo n.º 1
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();
            //}
        }
Exemplo n.º 2
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();
            }
        }