示例#1
0
        private void AutoSaveUpdater()
        {
            if (localHero.HealthPercent() > (float)minHpPercentForSave.Value / 100)
            {
                return;
            }

            var isFacingFountain = localHero.InFront(localHero.Distance2D(myFountain)).Distance2D(myFountain.Position) < 500;

            if (!localHero.IsEnchanted() && enchant.CanBeCasted())
            {
                if (isFacingFountain)
                {
                    enchant.UseAbility(localHero);
                }
                else
                {
                    localHero.MoveToDirection(localHero.Position.Extend(myFountain.Position, 400));
                }
                return;
            }

            if (smash.CanBeCasted() && localHero.IsEnchanted() && isFacingFountain)
            {
                smash.Base.Cast();
            }
        }
        private void IngameUpdate()
        {
            if (!smash.CanBeCasted() || sleeper.Sleeping)
            {
                return;
            }

            var target = EntityManager.GetEntities <Hero>().FirstOrDefault(x => x.Distance2D(localHero) < 300 &&
                                                                           x.IsAlive &&
                                                                           (!x.IsIllusion || x.HasModifier("modifier_morphling_replicate")) &&
                                                                           x.IsEnemy(context.LocalHero) &&
                                                                           x.IsVisible);

            if (target == null)
            {
                return;
            }

            var allies = EntityManager.GetEntities <Hero>().Where(x => x.IsAlly(localHero) &&
                                                                  x.IsAlive &&
                                                                  !x.IsIllusion);

            if (modeSelector.Value == "Also with agha" && enchant.CanBeCasted())
            {
                var alliesAround = allies.Where(x => x.Distance2D(target) < 1000);

                foreach (var ally in allies.Where(x => x.Distance2D(localHero) < 3000 &&
                                                  x.Distance2D(localHero) > 1000))
                {
                    if (ally == null)
                    {
                        break;
                    }

                    var destinationWithAghanim   = target.Position.Extend(ally.Position, 2000);
                    var alliesArroundDestination = allies.Where(x => x.Distance2D(destinationWithAghanim) < 1000);

                    if (alliesArroundDestination.Count() < alliesAround.Count())
                    {
                        continue;
                    }

                    if (alliesArroundDestination.All(x => x.HealthPercent() > (float)minAllyHpPercent.Value / 100))
                    {
                        enchant.Base.Cast(target);
                        sleeper.Sleep(500);

                        UpdateManager.BeginInvoke(500, () =>
                        {
                            smash.UseAbility(localHero.Position.Extend(ally.Position, 400));
                        });
                        return;
                    }
                }
            }

            var range = smash.PushDistance;

            var destination = target.Position.Extend(localHero.Position, -range);

            var alliesNear            = allies.Where(x => x.Distance2D(localHero) < range / 1.5f);
            var alliesNearDestination = allies.Where(x => x.Position.Distance2D(destination) < range);

            if (alliesNearDestination.Any(x => x.HealthPercent() < (float)minAllyHpPercent.Value / 100) ||
                alliesNear.Count() >= alliesNearDestination.Count())
            {
                return;
            }

            smash.Base.Cast(target);
            sleeper.Sleep(500);
        }
        private void IngameUpdate()
        {
            if (!smash.CanBeCasted())
            {
                CanPushInTower = false;
                return;
            }

            var nearestEnemyes = EntityManager.GetEntities <Hero>()
                                 .Where(x => x.Distance2D(localHero) < 350 &&
                                        x.IsEnemy(localHero) &&
                                        !x.IsMagicImmune() &&
                                        !x.IsIllusion &&
                                        x.IsVisible &&
                                        x.IsAlive);

            if (!nearestEnemyes.Any())
            {
                return;
            }

            if (modeSelector.Value == "Also with agha")
            {
                var tower = GetGoodTowerForAgha();

                if (tower != null)
                {
                    if (enchant.CanBeCasted())
                    {
                        CanPushInTower = true;
                        var firstEnemy = nearestEnemyes.First();

                        if (enchant.UseAbility(firstEnemy))
                        {
                            return;
                        }
                    }

                    if (nearestEnemyes.Any(x => x.IsEnchanted()))
                    {
                        CanPushInTower = true;
                        smash.Base.Cast(localHero.Position.Extend(tower.Position, 400));
                        return;
                    }
                }
            }

            var target = nearestEnemyes.First();

            var nearestTower = EntityManager.GetEntities <Tower>()
                               .FirstOrDefault(x => x.Distance2D(target) < 700 + smash.PushDistance + additionalRange.Value && //700 is tower attack range
                                               x.IsAlly(localHero) &&
                                               x.IsAlive);


            if (nearestTower == null)
            {
                CanPushInTower = false;
                return;
            }
            else if (localHero.Distance2D(target.Position.Extend(nearestTower.Position, -150)) < 250)
            {
                CanPushInTower = true;
            }

            var pushTargets = nearestEnemyes.Where(x => x.Position.Extend(localHero.Position, -smash.PushDistance).Distance2D(nearestTower.Position) < 700 + additionalRange.Value); //700 is tower attack range

            var pushTarget = pushTargets.FirstOrDefault(x => x.Position.Extend(localHero.Position, -smash.PushDistance).Distance2D(nearestTower.Position) < x.Distance2D(nearestTower));

            if (pushTarget != null)
            {
                smash.Base.Cast(pushTarget);
            }
        }