示例#1
0
        private void EntityOnInt32PropertyChange(Entity sender, Int32PropertyChangeEventArgs args)
        {
            if (args.PropertyName == "m_iCurrentXP")
            {
                enemies.FirstOrDefault(x => x.Handle == sender.Handle)?.SetExperience(args.OldValue, args.NewValue);
                return;
            }

            if (!menu.Enabled || args.NewValue > 0 || args.OldValue <= 0 || args.PropertyName != "m_iHealth")
            {
                return;
            }

            var creep = sender as Creep;

            if (creep == null || !creep.IsValid || creep.Team != heroTeam)
            {
                return;
            }

            var exp = creep.GetGrantedExperience();

            if (exp <= 0 || deadCreeps.ContainsKey(creep))
            {
                return;
            }

            //delay check to prevent incorrect information
            //when multiple creeps die at the same time
            deadCreeps.Add(creep, exp);
            sleeper.Sleep(150, deadCreeps);
        }
示例#2
0
        public async Task UseAbilities(UnitBase unitBase)
        {
            if (unitBase.Hero.IsInvisible() || unitBase.Hero.Modifiers.Any(x => x.Name.Contains("windwalk")))
            {
                return;
            }
            var flux          = unitBase.Flux;
            var magneticField = unitBase.MagneticField;
            var spark         = unitBase.Spark;

            if (!_multiSleeper.Sleeping(flux) && unitBase.AbilityChecker.IsAbilityEnabled(flux.GetAbilityId()) &&
                flux.CanBeCasted() && flux.CanHit(Core.Target))
            {
                if (Core.Target.IsLinkensProtected() || !MenuManager.SmartFlux || !EntityManager <Unit> .Entities.Any(
                        x =>
                        !x.Equals(Core.Target) && x.Team == Core.Target.Team && x.Name != "npc_dota_thinker" &&
                        x.IsAlive && x.IsVisible &&
                        Ensage.SDK.Extensions.EntityExtensions.Distance2D(x, Core.Target) <= 225))
                {
                    flux.UseAbility(Core.Target);
                    Printer.Both("Flux usages " + flux.GetAbilityDelay());
                    _multiSleeper.Sleep(500, flux);
                    await Task.Delay(flux.GetAbilityDelay(), Core.ComboToken.Token);
                }
            }
            var distance = unitBase.Hero.Distance2D(Core.Target);

            if (!_multiSleeper.Sleeping(magneticField) && magneticField != null &&
                unitBase.AbilityChecker.IsAbilityEnabled(magneticField.GetAbilityId()) && magneticField.CanBeCasted() &&
                !unitBase.Hero.HasModifier("modifier_arc_warden_magnetic_field") && distance <= 600 &&
                Core.Target.IsVisible)
            {
                if (!MenuManager.MagneticField && Core.Target.IsMelee)
                {
                    magneticField.UseAbility(Prediction.InFront(unitBase.Hero, -250));
                }
                else
                {
                    magneticField.UseAbility(Prediction.InFront(unitBase.Hero, 250));
                }
                _multiSleeper.Sleep(500, magneticField);
                Printer.Both("MagneticField usages");
                await Task.Delay(magneticField.GetAbilityDelay(), Core.ComboToken.Token);
            }
            if (!_multiSleeper.Sleeping(spark) && spark != null &&
                unitBase.AbilityChecker.IsAbilityEnabled(spark.GetAbilityId()) && spark.CanBeCasted() &&
                !Prediction.IsTurning(Core.Target) && unitBase.Hero.IsVisibleToEnemies)
            {
                if (UnitExtensions.IsInAttackRange(unitBase.Hero, Core.Target) && MenuManager.SmartSpark)
                {
                    return;
                }
                var delay       = spark.GetAbilityDelay();
                var predVector3 = Prediction.PredictedXYZ(Core.Target, 2000 + delay);
                spark.UseAbility(predVector3);
                _multiSleeper.Sleep(500, spark);
                Printer.Both("spark usages");
                await Task.Delay(spark.GetAbilityDelay(), Core.ComboToken.Token);
            }
        }
示例#3
0
        private void OnUpdate(EventArgs args)
        {
            if (!Game.IsInGame || Game.IsPaused || !Menu.ArmletAutoToggle)
            {
                return;
            }

            if (!Hero.IsAlive || !Hero.CanUseItems())
            {
                return;
            }

            var nearEnemies =
                ObjectManager.GetEntitiesParallel <Unit>()
                .Where(
                    x =>
                    x.IsValid && x.IsAlive && x.IsSpawned && x.AttackCapability != AttackCapability.None &&
                    x.Team != HeroTeam && x.Distance2D(Hero) < x.GetAttackRange() + 200);

            foreach (var enemy in nearEnemies.Where(x => x.AttackCapability == AttackCapability.Melee))
            {
                if (enemy.IsAttacking() && !attackStart.Sleeping(enemy))
                {
                    attacking.Sleep((float)UnitDatabase.GetAttackPoint(enemy) * 1000, enemy);
                    attackStart.Sleep(enemy.AttacksPerSecond * 1000 - Game.Ping, enemy);
                }
                else if (!enemy.IsAttacking() && attackStart.Sleeping(enemy))
                {
                    attackStart.Reset(enemy);
                    attacking.Sleep((float)UnitDatabase.GetAttackBackswing(enemy) * 1000, enemy);
                }
            }

            if (Sleeper.Sleeping)
            {
                return;
            }

            var heroProjectiles =
                ObjectManager.TrackingProjectiles.Where(x => x?.Target is Hero && x.Target.Equals(Hero)).ToList();

            var noProjectile =
                heroProjectiles.All(
                    x =>
                    x.Position.Distance2D(Hero) / x.Speed > 0.30 ||
                    x.Position.Distance2D(Hero) / x.Speed < Game.Ping / 1000);

            var noAutoAttack = nearEnemies.All(x => x.FindRelativeAngle(Hero.Position) > 0.5 || !attacking.Sleeping(x));

            if (Hero.Health < Menu.ArmetHpThreshold && noProjectile && noAutoAttack &&
                (nearEnemies.Any() || heroProjectiles.Any()))
            {
                Use(null, null);
            }
        }
示例#4
0
        public void OnUpdate()
        {
            if (sleeper.Sleeping(this))
            {
                return;
            }

            if (!sleeper.Sleeping(enemyHeroes))
            {
                foreach (var enemy in
                         Ensage.Common.Objects.Heroes.GetByTeam(enemyTeam)
                         .Where(x => x.IsValid && !x.IsIllusion && !enemyHeroes.Exists(z => z.Handle == x.Handle)))
                {
                    enemyHeroes.Add(new EnemyHero(enemy));
                }
                sleeper.Sleep(2000, enemyHeroes);
            }

            foreach (var enemy in enemyHeroes)
            {
                if (!enemy.IsVisible)
                {
                    enemy.ObserversCount = 0;
                    enemy.SentryCount    = 0;
                    continue;
                }

                if (PlacedWard(enemy, ClassId.CDOTA_Item_ObserverWard))
                {
                    AddWard <ObserverWard>(enemy);
                }

                if (PlacedWard(enemy, ClassId.CDOTA_Item_SentryWard))
                {
                    AddWard <SentryWard>(enemy);
                }
            }

            if (!sleeper.Sleeping(units))
            {
                var removeUnits = units.Where(x => x.Duration > 0 && x.EndTime <= Game.RawGameTime).ToList();
                if (removeUnits.Any())
                {
                    removeUnits.ForEach(x => x.ParticleEffect?.Dispose());
                    units.RemoveAll(x => removeUnits.Contains(x));
                }
                sleeper.Sleep(1000, units);
            }

            sleeper.Sleep(100, this);
        }
示例#5
0
        private void OnUpdate()
        {
            if (sleeper.Sleeping(this) || Game.IsPaused)
            {
                return;
            }

            sleeper.Sleep(menu.UpdateRate, this);

            var validControllables = controllables.Where(x => x.IsValid()).ToList();

            if (menu.ToggleKey && menu.EnabledToggleItems.Contains(0) ||
                menu.HoldKey && menu.EnabledHoldItems.Contains(0))
            {
                var runes = ObjectManager.GetEntitiesParallel <Rune>()
                            .Where(x => !sleeper.Sleeping(x.Handle) && x.IsVisible);

                foreach (var rune in runes)
                {
                    foreach (var controllable in validControllables)
                    {
                        if (controllable.CanPick(rune))
                        {
                            controllable.Pick(rune);
                            sleeper.Sleep(500, rune.Handle);
                            break;
                        }
                    }
                }
            }

            var items = ObjectManager.GetEntitiesParallel <PhysicalItem>()
                        .Where(
                x => x.IsVisible && !ignoredItems.Contains(x.Item.Handle) && !sleeper.Sleeping(x.Handle) &&
                (menu.ToggleKey && menu.EnabledToggleItems.Contains(x.Item.Id) ||
                 menu.HoldKey && menu.EnabledHoldItems.Contains(x.Item.Id)));

            foreach (var item in items)
            {
                foreach (var controllable in validControllables)
                {
                    if (controllable.CanPick(item, menu.ItemMoveCostThreshold))
                    {
                        controllable.Pick(item);
                        sleeper.Sleep(500, item.Handle);
                        break;
                    }
                }
            }
        }
示例#6
0
文件: Core.cs 项目: HDJN/EnsageSharp
 private static bool TryToDisable(Hero hero, IEnumerable <Item> myItems, IEnumerable <Ability> myAbilities)
 {
     myAbilities = myAbilities.Where(x => !Members.EscapeAbilityList.Contains(x.GetAbilityId()) && !x.IsShield() && !x.IsShield());
     myItems     = myItems.Where(x => !Members.EscapeItemList.Contains(x.GetItemId()) && !x.IsShield() && !x.IsShield());
     if (myItems.Any())
     {
         var item = myItems.First();
         if ((item.AbilityBehavior & AbilityBehavior.Point) != 0)
         {
             item.UseAbility(hero.Position);
         }
         else if ((item.AbilityBehavior & AbilityBehavior.UnitTarget) != 0)
         {
             item.UseAbility(hero);
         }
         else
         {
             item.UseAbility();
         }
         ComboSleeper.Sleep(350, item.StoredName() + hero.StoredName());
         Log.Debug($"item: {item.StoredName()}");
         if (MenuManager.IsUseOnlyOne)
         {
             ComboSleeper.Sleep(350, hero.StoredName());
         }
         return(MenuManager.IsUseOnlyOne);
     }
     if (myAbilities.Any())
     {
         var ability = myAbilities.First();
         if ((ability.AbilityBehavior & AbilityBehavior.Point) != 0)
         {
             if (ability.IsSkillShot())
             {
                 ability.CastSkillShot(hero);
             }
             else
             {
                 ability.UseAbility(hero.Position);
             }
         }
         else if ((ability.AbilityBehavior & AbilityBehavior.UnitTarget) != 0)
         {
             ability.UseAbility(hero);
         }
         else
         {
             ability.UseAbility();
         }
         ComboSleeper.Sleep(Helper.GetAbilityDelay(hero, ability), ability.StoredName() + hero.StoredName());
         Log.Debug($"ability: {ability.StoredName()}");
         if (MenuManager.IsUseOnlyOne)
         {
             ComboSleeper.Sleep(350, hero.StoredName());
         }
         return(MenuManager.IsUseOnlyOne);
     }
     return(false);
 }
示例#7
0
        private void OnUpdate()
        {
            if (Game.IsPaused)
            {
                return;
            }

            var validControllables = controllables.Where(x => x.IsValid()).ToList();

            if (menu.ToggleKey && menu.EnabledToggleItems.Contains(0) ||
                menu.HoldKey && menu.EnabledHoldItems.Contains(0))
            {
                //var runes = EntityManager<Rune>.Entities
                var runes = ObjectManager.GetEntitiesFast <Rune>().Where(x => !sleeper.Sleeping(x.Handle));

                foreach (var rune in runes)
                {
                    foreach (var controllable in validControllables)
                    {
                        if (controllable.CanPick(rune))
                        {
                            controllable.Pick(rune);
                            sleeper.Sleep(500, rune.Handle);
                            break;
                        }
                    }
                }
            }

            var items = EntityManager <PhysicalItem> .Entities.Where(
                x => x.IsValid && x.IsVisible && !ignoredItems.Contains(x.Item.Handle) &&
                !sleeper.Sleeping(x.Handle) &&
                (menu.ToggleKey && menu.EnabledToggleItems.Contains(x.Item.Id) ||
                 menu.HoldKey && menu.EnabledHoldItems.Contains(x.Item.Id)))
                        .OrderByDescending(x => x.Item.Id == AbilityId.item_aegis);

            foreach (var item in items)
            {
                foreach (var controllable in validControllables)
                {
                    if (controllable.CanPick(item, menu.ItemMoveCostThreshold))
                    {
                        controllable.Pick(item);
                        sleeper.Sleep(500, item.Handle);
                        break;
                    }
                }
            }
        }
示例#8
0
        private void OnAbuseChange(object sender, BoolEventArgs boolEventArgs)
        {
            if (boolEventArgs.Enabled)
            {
                manager.MyHero.DroppedItems.RemoveAll(
                    x => x == null || !x.IsValid ||
                    manager.MyHero.GetItems(ItemStoredPlace.Inventory | ItemStoredPlace.Backpack).Contains(x));
            }
            else if (usingItems && !menu.ItemsToBackpack)
            {
                sleeper.Sleep(manager.MyHero.DroppedItems.Count * 100, "blockEarlyKeyRelease");
            }

            sleeper.Sleep(0, this);
        }
示例#9
0
文件: MyHero.cs 项目: senzdota/Ensage
        public void DropItems(ItemStats dropItemStats, bool toBackpack = false, params IRecoveryAbility[] ignoredItems)
        {
            foreach (var item in GetItems(ItemStoredPlace.Inventory)
                     .Where(
                         x => ignoredItems.All(z => z.Handle != x.Handle) && !DroppedItems.Contains(x) &&
                         !disabledItems.Sleeping(x.Handle) && x.IsEnabled && x.IsDroppable &&
                         x.GetItemStats().HasFlag(dropItemStats)))
            {
                if (toBackpack && ItemsCanBeDisabled())
                {
                    if (!item.CanBeMovedToBackpack())
                    {
                        continue;
                    }

                    var slot = GetItemSlot(item.Handle, ItemStoredPlace.Inventory);
                    item.MoveItem(ItemSlot.BackPack_1);
                    disabledItems.Sleep(6000, item.Handle);
                    UsableAbilities.FirstOrDefault(x => x.Handle == item.Handle)?.SetSleep(6000);

                    if (slot != null)
                    {
                        item.MoveItem(slot.Value);
                    }
                }
                else
                {
                    DropItem(item, ItemStoredPlace.Inventory);
                }
            }
        }
示例#10
0
        private void Modifier(Hero hero, Modifier modifier, Vector3 position, string modifierName, int sleepTime, HeroId heroId = 0)
        {
            try
            {
                var abilityTextureName = modifier.TextureName;

                if (modifierName.StartsWith("modifier_rune"))
                {
                    abilityTextureName = modifierName.Substring("modifier_".Length);
                }

                var heroTextureName = hero.Name;
                if (MultiSleeper <string> .Sleeping($"Modifers_{abilityTextureName}_{heroTextureName}"))
                {
                    return;
                }

                var player = hero.Player;
                if (player == null)
                {
                    return;
                }

                Verification.ModifierVerification(position, heroTextureName, abilityTextureName, player.Id + 1, heroId);
                MultiSleeper <string> .Sleep($"Modifers_{abilityTextureName}_{heroTextureName}", sleepTime);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
示例#11
0
 public static bool RazeCaster(Ability raze, Hero target, bool checkForAngle = true)
 {
     if (!raze.CanBeCasted())
     {
         return(false);
     }
     if (Core.RazeCanceler.Sleeping(raze) || raze.IsInAbilityPhase)
     {
         if (raze.CanHit(target))
         {
             return(true);
         }
         if (StopSleeper.Sleeping(raze))
         {
             return(true);
         }
         Core.Me.Stop();
         Core.RazeCanceler.Reset(raze);
         StopSleeper.Sleep(Game.Ping + 10, raze);
         Printer.Print($"stop: [sl: {Core.RazeCanceler.Sleeping(raze)}] [ph: {raze.IsInAbilityPhase}]");
     }
     else if (raze.CanHit(target, true, checkForAngle))
     {
         if (Core.Razes.Any(x => x.IsInAbilityPhase))
         {
             return(false);
         }
         raze.UseAbility();
         //StopSystem.New(raze, target);
         Core.RazeCanceler.Sleep(raze.GetAbilityDelay() + 50, raze);
         Printer.Print($"cast: [{raze.Name}]->{raze.GetAbilityDelay() + 50}");
         return(true);
     }
     return(false);
 }
示例#12
0
        private static async Task UseInvis(Hero target, CancellationToken cancellationToken)
        {
            while (true)
            {
                var invis = Members.MyHero.FindItem("item_invis_sword", true) ??
                            Members.MyHero.FindItem("item_silver_edge", true);
                var dist = Members.MyHero.Distance2D(target);
                if (UseHealBeforeInvis && dist <= InvisRange)
                {
                    await UseHeal(cancellationToken);
                }

                if (dist <= InvisRange)
                {
                    if (invis.CanBeCasted() && Members.MyCurrentMana > invis.ManaCost)
                    {
                        Printer.Print("inv");
                        invis.UseAbility();
                        Members.MyCurrentMana -= invis.ManaCost;
                        await Task.Delay(5, cancellationToken);

                        ComboSleeper.Sleep(1000, "invisAction");
                    }
                    else
                    {
                        if (!UseHealBeforeInvis)
                        {
                            await UseHeal(cancellationToken);
                        }
                    }
                }
                else
                {
                    if (Utils.SleepCheck("move_rate"))
                    {
                        Members.MyHero.Move(target.Position);
                        Utils.Sleep(125, "move_rate");
                    }

                    await Task.Delay(5, cancellationToken);

                    continue;
                }

                break;
            }
        }
示例#13
0
 private static async Task UseItem(Item ability, Unit target, CancellationToken cancellationToken,
                                   int extraDelay = 0)
 {
     ComboSleeper.Sleep(250, ability);
     ability.UseAbility(target);
     Printer.Print($"[{(int) Game.RawGameTime}] [Item] {ability.Name}: {50}");
     await Task.Delay(10, cancellationToken);
 }
示例#14
0
        private void OnUpdate(EventArgs args)
        {
            if (!sleeper.Sleeping(units))
            {
                foreach (var unit in
                         ObjectManager.GetEntitiesParallel <Unit>()
                         .Where(x => x.IsValid && !units.ContainsKey(x) && x.IsSpawned && x.IsAlive && !x.Equals(Hero)))
                {
                    var obstacle = AddObstacle(unit.NetworkPosition, unit.HullRadius);
                    if (obstacle != null)
                    {
                        units.Add(unit, obstacle.Value);
                    }
                }

                sleeper.Sleep(1000, units);
            }

            if (!sleeper.Sleeping(Pathfinding))
            {
                var remove = new List <Unit>();
                foreach (var unitPair in units)
                {
                    var unit     = unitPair.Key;
                    var obstacle = unitPair.Value;

                    if (unit == null || !unit.IsValid || !unit.IsAlive)
                    {
                        remove.Add(unit);
                        RemoveObstacle(obstacle);
                        continue;
                    }

                    UpdateObstacle(obstacle, unit.NetworkPosition, unit.HullRadius);
                }

                foreach (var unit in remove)
                {
                    units.Remove(unit);
                }

                sleeper.Sleep(100, Pathfinding);
            }
        }
示例#15
0
        public async Task UseAbilities(UnitBase unitBase)
        {
            if (unitBase.Hero.IsInvisible() || unitBase.Hero.Modifiers.Any(x => x.Name.Contains("windwalk")))
            {
                return;
            }
            var flux          = unitBase.Flux;
            var magneticField = unitBase.MagneticField;
            var spark         = unitBase.Spark;

            if (!_multiSleeper.Sleeping(flux) && unitBase.AbilityChecker.IsAbilityEnabled(flux.GetAbilityId()) && flux.CanBeCasted() && flux.CanHit(Core.Target))
            {
                flux.UseAbility(Core.Target);
                Printer.Both("Flux usages " + flux.GetAbilityDelay());
                _multiSleeper.Sleep(500, flux);
                await Task.Delay(flux.GetAbilityDelay(), Core.ComboToken.Token);
            }
            var distance = unitBase.Hero.Distance2D(Core.Target);

            if (!_multiSleeper.Sleeping(magneticField) && magneticField != null && unitBase.AbilityChecker.IsAbilityEnabled(magneticField.GetAbilityId()) && magneticField.CanBeCasted() &&
                !unitBase.Hero.HasModifier("modifier_arc_warden_magnetic_field") && distance <= 600 && Core.Target.IsVisible)
            {
                if (!MenuManager.MagneticField && Core.Target.IsMelee)
                {
                    magneticField.UseAbility(Prediction.InFront(unitBase.Hero, -250));
                }
                else
                {
                    magneticField.UseAbility(Prediction.InFront(unitBase.Hero, 250));
                }
                _multiSleeper.Sleep(500, magneticField);
                Printer.Both("MagneticField usages");
                await Task.Delay(magneticField.GetAbilityDelay(), Core.ComboToken.Token);
            }
            if (!_multiSleeper.Sleeping(spark) && spark != null && unitBase.AbilityChecker.IsAbilityEnabled(spark.GetAbilityId()) && spark.CanBeCasted() && !Prediction.IsTurning(Core.Target) && unitBase.Hero.IsVisibleToEnemies)
            {
                var delay       = spark.GetAbilityDelay();
                var predVector3 = Prediction.PredictedXYZ(Core.Target, 2000 + delay);
                spark.UseAbility(predVector3);
                _multiSleeper.Sleep(500, spark);
                Printer.Both("spark usages");
                await Task.Delay(spark.GetAbilityDelay(), Core.ComboToken.Token);
            }
        }
示例#16
0
        public bool Attack(Unit unit, Unit target)
        {
            if (!MultiSleeper.Sleeping($"Attack{ unit.Handle }"))
            {
                MultiSleeper.Sleep(200, $"Attack{ unit.Handle }");
                return(unit.Attack(target));
            }

            return(false);
        }
示例#17
0
        public bool BottleCanBeRefilled()
        {
            if (manager.MyHero.Distance2D(fountain) < 1300)
            {
                return(true);
            }

            if (!manager.MyHero.HasModifier(ModifierUtils.FountainRegeneration))
            {
                return(false);
            }

            if (!sleeper.Sleeping("FountainRegeneration"))
            {
                sleeper.Sleep(5000, "FountainRegeneration");
                sleeper.Sleep(2000, "CanRefill");
            }

            return(sleeper.Sleeping("CanRefill"));
        }
示例#18
0
        private void OnUpdate()
        {
            if (Game.IsPaused || !manager.MyHero.IsAlive)
            {
                return;
            }

            var canUseItems     = manager.MyHero.CanUseItems();
            var canUseAbilities = manager.MyHero.CanUseAbilities();

            foreach (var offensiveAbility in offensiveAbilities
                     .Where(
                         x => menu.IsAbilityEnabled(x.Name) && x.CanBeCasted() && (x.IsItem ? canUseItems : canUseAbilities))
                     .OrderByDescending(x => menu.GetPriority(x.Name)))
            {
                var target = manager.MyHero.Target;

                if (!offensiveAbility.CanBeCasted(target) || sleeper.Sleeping(target) ||
                    !menu.IsHeroEnabled(target.StoredName()))
                {
                    target = null;
                }

                if (offensiveAbility.Menu.AlwaysUse && target == null)
                {
                    target = EntityManager <Hero> .Entities
                             .Where(
                        x => x.IsValid && !sleeper.Sleeping(x) && x.Team != manager.MyHero.Team &&
                        menu.IsHeroEnabled(x.StoredName()) && !x.IsIllusion)
                             .OrderBy(x => manager.MyHero.Hero.FindRotationAngle(x.Position))
                             .FirstOrDefault(x => offensiveAbility.CanBeCasted(x));
                }

                if (target == null)
                {
                    return;
                }

                DelayAction.Add(
                    offensiveAbility.Menu.Delay,
                    () =>
                {
                    if (!offensiveAbility.CanBeCasted() || !offensiveAbility.CanBeCasted(target))
                    {
                        return;
                    }

                    offensiveAbility.Use(target);
                });

                sleeper.Sleep(Math.Max(500, offensiveAbility.Menu.Delay), target);
            }
        }
示例#19
0
        public override void UseItems(Hero target)
        {
            var inventory =
                Me.Inventory.Items.Where(
                    x => MenuManager.IsItemEnable(x.StoredName()) && x.CanBeCasted() && x.CanHit(target) && !_comboSleeper.Sleeping(x));

            foreach (var ability in inventory)
            {
                if (ability.StoredName() == "item_ethereal_blade")
                {
                    _ethereal.Sleep(1000);
                }
                if (ability.DamageType == DamageType.Magical || ability.StoredName().Contains("dagon"))
                {
                    if (_ethereal.Sleeping && !target.HasModifier("modifier_item_ethereal_blade_ethereal"))
                    {
                        continue;
                    }
                }
                if ((ability.AbilityBehavior & AbilityBehavior.Point) != 0)
                {
                    if (ability.IsSkillShot())
                    {
                        if (!ability.CastSkillShot(target))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        ability.UseAbility(target.Position);
                    }
                }
                else if ((ability.AbilityBehavior & AbilityBehavior.UnitTarget) != 0)
                {
                    if (ability.TargetTeamType == TargetTeamType.Enemy || ability.TargetTeamType == TargetTeamType.All)
                    {
                        ability.UseAbility(target);
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    ability.UseAbility();
                }
                var delay = Me.GetAbilityDelay(target, ability);
                Log.Debug($"Item: {ability.StoredName()} -> {delay}ms");
                _comboSleeper.Sleep(delay, ability);
            }
        }
        /// <summary>
        ///     The find angle r.
        /// </summary>
        /// <param name="entity">
        ///     The entity.
        /// </param>
        /// <returns>
        ///     The <see cref="float" />.
        /// </returns>
        public static float FindAngleR(this Entity entity)
        {
            var handle      = entity.Handle;
            var sleeping    = sleeper.Sleeping(handle);
            var rotationRad = sleeping ? rotationDictionary[handle] : entity.RotationRad;

            if (!sleeping)
            {
                rotationDictionary[handle] = rotationRad;
                sleeper.Sleep(handle, 5);
            }

            return((float)(rotationRad < 0 ? Math.Abs(rotationRad) : 2 * Math.PI - rotationRad));
        }
示例#21
0
        public bool Follow(Unit unit, Unit target)
        {
            if (unit.IsRooted())
            {
                return(false);
            }

            if (!MultiSleeper.Sleeping($"Follow{ unit.Handle }"))
            {
                MultiSleeper.Sleep(200, $"Follow{ unit.Handle }");
                return(unit.Follow(target));
            }

            return(false);
        }
示例#22
0
        public bool Move(Unit unit, Vector3 position)
        {
            if (unit.IsRooted())
            {
                return(false);
            }

            if (!MultiSleeper.Sleeping($"Move{ unit.Handle }"))
            {
                MultiSleeper.Sleep(200, $"Move{ unit.Handle }");
                return(unit.Move(position));
            }

            return(false);
        }
示例#23
0
        public virtual void UseAbilities(Hero target)
        {
            var spells =
                Me.Spellbook()
                .Spells.Where(
                    x =>
                    !x.IsAbilityBehavior(AbilityBehavior.Passive) && x.AbilityType != AbilityType.Ultimate &&
                    x.CanBeCasted() && x.CanHit(target) &&
                    !_abilitySleeper.Sleeping(x));

            foreach (var ability in spells)
            {
                if ((ability.AbilityBehavior & AbilityBehavior.Point) != 0)
                {
                    if (ability.IsSkillShot())
                    {
                        if (!ability.CastSkillShot(target))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        ability.UseAbility(target.Position);
                    }
                }
                else if ((ability.AbilityBehavior & AbilityBehavior.UnitTarget) != 0)
                {
                    if (ability.TargetTeamType == TargetTeamType.Enemy)
                    {
                        ability.UseAbility(target);
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    ability.UseAbility();
                }
                var delay = Me.GetAbilityDelay(target, ability);
                Log.Debug($"Ability: {ability.StoredName()} -> {delay}ms");
                _abilitySleeper.Sleep(delay, ability);
            }
        }
示例#24
0
        public static void OnUpdate(EventArgs args)
        {
            if (!MenuManager.IsEnable)
            {
                return;
            }
            var spellAmp = 0;//UnitExtensions.GetSpellAmplification(Me);

            foreach (var hero in Heroes.GetByTeam(EnemyTeam))
            {
                if (HeroSleeper.Sleeping(hero) || !hero.IsAlive || !hero.IsVisible || !hero.CanDie(MenuManager.CheckForAegis))
                {
                    continue;
                }
                var listForDetonation = new List <BombManager>();
                var heroHealth        = hero.Health + hero.HealthRegeneration;
                var reduction         = RemoteMine.GetDamageReduction(hero);
                foreach (var element in Bombs)
                {
                    if (element.IsRemoteMine && element.Active)
                    {
                        if (element.CanHit(hero))
                        {
                            //Printer.Print($"BombDelay: {element.GetBombDelay(hero)} MaxDelay: {MenuManager.GetBombDelay}");
                            if (MenuManager.IsEnableDelayBlow &&
                                !(element.GetBombDelay(hero) >= MenuManager.GetBombDelay))
                            {
                                continue;
                            }
                            heroHealth -= DamageHelpers.GetSpellDamage(element.Damage, spellAmp, reduction);
                            listForDetonation.Add(element);
                            if (heroHealth <= 0)
                            {
                                HeroSleeper.Sleep(300 + listForDetonation.Count * 30, hero);
                                foreach (var manager in listForDetonation)
                                {
                                    manager.Detonate();
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
示例#25
0
        private bool InvokeThisShit(ActiveAbility ability)
        {
            InvokerCrappahilationPaid.Log.Debug($"Trying to invoke -> {ability.Ability.Id}");
            if (_sleeper.Sleeping($"{ability} shit"))
            {
                InvokerCrappahilationPaid.Log.Debug($"Invoke [blocked] ({ability})");
                return(false);
            }

            if (Abilities.Invoke.IsReady)
            {
                var requiredOrbs = (ability as IInvokableAbility)?.RequiredOrbs;
                if (requiredOrbs != null)
                {
                    foreach (var abilityId in requiredOrbs)
                    {
                        var sphere = (ActiveAbility)_main.Context.AbilityFactory.GetAbility(abilityId);
                        if (sphere == null)
                        {
                            return(false);
                        }
                        if (!sphere.UseAbility())
                        {
                            return(false);
                        }
                        InvokerCrappahilationPaid.Log.Debug($"Invoke [Sphere: {abilityId}] ({ability})");
                    }

                    var invoked = Abilities.Invoke.Ability.UseAbility();
                    if (invoked)
                    {
                        _sleeper.Sleep(200, $"{ability} shit");
                        InvokerCrappahilationPaid.Log.Debug($"Invoke [{ability}]");
                    }

                    return(invoked);
                }

                InvokerCrappahilationPaid.Log.Debug($"Error in Invoke function: {ability.Ability.Id}");
                return(false);
            }

            InvokerCrappahilationPaid.Log.Debug($"Invoke [on cd] ({ability})");
            return(false);
        }
示例#26
0
        private bool UpdateDamage(Hero enemy, out bool heroWillDie)
        {
            if (_multiSleeper.Sleeping(enemy.Handle))
            {
                if (_damageDict.TryGetValue(enemy.Handle, out var hp))
                {
                    heroWillDie = hp <= 0;
                    if (!heroWillDie)
                    {
                        FlushTiming(enemy);
                    }
                    return(heroWillDie);
                }

                FlushTiming(enemy);
                heroWillDie = false;
                return(false);
            }

            _multiSleeper.Sleep(50, enemy.Handle);
            var willTakeDamageFromTornado =
                enemy.GetModifierByName(_config.Main.AbilitiesInCombo.Tornado.TargetModifierName) != null;
            var damageFromTornado =
                willTakeDamageFromTornado ? _config.Main.AbilitiesInCombo.Tornado.GetDamage(enemy) : 0;
            var healthAfterCast = enemy.Health + enemy.HealthRegeneration * 2 - SunStrike.GetDamage(enemy) -
                                  damageFromTornado;

            if (!_damageDict.TryGetValue(enemy.Handle, out _))
            {
                _damageDict.Add(enemy.Handle, (int)healthAfterCast);
            }
            else
            {
                _damageDict[enemy.Handle] = (int)healthAfterCast;
            }
            heroWillDie = healthAfterCast <= 0;
            if (!heroWillDie)
            {
                FlushTiming(enemy);
            }
            return(heroWillDie);
        }
示例#27
0
        private static void CastAbilities(float distance)
        {
            if (!IsEnable)
            {
                return;
            }
            if (!IsComboHero)
            {
                return;
            }
            if (GlobalTarget == null || !GlobalTarget.IsValid || !GlobalTarget.IsVisible || GlobalTarget.IsMagicImmune() || !GlobalTarget.IsAlive)
            {
                return;
            }
            var smash           = Abilities.FindAbility("earth_spirit_boulder_smash");
            var geomagneticGrip = Abilities.FindAbility("earth_spirit_geomagnetic_grip");
            var magnetize       = Abilities.FindAbility("earth_spirit_magnetize");
            var rollingBoulder  = Abilities.FindAbility("earth_spirit_rolling_boulder");
            var stoneCaller     = Abilities.FindAbility("earth_spirit_stone_caller");

            if (distance >= 1000)
            {
                return;
            }
            var pos = GlobalTarget.NetworkPosition;

            if (Helper.IsAbilityEnable(smash.StoredName()) && smash.CanBeCasted())
            {
                if (smash.CanBeCasted() && !_spellSleeper.Sleeping("combo" + smash))
                {
                    var remnant = Helper.FindRemnant();
                    if (stoneCaller.CanBeCasted() && remnant == null)
                    {
                        stoneCaller.UseAbility(Members.MyHero.InFront(75));
                    }
                    if (UsePrediction)
                    {
                        if (smash.CastSkillShot(GlobalTarget))
                        {
                            _spellSleeper.Sleep(500, "combo" + smash);
                            _spellSleeper.Sleep(distance / 900 * 1000 + 1000, "w8" + smash);
                            Printer.Print($"Time: {distance/900*1000 + 500}ms");
                        }
                    }
                    else
                    {
                        smash.UseAbility(GlobalTarget.NetworkPosition);
                        _spellSleeper.Sleep(500, "combo" + smash);
                        _spellSleeper.Sleep(distance / 900 * 1000 + 500, "w8" + smash);
                        Printer.Print($"Time: {distance / 900 * 1000 + 1000}ms");
                    }
                }
            }
            if (Helper.IsAbilityEnable(geomagneticGrip.StoredName()) && geomagneticGrip.CanBeCasted() && !_spellSleeper.Sleeping("combo" + geomagneticGrip))
            {
                if (GlobalTarget.IsStunned())
                {
                    Printer.Print("stunned!");
                }
                if (_spellSleeper.Sleeping("w8" + smash) &&
                    !GlobalTarget.IsStunned())
                {
                }
                else
                {
                    var remnant = Helper.FindRemnant(pos, 250);
                    if (stoneCaller.CanBeCasted() && remnant == null)
                    {
                        stoneCaller.UseAbility(pos);
                        geomagneticGrip.UseAbility(pos, true);
                        Printer.Print("new");
                    }
                    else if (remnant != null)
                    {
                        Printer.Print("finded");
                        geomagneticGrip.UseAbility(remnant.NetworkPosition);
                    }
                    _spellSleeper.Sleep(250, "combo" + geomagneticGrip);
                }
            }
            else if (Helper.IsAbilityEnable(rollingBoulder.StoredName()) && rollingBoulder.CanBeCasted() && !_spellSleeper.Sleeping("combo" + rollingBoulder))
            {
                if (UsePrediction)
                {
                    if (rollingBoulder.CastSkillShot(GlobalTarget))
                    {
                    }
                }
                else /*if (remnant!=null)*/
                {
                    rollingBoulder.UseAbility(GlobalTarget.NetworkPosition);
                }
                _spellSleeper.Sleep(250, "combo" + rollingBoulder);
            }
            else if (rollingBoulder.Cooldown >= 3.5)
            {
                var myPos = Members.MyHero.Position;

                var angle = Members.MyHero.FindAngleBetween(pos, true);
                var point = new Vector3(
                    (float)
                    (myPos.X +
                     100 *
                     Math.Cos(angle)),
                    (float)
                    (myPos.Y +
                     100 *
                     Math.Sin(angle)),
                    0);
                var remnant = Helper.FindRemnant(point, 100) ??
                              Helper.FindRemnantWithModifier(pos, "modifier_earth_spirit_geomagnetic_grip");
                if (stoneCaller.CanBeCasted() && remnant == null &&
                    Members.MyHero.HasModifier("modifier_earth_spirit_rolling_boulder_caster"))
                {
                    if (!_spellSleeper.Sleeping("combo" + rollingBoulder + "Caller"))
                    {
                        Printer.Print($"cd: ({rollingBoulder.Cooldown}) | cant find remnant!");
                        //stoneCaller.UseAbility(point);
                        stoneCaller.UseAbility(Members.MyHero.Position);
                        _spellSleeper.Sleep(2000, "combo" + rollingBoulder + "Caller");
                    }
                }
            }
            if (Helper.IsAbilityEnable(magnetize.StoredName()) && magnetize.CanBeCasted() && !_spellSleeper.Sleeping("combo" + magnetize))
            {
                if (distance <= 300)
                {
                    magnetize.UseAbility();
                    _spellSleeper.Sleep(250, "combo" + magnetize);
                }
            }
            var mod = GlobalTarget.FindModifier("modifier_earth_spirit_magnetize");

            if (Helper.IsAbilityEnable(stoneCaller.StoredName()) && mod != null && mod.RemainingTime <= 0.2 &&
                !_spellSleeper.Sleeping("combo" + stoneCaller) && stoneCaller.CanBeCasted())
            {
                Printer.Print($"remTime: {mod.RemainingTime}");
                stoneCaller.UseAbility(pos);
                _spellSleeper.Sleep(1000, "combo" + stoneCaller);
            }
        }
示例#28
0
        public static bool CanHit(this Ability ability, Unit target, Vector3 sourcePosition, string abilityName = null)
        {
            if (ability == null || !ability.IsValid)
            {
                return(false);
            }

            if (target == null || !target.IsValid)
            {
                return(false);
            }

            var name = abilityName ?? ability.StoredName();

            if (ability.Owner.Equals(target))
            {
                return(true);
            }

            var id = ability.Handle + target.Handle;

            if (sleeper.Sleeping(id))
            {
                return(canHitDictionary[id]);
            }

            var position = sourcePosition;

            if (ability.IsAbilityBehavior(AbilityBehavior.Point, name) || name == "lion_impale")
            {
                var pred = ability.GetPrediction(target, abilityName: name);
                var lion = name == "lion_impale" ? ability.GetAbilityData("length_buffer") : 0;
                return(position.Distance2D(pred)
                       <= ability.TravelDistance() + ability.GetRadius(name) + lion + target.HullRadius);
            }

            if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
            {
                var pred        = ability.GetPrediction(target, abilityName: name);
                var distanceXyz = position.Distance2D(pred);
                var radius      = ability.GetRadius(name);
                var range       = ability.GetCastRange(name);
                if (name.StartsWith("nevermore_shadowraze"))
                {
                    range += radius / 2;
                }

                if (name.Contains("earthshaker_enchant_totem") && (ability.Owner as Hero).AghanimState())
                {
                    range += 1100;
                }

                if (name.Contains("faceless_void_time_walk"))
                {
                    range += GetAbilityCastRange(ability.Owner as Unit, ability);
                }

                if (distanceXyz <= range && position.Distance2D(target.Position) <= range)
                {
                    canHitDictionary[id] = true;
                    sleeper.Sleep(50, id);
                    return(true);
                }

                canHitDictionary[id] = name == "pudge_rot" && target.HasModifier("modifier_pudge_meat_hook") &&
                                       position.Distance2D(target) < 1500;
                sleeper.Sleep(50, id);
                return(canHitDictionary[id]);
            }

            if (!ability.IsAbilityBehavior(AbilityBehavior.UnitTarget, name))
            {
                canHitDictionary[id] = false;
                sleeper.Sleep(50, id);
                return(false);
            }

            if (target.IsInvul())
            {
                canHitDictionary[id] = false;
                sleeper.Sleep(50, id);
                return(false);
            }

            if (position.Distance2D(target.Position) <= GetAbilityCastRange(ability.Owner as Unit, ability) + 100)
            {
                canHitDictionary[id] = true;
                sleeper.Sleep(50, id);
                return(true);
            }

            canHitDictionary[id] = name == "pudge_dismember" && target.HasModifier("modifier_pudge_meat_hook") &&
                                   position.Distance2D(target) < 600;
            sleeper.Sleep(50, id);
            return(canHitDictionary[id]);
        }
示例#29
0
        private async Task ExecuteAsync(CancellationToken token)
        {
            try
            {
                if (Game.IsPaused || !Owner.IsValid || !Owner.IsAlive || Owner.IsStunned() || Owner.IsInvisible())
                {
                    return;
                }

                if (Menu.AutoComboWhenComboItem && Menu.ComboKeyItem)
                {
                    return;
                }

                if (Menu.AutoOwnerMinHealthItem > ((float)Owner.Health / Owner.MaximumHealth) * 100)
                {
                    return;
                }

                var target = EntityManager <Hero> .Entities.Where(x =>
                                                                  x.IsValid &&
                                                                  x.IsVisible &&
                                                                  x.IsAlive &&
                                                                  !x.IsIllusion &&
                                                                  x.IsEnemy(Owner) &&
                                                                  Extensions.Active(x)).OrderBy(x => x.Distance2D(Owner)).FirstOrDefault();

                if (target == null)
                {
                    return;
                }

                if (!Extensions.Cancel(target) || Extensions.ComboBreaker(target, false))
                {
                    return;
                }

                if (Menu.BladeMailItem && target.HasModifier("modifier_item_blade_mail_reflect"))
                {
                    return;
                }

                if (target.IsBlockingAbilities())
                {
                    Config.LinkenBreaker.Handler.RunAsync();
                    return;
                }

                var stunDebuff = target.Modifiers.FirstOrDefault(x => x.IsStunDebuff);
                var hexDebuff  = target.Modifiers.FirstOrDefault(x => x.Name == "modifier_sheepstick_debuff");

                // Hex
                var hex = Main.Hex;
                if (hex != null &&
                    Menu.AutoItemToggler.Value.IsEnabled(hex.ToString()) &&
                    hex.CanBeCasted &&
                    hex.CanHit(target) &&
                    (stunDebuff == null || !stunDebuff.IsValid || stunDebuff.RemainingTime <= 0.3f) &&
                    (hexDebuff == null || !hexDebuff.IsValid || hexDebuff.RemainingTime <= 0.3f))
                {
                    hex.UseAbility(target);
                    await Await.Delay(hex.GetCastDelay(target), token);
                }

                // Orchid
                var orchid = Main.Orchid;
                if (orchid != null &&
                    Menu.AutoItemToggler.Value.IsEnabled(orchid.ToString()) &&
                    orchid.CanBeCasted &&
                    orchid.CanHit(target))
                {
                    orchid.UseAbility(target);
                    await Await.Delay(orchid.GetCastDelay(target), token);
                }

                // Bloodthorn
                var bloodthorn = Main.Bloodthorn;
                if (bloodthorn != null &&
                    Menu.AutoItemToggler.Value.IsEnabled(bloodthorn.ToString()) &&
                    bloodthorn.CanBeCasted &&
                    bloodthorn.CanHit(target))
                {
                    bloodthorn.UseAbility(target);
                    await Await.Delay(bloodthorn.GetCastDelay(target), token);
                }

                // Mystic Flare
                var mysticFlare = Main.MysticFlare;
                if (Menu.AutoAbilityToggler.Value.IsEnabled(mysticFlare.ToString()) &&
                    Menu.AutoMinHealthToUltItem <= ((float)target.Health / target.MaximumHealth) * 100 &&
                    mysticFlare.CanBeCasted &&
                    mysticFlare.CanHit(target))
                {
                    var enemies = EntityManager <Hero> .Entities.Where(x =>
                                                                       x.IsVisible &&
                                                                       x.IsAlive &&
                                                                       x.IsValid &&
                                                                       !x.IsIllusion &&
                                                                       x.IsEnemy(Owner) &&
                                                                       x.Distance2D(Owner) <= mysticFlare.CastRange).ToList();

                    var dubleMysticFlare = Owner.HasAghanimsScepter() && enemies.Count() == 1;
                    var input            = new PredictionInput
                    {
                        Owner  = Owner,
                        Range  = mysticFlare.CastRange,
                        Radius = dubleMysticFlare ? -250 : -100
                    };

                    var output = Prediction.GetPrediction(input.WithTarget(target));

                    mysticFlare.UseAbility(output.CastPosition);
                    await Await.Delay(mysticFlare.GetCastDelay(output.CastPosition), token);
                }

                // Nullifier
                var nullifier = Main.Nullifier;
                if (nullifier != null &&
                    Menu.ItemToggler.Value.IsEnabled(nullifier.ToString()) &&
                    nullifier.CanBeCasted &&
                    nullifier.CanHit(target) &&
                    (stunDebuff == null || !stunDebuff.IsValid || stunDebuff.RemainingTime <= 0.5f) &&
                    (hexDebuff == null || !hexDebuff.IsValid || hexDebuff.RemainingTime <= 0.5f))
                {
                    nullifier.UseAbility(target);
                    await Await.Delay(nullifier.GetCastDelay(target), token);
                }

                // RodofAtos
                var rodofAtos = Main.RodofAtos;
                if (rodofAtos != null &&
                    Menu.AutoItemToggler.Value.IsEnabled(rodofAtos.ToString()) &&
                    rodofAtos.CanBeCasted &&
                    rodofAtos.CanHit(target) &&
                    !target.Modifiers.Any(x => x.IsValid && x.Name == "modifier_rod_of_atos_debuff" && x.RemainingTime > 0.5f) &&
                    (stunDebuff == null || !stunDebuff.IsValid || stunDebuff.RemainingTime <= 0.5f))
                {
                    rodofAtos.UseAbility(target);
                    await Await.Delay(rodofAtos.GetCastDelay(target), token);
                }

                // AncientSeal
                var ancientSeal = Main.AncientSeal;
                if (Menu.AutoAbilityToggler.Value.IsEnabled(ancientSeal.ToString()) &&
                    ancientSeal.CanBeCasted &&
                    ancientSeal.CanHit(target))
                {
                    ancientSeal.UseAbility(target);
                    await Await.Delay(ancientSeal.GetCastDelay(target), token);

                    return;
                }

                // Veil
                var veil = Main.Veil;
                if (veil != null &&
                    Menu.AutoItemToggler.Value.IsEnabled(veil.ToString()) &&
                    veil.CanBeCasted &&
                    veil.CanHit(target))
                {
                    veil.UseAbility(target.Position);
                    await Await.Delay(veil.GetCastDelay(target.Position), token);
                }

                // Ethereal
                var ethereal = Main.Ethereal;
                if (ethereal != null &&
                    Menu.AutoItemToggler.Value.IsEnabled(ethereal.ToString()) &&
                    ethereal.CanBeCasted &&
                    ethereal.CanHit(target))
                {
                    ethereal.UseAbility(target);
                    MultiSleeper.Sleep(ethereal.GetHitTime(target), "ethereal");
                    await Await.Delay(ethereal.GetCastDelay(target), token);
                }

                // Shivas
                var shivas = Main.Shivas;
                if (shivas != null &&
                    Menu.AutoItemToggler.Value.IsEnabled(shivas.ToString()) &&
                    shivas.CanBeCasted &&
                    shivas.CanHit(target))
                {
                    shivas.UseAbility();
                    await Await.Delay(shivas.GetCastDelay(), token);
                }

                if (!MultiSleeper.Sleeping("ethereal") || target.IsEthereal())
                {
                    // ConcussiveShot
                    var concussiveShot = Main.ConcussiveShot;
                    if (Menu.AutoAbilityToggler.Value.IsEnabled(concussiveShot.ToString()) &&
                        Extensions.ConcussiveShotTarget(target, concussiveShot.TargetHit) &&
                        concussiveShot.CanBeCasted &&
                        Owner.Distance2D(target) < Menu.ConcussiveShotUseRadiusItem - Owner.HullRadius)
                    {
                        concussiveShot.UseAbility();
                        await Await.Delay(concussiveShot.GetCastDelay(), token);
                    }

                    // ArcaneBolt
                    var arcaneBolt = Main.ArcaneBolt;
                    if (Menu.AutoAbilityToggler.Value.IsEnabled(arcaneBolt.ToString()) &&
                        arcaneBolt.CanBeCasted &&
                        arcaneBolt.CanHit(target))
                    {
                        arcaneBolt.UseAbility(target);

                        UpdateManager.BeginInvoke(() =>
                        {
                            MultiSleeper.Sleep(arcaneBolt.GetHitTime(target) - (arcaneBolt.GetCastDelay(target) + 350), $"arcanebolt_{ target.Name }");
                        },
                                                  arcaneBolt.GetCastDelay(target) + 50);

                        await Await.Delay(arcaneBolt.GetCastDelay(target), token);

                        return;
                    }

                    // Dagon
                    var dagon = Main.Dagon;
                    if (dagon != null &&
                        Menu.AutoItemToggler.Value.IsEnabled("item_dagon_5") &&
                        dagon.CanBeCasted &&
                        dagon.CanHit(target))
                    {
                        dagon.UseAbility(target);
                        await Await.Delay(dagon.GetCastDelay(target), token);

                        return;
                    }
                }
            }
            catch (TaskCanceledException)
            {
                // canceled
            }
            catch (Exception e)
            {
                Main.Log.Error(e);
            }
        }
示例#30
0
        private void OnOnIngameUpdate(EventArgs args)
        {
            Mode = OrbwalkingMode.Idle;
            if (Game.IsPaused || Game.IsChatOpen)
            {
                return;
            }
            if (Members.Menu.Item("Combo.key").GetValue <KeyBind>().Active)
            {
                Mode = OrbwalkingMode.Combo;
            }
            else if (Mode == OrbwalkingMode.Idle)
            {
                _globalTarget = null;
                EffectManager.Remove("attackTarget" + Owner.Handle);
                return;
            }
            if (TurnEndTime > Game.RawGameTime)
            {
                return;
            }
            var target = GetTarget();

            if (!UnitExtensions.HasModifier(Owner, "modifier_templar_assassin_meld"))
            {
                var tempTarget = GetTarget(false);
                if (tempTarget != null)
                {
                    var blink   = Owner.GetItemById(AbilityId.item_blink);
                    var tempPos = new Vector3();
                    if (blink != null && blink.CanBeCasted() && blink.CanHit(tempTarget, ref tempPos) &&
                        !_sleeper.Sleeping(blink))
                    {
                        blink.UseAbility(tempPos);
                        _sleeper.Sleep(300, blink);
                    }
                    if (!UnitExtensions.HasModifier(tempTarget, "modifier_templar_assassin_trap_slow"))
                    {
                        var trap = UnitExtensions.GetAbilityById(ObjectManager.LocalHero,
                                                                 AbilityId.templar_assassin_psionic_trap);
                        var trapNearTarget =
                            EntityManager <Unit> .Entities.FirstOrDefault(
                                x =>
                                x.IsValid && x.Name == "npc_dota_templar_assassin_psionic_trap" &&
                                Ensage.SDK.Extensions.EntityExtensions.Distance2D(tempTarget, x.Position) <= 400);

                        if (trapNearTarget != null)
                        {
                            if (!_sleeper.Sleeping(trap + "activate"))
                            {
                                var activator = trapNearTarget.Spellbook.Spell1;
                                if (activator.CanBeCasted())
                                {
                                    activator.UseAbility();
                                }
                                _sleeper.Sleep(300, trap + "activate");
                            }
                        }
                        else if (trap.CanBeCasted())
                        {
                            if (!_sleeper.Sleeping(trap + "place"))
                            {
                                trap.UseAbility(tempTarget.Position);
                                _sleeper.Sleep(300, trap + "place");
                            }
                        }
                    }
                }
            }
            if ((target == null || !CanAttack(target)) && CanMove())
            {
                if (Move(Game.MousePosition))
                {
                    return;
                }
            }

            if (target != null && CanAttack(target))
            {
                LastTarget = target;
                var refraction = UnitExtensions.GetAbilityById(ObjectManager.LocalHero, AbilityId.templar_assassin_refraction);
                if (refraction.CanBeCasted() && !_sleeper.Sleeping(refraction))
                {
                    refraction.UseAbility();
                    _sleeper.Sleep(300, refraction);
                }
                var meld = UnitExtensions.GetAbilityById(ObjectManager.LocalHero, AbilityId.templar_assassin_meld);
                if (meld.CanBeCasted() && !_sleeper.Sleeping(meld))
                {
                    meld.UseAbility();
                    _sleeper.Sleep(300, meld);
                }
                Attack(target);
            }
            if (LastTarget != null && LastTarget.IsValid && LastTarget.IsAlive)
            {
                EffectManager.DrawRange(LastTarget, "attackTarget" + Owner.Handle, 60, Color.Red);
            }
            else
            {
                EffectManager.Remove("attackTarget" + Owner.Handle);
            }
        }