Esempio n. 1
0
        public override void OnFrame(Tyr tyr)
        {
            tyr.OrbitalAbilityManager.SaveEnergy = 200;

            if (tyr.Frame % 448 == 0)
            {
                if (tyr.OrbitalAbilityManager.ScanCommands.Count == 0)
                {
                    foreach (Agent agent in tyr.UnitManager.Agents.Values)
                    {
                        if (agent.Unit.UnitType != UnitTypes.REAPER &&
                            agent.Unit.UnitType != UnitTypes.CYCLONE)
                        {
                            continue;
                        }

                        Unit scanTarget = null;
                        foreach (Unit enemy in Tyr.Bot.Enemies())
                        {
                            if (!UnitTypes.CanAttackGround(enemy.UnitType))
                            {
                                continue;
                            }
                            if (agent.DistanceSq(enemy) >= 13 * 13)
                            {
                                continue;
                            }

                            scanTarget = enemy;
                            break;
                        }
                        if (scanTarget != null)
                        {
                            tyr.OrbitalAbilityManager.ScanCommands.Add(new Managers.ScanCommand()
                            {
                                FromFrame = tyr.Frame, Pos = SC2Util.To2D(scanTarget.Pos)
                            });
                            break;
                        }
                    }
                }
            }
            if (tyr.Frame % 448 == 20)
            {
                tyr.OrbitalAbilityManager.ScanCommands.Clear();
            }

            if (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.REAPER) >= 2 && RetreatAgainstReapers)
            {
                TimingAttackTask.Task.RequiredSize = 10;
                TimingAttackTask.Task.RetreatSize  = 5;
            }
            else
            {
                TimingAttackTask.Task.RequiredSize = 1;
                TimingAttackTask.Task.RetreatSize  = 0;
            }
        }
Esempio n. 2
0
        public override void OnFrame(Bot bot)
        {
            UpdateEnemyBases();
            if (units.Count == 0)
            {
                return;
            }
            Bot.Main.DrawText("Enemy bases for scouting: " + EnemyBases.Count);
            Base  target = null;
            float dist   = 1000000;

            foreach (Base loc in EnemyBases)
            {
                float newDist = Units[0].DistanceSq(loc.BaseLocation.Pos);
                if (newDist < dist)
                {
                    dist   = newDist;
                    target = loc;
                }
            }

            foreach (Agent agent in units)
            {
                Unit  fleeEnemy = null;
                float enemyDist = 13 * 13;
                foreach (Unit enemy in bot.Enemies())
                {
                    if (!UnitTypes.CanAttackGround(enemy.UnitType))
                    {
                        continue;
                    }
                    float newDist = agent.DistanceSq(enemy);
                    if (newDist < enemyDist)
                    {
                        enemyDist = newDist;
                        fleeEnemy = enemy;
                    }
                }

                if (fleeEnemy != null)
                {
                    agent.Order(Abilities.MOVE, agent.From(fleeEnemy, 4));
                    continue;
                }

                if (target != null)
                {
                    agent.Order(Abilities.MOVE, target.BaseLocation.Pos);
                    if (RemoveBase(target, agent))
                    {
                        EnemyBases.Remove(target);
                    }
                }
            }
        }
Esempio n. 3
0
        public override bool DetermineAction(Agent agent, Point2D target)
        {
            if (agent.Unit.UnitType != UnitTypes.CYCLONE)
            {
                return(false);
            }

            if (agent.Unit.Orders != null && agent.Unit.Orders.Count >= 2 && (!LockOnFrame.ContainsKey(agent.Unit.Tag) || Bot.Main.Frame - LockOnFrame[agent.Unit.Tag] >= 22.4 * 15))
            {
                if (!LockOnFrame.ContainsKey(agent.Unit.Tag))
                {
                    LockOnFrame.Add(agent.Unit.Tag, Bot.Main.Frame);
                }
                else
                {
                    LockOnFrame[agent.Unit.Tag] = Bot.Main.Frame;
                }
            }

            if (LockOnFrame.ContainsKey(agent.Unit.Tag) && Bot.Main.Frame - LockOnFrame[agent.Unit.Tag] < 22.4 * 16)
            {
                Bot.Main.DrawSphere(agent.Unit.Pos);
            }

            if (LockOnFrame.ContainsKey(agent.Unit.Tag) && Bot.Main.Frame - LockOnFrame[agent.Unit.Tag] < 11)
            {
                return(true);
            }
            bool lockedOn = LockOnFrame.ContainsKey(agent.Unit.Tag) && Bot.Main.Frame - LockOnFrame[agent.Unit.Tag] < 22.4 * 16;

            if (!lockedOn)
            {
                return(false);
            }



            foreach (Unit enemy in Bot.Main.Enemies())
            {
                if (!UnitTypes.CanAttackGround(enemy.UnitType))
                {
                    continue;
                }
                if (agent.DistanceSq(enemy) <= 12 * 12)
                {
                    agent.Order(Abilities.MOVE, SC2Util.To2D(Bot.Main.MapAnalyzer.StartLocation));
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 4
0
        public override bool DetermineAction(Agent agent, Point2D target)
        {
            if (agent.Unit.UnitType != UnitTypes.DISRUPTOR)
            {
                return(false);
            }

            if (PhaseFrame.ContainsKey(agent.Unit.Tag) && Tyr.Bot.Frame - PhaseFrame[agent.Unit.Tag] <= 22)
            {
                return(true);
            }

            if (Phase(agent))
            {
                return(true);
            }

            Unit  closestEnemy = null;
            float distance     = 9 * 9;

            foreach (Unit unit in Tyr.Bot.Enemies())
            {
                if (!UnitTypes.CanAttackGround(unit.UnitType))
                {
                    continue;
                }
                float newDist = agent.DistanceSq(unit);
                if (newDist >= distance)
                {
                    continue;
                }

                distance     = newDist;
                closestEnemy = unit;
            }

            if (closestEnemy == null)
            {
                agent.Order(Abilities.MOVE, target);
                return(true);
            }

            agent.Order(Abilities.MOVE, agent.From(closestEnemy, 4));
            return(true);
        }
Esempio n. 5
0
        public void Advance(Tyr tyr)
        {
            bool enemyClose = false;

            foreach (Agent agent in units)
            {
                foreach (Unit enemy in tyr.Enemies())
                {
                    if (!UnitTypes.CanAttackGround(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType))
                    {
                        continue;
                    }

                    if (!UnitTypes.RangedTypes.Contains(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType))
                    {
                        continue;
                    }

                    if (enemy.IsFlying)
                    {
                        continue;
                    }

                    if (agent.DistanceSq(enemy) <= 15 * 15)
                    {
                        enemyClose = true;
                        break;
                    }
                }
                Attack(agent, tyr.TargetManager.PotentialEnemyStartLocations[0]);
            }

            if (enemyClose)
            {
                CurrentState = State.SiegeUp;
            }
        }
Esempio n. 6
0
        public override bool DetermineAction(Agent agent, Point2D target)
        {
            if (agent.Unit.UnitType != UnitTypes.INFESTOR)
            {
                return(false);
            }

            if (Tyr.Bot.Frame != CleanFungalTargetsFrame)
            {
                CleanFungalTargetsFrame = Tyr.Bot.Frame;

                List <ulong> clearTags = new List <ulong>();
                foreach (FungalTarget fungal in FungalTargets.Values)
                {
                    if (Tyr.Bot.Frame - fungal.Frame >= 22.4 * 3)
                    {
                        clearTags.Add(fungal.InfestorTag);
                    }
                }

                foreach (ulong tag in clearTags)
                {
                    FungalTargets.Remove(tag);
                }
            }


            if (NeuralFrame.ContainsKey(agent.Unit.Tag) && Tyr.Bot.Frame - NeuralFrame[agent.Unit.Tag] < 22)
            {
                return(true);
            }

            if (Fungal(agent))
            {
                return(true);
            }

            if (NeuralParasite(agent))
            {
                return(true);
            }

            Unit  closestEnemy = null;
            float distance     = agent.Unit.Energy < 70 ? 12 * 12 : 9 * 9;

            foreach (Unit unit in Tyr.Bot.Enemies())
            {
                if (!UnitTypes.CanAttackGround(unit.UnitType))
                {
                    continue;
                }
                float newDist = agent.DistanceSq(unit);
                if (newDist >= distance)
                {
                    continue;
                }

                distance     = newDist;
                closestEnemy = unit;
            }

            if (closestEnemy == null)
            {
                agent.Order(Abilities.MOVE, target);
                return(true);
            }

            agent.Order(Abilities.MOVE, agent.From(closestEnemy, 4));
            return(true);
        }
Esempio n. 7
0
        public void LeapFrog(Tyr tyr)
        {
            List <Agent> tanks = GetTanks();

            foreach (Agent tank in tanks)
            {
                if (tyr.MapAnalyzer.EnemyDistances[(int)tank.Unit.Pos.X, (int)tank.Unit.Pos.Y] <= 50 ||
                    tank.DistanceSq(tyr.TargetManager.PotentialEnemyStartLocations[0]) <= 20 * 20)
                {
                    CurrentState = State.Kill;
                    break;
                }
            }

            int tanksSieged   = 0;
            int tanksUnsieged = 0;

            foreach (Agent agent in units)
            {
                if (agent.Unit.UnitType == UnitTypes.SIEGE_TANK)
                {
                    tanksUnsieged++;
                }
                else if (agent.Unit.UnitType == UnitTypes.SIEGE_TANK_SIEGED)
                {
                    if (UnsiegingTanks.Contains(agent.Unit.Tag))
                    {
                        tanksUnsieged++;
                    }
                    else
                    {
                        tanksSieged++;
                    }
                }
            }

            int allowedUnsiegedTanks = (tanksUnsieged + tanksSieged) / 2;

            if (allowedUnsiegedTanks < 2)
            {
                allowedUnsiegedTanks = 2;
            }

            List <Agent> potentialUnsiegers = GetPotentialUnsiegers();

            foreach (Agent agent in potentialUnsiegers)
            {
                if (allowedUnsiegedTanks - tanksUnsieged <= 0)
                {
                    break;
                }

                bool enemyClose = false;
                foreach (Unit enemy in tyr.Enemies())
                {
                    if (!UnitTypes.CanAttackGround(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType))
                    {
                        continue;
                    }

                    if (!UnitTypes.RangedTypes.Contains(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType))
                    {
                        continue;
                    }

                    if (enemy.IsFlying)
                    {
                        continue;
                    }

                    if (agent.DistanceSq(enemy) <= 13 * 13)
                    {
                        enemyClose = true;
                        break;
                    }
                }
                if (enemyClose)
                {
                    tyr.DrawSphere(agent.Unit.Pos, 1, new Color()
                    {
                        R = 0, G = 255, B = 0
                    });
                }
            }

            foreach (Agent agent in potentialUnsiegers)
            {
                if (allowedUnsiegedTanks - tanksUnsieged <= 0)
                {
                    break;
                }

                bool enemyClose = false;
                foreach (Unit enemy in tyr.Enemies())
                {
                    if (!UnitTypes.CanAttackGround(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType))
                    {
                        continue;
                    }

                    if (!UnitTypes.RangedTypes.Contains(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType))
                    {
                        continue;
                    }

                    if (enemy.IsFlying)
                    {
                        continue;
                    }

                    if (agent.DistanceSq(enemy) <= 13 * 13)
                    {
                        enemyClose = true;
                        break;
                    }
                }
                if (enemyClose)
                {
                    continue;
                }

                allowedUnsiegedTanks--;
                UnsiegingTanks.Add(agent.Unit.Tag);
            }

            float closestDistance = 1000000;

            foreach (Agent agent in Units)
            {
                if (UnsiegingTanks.Contains(agent.Unit.Tag))
                {
                    tyr.DrawSphere(agent.Unit.Pos);
                }
                if (agent.Unit.UnitType != UnitTypes.SIEGE_TANK_SIEGED ||
                    UnsiegingTanks.Contains(agent.Unit.Tag))
                {
                    continue;
                }

                tyr.DrawLine(agent, tyr.TargetManager.PotentialEnemyStartLocations[0]);

                float distSq = agent.DistanceSq(tyr.TargetManager.PotentialEnemyStartLocations[0]);
                if (distSq < closestDistance)
                {
                    closestDistance = distSq;
                }
            }

            float minimumDist = (float)Math.Sqrt(closestDistance) + 8;

            float farthestDistance = 0;

            foreach (Agent agent in Units)
            {
                if (agent.Unit.UnitType != UnitTypes.SIEGE_TANK_SIEGED ||
                    UnsiegingTanks.Contains(agent.Unit.Tag))
                {
                    continue;
                }

                float distSq = agent.DistanceSq(tyr.TargetManager.PotentialEnemyStartLocations[0]);
                if (distSq >= minimumDist * minimumDist)
                {
                    continue;
                }

                if (distSq > farthestDistance)
                {
                    farthestDistance = distSq;
                }
            }

            farthestDistance = (float)Math.Sqrt(farthestDistance);
            closestDistance  = (float)Math.Sqrt(closestDistance);

            tyr.DrawText("Closest tank dist: " + closestDistance);
            tyr.DrawText("Farthest tank dist: " + farthestDistance);


            foreach (Agent agent in Units)
            {
                if (agent.Unit.UnitType == UnitTypes.SIEGE_TANK)
                {
                    if (!UnsiegingTanks.Contains(agent.Unit.Tag))
                    {
                        agent.Order(Abilities.SIEGE);
                    }
                    else
                    {
                        float dist = agent.DistanceSq(tyr.TargetManager.PotentialEnemyStartLocations[0]);
                        if (dist < (farthestDistance - 6) * (farthestDistance - 6) || dist < (closestDistance - 2) + (closestDistance - 2) &&
                            SufficientlySpread(agent))
                        {
                            UnsiegingTanks.Remove(agent.Unit.Tag);
                            agent.Order(Abilities.UNSIEGE);
                        }
                        else
                        {
                            Attack(agent, tyr.TargetManager.PotentialEnemyStartLocations[0]);
                        }
                    }
                }
                else if (agent.Unit.UnitType == UnitTypes.SIEGE_TANK_SIEGED)
                {
                    if (UnsiegingTanks.Contains(agent.Unit.Tag))
                    {
                        bool closeEnemy = false;
                        foreach (Unit enemy in Tyr.Bot.Enemies())
                        {
                            if (!UnitTypes.CanAttackGround(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType))
                            {
                                continue;
                            }

                            if (!UnitTypes.RangedTypes.Contains(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType))
                            {
                                continue;
                            }

                            if (enemy.IsFlying)
                            {
                                continue;
                            }

                            if (agent.DistanceSq(enemy) <= 13 * 13)
                            {
                                closeEnemy = true;
                                break;
                            }
                        }
                        if (!closeEnemy)
                        {
                            agent.Order(Abilities.UNSIEGE);
                        }
                    }
                }
                else
                {
                    if (agent.Unit.UnitType == UnitTypes.HELLBAT ||
                        agent.Unit.UnitType == UnitTypes.HELLION ||
                        agent.Unit.UnitType == UnitTypes.MARINE)
                    {
                        Agent closestTank = null;
                        float distance    = 18 * 18;
                        foreach (Agent tank in tanks)
                        {
                            float newDist = tank.DistanceSq(agent);
                            if (newDist < distance)
                            {
                                closestTank = tank;
                                distance    = newDist;
                            }
                        }
                        if (distance >= 5 * 5 && closestTank != null)
                        {
                            agent.Order(Abilities.MOVE, SC2Util.To2D(closestTank.Unit.Pos));
                            continue;
                        }
                    }
                    Attack(agent, tyr.TargetManager.PotentialEnemyStartLocations[0]);
                }
            }
        }
Esempio n. 8
0
        public override void OnFrame(Tyr tyr)
        {
            Point2D hideLocation = GetHideLocation();

            if (hideLocation == null)
            {
                return;
            }
            UnitCounts = new Dictionary <uint, int>();
            foreach (Agent agent in tyr.UnitManager.Agents.Values)
            {
                if (agent.DistanceSq(HideLocation) > 20 * 20)
                {
                    continue;
                }

                CollectionUtil.Increment(UnitCounts, agent.Unit.UnitType);
            }
            DetermineNextBuilding(UnitCounts);
            List <BuildRequest> doneRequests = new List <BuildRequest>();

            foreach (BuildRequest request in BuildRequests)
            {
                if (request.worker != null && !Tyr.Bot.UnitManager.Agents.ContainsKey(request.worker.Unit.Tag))
                {
                    request.worker = null;
                }
                if (request.worker == null)
                {
                    foreach (Agent agent in Units)
                    {
                        if (BuildingType.BuildingAbilities.Contains((int)agent.CurrentAbility()))
                        {
                            continue;
                        }
                        request.worker = agent;
                        break;
                    }
                }

                if (!ProxyBuildingPlacer.CheckPlacement(request.Pos, BuildingType.LookUp[request.Type].Size, request.Type, null, true))
                {
                    doneRequests.Add(request);
                    continue;
                }
                foreach (Agent agent in tyr.UnitManager.Agents.Values)
                {
                    if (agent.Unit.UnitType == request.Type &&
                        agent.DistanceSq(request.Pos) < 4)
                    {
                        doneRequests.Add(request);
                        break;
                    }
                }
            }

            foreach (BuildRequest request in doneRequests)
            {
                BuildRequests.Remove(request);
            }

            foreach (Agent agent in Units)
            {
                if (EvadeEnemies)
                {
                    float dist   = 20 * 20;
                    Unit  target = null;
                    foreach (Unit enemy in Tyr.Bot.Enemies())
                    {
                        if (!UnitTypes.CombatUnitTypes.Contains(enemy.UnitType))
                        {
                            continue;
                        }
                        if (!UnitTypes.CanAttackGround(enemy.UnitType))
                        {
                            continue;
                        }
                        float newDist = agent.DistanceSq(enemy);
                        if (newDist > dist)
                        {
                            continue;
                        }
                        dist   = newDist;
                        target = enemy;
                    }
                    if (target != null)
                    {
                        Tyr.Bot.DrawLine(agent.Unit.Pos, target.Pos);
                        agent.Order(Abilities.MOVE, agent.From(target, 4));
                        continue;
                    }
                }

                bool building = false;
                foreach (BuildRequest request in BuildRequests)
                {
                    if (request.worker == null || request.worker.Unit.Tag != agent.Unit.Tag)
                    {
                        continue;
                    }

                    building = true;
                    if (agent.DistanceSq(request.Pos) <= 10 * 10)
                    {
                        agent.Order(BuildingType.LookUp[request.Type].Ability, request.Pos);
                    }
                    else
                    {
                        agent.Order(Abilities.MOVE, request.Pos);
                    }
                    break;
                }
                if (building)
                {
                    continue;
                }

                if (agent.DistanceSq(GetHideLocation()) >= 4 * 4)
                {
                    agent.Order(Abilities.MOVE, GetHideLocation());
                    continue;
                }
            }
        }
Esempio n. 9
0
        public override void OnFrame(Tyr tyr)
        {
            while (unassignedAgents.Count > 0 && UnassignedRequests.Count > 0)
            {
                UnassignedRequests[UnassignedRequests.Count - 1].worker = unassignedAgents[unassignedAgents.Count - 1];
                UnassignedRequests[UnassignedRequests.Count - 1].LastImprovementFrame = Tyr.Bot.Frame;
                UnassignedRequests[UnassignedRequests.Count - 1].Closest = unassignedAgents[unassignedAgents.Count - 1].DistanceSq(UnassignedRequests[UnassignedRequests.Count - 1].Pos);
                BuildRequests.Add(UnassignedRequests[UnassignedRequests.Count - 1]);
                UnassignedRequests.RemoveAt(UnassignedRequests.Count - 1);
                unassignedAgents.RemoveAt(unassignedAgents.Count - 1);
            }

            for (int i = BuildRequests.Count - 1; i >= 0; i--)
            {
                BuildRequest buildRequest = BuildRequests[i];
                bool         completed    = false;
                if (buildRequest.worker != null)
                {
                    float newDist = buildRequest.worker.DistanceSq(buildRequest.Pos);
                    if (newDist < buildRequest.Closest)
                    {
                        buildRequest.Closest = newDist;
                        buildRequest.LastImprovementFrame = Tyr.Bot.Frame;
                    }
                    else if (Tyr.Bot.Frame - buildRequest.LastImprovementFrame >= 448)
                    {
                        UnassignedRequests.Add(buildRequest);
                        BlockedWorkers.Add(buildRequest.worker.Unit.Tag);
                        BuildRequests[i] = BuildRequests[BuildRequests.Count - 1];
                        BuildRequests.RemoveAt(BuildRequests.Count - 1);
                        IdleTask.Task.Add(buildRequest.worker);
                        units.Remove(buildRequest.worker);
                    }
                    else if (UnitTypes.ResourceCenters.Contains(buildRequest.Type))
                    {
                        bool closeEnemy = false;
                        foreach (Unit enemy in Tyr.Bot.Enemies())
                        {
                            if (!UnitTypes.CanAttackGround(enemy.UnitType))
                            {
                                continue;
                            }
                            if (buildRequest.worker.DistanceSq(enemy) <= 8 * 8)
                            {
                                closeEnemy = true;
                                break;
                            }
                        }

                        if (closeEnemy)
                        {
                            ExpandingBlockedUntilFrame = Tyr.Bot.Frame + 224;
                            BuildRequests[i]           = BuildRequests[BuildRequests.Count - 1];
                            BuildRequests.RemoveAt(BuildRequests.Count - 1);
                            IdleTask.Task.Add(buildRequest.worker);
                            units.Remove(buildRequest.worker);
                            DebugUtil.WriteLine("Base blocked, cancelling base. BuildRequest length: " + BuildRequests.Count);
                            continue;
                        }
                    }
                }
                foreach (Agent agent in tyr.UnitManager.Agents.Values)
                {
                    if (agent.Unit.UnitType == buildRequest.Type && SC2Util.DistanceSq(agent.Unit.Pos, buildRequest.Pos) <= 1)
                    {
                        completed            = true;
                        agent.Base           = buildRequest.Base;
                        agent.AroundLocation = buildRequest.AroundLocation;
                        agent.Exact          = buildRequest.Exact;
                        break;
                    }
                }
                if (completed)
                {
                    BuildRequests[i] = BuildRequests[BuildRequests.Count - 1];
                    BuildRequests.RemoveAt(BuildRequests.Count - 1);
                    IdleTask.Task.Add(buildRequest.worker);
                    units.Remove(buildRequest.worker);
                }
                else if (!tyr.UnitManager.Agents.ContainsKey(buildRequest.worker.Unit.Tag))
                {
                    buildRequest.worker = null;
                    UnassignedRequests.Add(buildRequest);
                    BuildRequests[i] = BuildRequests[BuildRequests.Count - 1];
                    BuildRequests.RemoveAt(BuildRequests.Count - 1);
                }
                else if (CancelBlockedBuildings && Unbuildable(buildRequest))
                {
                    BuildRequests[i] = BuildRequests[BuildRequests.Count - 1];
                    BuildRequests.RemoveAt(BuildRequests.Count - 1);
                    IdleTask.Task.Add(buildRequest.worker);
                    units.Remove(buildRequest.worker);
                }
                else if (buildRequest.worker.Unit.Orders.Count == 0 ||
                         buildRequest.worker.Unit.Orders[0].AbilityId != BuildingType.LookUp[buildRequest.Type].Ability ||
                         (buildRequest.worker.Unit.Orders[0].TargetWorldSpacePos != null && buildRequest.worker.Unit.Orders[0].TargetWorldSpacePos.X != buildRequest.Pos.X) ||
                         (buildRequest.worker.Unit.Orders[0].TargetWorldSpacePos != null && buildRequest.worker.Unit.Orders[0].TargetWorldSpacePos.Y != buildRequest.Pos.Y) ||
                         (buildRequest is BuildRequestGas && ((BuildRequestGas)buildRequest).Gas.Tag != buildRequest.worker.Unit.Orders[0].TargetUnitTag))
                {
                    Tyr.Bot.ReservedMinerals += BuildingType.LookUp[buildRequest.Type].Minerals;
                    Tyr.Bot.ReservedGas      += BuildingType.LookUp[buildRequest.Type].Gas;

                    if (buildRequest is BuildRequestGas)
                    {
                        tyr.DrawLine(buildRequest.worker, ((BuildRequestGas)buildRequest).Gas.Pos);
                    }
                    else
                    {
                        tyr.DrawLine(buildRequest.worker, SC2Util.Point(buildRequest.Pos.X, buildRequest.Pos.Y, buildRequest.worker.Unit.Pos.Z));
                    }
                    if (tyr.Observation.Observation.PlayerCommon.Minerals < BuildingType.LookUp[buildRequest.Type].Minerals ||
                        tyr.Observation.Observation.PlayerCommon.Vespene < BuildingType.LookUp[buildRequest.Type].Gas)
                    {
                        Point2D target = buildRequest is BuildRequestGas?SC2Util.To2D(((BuildRequestGas)buildRequest).Gas.Pos) : buildRequest.Pos;

                        if (buildRequest.worker.DistanceSq(target) > 3 * 3)
                        {
                            buildRequest.worker.Order(Abilities.MOVE, target);
                            continue;
                        }
                    }

                    if (buildRequest is BuildRequestGas)
                    {
                        Unit gas = ((BuildRequestGas)buildRequest).Gas.Unit;
                        foreach (Unit unit in tyr.Observation.Observation.RawData.Units)
                        {
                            if (SC2Util.DistanceSq(unit.Pos, ((BuildRequestGas)buildRequest).Gas.Pos) > 2 * 2)
                            {
                                continue;
                            }
                            gas = unit;
                            break;
                        }
                        buildRequest.worker.Order(BuildingType.LookUp[buildRequest.Type].Ability, gas.Tag);
                    }
                    else
                    {
                        buildRequest.worker.Order(BuildingType.LookUp[buildRequest.Type].Ability, buildRequest.Pos);
                    }
                }
            }

            foreach (BuildRequest request in UnassignedRequests)
            {
                Tyr.Bot.DrawText("BuildRequest: " + UnitTypes.LookUp[request.Type].Name);
            }
            foreach (BuildRequest request in BuildRequests)
            {
                Tyr.Bot.DrawText("BuildRequest: " + UnitTypes.LookUp[request.Type].Name);
            }
        }
Esempio n. 10
0
        public void OnFrame(Tyr tyr)
        {
            tyr.DrawSphere(SC2Util.Point(NaturalDefensePos.X, NaturalDefensePos.Y, 10));
            AvailableGasses = 0;
            foreach (Base b in Bases)
            {
                if (b.ResourceCenter != null && !tyr.UnitManager.Agents.ContainsKey(b.ResourceCenter.Unit.Tag))
                {
                    b.ResourceCenter = null;
                    b.Owner          = -1;
                }

                if (b.ResourceCenter == null)
                {
                    foreach (Agent agent in tyr.UnitManager.Agents.Values)
                    {
                        if (!agent.IsResourceCenter)
                        {
                            continue;
                        }

                        if (SC2Util.DistanceGrid(b.BaseLocation.Pos, agent.Unit.Pos) <= 10)
                        {
                            b.ResourceCenter = agent;
                            b.Owner          = b.ResourceCenter.Unit.Owner;
                            agent.Base       = b;
                            break;
                        }
                    }
                }

                if (b.ResourceCenter == null)
                {
                    if (b.Owner == (int)tyr.PlayerId)
                    {
                        b.Owner = -1;
                    }
                    foreach (BuildRequest request in ConstructionTask.Task.BuildRequests)
                    {
                        if (UnitTypes.ResourceCenters.Contains(request.Type) && SC2Util.DistanceSq(b.BaseLocation.Pos, request.Pos) <= 2 * 2)
                        {
                            b.Owner = (int)tyr.PlayerId;
                            break;
                        }
                    }
                }

                if (b.Owner != tyr.PlayerId)
                {
                    b.Owner = -1;
                    foreach (Unit unit in tyr.Enemies())
                    {
                        // If an enemy has built near this base we set it as its owner.
                        if (UnitTypes.BuildingTypes.Contains(unit.UnitType) &&
                            SC2Util.DistanceGrid(unit.Pos, b.BaseLocation.Pos) <= 10)
                        {
                            b.Owner = unit.Owner;
                        }
                    }
                }

                b.BaseLocation.MineralFields = new List <MineralField>();
                b.BaseLocation.Gasses        = new List <Gas>();
                foreach (Unit unit in tyr.Observation.Observation.RawData.Units)
                {
                    if (UnitTypes.MineralFields.Contains(unit.UnitType) &&
                        SC2Util.DistanceSq(unit.Pos, b.BaseLocation.Pos) <= 10 * 10)
                    {
                        b.BaseLocation.MineralFields.Add(new MineralField()
                        {
                            Pos = unit.Pos, Tag = unit.Tag
                        });
                    }
                    else if (UnitTypes.GasGeysers.Contains(unit.UnitType) &&
                             SC2Util.DistanceSq(unit.Pos, b.BaseLocation.Pos) <= 10 * 10)
                    {
                        bool available = b.ResourceCenter != null &&
                                         unit.UnitType != UnitTypes.ASSIMILATOR &&
                                         unit.UnitType != UnitTypes.REFINERY &&
                                         unit.UnitType != UnitTypes.EXTRACTOR;

                        b.BaseLocation.Gasses.Add(new Gas {
                            Pos = unit.Pos, Tag = unit.Tag, Available = available, CanBeGathered = !available, Unit = unit
                        });
                    }
                }

                foreach (Gas gas1 in b.BaseLocation.Gasses)
                {
                    foreach (Gas gas2 in b.BaseLocation.Gasses)
                    {
                        if (gas1.Tag == gas2.Tag)
                        {
                            continue;
                        }
                        if (gas1.Pos.X == gas2.Pos.X && gas1.Pos.Y == gas2.Pos.Y)
                        {
                            gas1.Available = false;
                            gas2.Available = false;
                        }
                    }
                }
                foreach (Gas gas in b.BaseLocation.Gasses)
                {
                    if (gas.Available)
                    {
                        AvailableGasses++;
                    }
                }

                b.UnderAttack = false;
                b.Evacuate    = false;
                int attackerCount = 0;
                foreach (Unit enemy in tyr.Enemies())
                {
                    if (!UnitTypes.CombatUnitTypes.Contains(enemy.UnitType))
                    {
                        continue;
                    }
                    if (SC2Util.DistanceSq(enemy.Pos, b.BaseLocation.Pos) >= 15 * 15)
                    {
                        continue;
                    }

                    if (enemy.UnitType == UnitTypes.ORACLE)
                    {
                        attackerCount += 8;
                    }

                    b.UnderAttack = true;
                    if (UnitTypes.CanAttackGround(enemy.UnitType))
                    {
                        attackerCount++;
                    }
                }
                if (attackerCount >= 8)
                {
                    b.Evacuate = true;
                }

                if (b.ResourceCenter == null || b.ResourceCenter.Unit.BuildProgress < 0.99)
                {
                    b.ResourceCenterFinishedFrame = -1;
                }
                else if (b.ResourceCenterFinishedFrame == -1)
                {
                    b.ResourceCenterFinishedFrame = tyr.Frame;
                }
            }


            foreach (Base b in Bases)
            {
                if (b.Owner == -1)
                {
                    Tyr.Bot.DrawSphere(b.BaseLocation.Pos);
                }
            }

            CheckBlockedBases();
        }
Esempio n. 11
0
        public override bool DetermineAction(Agent agent, Point2D target)
        {
            if (agent.Unit.UnitType != UnitTypes.DARK_TEMPLAR)
            {
                return(false);
            }

            float dist         = 10 * 10;
            Unit  detectTarget = null;

            foreach (Unit enemy in Bot.Main.CloakedEnemies())
            {
                if (enemy.UnitType != UnitTypes.OBSERVER)
                {
                    continue;
                }

                float newDist = agent.DistanceSq(enemy);

                if (newDist < dist)
                {
                    detectTarget = enemy;
                    dist         = newDist;
                }
            }
            foreach (Unit enemy in Bot.Main.Enemies())
            {
                if (enemy.UnitType != UnitTypes.PHOTON_CANNON)
                {
                    continue;
                }

                float newDist = agent.DistanceSq(enemy);

                if (newDist < dist)
                {
                    detectTarget = enemy;
                    dist         = newDist;
                }
            }
            if (detectTarget == null)
            {
                return(false);
            }

            dist = 10 * 10;
            Unit fleeTarget = null;

            foreach (Unit enemy in Bot.Main.Enemies())
            {
                if (!UnitTypes.CanAttackGround(enemy.UnitType))
                {
                    continue;
                }

                float newDist = agent.DistanceSq(enemy);

                if (newDist < dist)
                {
                    fleeTarget = enemy;
                    dist       = newDist;
                }
            }

            if (fleeTarget != null)
            {
                agent.Flee(fleeTarget.Pos);
                return(true);
            }

            return(false);
        }
Esempio n. 12
0
        public override bool DetermineAction(Agent agent, Point2D target)
        {
            if (agent.Unit.UnitType != UnitTypes.SWARM_HOST)
            {
                return(false);
            }

            UpdateLocusts();

            float distance   = 15 * 15;
            Unit  closeEnemy = null;

            foreach (Unit unit in Tyr.Bot.Enemies())
            {
                if (!UnitTypes.CanAttackGround(unit.UnitType))
                {
                    continue;
                }

                float newDist = SC2Util.DistanceSq(unit.Pos, agent.Unit.Pos);
                if (newDist > distance)
                {
                    continue;
                }

                closeEnemy = unit;
                distance   = newDist;
            }

            if (closeEnemy != null && distance <= 12 * 12)
            {
                agent.Order(Abilities.MOVE, agent.From(closeEnemy, 4));
                return(true);
            }

            if (Tyr.Bot.Frame - LastLocustFrame < 22.4 || Tyr.Bot.Frame - LastLocustFrame > 40 * 22.4 + 11)
            {
                float targetDistance = 15 * 15;
                Unit  targetEnemy    = null;
                foreach (Unit unit in Tyr.Bot.Enemies())
                {
                    if (unit.IsFlying)
                    {
                        continue;
                    }

                    float newDist = SC2Util.DistanceSq(unit.Pos, agent.Unit.Pos);
                    if (newDist > targetDistance)
                    {
                        continue;
                    }

                    targetEnemy    = unit;
                    targetDistance = newDist;
                }

                if (targetEnemy != null)
                {
                    agent.Order(2704, SC2Util.To2D(targetEnemy.Pos));
                    return(true);
                }
            }

            if (closeEnemy != null)
            {
                if (distance >= 13 * 13)
                {
                    agent.Order(Abilities.MOVE, target);
                }
                else
                {
                    agent.Order(Abilities.MOVE, agent.From(closeEnemy, 4));
                }
                return(true);
            }

            agent.Order(Abilities.MOVE, target);
            return(true);
        }
Esempio n. 13
0
        public override void OnFrame(Bot bot)
        {
            if (NaturalProbe != null)
            {
                bool naturalProbeAlive = false;
                int  probePos          = -1;
                int  i = 0;
                foreach (Agent agent in Units)
                {
                    if (agent == NaturalProbe)
                    {
                        probePos          = i;
                        naturalProbeAlive = true;
                        break;
                    }
                    i++;
                }
                if (!naturalProbeAlive)
                {
                    NaturalProbe = null;
                }

                if (NaturalProbe != null &&
                    !DedicatedNaturalProbe &&
                    probePos >= 0)
                {
                    Bot.Main.DrawText("Removing natural probe.");
                    bool alreadyAssigned = false;
                    foreach (BuildRequest request in BuildRequests)
                    {
                        if (request.worker == NaturalProbe)
                        {
                            alreadyAssigned = true;
                            break;
                        }
                    }
                    if (!alreadyAssigned)
                    {
                        DebugUtil.WriteLine("Clearing natural probe.");
                        ClearAt(probePos);
                        NaturalProbe = null;
                    }
                    else
                    {
                        Bot.Main.DrawText("Natural probe already assigned.");
                    }
                }
            }

            if (DedicatedNaturalProbe &&
                NaturalProbe != null)
            {
                bool alreadyAssigned = false;
                foreach (BuildRequest request in BuildRequests)
                {
                    if (request.worker == NaturalProbe)
                    {
                        alreadyAssigned = true;
                    }
                }
                if (!alreadyAssigned)
                {
                    BuildRequest pickedRequest = null;
                    foreach (BuildRequest request in UnassignedRequests)
                    {
                        if (request.Base == Bot.Main.BaseManager.Natural)
                        {
                            pickedRequest = request;
                        }
                    }
                    if (pickedRequest != null)
                    {
                        pickedRequest.worker = NaturalProbe;
                        pickedRequest.LastImprovementFrame = Bot.Main.Frame;
                        pickedRequest.Closest = NaturalProbe.DistanceSq(pickedRequest.Pos);
                        BuildRequests.Add(pickedRequest);
                        UnassignedRequests.Remove(pickedRequest);
                        alreadyAssigned = true;
                    }
                }
                if (!alreadyAssigned &&
                    NaturalProbe != null &&
                    NaturalProbe.DistanceSq(bot.BaseManager.Natural.OppositeMineralLinePos) >= 4 * 4)
                {
                    NaturalProbe.Order(Abilities.MOVE, bot.BaseManager.Natural.OppositeMineralLinePos);
                }
            }

            while (unassignedAgents.Count > 0 && UnassignedRequests.Count > 0)
            {
                UnassignedRequests[UnassignedRequests.Count - 1].worker = unassignedAgents[unassignedAgents.Count - 1];
                UnassignedRequests[UnassignedRequests.Count - 1].LastImprovementFrame = Bot.Main.Frame;
                UnassignedRequests[UnassignedRequests.Count - 1].Closest = unassignedAgents[unassignedAgents.Count - 1].DistanceSq(UnassignedRequests[UnassignedRequests.Count - 1].Pos);
                BuildRequests.Add(UnassignedRequests[UnassignedRequests.Count - 1]);
                UnassignedRequests.RemoveAt(UnassignedRequests.Count - 1);
                unassignedAgents.RemoveAt(unassignedAgents.Count - 1);
            }

            for (int i = BuildRequests.Count - 1; i >= 0; i--)
            {
                BuildRequest buildRequest = BuildRequests[i];
                bool         completed    = false;
                if (buildRequest.worker != null)
                {
                    float newDist = buildRequest.worker.DistanceSq(buildRequest.Pos);
                    if (newDist < buildRequest.Closest)
                    {
                        buildRequest.Closest = newDist;
                        buildRequest.LastImprovementFrame = Bot.Main.Frame;
                    }
                    else if (Bot.Main.Frame - buildRequest.LastImprovementFrame >= 448)
                    {
                        UnassignedRequests.Add(buildRequest);
                        BlockedWorkers.Add(buildRequest.worker.Unit.Tag);
                        BuildRequests[i] = BuildRequests[BuildRequests.Count - 1];
                        BuildRequests.RemoveAt(BuildRequests.Count - 1);
                        IdleTask.Task.Add(buildRequest.worker);
                        units.Remove(buildRequest.worker);
                    }
                    else if (UnitTypes.ResourceCenters.Contains(buildRequest.Type))
                    {
                        bool closeEnemy            = false;
                        int  closeEnemyWorkerCount = 0;
                        foreach (Unit enemy in Bot.Main.Enemies())
                        {
                            if (!UnitTypes.CanAttackGround(enemy.UnitType))
                            {
                                continue;
                            }
                            if (UnitTypes.WorkerTypes.Contains(enemy.UnitType))
                            {
                                if (buildRequest.worker.DistanceSq(enemy) <= 4 * 4)
                                {
                                    closeEnemyWorkerCount++;
                                }
                                continue;
                            }
                            if (buildRequest.worker.DistanceSq(enemy) <= 8 * 8)
                            {
                                closeEnemy = true;
                                break;
                            }
                        }

                        if (closeEnemy || closeEnemyWorkerCount > 1)
                        {
                            ExpandingBlockedUntilFrame = Bot.Main.Frame + 224;
                            BuildRequests[i]           = BuildRequests[BuildRequests.Count - 1];
                            BuildRequests.RemoveAt(BuildRequests.Count - 1);
                            if (buildRequest.worker != NaturalProbe)
                            {
                                IdleTask.Task.Add(buildRequest.worker);
                                units.Remove(buildRequest.worker);
                            }
                            DebugUtil.WriteLine("Base blocked, cancelling base. BuildRequest length: " + BuildRequests.Count);
                            continue;
                        }
                    }
                }
                foreach (Agent agent in bot.UnitManager.Agents.Values)
                {
                    if ((agent.Unit.UnitType == buildRequest.Type || (UnitTypes.GasGeysers.Contains(agent.Unit.UnitType) && UnitTypes.GasGeysers.Contains(buildRequest.Type))) &&
                        SC2Util.DistanceSq(agent.Unit.Pos, buildRequest.Pos) <= 1)
                    {
                        completed            = true;
                        agent.Base           = buildRequest.Base;
                        agent.AroundLocation = buildRequest.AroundLocation;
                        agent.Exact          = buildRequest.Exact;
                        break;
                    }
                }
                if (completed)
                {
                    BuildRequests[i] = BuildRequests[BuildRequests.Count - 1];
                    BuildRequests.RemoveAt(BuildRequests.Count - 1);
                    if (buildRequest.worker != NaturalProbe)
                    {
                        IdleTask.Task.Add(buildRequest.worker);
                        units.Remove(buildRequest.worker);
                    }
                }
                else if (!bot.UnitManager.Agents.ContainsKey(buildRequest.worker.Unit.Tag))
                {
                    buildRequest.worker = null;
                    UnassignedRequests.Add(buildRequest);
                    BuildRequests[i] = BuildRequests[BuildRequests.Count - 1];
                    BuildRequests.RemoveAt(BuildRequests.Count - 1);
                }
                else if (CancelBlockedBuildings && Unbuildable(buildRequest))
                {
                    BuildRequests[i] = BuildRequests[BuildRequests.Count - 1];
                    BuildRequests.RemoveAt(BuildRequests.Count - 1);
                    if (buildRequest.worker != NaturalProbe)
                    {
                        IdleTask.Task.Add(buildRequest.worker);
                        units.Remove(buildRequest.worker);
                    }
                }
                else if (buildRequest.worker.Unit.Orders.Count == 0 ||
                         buildRequest.worker.Unit.Orders[0].AbilityId != BuildingType.LookUp[buildRequest.Type].Ability ||
                         (buildRequest.worker.Unit.Orders[0].TargetWorldSpacePos != null && buildRequest.worker.Unit.Orders[0].TargetWorldSpacePos.X != buildRequest.Pos.X) ||
                         (buildRequest.worker.Unit.Orders[0].TargetWorldSpacePos != null && buildRequest.worker.Unit.Orders[0].TargetWorldSpacePos.Y != buildRequest.Pos.Y) ||
                         (buildRequest is BuildRequestGas && ((BuildRequestGas)buildRequest).Gas.Tag != buildRequest.worker.Unit.Orders[0].TargetUnitTag))
                {
                    Bot.Main.ReservedMinerals += BuildingType.LookUp[buildRequest.Type].Minerals;
                    Bot.Main.ReservedGas      += BuildingType.LookUp[buildRequest.Type].Gas;

                    if (buildRequest is BuildRequestGas)
                    {
                        bot.DrawLine(buildRequest.worker, ((BuildRequestGas)buildRequest).Gas.Pos);
                    }
                    else
                    {
                        bot.DrawLine(buildRequest.worker, SC2Util.Point(buildRequest.Pos.X, buildRequest.Pos.Y, buildRequest.worker.Unit.Pos.Z));
                    }
                    if (bot.Observation.Observation.PlayerCommon.Minerals < BuildingType.LookUp[buildRequest.Type].Minerals ||
                        bot.Observation.Observation.PlayerCommon.Vespene < BuildingType.LookUp[buildRequest.Type].Gas ||
                        buildRequest.worker.DistanceSq(buildRequest.Pos) >= 5)
                    {
                        Point2D target = buildRequest is BuildRequestGas?SC2Util.To2D(((BuildRequestGas)buildRequest).Gas.Pos) : buildRequest.Pos;

                        if (buildRequest.worker.DistanceSq(target) > 3 * 3)
                        {
                            buildRequest.worker.Order(Abilities.MOVE, new PotentialHelper(target, 1).To(buildRequest.worker.Unit.Pos).Get());
                            continue;
                        }
                    }

                    if (buildRequest is BuildRequestGas)
                    {
                        Unit gas = ((BuildRequestGas)buildRequest).Gas.Unit;
                        foreach (Unit unit in bot.Observation.Observation.RawData.Units)
                        {
                            if (SC2Util.DistanceSq(unit.Pos, ((BuildRequestGas)buildRequest).Gas.Pos) > 2 * 2)
                            {
                                continue;
                            }
                            gas = unit;
                            break;
                        }
                        buildRequest.worker.Order(BuildingType.LookUp[buildRequest.Type].Ability, gas.Tag);
                    }
                    else
                    {
                        buildRequest.worker.Order(BuildingType.LookUp[buildRequest.Type].Ability, buildRequest.Pos);
                    }
                }
            }

            foreach (BuildRequest request in UnassignedRequests)
            {
                Bot.Main.DrawText("BuildRequest: " + UnitTypes.LookUp[request.Type].Name + " " + request.Pos);
            }
            foreach (BuildRequest request in BuildRequests)
            {
                Bot.Main.DrawText("BuildRequest: " + UnitTypes.LookUp[request.Type].Name + " " + request.Pos);
            }
        }
Esempio n. 14
0
        public override bool DetermineAction(Agent agent, Point2D target)
        {
            if (agent.Unit.UnitType != UnitTypes.REAPER)
            {
                return(false);
            }

            if (agent.Unit.Health <= 15)
            {
                RegeneratingReapers.Add(agent.Unit.Tag);
            }

            if (agent.Unit.Health >= agent.Unit.HealthMax)
            {
                RegeneratingReapers.Remove(agent.Unit.Tag);
            }

            if (RegeneratingReapers.Contains(agent.Unit.Tag))
            {
                agent.Order(Abilities.MOVE, SC2Util.To2D(Tyr.Bot.MapAnalyzer.StartLocation));
                return(true);
            }
            foreach (Unit unit in Tyr.Bot.Enemies())
            {
                if (unit.UnitType != UnitTypes.BUNKER &&
                    unit.UnitType != UnitTypes.MARAUDER &&
                    unit.UnitType != UnitTypes.QUEEN &&
                    unit.UnitType != UnitTypes.SPINE_CRAWLER &&
                    unit.UnitType != UnitTypes.ZERGLING &&
                    unit.UnitType != UnitTypes.PHOTON_CANNON &&
                    unit.UnitType != UnitTypes.STALKER &&
                    unit.UnitType != UnitTypes.ZEALOT)
                {
                    continue;
                }
                int dist;
                if (unit.UnitType == UnitTypes.BUNKER || unit.UnitType == UnitTypes.SPINE_CRAWLER || unit.UnitType == UnitTypes.PHOTON_CANNON)
                {
                    dist = 12 * 12;
                }
                else if (unit.UnitType == UnitTypes.ZERGLING || unit.UnitType == UnitTypes.ZEALOT)
                {
                    dist = 5 * 5;
                }
                else
                {
                    dist = 10 * 10;
                }
                if (agent.DistanceSq(unit) < dist)
                {
                    if (unit.UnitType == UnitTypes.ZERGLING && agent.Unit.WeaponCooldown == 0)
                    {
                        return(false);
                    }

                    agent.Order(Abilities.MOVE, SC2Util.To2D(Tyr.Bot.MapAnalyzer.StartLocation));
                    return(true);
                }
            }

            if (agent.Unit.WeaponCooldown == 0)
            {
                return(false);
            }

            float distance   = 12 * 12;
            Unit  killTarget = null;

            foreach (Unit unit in Tyr.Bot.Enemies())
            {
                if (!UnitTypes.WorkerTypes.Contains(unit.UnitType))
                {
                    continue;
                }
                float newDist = agent.DistanceSq(unit);
                if (newDist >= distance)
                {
                    continue;
                }
                distance   = newDist;
                killTarget = unit;
            }

            if (killTarget != null)
            {
                if (distance >= 3 * 3)
                {
                    agent.Order(Abilities.MOVE, SC2Util.To2D(killTarget.Pos));
                }
                else
                {
                    agent.Order(Abilities.MOVE, agent.From(killTarget, 4));
                }
                return(true);
            }

            foreach (Unit unit in Tyr.Bot.Enemies())
            {
                if (UnitTypes.CanAttackGround(unit.UnitType) &&
                    agent.DistanceSq(unit) <= 5 * 5)
                {
                    return(false);
                }
            }


            foreach (Unit unit in Tyr.Bot.Enemies())
            {
                if (!UnitTypes.ResourceCenters.Contains(unit.UnitType))
                {
                    continue;
                }
                if (SC2Util.DistanceSq(unit.Pos, Tyr.Bot.MapAnalyzer.StartLocation) > 4)
                {
                    continue;
                }

                PotentialHelper potential = new PotentialHelper(unit.Pos);
                potential.Magnitude = 4;
                potential.From(Tyr.Bot.MapAnalyzer.StartLocation);
                Point2D targetLoc = potential.Get();

                if (agent.DistanceSq(targetLoc) < 4 * 4)
                {
                    return(false);
                }

                agent.Order(Abilities.MOVE, targetLoc);
                return(true);
            }

            return(false);
        }