Esempio n. 1
0
        private void OnUpdate()
        {
            var teammates = EntityManager <Hero> .Entities.Where(
                x =>
                x.IsValid && x.Team == this.Owner.Team &&
                x.Distance2D(this.Owner) <= this.Magnus.Empower.CastRange &&
                this.Magnus.EmpowerHeroes.Value.IsEnabled(x.Name) &&
                !x.HasModifier("modifier_magnataur_empower"))
                            .OrderBy(x => x.Distance2D(this.Owner)).FirstOrDefault();

            var condition = ((!this.Magnus.ReversePolarity.CanBeCasted && !this.Magnus.Skewer.CanBeCasted) ||
                             !this.Magnus.Config.General.ComboKey || !this.Owner.IsChanneling());

            if (teammates != null && this.Owner.IsAlive && this.Magnus.Empower.CanBeCasted && condition && !this.Magnus.Empower.Ability.IsInAbilityPhase)
            {
                this.Magnus.Empower.UseAbility(teammates);
                Task.Delay(this.Magnus.Empower.GetCastDelay(teammates) + 100);
            }

            if (this.Magnus.DebugDrawings)
            {
                if (this.Magnus.Context.TargetSelector.IsActive)
                {
                    Context.Particle.Remove("Metin");
                }
                else
                {
                    Magnus.Context.Particle.AddOrUpdate(
                        Owner,
                        "Metin",
                        "materials/ensage_ui/particles/text.vpcf",
                        ParticleAttachment.AbsOrigin,
                        RestartType.None,
                        0,
                        Owner.Position - new Vector3(0, 200, 0),
                        1,
                        new Vector3(121, 8611111, 231651),
                        2,
                        new Vector3(111, 1111121, 115111),
                        3,
                        new Vector3(113, 1151114, 111111),
                        4,
                        new Vector3(111, 1111111, 111118),
                        5,
                        new Vector3(111, 1111511, 111111),
                        6,
                        new Vector3(111, 1111111, 111111),
                        7,
                        new Vector3(511, 1111111, 111111),
                        10,
                        new Vector3(50, 16, 0),
                        11,
                        new Vector3(255, 0, 0));
                }
            }


            targets = EntityManager <Hero> .Entities.OrderBy(x => x == this.CurrentTarget).Where(
                x => x.IsValid && x.IsVisible && x.Team != Owner.Team && !x.IsIllusion).ToList();

            if (CurrentTarget != null)
            {
                Input = new PredictionInput(this.Owner, this.CurrentTarget,
                                            this.Magnus.ReversePolarity.GetCastDelay() / 1000f, float.MaxValue, 1200, 410,
                                            PredictionSkillshotType.SkillshotCircle, true, targets, true);
                Output = this.Magnus.Context.Prediction.GetPrediction(Input);
            }

            if (CurrentTarget != null && Output != null && CurrentTarget.Distance2D(Output.CastPosition) <= 1000 &&
                Output.AoeTargetsHit.Count(x => x?.Unit is Hero && x.Unit.IsValid && x.Unit.IsAlive && x.Unit.Team != this.Owner.Team) + 1 >= (this.Magnus.Amount.Value == 1 ? 0 : this.Magnus.Amount.Value) &&
                this.Magnus.DebugDrawings)
            {
                this.Magnus.Context.Particle.AddOrUpdate(
                    Owner,
                    "RpRadius",
                    "particles/ui_mouseactions/drag_selected_ring.vpcf",
                    ParticleAttachment.AbsOrigin,
                    RestartType.None,
                    0,
                    Output.CastPosition,
                    1,
                    Color.Aqua,
                    2,
                    410 * 1.1f);
            }
            else
            {
                this.Magnus.Context.Particle.Remove("RpRadius");
            }

            if (CurrentTarget != null && this.Magnus.DebugDrawings)
            {
                Context.Particle.DrawTargetLine(
                    Owner,
                    "Target",
                    CurrentTarget != null
                        ? CurrentTarget.Position
                        : (Output != null && Output.AoeTargetsHit.Count(x => x?.Unit is Hero && x.Unit.Team != this.Owner.Team) + 1
                           >= (this.Magnus.Amount.Value == 1 ? 0 : this.Magnus.Amount.Value))
                            ? Output.CastPosition
                            : CurrentTarget.Position,
                    CurrentTarget != null ? Color.Red : Color.Aqua);
            }
            else
            {
                Context.Particle.Remove("Target");
            }

            fountain =
                EntityManager <Unit> .Entities
                .FirstOrDefault(
                    x => x.IsValid && x.Team == this.Owner.Team && x.Name == "dota_fountain");

            if (this.CurrentTarget != null)
            {
                teammateys =
                    EntityManager <Hero> .Entities.Where(
                        x =>
                        x.IsValid && x.Team == this.Owner.Team && x != this.Owner &&
                        x.Distance2D(targets.FirstOrDefault()) <= this.Magnus.Skewer.CastRange + 400)
                    .OrderBy(x => x.Distance2D(targets.FirstOrDefault())).FirstOrDefault();

                if (Magnus.SkewerTarget == SkewerTarget.Teammate && teammateys != null && this.CurrentTarget != null)
                {
                    position = teammateys.NetworkPosition.Extend(this.CurrentTarget.NetworkPosition,
                                                                 teammateys.Distance2D(this.CurrentTarget));
                    skewerPosition = teammateys.NetworkPosition;
                }
                else if (this.CurrentTarget != null)
                {
                    position = fountain.NetworkPosition.Extend(this.CurrentTarget.NetworkPosition,
                                                               fountain.Distance2D(this.CurrentTarget));
                    skewerPosition = fountain.NetworkPosition;
                }
            }
            else
            {
                teammateys = null;
            }
        }