Exemplo n.º 1
0
        public override void OnFrame(Tyr tyr)
        {
            TimingAttackTask.Task.RequiredSize = RequiredSize;
            TimingAttackTask.Task.UnitType     = UnitTypes.TEMPEST;

            tyr.buildingPlacer.BuildCompact = true;

            float Z = 0;

            foreach (Agent agent in tyr.Units())
            {
                Z = System.Math.Max(Z, agent.Unit.Pos.Z);
            }
            tyr.DrawSphere(new SC2APIProtocol.Point()
            {
                X = WallIn.Wall[3].Pos.X, Y = WallIn.Wall[3].Pos.Y, Z = Z
            });

            DefenseTask.GroundDefenseTask.MainDefenseRadius  = 40;
            DefenseTask.GroundDefenseTask.DrawDefenderRadius = 100;

            if (tyr.Frame % 224 == 0)
            {
                foreach (Agent agent in tyr.UnitManager.Agents.Values)
                {
                    if (agent.Unit.UnitType == UnitTypes.GATEWAY)
                    {
                        agent.Order(Abilities.MOVE, Natural.BaseLocation.Pos);
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void OnFrame(Tyr tyr)
        {
            tyr.DrawText("Replenishing scvs: " + Units.Count);
            List <Agent>            unassignedSCVs   = new List <Agent>();
            Dictionary <ulong, int> alreadyRepairing = new Dictionary <ulong, int>();

            foreach (Agent agent in Units)
            {
                tyr.DrawSphere(agent.Unit.Pos);
                if (RepairMap.ContainsKey(agent.Unit.Tag) &&
                    !NeedsRepairing.Contains(RepairMap[agent.Unit.Tag]))
                {
                    RepairMap.Remove(agent.Unit.Tag);
                }

                if (!RepairMap.ContainsKey(agent.Unit.Tag))
                {
                    unassignedSCVs.Add(agent);
                }
                else
                {
                    if (!alreadyRepairing.ContainsKey(RepairMap[agent.Unit.Tag]))
                    {
                        alreadyRepairing.Add(RepairMap[agent.Unit.Tag], 1);
                    }
                    else
                    {
                        alreadyRepairing[RepairMap[agent.Unit.Tag]]++;
                    }
                }
            }

            foreach (ulong tag in NeedsRepairing)
            {
                if (!alreadyRepairing.ContainsKey(tag))
                {
                    alreadyRepairing[tag] = 0;
                }
                while (alreadyRepairing[tag] == 0 &&
                       unassignedSCVs.Count > 0)
                {
                    alreadyRepairing[tag]++;
                    RepairMap.Add(unassignedSCVs[unassignedSCVs.Count - 1].Unit.Tag, tag);
                    unassignedSCVs.RemoveAt(unassignedSCVs.Count - 1);
                }
            }

            for (int i = unassignedSCVs.Count - 1; i >= 0; i--)
            {
                IdleTask.Task.Add(unassignedSCVs[i]);
                Units.Remove(unassignedSCVs[i]);
            }

            foreach (Agent agent in Units)
            {
                tyr.DrawLine(agent, tyr.UnitManager.Agents[RepairMap[agent.Unit.Tag]].Unit.Pos);
                agent.Order(Abilities.MOVE, RepairMap[agent.Unit.Tag]);
            }
        }
Exemplo n.º 3
0
        public override void OnFrame(Tyr tyr)
        {
            Point2D targetLocation  = GetTarget();
            bool    starportsRemain = false;

            /*
             * foreach (Unit unit in tyr.Enemies())
             *  if (unit.UnitType == UnitTypes.STARPORT)
             *  {
             *      starportsRemain = true;
             *      Search = true;
             *      break;
             *  }
             */
            tyr.DrawText("Search: " + Search);
            tyr.DrawSphere(targetLocation);
            foreach (Agent agent in units)
            {
                Unit target = Targetting.GetTarget(agent);
                if (Search)
                {
                    if (target != null && (target.UnitType == UnitTypes.STARPORT ||
                                           (UnitTypes.AirAttackTypes.Contains(target.UnitType) && agent.DistanceSq(target) <= 15 * 15)))
                    {
                        agent.Order(Abilities.ATTACK, target.Tag);
                        tyr.DrawLine(agent.Unit.Pos, target.Pos);
                    }
                    else
                    {
                        agent.Order(Abilities.MOVE, targetLocation);
                    }

                    if (agent.DistanceSq(targetLocation) <= 4 * 4 && !starportsRemain)
                    {
                        Search = false;
                    }
                }
                else
                {
                    if (target != null)
                    {
                        agent.Order(Abilities.ATTACK, target.Tag);
                        tyr.DrawLine(agent.Unit.Pos, target.Pos);
                    }
                    else
                    {
                        agent.Order(Abilities.ATTACK, targetLocation);
                    }
                }
            }
        }
Exemplo n.º 4
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))
                {
                    if (tyr.UnitManager.Agents.ContainsKey(b.ResourceCenter.Unit.Tag))
                    {
                        b.ResourceCenter = tyr.UnitManager.Agents[b.ResourceCenter.Unit.Tag];
                    }
                    else
                    {
                        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;
                            break;
                        }
                    }
                }

                if (b.ResourceCenter == null)
                {
                    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.DistanceGrid(unit.Pos, b.BaseLocation.Pos) <= 15)
                    {
                        b.BaseLocation.MineralFields.Add(new MineralField()
                        {
                            Pos = unit.Pos, Tag = unit.Tag
                        });
                    }
                    else if (UnitTypes.GasGeysers.Contains(unit.UnitType) &&
                             SC2Util.DistanceGrid(unit.Pos, b.BaseLocation.Pos) <= 15)
                    {
                        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;
                foreach (Unit enemy in tyr.Enemies())
                {
                    if (!UnitTypes.CombatUnitTypes.Contains(enemy.UnitType))
                    {
                        continue;
                    }
                    if (SC2Util.DistanceSq(enemy.Pos, b.BaseLocation.Pos) <= 15 * 15)
                    {
                        b.UnderAttack = true;
                        break;
                    }
                }
            }
        }
Exemplo n.º 5
0
        public override void OnFrame(Tyr tyr)
        {
            if (Count(UnitTypes.PROBE) <= 10)
            {
                GasWorkerTask.WorkersPerGas = 0;
            }
            else if (Count(UnitTypes.NEXUS) < 3)
            {
                GasWorkerTask.WorkersPerGas = 2;
            }
            else
            {
                BalanceGas();
            }

            if (!CannonDefenseDetected && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.PHOTON_CANNON) + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.FORGE) >= 0 && tyr.Frame < 22.4 * 60 * 4)
            {
                CannonDefenseDetected = true;
            }

            if (!TempestDetected && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.TEMPEST) > 0)
            {
                TempestDetected = true;
            }

            MechDestroyExpandsTask.Task.MaxSize      = 3;
            MechDestroyExpandsTask.Task.RequiredSize = 3;
            MechDestroyExpandsTask.Task.RetreatSize  = 0;
            MechDestroyExpandsTask.Task.UnitType     = UnitTypes.ZEALOT;
            MechDestroyExpandsTask.Task.Stopped      = !CannonDefenseDetected;

            tyr.NexusAbilityManager.PriotitizedAbilities.Add(917);

            if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.BATTLECRUISER) > 0)
            {
                BattlecruisersDetected = true;
            }

            if (TempestDetected)
            {
                AttackTask.RequiredSize = 25;
                AttackTask.RetreatSize  = 8;
            }
            else
            {
                AttackTask.RequiredSize = 25;
                AttackTask.RetreatSize  = 8;
            }

            if (Count(UnitTypes.ZEALOT) + Count(UnitTypes.ADEPT) + Count(UnitTypes.STALKER) + Count(UnitTypes.IMMORTAL) >= AttackTask.RequiredSize)
            {
                Attacking = true;
            }

            foreach (WallBuilding building in WallIn.Wall)
            {
                tyr.DrawSphere(new Point()
                {
                    X = building.Pos.X, Y = building.Pos.Y, Z = tyr.MapAnalyzer.StartLocation.Z
                });
            }

            foreach (WorkerDefenseTask task in WorkerDefenseTask.Tasks)
            {
                task.Stopped = Completed(UnitTypes.ZEALOT) >= 5;
            }

            if (tyr.EnemyStrategyAnalyzer.CannonRushDetected)
            {
                AttackTask.RequiredSize = 5;
            }
            else if (SmellCheese)
            {
                AttackTask.RequiredSize = 30;
            }

            if (Natural.Owner == tyr.PlayerId && Count(UnitTypes.NEXUS) < 3 && Completed(UnitTypes.STALKER) < 15)
            {
                IdleTask.Task.OverrideTarget = SC2Util.Point((tyr.MapAnalyzer.GetMainRamp().X + Natural.BaseLocation.Pos.X) / 2f, (tyr.MapAnalyzer.GetMainRamp().Y + Natural.BaseLocation.Pos.Y) / 2f);
            }
            else if (Count(UnitTypes.NEXUS) >= 4)
            {
                IdleTask.Task.OverrideTarget = OverrideDefenseTarget;
            }
            else
            {
                IdleTask.Task.OverrideTarget = null;
            }

            DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 25;
            DefenseTask.GroundDefenseTask.MainDefenseRadius   = 30;
            DefenseTask.GroundDefenseTask.MaxDefenseRadius    = 120;
            DefenseTask.GroundDefenseTask.DrawDefenderRadius  = 80;


            if (TempestDetected && Count(UnitTypes.STALKER) + Count(UnitTypes.VOID_RAY) >= 12)
            {
                DefenseTask.AirDefenseTask.ExpandDefenseRadius = 40;
                DefenseTask.AirDefenseTask.MainDefenseRadius   = 40;
                DefenseTask.AirDefenseTask.MaxDefenseRadius    = 120;
                DefenseTask.AirDefenseTask.DrawDefenderRadius  = 80;
            }
            else
            {
                DefenseTask.AirDefenseTask.ExpandDefenseRadius = 25;
                DefenseTask.AirDefenseTask.MainDefenseRadius   = 30;
                DefenseTask.AirDefenseTask.MaxDefenseRadius    = 120;
                DefenseTask.AirDefenseTask.DrawDefenderRadius  = 80;
            }

            if (Tyr.Bot.EnemyStrategyAnalyzer.EarlyPool && !Tyr.Bot.EnemyStrategyAnalyzer.Expanded && Completed(UnitTypes.ZEALOT) < 2)
            {
                foreach (Agent agent in tyr.UnitManager.Agents.Values)
                {
                    if (agent.Unit.UnitType == UnitTypes.NEXUS &&
                        agent.Unit.BuildProgress < 0.99)
                    {
                        agent.Order(Abilities.CANCEL);
                    }
                }
            }
        }
Exemplo n.º 6
0
        public override void OnFrame(Tyr tyr)
        {
            BalanceGas();

            TimedObserverTask.Target  = tyr.TargetManager.PotentialEnemyStartLocations[0];
            TimedObserverTask.Stopped = tyr.Frame < 22.4 * 60 * 6 || tyr.Frame >= 22.4 * 60 * 7 || tyr.EnemyStrategyAnalyzer.Count(UnitTypes.SPIRE) > 0;
            if (TimedObserverTask.Stopped)
            {
                TimedObserverTask.Clear();
            }

            if (Count(UnitTypes.ZEALOT) + Count(UnitTypes.ADEPT) + Count(UnitTypes.STALKER) + Count(UnitTypes.IMMORTAL) >= attackTask.RequiredSize)
            {
                Attacking = true;
            }

            foreach (WallBuilding building in WallIn.Wall)
            {
                tyr.DrawSphere(new Point()
                {
                    X = building.Pos.X, Y = building.Pos.Y, Z = tyr.MapAnalyzer.StartLocation.Z
                });
            }

            foreach (WorkerDefenseTask task in WorkerDefenseTask.Tasks)
            {
                task.Stopped = Completed(UnitTypes.ZEALOT) >= 5;
            }

            /*
             * foreach (Agent agent in tyr.UnitManager.Agents.Values)
             *  if (agent.Unit.UnitType == UnitTypes.PROBE && agent.CurrentAbility() == 883)
             *      System.Console.WriteLine("Building gateway at: " + agent.Unit.Orders[0].TargetWorldSpacePos);
             */
            if (Tyr.Bot.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ZERGLING) >= 5 && tyr.Frame <= 22.4 * 60 * 2)
            {
                SmellCheese = true;
            }
            if (Tyr.Bot.EnemyStrategyAnalyzer.Count(UnitTypes.SPAWNING_POOL) > 0 && tyr.Frame <= 22.4 * 60 * 1.4 && !tyr.EnemyStrategyAnalyzer.Expanded)
            {
                SmellCheese = true;
            }
            if (!SpinePushDetected && SmellCheese)
            {
                foreach (Unit enemy in tyr.Enemies())
                {
                    if (enemy.UnitType != UnitTypes.QUEEN && enemy.UnitType != UnitTypes.SPINE_CRAWLER && enemy.UnitType != UnitTypes.SPINE_CRAWLER_UPROOTED)
                    {
                        continue;
                    }
                    if (SC2Util.DistanceSq(enemy.Pos, tyr.MapAnalyzer.StartLocation) <= 50 * 50)
                    {
                        SpinePushDetected = true;
                        break;
                    }
                }
            }

            FearSpinesController.Stopped = !SpinePushDetected;

            if (tyr.EnemyRace == Race.Zerg)
            {
                if (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.MUTALISK)
                    + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.BROOD_LORD)
                    + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.CORRUPTOR)
                    + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.SPIRE)
                    + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.GREATER_SPIRE) > 0)
                {
                    DesiredStalkers = 15;
                }
                else
                {
                    DesiredStalkers = 2;
                }
            }

            if (tyr.EnemyStrategyAnalyzer.CannonRushDetected)
            {
                attackTask.RequiredSize = 5;
            }
            else if (SmellCheese)
            {
                attackTask.RequiredSize = 30;
            }

            if (Count(UnitTypes.NEXUS) >= 3)
            {
                IdleTask.Task.OverrideTarget = OverrideDefenseTarget;
            }
            else
            {
                IdleTask.Task.OverrideTarget = null;
            }

            DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 25;
            DefenseTask.GroundDefenseTask.MainDefenseRadius   = 30;
            DefenseTask.GroundDefenseTask.MaxDefenseRadius    = 120;
            DefenseTask.GroundDefenseTask.DrawDefenderRadius  = 80;

            DefenseTask.AirDefenseTask.ExpandDefenseRadius = 25;
            DefenseTask.AirDefenseTask.MainDefenseRadius   = 30;
            DefenseTask.AirDefenseTask.MaxDefenseRadius    = 120;
            DefenseTask.AirDefenseTask.DrawDefenderRadius  = 80;

            if (Tyr.Bot.EnemyStrategyAnalyzer.EarlyPool && !Tyr.Bot.EnemyStrategyAnalyzer.Expanded && Completed(UnitTypes.ZEALOT) < 2)
            {
                foreach (Agent agent in tyr.UnitManager.Agents.Values)
                {
                    if (agent.Unit.UnitType == UnitTypes.NEXUS &&
                        agent.Unit.BuildProgress < 0.99)
                    {
                        agent.Order(Abilities.CANCEL);
                    }
                }
            }
        }
Exemplo n.º 7
0
        public override void OnFrame(Tyr tyr)
        {
            WorkerTask.Task.EvacuateThreatenedBases = true;

            foreach (Agent agent in tyr.UnitManager.Agents.Values)
            {
                if (tyr.Frame % 224 != 0)
                {
                    break;
                }
                if (agent.Unit.UnitType != UnitTypes.GATEWAY)
                {
                    continue;
                }

                if (Count(UnitTypes.NEXUS) < 2 && TimingAttackTask.Task.Units.Count == 0)
                {
                    agent.Order(Abilities.MOVE, Main.BaseLocation.Pos);
                }
                else
                {
                    agent.Order(Abilities.MOVE, tyr.TargetManager.PotentialEnemyStartLocations[0]);
                }
            }

            if (TotalEnemyCount(UnitTypes.ZEALOT) >= 3 || EnemyCount(UnitTypes.PHOTON_CANNON) > 0)
            {
                KillImmortals.Stopped = true;
                KillStalkers.Stopped  = true;
                KillRobos.Stopped     = true;
            }
            else
            {
                KillImmortals.Stopped = false;
                KillStalkers.Stopped  = false;
                KillRobos.Stopped     = false;
            }

            EnemyArmy = System.Math.Max(EnemyArmy, EnemyCount(UnitTypes.ZEALOT) + EnemyCount(UnitTypes.STALKER));
            tyr.DrawText("Enemy army: " + EnemyArmy);

            if (EnemyCount(UnitTypes.PHOENIX) <= 3)
            {
                DefenseTask.AirDefenseTask.IgnoreEnemyTypes.Add(UnitTypes.PHOENIX);
            }
            else
            {
                DefenseTask.AirDefenseTask.IgnoreEnemyTypes.Remove(UnitTypes.PHOENIX);
            }

            if (tyr.EnemyStrategyAnalyzer.WorkerRushDetected &&
                Count(UnitTypes.ZEALOT) < 2)
            {
                GasWorkerTask.WorkersPerGas = 0;
            }
            else
            {
                BalanceGas();
            }

            if (TotalEnemyCount(UnitTypes.FORGE) > 0 && tyr.Frame <= 22.4 * 60 * 2)
            {
                EarlyForgeDetected = true;
            }

            ScoutTask.Task.ScoutType = UnitTypes.PHOENIX;
            ScoutTask.Task.Target    = tyr.TargetManager.PotentialEnemyStartLocations[0];

            if (CannonDefenseDetected &&
                TotalEnemyCount(UnitTypes.STARGATE) + TotalEnemyCount(UnitTypes.DARK_SHRINE) + TotalEnemyCount(UnitTypes.VOID_RAY) == 0)
            {
                foreach (Agent agent in tyr.Units())
                {
                    if (agent.Unit.UnitType != UnitTypes.SENTRY)
                    {
                        continue;
                    }
                    if (agent.Unit.Energy < 75)
                    {
                        continue;
                    }
                    // Hallucinate scouting phoenix.
                    agent.Order(154);
                }
            }

            if (!VoidraysDetected && TotalEnemyCount(UnitTypes.VOID_RAY) > 0)
            {
                VoidraysDetected = true;
                if (TimingAttackTask.Task.Units.Count < 12)
                {
                    TimingAttackTask.Task.Clear();
                }
            }

            if (!ZealotRushSuspected && !tyr.EnemyStrategyAnalyzer.WorkerRushDetected)
            {
                if ((Tyr.Bot.Frame >= 22.4 * 60 * 1.5 &&
                     !Tyr.Bot.EnemyStrategyAnalyzer.NoProxyGatewayConfirmed &&
                     TotalEnemyCount(UnitTypes.ASSIMILATOR) + TotalEnemyCount(UnitTypes.CYBERNETICS_CORE) == 0) ||
                    (Tyr.Bot.Frame < 22.4 * 60 * 1.5 && Tyr.Bot.EnemyStrategyAnalyzer.ThreeGateDetected))
                {
                    ZealotRushSuspected = true;
                }
            }

            if (!LowGroundCannons)
            {
                foreach (Unit enemy in tyr.Enemies())
                {
                    if (enemy.UnitType != UnitTypes.PHOTON_CANNON)
                    {
                        continue;
                    }
                    if (tyr.MapAnalyzer.MapHeight((int)enemy.Pos.X, (int)enemy.Pos.Y) < tyr.MapAnalyzer.MapHeight((int)tyr.TargetManager.PotentialEnemyStartLocations[0].X, (int)tyr.TargetManager.PotentialEnemyStartLocations[0].Y))
                    {
                        LowGroundCannons = true;
                        break;
                    }
                }
            }

            if (!CannonDefenseDetected &&
                TotalEnemyCount(UnitTypes.PHOTON_CANNON) + TotalEnemyCount(UnitTypes.FORGE) > 0 &&
                tyr.Frame < 22.4 * 60 * 4 &&
                (EarlyForgeDetected || tyr.EnemyStrategyAnalyzer.Expanded || LowGroundCannons))
            {
                CannonDefenseDetected = true;
                if (TimingAttackTask.Task.Units.Count < 12)
                {
                    TimingAttackTask.Task.Clear();
                }
            }

            if (tyr.EnemyStrategyAnalyzer.WorkerRushDetected &&
                Count(UnitTypes.ZEALOT) < 2)
            {
                foreach (Agent agent in tyr.UnitManager.Agents.Values)
                {
                    if (agent.Unit.UnitType == UnitTypes.ASSIMILATOR &&
                        agent.Unit.BuildProgress < 0.99)
                    {
                        agent.Order(Abilities.CANCEL);
                    }
                }
            }

            tyr.TargetManager.TargetCannons = true;
            if (ZealotRushSuspected)
            {
                tyr.TargetManager.TargetGateways = true;
                WorkerScoutTask.Task.Stopped     = true;
                WorkerScoutTask.Task.Clear();
            }

            if (WorkerScoutTask.Task.BaseCircled())
            {
                WorkerScoutTask.Task.Stopped = true;
                WorkerScoutTask.Task.Clear();
            }

            if (ZealotRushSuspected ||
                Completed(UnitTypes.IMMORTAL) > 0)
            {
                foreach (WorkerDefenseTask task in WorkerDefenseTask.Tasks)
                {
                    task.Stopped = true;
                    task.Clear();
                }
            }

            if (ZealotRushSuspected && Completed(UnitTypes.STALKER) >= 12)
            {
                foreach (Agent agent in tyr.Units())
                {
                    if (agent.Unit.UnitType != UnitTypes.GATEWAY)
                    {
                        continue;
                    }
                    if (agent.DistanceSq(WallIn.Wall[2].Pos) >= 2)
                    {
                        continue;
                    }
                    KillOwnUnitTask.Task.TargetTag = agent.Unit.Tag;
                    break;
                }
            }

            WorkerScoutTask.Task.StartFrame = 600;
            ObserverScoutTask.Task.Priority = 6;

            tyr.NexusAbilityManager.Stopped = Count(UnitTypes.STALKER) == 0 && tyr.Frame >= 120 * 22.4;
            tyr.NexusAbilityManager.PriotitizedAbilities.Add(917);

            if (EnemyExpandFrame >= 1000000 &&
                tyr.EnemyStrategyAnalyzer.Expanded)
            {
                EnemyExpandFrame = tyr.Frame;
            }

            if (EnemyExpandFrame < 3 * 60 * 22.4)
            {
                EarlyExpand = true;
            }

            if (VoidraysDetected ||
                (TotalEnemyCount(UnitTypes.PHOTON_CANNON) + TotalEnemyCount(UnitTypes.FORGE) > 0 && !LowGroundCannons && !EarlyExpand))
            {
                TimingAttackTask.Task.RequiredSize = 24;
            }
            else if (ZealotRushSuspected ||
                     (CannonDefenseDetected && EarlyExpand))
            {
                TimingAttackTask.Task.RequiredSize = 12;
            }
            else
            {
                TimingAttackTask.Task.RequiredSize = 4;
            }
            TimingAttackTask.Task.RetreatSize = 0;

            if (EnemyCount(UnitTypes.ZEALOT) + EnemyCount(UnitTypes.STALKER) >= 6 &&
                tyr.Frame < 22.4 * 60 * 5)
            {
                CancelElevator = true;
                WarpPrismElevatorTask.Task.Cancelled = true;
            }
            if (EnemyCount(UnitTypes.IMMORTAL)
                + EnemyCount(UnitTypes.VOID_RAY) > 0)
            {
                CancelElevator = true;
                WarpPrismElevatorTask.Task.Cancelled = true;
            }

            if (TotalEnemyCount(UnitTypes.PHOTON_CANNON) + TotalEnemyCount(UnitTypes.FORGE) > 0 &&
                !LowGroundCannons &&
                !EarlyExpand &&
                TimingAttackTask.Task.Units.Count < 18 &&
                TimingAttackTask.Task.RequiredSize > 18)
            {
                TimingAttackTask.Task.Clear();
            }

            if (CannonDefenseDetected && !CancelElevator)
            {
                TimingAttackTask.Task.Stopped = true;
                TimingAttackTask.Task.Clear();
                ShieldRegenTask.Task.Stopped = true;
                ShieldRegenTask.Task.Clear();
                WarpPrismElevatorTask.Task.Stopped   = false;
                tyr.TargetManager.PrefferDistant     = false;
                tyr.TargetManager.TargetAllBuildings = true;
                PotentialHelper potential = new PotentialHelper(tyr.TargetManager.PotentialEnemyStartLocations[0], 6);
                potential.From(tyr.MapAnalyzer.GetEnemyRamp());
                StutterController.Toward = potential.Get();
                tyr.DrawSphere(new Point()
                {
                    X = StutterController.Toward.X, Y = StutterController.Toward.Y, Z = tyr.MapAnalyzer.StartLocation.Z
                });
                EvadeCannonsController.Stopped    = Completed(UnitTypes.STALKER) + Completed(UnitTypes.IMMORTAL) >= 12;
                EvadeCannonsController.FleeToward = StutterController.Toward;
                FallBackController.Stopped        = true;
            }
            else
            {
                TimingAttackTask.Task.Stopped        = false;
                WarpPrismElevatorTask.Task.Stopped   = true;
                tyr.TargetManager.PrefferDistant     = true;
                ShieldRegenTask.Task.Stopped         = false;
                tyr.TargetManager.TargetAllBuildings = false;
                StutterController.Toward             = null;
                EvadeCannonsController.Stopped       = true;
                FallBackController.Stopped           = ZealotRushSuspected;
            }

            ForwardProbeTask.Task.Stopped =
                Completed(UnitTypes.STALKER) + Count(UnitTypes.ADEPT) + Completed(UnitTypes.IMMORTAL) < Math.Max(8, TimingAttackTask.Task.RequiredSize) &&
                (!CannonDefenseDetected || !StargateDetected || EarlyExpand);

            if (ForwardProbeTask.Task.Stopped)
            {
                ForwardProbeTask.Task.Clear();
            }


            if (Count(UnitTypes.NEXUS) <= 1)
            {
                IdleTask.Task.OverrideTarget = OverrideMainDefenseTarget;
            }
            else if (Count(UnitTypes.NEXUS) >= 3)
            {
                IdleTask.Task.OverrideTarget = OverrideDefenseTarget;
            }
            else
            {
                IdleTask.Task.OverrideTarget = null;
            }

            if (ZealotRushSuspected)
            {
                DefenseTask.GroundDefenseTask.BufferZone          = 0;
                DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 20;
                DefenseTask.GroundDefenseTask.MainDefenseRadius   = 20;
                DefenseTask.GroundDefenseTask.MaxDefenseRadius    = 120;
                DefenseTask.GroundDefenseTask.DrawDefenderRadius  = 80;
            }
            else
            {
                DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 30;
                DefenseTask.GroundDefenseTask.MainDefenseRadius   = 30;
                DefenseTask.GroundDefenseTask.MaxDefenseRadius    = 120;
                DefenseTask.GroundDefenseTask.DrawDefenderRadius  = 80;
            }

            if (TotalEnemyCount(UnitTypes.TEMPEST) > 0)
            {
                DefenseTask.AirDefenseTask.ExpandDefenseRadius = 50;
                DefenseTask.AirDefenseTask.MainDefenseRadius   = 50;
                DefenseTask.AirDefenseTask.MaxDefenseRadius    = 120;
                DefenseTask.AirDefenseTask.DrawDefenderRadius  = 80;
            }
            else
            {
                DefenseTask.AirDefenseTask.ExpandDefenseRadius = 30;
                DefenseTask.AirDefenseTask.MainDefenseRadius   = 30;
                DefenseTask.AirDefenseTask.MaxDefenseRadius    = 120;
                DefenseTask.AirDefenseTask.DrawDefenderRadius  = 80;
            }

            //EarlyNexus = CannonDefenseDetected;
            EarlyNexus = false;

            StargateDetected = TotalEnemyCount(UnitTypes.STARGATE)
                               + TotalEnemyCount(UnitTypes.VOID_RAY)
                               + TotalEnemyCount(UnitTypes.PHOENIX)
                               + TotalEnemyCount(UnitTypes.TEMPEST)
                               + TotalEnemyCount(UnitTypes.CARRIER)
                               + TotalEnemyCount(UnitTypes.FLEET_BEACON) > 0;
        }
Exemplo n.º 8
0
        public override void OnFrame(Tyr tyr)
        {
            BalanceGas();

            tyr.NexusAbilityManager.PriotitizedAbilities.Add(917);

            if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.BATTLECRUISER) > 0)
            {
                BattlecruisersDetected = true;
            }

            if (tyr.EnemyStrategyAnalyzer.FourRaxDetected)
            {
                FourRaxSuspected = true;
            }
            if (!FourRaxSuspected)
            {
                Point2D enemyRamp             = tyr.MapAnalyzer.GetEnemyRamp();
                int     enemyBarrackWallCount = 0;
                foreach (Unit enemy in tyr.Enemies())
                {
                    if (enemyRamp == null)
                    {
                        break;
                    }
                    if (enemy.UnitType == UnitTypes.BARRACKS && SC2Util.DistanceSq(enemy.Pos, enemyRamp) <= 5.5 * 5.5)
                    {
                        enemyBarrackWallCount++;
                    }
                }
                if (enemyBarrackWallCount >= 2)
                {
                    WorkerScoutTask.Stopped = true;
                    WorkerScoutTask.Clear();
                    FourRaxSuspected = true;
                }
            }

            if (BattlecruisersDetected ||
                (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.WIDOW_MINE) >= 12 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.MARINE) < 80))
            {
                attackTask.RequiredSize = 30;
                attackTask.RetreatSize  = 8;
            }
            else
            {
                attackTask.RequiredSize = 50;
                attackTask.RetreatSize  = 15;
            }

            if (Count(UnitTypes.ZEALOT) + Count(UnitTypes.ADEPT) + Count(UnitTypes.STALKER) + Count(UnitTypes.IMMORTAL) >= attackTask.RequiredSize)
            {
                Attacking = true;
            }

            foreach (WallBuilding building in WallIn.Wall)
            {
                tyr.DrawSphere(new Point()
                {
                    X = building.Pos.X, Y = building.Pos.Y, Z = tyr.MapAnalyzer.StartLocation.Z
                });
            }

            foreach (WorkerDefenseTask task in WorkerDefenseTask.Tasks)
            {
                task.Stopped = Completed(UnitTypes.ZEALOT) >= 5;
            }


            foreach (DefenseSquadTask task in StalkerDefenseSquads)
            {
                task.Stopped      = (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.REAPER) < 3 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.BANSHEE) == 0 || tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.MARINE) + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.MARAUDER) >= 10);
                task.MaxDefenders = Math.Min(5, Completed(UnitTypes.STALKER) / Math.Max(1, Count(UnitTypes.NEXUS)));
                task.Priority     = 10;
            }

            if (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.REAPER) >= 3 || tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.BANSHEE) > 0)
            {
                DefenseTask.AirDefenseTask.IgnoreEnemyTypes.Add(UnitTypes.VIKING_FIGHTER);
                DefenseTask.GroundDefenseTask.IgnoreEnemyTypes.Add(UnitTypes.REAPER);
                tyr.buildingPlacer.SpreadCannons = true;
                attackTask.DefendOtherAgents     = false;
            }

            FearSpinesController.Stopped = !SpinePushDetected;

            if (tyr.EnemyRace == Race.Zerg)
            {
                if (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.MUTALISK)
                    + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.BROOD_LORD)
                    + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.CORRUPTOR)
                    + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.SPIRE)
                    + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.GREATER_SPIRE) > 0)
                {
                    DesiredStalkers = 15;
                }
                else
                {
                    DesiredStalkers = 2;
                }
            }

            if (tyr.EnemyStrategyAnalyzer.CannonRushDetected)
            {
                attackTask.RequiredSize = 5;
            }
            else if (SmellCheese)
            {
                attackTask.RequiredSize = 30;
            }

            if (Count(UnitTypes.NEXUS) >= 3)
            {
                IdleTask.Task.OverrideTarget = OverrideDefenseTarget;
            }
            else
            {
                IdleTask.Task.OverrideTarget = null;
            }

            DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 30;
            DefenseTask.GroundDefenseTask.MainDefenseRadius   = 30;
            DefenseTask.GroundDefenseTask.MaxDefenseRadius    = 120;
            DefenseTask.GroundDefenseTask.DrawDefenderRadius  = 80;

            DefenseTask.AirDefenseTask.ExpandDefenseRadius = 30;
            DefenseTask.AirDefenseTask.MainDefenseRadius   = 30;
            DefenseTask.AirDefenseTask.MaxDefenseRadius    = 120;
            DefenseTask.AirDefenseTask.DrawDefenderRadius  = 80;

            if (Tyr.Bot.EnemyStrategyAnalyzer.EarlyPool && !Tyr.Bot.EnemyStrategyAnalyzer.Expanded && Completed(UnitTypes.ZEALOT) < 2)
            {
                foreach (Agent agent in tyr.UnitManager.Agents.Values)
                {
                    if (agent.Unit.UnitType == UnitTypes.NEXUS &&
                        agent.Unit.BuildProgress < 0.99)
                    {
                        agent.Order(Abilities.CANCEL);
                    }
                }
            }
        }
Exemplo n.º 9
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]);
                }
            }
        }
Exemplo n.º 10
0
        public override void OnFrame(Tyr tyr)
        {
            if (WarpPrism != null)
            {
                bool warpPrismAlive = false;
                foreach (Agent agent in Units)
                {
                    if (agent.Unit.Tag == WarpPrism.Unit.Tag)
                    {
                        warpPrismAlive = true;
                        break;
                    }
                }
                if (!warpPrismAlive)
                {
                    WarpPrism = null;
                }
            }

            if (Cancelled)
            {
                for (int i = Units.Count - 1; i >= 0; i--)
                {
                    if (!DroppedUnits.Contains(Units[i].Unit.Tag) &&
                        Units[i].Unit.UnitType != UnitTypes.WARP_PRISM)
                    {
                        ClearAt(i);
                    }
                }
            }

            if (EnemyThird == null && tyr.TargetManager.PotentialEnemyStartLocations.Count == 1)
            {
                Point2D enemyNatural = tyr.MapAnalyzer.GetEnemyNatural().Pos;
                Point2D enemyMain    = tyr.TargetManager.PotentialEnemyStartLocations[0];
                Point2D enemyRamp    = tyr.MapAnalyzer.GetEnemyRamp();
                float   dist         = 1000000;
                foreach (BaseLocation loc in tyr.MapAnalyzer.BaseLocations)
                {
                    if (SC2Util.DistanceSq(loc.Pos, enemyNatural) <= 2 * 2)
                    {
                        continue;
                    }
                    float mainDist = SC2Util.DistanceSq(loc.Pos, enemyMain);
                    if (mainDist <= 2 * 2)
                    {
                        continue;
                    }
                    if (mainDist > 50 * 50)
                    {
                        continue;
                    }
                    //float newDist = SC2Util.DistanceSq(loc.Pos, enemyRamp);
                    if (mainDist > dist)
                    {
                        continue;
                    }
                    dist       = mainDist;
                    EnemyThird = loc.Pos;
                }
                PotentialHelper potential;
                dist = 25 * 25;
                for (int x = 0; x < tyr.MapAnalyzer.EnemyDistances.GetLength(0); x++)
                {
                    for (int y = 0; y < tyr.MapAnalyzer.EnemyDistances.GetLength(1); y++)
                    {
                        if (tyr.MapAnalyzer.EnemyDistances[x, y] > 30)
                        {
                            continue;
                        }

                        Point2D point = new Point2D()
                        {
                            X = x, Y = y
                        };
                        float newDist = SC2Util.DistanceSq(point, EnemyThird);
                        if (newDist > dist)
                        {
                            continue;
                        }
                        dist = newDist;

                        StagingArea = new PotentialHelper(point, 1)
                                      .To(tyr.TargetManager.PotentialEnemyStartLocations[0])
                                      .Get();
                    }
                }

                potential = new PotentialHelper(StagingArea, 7f);
                potential.From(tyr.TargetManager.PotentialEnemyStartLocations[0]);
                LoadArea = potential.Get();
            }

            if (StagingArea != null)
            {
                tyr.DrawSphere(new Point()
                {
                    X = StagingArea.X, Y = StagingArea.Y, Z = tyr.MapAnalyzer.StartLocation.Z
                });
            }

            if (units.Count == 0)
            {
                return;
            }

            if (WarpPrism == null)
            {
                foreach (Agent agent in units)
                {
                    if (agent.Unit.UnitType == UnitTypes.WARP_PRISM)
                    {
                        WarpPrism = agent;
                        break;
                    }
                }
            }
            OrderWarpPrism();
            foreach (Agent agent in units)
            {
                if (WarpPrism != null && agent.Unit.Tag == WarpPrism.Unit.Tag)
                {
                    continue;
                }
                if (agent.Unit.IsFlying)
                {
                    DroppedUnits.Add(agent.Unit.Tag);
                }
                if (DroppedUnits.Contains(agent.Unit.Tag))
                {
                    Attack(agent, tyr.TargetManager.AttackTarget);
                }
                else if (WarpPrismInPlace)
                {
                    Attack(agent, LoadArea);
                }
                else
                {
                    Attack(agent, EnemyThird);
                }
            }
        }
Exemplo n.º 11
0
        public override void OnFrame(Tyr tyr)
        {
            foreach (Agent agent in tyr.UnitManager.Agents.Values)
            {
                if (agent.Unit.UnitType != UnitTypes.CREEP_TUMOR_BURROWED)
                {
                    continue;
                }
                if (!BurrowFrames.ContainsKey(agent.Unit.Tag))
                {
                    BurrowFrames.Add(agent.Unit.Tag, tyr.Frame);
                }

                if (tyr.Frame - BurrowFrames[agent.Unit.Tag] < 336 &&
                    tyr.Frame - BurrowFrames[agent.Unit.Tag] >= 224)
                {
                    Point2D aroundLoc = tyr.MapAnalyzer.Walk(SC2Util.To2D(agent.Unit.Pos), tyr.MapAnalyzer.EnemyDistances, 9);
                    Point2D finalLoc  = tyr.buildingPlacer.FindPlacementLocal(aroundLoc, SC2Util.Point(1, 1), UnitTypes.CREEP_TUMOR, 10, SC2Util.To2D(agent.Unit.Pos), 9);
                    if (finalLoc != null)
                    {
                        agent.Order(1733, finalLoc);
                    }
                }
            }

            if (Tyr.Bot.Build.Count(UnitTypes.CREEP_TUMOR) + Tyr.Bot.Build.Count(UnitTypes.CREEP_TUMOR_QUEEN) + Tyr.Bot.Build.Count(UnitTypes.CREEP_TUMOR_BURROWED) >= 6)
            {
                Clear();
            }

            if (units.Count == 0)
            {
                return;
            }

            int bases = 0;

            foreach (Base b in tyr.BaseManager.Bases)
            {
                if (b.ResourceCenter != null)
                {
                    bases++;
                }
            }


            Point2D tumorTarget;

            if (PlaceTumorsInMain)
            {
                Point2D main    = tyr.BaseManager.Main.BaseLocation.Pos;
                Point2D natural = tyr.BaseManager.Natural.BaseLocation.Pos;
                Point2D halfway = SC2Util.Point((main.X + natural.X) / 2, (main.Y + natural.Y) / 2);
                tumorTarget = tyr.buildingPlacer.FindPlacement(halfway, SC2Util.Point(1, 1), UnitTypes.CREEP_TUMOR);;
            }
            else
            {
                Point2D target;
                Base    defendBase = null;
                if (bases >= 2)
                {
                    target     = tyr.BaseManager.NaturalDefensePos;
                    defendBase = tyr.BaseManager.Natural;
                }
                else
                {
                    target     = tyr.BaseManager.MainDefensePos;
                    defendBase = tyr.BaseManager.Main;
                }
                tumorTarget = tyr.buildingPlacer.FindPlacement(tyr.MapAnalyzer.Walk(target, tyr.MapAnalyzer.EnemyDistances, 4), SC2Util.Point(1, 1), UnitTypes.CREEP_TUMOR);;
            }

            foreach (Agent queen in units)
            {
                if (queen.Unit.Energy >= 75)
                {
                    tyr.DrawSphere(SC2Util.Point(tumorTarget.X, tumorTarget.Y, 0));
                    queen.Order(1694, tumorTarget);
                }
            }

            for (int i = units.Count - 1; i >= 0; i--)
            {
                if (units[i].Unit.Energy < 75)
                {
                    IdleTask.Task.Add(units[i]);
                    RemoveAt(i);
                }
            }
        }