Exemple #1
0
        public static PushPower GetPushPower()
        {
            //Будем скинровать на большом радиусе, на всякий случай,
            //но при учете опасности все равно будем учитывть расстрояние то меня
            var enemyScanRange = Tick.Self.CastRange * 1.5;
            var friendRange    = Tick.Self.CastRange;

            var enemyWizardsPower = UnitHelper.GetNearestWizards(enemyScanRange, false).Select(GetWizardPower).Sum();
            var enemyMinionsPower = UnitHelper.GetNearestMinions(enemyScanRange, false).Select(GetMinionPower).Sum();
            var enemyTowersPower  = UnitHelper.GetNearestBuidigs(enemyScanRange, false).Select(GetBuildingPower).Sum();
            var enemyPower        = enemyWizardsPower + enemyMinionsPower + enemyTowersPower;

            var friendlyWizardsPower = UnitHelper.GetNearestWizards(friendRange, true).Select(GetWizardPower).Sum();
            var friendlyMinionsPower = UnitHelper.GetNearestMinions(friendRange, true).Select(GetMinionPower).Sum();
            var friendlyTowersPower  = UnitHelper.GetNearestBuidigs(friendRange, true).Select(GetBuildingPower).Sum();
            var friendlyPower        = friendlyWizardsPower + friendlyMinionsPower + friendlyTowersPower;

            friendlyPower = friendlyPower * (Tick.Self.Life / (double)Tick.Self.MaxLife);

            var pushPower = new PushPower()
            {
                FrienlyPower = friendlyPower,
                EnemyPower   = enemyPower
            };

            return(pushPower);
        }
Exemple #2
0
        private static bool CanEvadeFromInterselectPointHead(ProjectilesInfo projectile)
        {
            var interselectPointRange = projectile.CurrentPoint.GetDistanceTo(projectile.EndPoint);

            var safeDistance = Tick.Self.Radius + projectile.Radius;
            var evadeVector  =
                new Vector(projectile.EndPoint) -
                new Vector(Tick.Self.GetPositionPoint());

            evadeVector.Negate();
            evadeVector.Normalize();
            evadeVector = safeDistance * evadeVector;
            var safePoint = projectile.EndPoint + evadeVector;

            //VisualClientHelper.Circle(safePoint.X,safePoint.Y, 5, 1,0,0);

            var distanceToEscape = Tick.Self.GetDistanceTo(safePoint.X, safePoint.Y);

            var wizardSpeed = 3 * UnitHelper.GetSpeedBonusFactorFromSkillsAndAuras();

            var projectilesToInterselectTicks = Math.Abs(interselectPointRange / projectile.Speed);
            var escapeTicks = Math.Abs(distanceToEscape / wizardSpeed);

            //DebugTrace.ConsoleWriteLite($"{projectilesToInterselectTicks.ToString("N3")} / {escapeTicks.ToString("N3")}");

            return(escapeTicks <= projectilesToInterselectTicks);
        }
Exemple #3
0
        private static bool CanEvadeFromInterselectPoint(ProjectilesInfo projectile, Point2D interselectPoint)
        {
            var interselectPointRange = projectile.CurrentPoint.GetDistanceTo(interselectPoint);
            var interselectMyRange    = Tick.Self.GetDistanceTo(interselectPoint.X, interselectPoint.Y);

            var distanceToEscape = Tick.Self.Radius + projectile.Radius - interselectMyRange;

            if (distanceToEscape < 0)
            {
                return(true);
            }

            var wizardSpeed = 3 * UnitHelper.GetSpeedBonusFactorFromSkillsAndAuras();

            var projectilesToInterselectTicks = Math.Abs(/*(int)*/ (interselectPointRange / projectile.Speed));
            var escapeTicks = Math.Abs(/*(int)*/ (distanceToEscape / wizardSpeed));

            //DebugTrace.ConsoleWriteLite($"{projectilesToInterselectTicks.ToString("N3")} / {escapeTicks.ToString("N3")}");

            return(escapeTicks <= projectilesToInterselectTicks);
        }
        public static void MoveTo(MoveToParams moveToParams)
        {
            var myPosition = Tick.Self.GetPositionPoint();

            var pathNextPoint = moveToParams.TargetPoint;

            var globalPath = GlobalMapHelper.GetPath(Tick.Self.GetPositionPoint(), pathNextPoint);

            if (globalPath != null && globalPath.Count > 0)
            {
                var nextGlobalPoint = GlobalMapHelper.GetCellCenterPoint(globalPath[1], GlobalMapHelper.gridStep);
                if (myPosition.GetDistanceTo(nextGlobalPoint) < Tick.Self.Radius)
                {
                    if (globalPath.Count > 1)
                    {
                        var secondPathPoint = PathFindingHelper.GetCellCenterPoint(globalPath[2], PathFindingHelper.gridStep);
                        nextGlobalPoint = secondPathPoint;
                    }
                }

                var microPath = PathFindingHelper.GetPath(Tick.Self.GetPositionPoint(), nextGlobalPoint);
                if (microPath != null && microPath.Count > 0)
                {
                    var firstMicroPathPoint = PathFindingHelper.GetCellCenterPoint(microPath[0], PathFindingHelper.gridStep);
                    //Если достигли точки микропути, попробуем пойти к следующей или  если её нет пропустим её
                    if (myPosition.GetDistanceTo(firstMicroPathPoint) < Tick.Self.Radius)
                    {
                        if (microPath.Count > 1)
                        {
                            var secondMicroPathPoint = PathFindingHelper.GetCellCenterPoint(microPath[1], PathFindingHelper.gridStep);
                            pathNextPoint = secondMicroPathPoint;
                        }
                    }
                    else
                    {
                        pathNextPoint = firstMicroPathPoint;
                    }
                }
            }

            var angleToTargetPoint = Tick.Self.GetAngleTo(pathNextPoint.X, pathNextPoint.Y);

            var allNearLivingUnins = UnitHelper.GetForwardStuckedLivingUnits();
            var stuckedLivingUnins = allNearLivingUnins.Where(x =>
                                                              (Tick.Self.GetAngleTo(x) <= angleToTargetPoint + Math.PI / 2) ||
                                                              (Tick.Self.GetAngleTo(x) >= angleToTargetPoint - Math.PI / 2)
                                                              ).ToList();

            if (stuckedLivingUnins.Any())
            {
                var firstUnit = stuckedLivingUnins.First();

                var faceForward = Math.Abs(angleToTargetPoint) <= Math.PI / 2;
                var angle1      = Tick.Self.GetAngleTo(firstUnit);

                var escapeSpeed  = faceForward ? Tick.Game.WizardForwardSpeed : -Tick.Game.WizardBackwardSpeed;;
                var escapeStrafe = angle1 <= 0 ? Tick.Game.WizardStrafeSpeed : -Tick.Game.WizardStrafeSpeed;

                escapeSpeed  = escapeSpeed * Math.Abs(Math.Sin(angle1));
                escapeStrafe = escapeStrafe * Math.Abs(Math.Cos(angle1));

                Tick.Move.Speed       = escapeSpeed;
                Tick.Move.StrafeSpeed = escapeStrafe;

                //DebugTrace.ExecuteVisualizer(() =>
                //{
                //    var endPoint = Point2D.GetPointAt(new Point2D(Tick.Self.X, Tick.Self.Y), Tick.Self.Angle + escapeAngle, 200);
                //    VisualClientHelper.BeginPost();
                //    VisualClientHelper.Line(Tick.Self.X, Tick.Self.Y, endPoint.X, endPoint.Y, 0, 1, 1);
                //    VisualClientHelper.EndPost();
                //});

                //Если застряли надолго пробуем пробить путь вперед
                if (GameState.StackedTickCount >= 30)
                {
                    var firstEnemyUnit =
                        stuckedLivingUnins.Where(x => x.Faction != Tick.Self.Faction)
                        .OrderBy(x => x.Life)
                        .FirstOrDefault();

                    if (firstEnemyUnit == null)
                    {
                        firstEnemyUnit = allNearLivingUnins.Where(x => x.Faction != Tick.Self.Faction)
                                         .OrderBy(x => x.Life)
                                         .FirstOrDefault();
                    }

                    if (firstEnemyUnit != null)
                    {
                        Strategy.AtackTarget(firstEnemyUnit);
                    }
                }

                GameState.StackedTickCount++;

                return;
            }
            GameState.StackedTickCount = 0;

            var angleToMovePoint = Tick.Self.GetAngleTo(pathNextPoint.X, pathNextPoint.Y);
            var speed            = Math.Abs(angleToMovePoint) < Math.PI / 2
                ? Tick.Game.WizardForwardSpeed
                : -Tick.Game.WizardBackwardSpeed;

            var strafeSpeed = angleToMovePoint > 0
                ? Tick.Game.WizardStrafeSpeed
                : -Tick.Game.WizardStrafeSpeed;

            var a = Math.Abs(Math.Sin(angleToMovePoint));
            var b = Math.Abs(Math.Cos(angleToMovePoint));

            speed       = speed * b;
            strafeSpeed = strafeSpeed * a;


            var turnAngle = moveToParams.LookAtPoint != null
                ? Tick.Self.GetAngleTo(moveToParams.LookAtPoint.X, moveToParams.LookAtPoint.Y)
                : angleToMovePoint;


            Tick.Move.Speed       = speed;
            Tick.Move.StrafeSpeed = strafeSpeed;
            Tick.Move.Turn        = turnAngle;
        }
Exemple #5
0
        private static double GetMinionPower(Minion minion)
        {
            if (minion.Faction == Tick.Self.Faction)
            {
                //Пока не будем считать союзных крипов как силу
                return(0);
            }
            else if (minion.Faction == Faction.Neutral || minion.Faction == Faction.Other)
            {
                var isAgressive = UnitHelper.IsNeutralMinionAgressive(minion);

                if (isAgressive)
                {
                    if (minion.Type == MinionType.OrcWoodcutter)
                    {
                        if (Tick.Self.GetDistanceTo(minion) - Tick.Self.Radius < Tick.Game.OrcWoodcutterAttackRange)
                        {
                            return(ordWoodcutterBasePower);
                        }
                        else
                        {
                            return(0);
                        }
                    }
                    else if (minion.Type == MinionType.FetishBlowdart)
                    {
                        if (Tick.Self.GetDistanceTo(minion) - Tick.Self.Radius < Tick.Game.FetishBlowdartAttackRange)
                        {
                            return(fetishBlowdartBasePower);
                        }
                        else
                        {
                            return(0);
                        }
                    }
                    return(0);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                if (minion.Type == MinionType.OrcWoodcutter)
                {
                    if (Tick.Self.GetDistanceTo(minion) - Tick.Self.Radius < Tick.Game.OrcWoodcutterAttackRange)
                    {
                        return(ordWoodcutterBasePower);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else if (minion.Type == MinionType.FetishBlowdart)
                {
                    if (Tick.Self.GetDistanceTo(minion) - Tick.Self.Radius < Tick.Game.FetishBlowdartAttackRange)
                    {
                        return(fetishBlowdartBasePower);
                    }
                    else
                    {
                        return(0);
                    }
                }

                return(0);
            }
        }