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

            if (Tyr.Bot.Frame % 22 == 0)
            {
                foreach (Unit enemy in Tyr.Bot.Enemies())
                {
                    if (!UnitTypes.CanAttackAir(enemy.UnitType))
                    {
                        continue;
                    }
                    if (agent.DistanceSq(enemy) <= 12 * 12)
                    {
                        agent.Order(392);
                        return(true);
                    }
                }
            }
            Unit  targetWorker = null;
            float distance     = 9 * 9;

            foreach (Unit enemy in Tyr.Bot.Enemies())
            {
                if (enemy.IsFlying)
                {
                    continue;
                }
                bool isWorker      = UnitTypes.WorkerTypes.Contains(enemy.UnitType);
                bool isAirAttacker = UnitTypes.AirAttackTypes.Contains(enemy.UnitType);
                if (!isAirAttacker && !isWorker)
                {
                    continue;
                }

                float newDistance = agent.DistanceSq(enemy);
                if (isWorker && newDistance <= distance)
                {
                    distance     = newDistance;
                    targetWorker = enemy;
                }
                else if (isAirAttacker && newDistance <= 9 * 9)
                {
                    return(false);
                }
            }
            if (targetWorker != null)
            {
                agent.Order(Abilities.ATTACK, targetWorker.Tag);
                return(true);
            }

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

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

            float dist       = 12 * 12;
            Unit  fleeTarget = null;

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

                float newDist = agent.DistanceSq(enemy);

                if (!enemy.IsFlying && newDist >= 10.5 * 10.5)
                {
                    continue;
                }
                if (newDist >= dist)
                {
                    continue;
                }
                fleeTarget = enemy;
                dist       = newDist;
            }

            if (fleeTarget != null)
            {
                Bot.Main.DrawLine(agent, fleeTarget.Pos);
                if (RetreatPos != null)
                {
                    agent.Flee(fleeTarget.Pos, RetreatPos);
                }
                else
                {
                    agent.Flee(fleeTarget.Pos);
                }
                return(true);
            }

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

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

            float dist       = 9 * 9;
            Unit  fleeTarget = null;

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

                float newDist = agent.DistanceSq(enemy);
                if (newDist < dist)
                {
                    fleeTarget = enemy;
                    dist       = newDist;
                }
            }

            if (fleeTarget != null)
            {
                agent.Order(Abilities.MOVE, agent.From(fleeTarget.Pos, 4));
                return(true);
            }

            return(false);
        }
Esempio n. 4
0
        public override void OnFrame(Bot bot)
        {
            if (!UnitTypes.CanAttackAir(UnitTypes.QUEEN) &&
                bot.Frame == 10)
            {
                bot.Chat("Omg Queens can't shoot!");
            }
            bot.NexusAbilityManager.PriotitizedAbilities.Add(1568);
            ProxyTask.Task.EvadeEnemies = true;

            bot.buildingPlacer.BuildCompact      = true;
            bot.TargetManager.PrefferDistant     = false;
            bot.TargetManager.TargetAllBuildings = true;

            foreach (WorkerDefenseTask task in WorkerDefenseTask.Tasks)
            {
                task.Stopped = true;
            }

            TimingAttackTask.Task.RequiredSize = RequiredSize;
            TimingAttackTask.Task.RetreatSize  = 0;
            TimingAttackTask.Task.UnitType     = UnitTypes.TEMPEST;

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

                agent.Order(Abilities.MOVE, agent.From(bot.MapAnalyzer.GetMainRamp(), 4));
            }
        }
Esempio n. 5
0
        public override void OnFrame(Tyr tyr)
        {
            if (!ChatMessageSent)
            {
                if (Completed(UnitTypes.TEMPEST) > 0)
                {
                    tyr.Chat("This build is dedicated to Andyman!");
                    ChatMessageSent = true;
                }
            }

            if (HideLocation == null)
            {
                HideLocation = ProxyTask.Task.GetHideLocation();
            }
            if (HideLocation != null)
            {
                if (ProxyTask.Task.UnitCounts.ContainsKey(UnitTypes.PYLON) &&
                    ProxyTask.Task.UnitCounts[UnitTypes.PYLON] > 0 &&
                    ProxyTask.Task.UnitCounts.ContainsKey(UnitTypes.STARGATE) &&
                    ProxyTask.Task.UnitCounts[UnitTypes.STARGATE] > 0)
                {
                    float dist      = 10 * 10;
                    Unit  fleeEnemy = null;
                    foreach (Unit enemy in tyr.Enemies())
                    {
                        if (!UnitTypes.CanAttackAir(enemy.UnitType))
                        {
                            continue;
                        }
                        float newDist = SC2Util.DistanceSq(enemy.Pos, HideLocation);
                        if (newDist > dist)
                        {
                            continue;
                        }
                        dist      = newDist;
                        fleeEnemy = enemy;
                    }
                    if (fleeEnemy != null)
                    {
                        TempestController.RetreatPos = new PotentialHelper(HideLocation, 6).From(fleeEnemy.Pos).Get();
                    }
                    else
                    {
                        TempestController.RetreatPos = HideLocation;
                    }
                }
                else
                {
                    TempestController.RetreatPos = null;
                }
            }
            if (TempestController.RetreatPos == null)
            {
                TempestController.RetreatPos = ProxyTask.Task.GetHideLocation();
            }

            DepoweredStargates = 0;
            foreach (Agent agent in tyr.Units())
            {
                if (agent.Unit.UnitType == UnitTypes.STARGATE &&
                    !agent.Unit.IsPowered &&
                    agent.Unit.BuildProgress >= 0.99)
                {
                    DepoweredStargates++;
                }
            }
            tyr.DrawText("DepoweredStargates: " + DepoweredStargates);

            tyr.NexusAbilityManager.PriotitizedAbilities.Add(1568);
            ProxyTask.Task.EvadeEnemies = true;

            tyr.buildingPlacer.BuildCompact      = true;
            tyr.TargetManager.PrefferDistant     = false;
            tyr.TargetManager.TargetAllBuildings = true;


            TrainStep.WarpInLocation = ProxyTask.Task.GetHideLocation();
            DefendRegionTask.Task.DefenseLocation = ProxyTask.Task.GetHideLocation();


            TimingAttackTask.Task.RequiredSize = 1;
            TimingAttackTask.Task.RetreatSize  = 0;
            TimingAttackTask.Task.UnitType     = UnitTypes.TEMPEST;


            if (tyr.Frame >= 22.4 * 60 * 4)
            {
                ProxyTask.Task.Stopped = true;
            }
            else
            {
                ProxyTask.Task.Stopped = Count(UnitTypes.GATEWAY) == 0;
                if (ProxyTask.Task.Stopped)
                {
                    ProxyTask.Task.Clear();
                }
            }
            if (UpgradeType.LookUp[UpgradeType.WarpGate].Progress() >= 0.5 &&
                IdleTask.Task.OverrideTarget == null &&
                (tyr.EnemyRace != Race.Protoss || tyr.Frame >= 22.4 * 4 * 60))
            {
                IdleTask.Task.OverrideTarget = tyr.MapAnalyzer.Walk(ProxyTask.Task.GetHideLocation(), tyr.MapAnalyzer.EnemyDistances, 10);
            }

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

                agent.Order(Abilities.MOVE, agent.From(tyr.MapAnalyzer.GetMainRamp(), 4));
            }
        }
Esempio n. 6
0
        public override bool DetermineAction(Agent agent, Point2D target)
        {
            if (agent.Unit.UnitType != UnitTypes.MEDIVAC)
            {
                return(false);
            }


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

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

                float newDist = agent.DistanceSq(enemy);
                if (newDist < dist)
                {
                    fleeTarget = enemy;
                    dist       = newDist;
                }
            }
            if (fleeTarget != null)
            {
                agent.Order(Abilities.MOVE, agent.From(fleeTarget, 4));
                return(true);
            }

            if (HealTargets.ContainsKey(agent.Unit.Tag))
            {
                ulong targetTag = HealTargets[agent.Unit.Tag];
                if (Bot.Main.UnitManager.Agents.ContainsKey(targetTag) &&
                    Bot.Main.UnitManager.Agents[targetTag].DistanceSq(agent) <= 7 * 7)
                {
                    agent.Order(386, targetTag);
                    return(true);
                }
                else
                {
                    HealTargets.Remove(agent.Unit.Tag);
                }
            }

            foreach (Agent ally in Bot.Main.UnitManager.Agents.Values)
            {
                if (!UnitTypes.LookUp[ally.Unit.UnitType].Attributes.Contains(Attribute.Biological))
                {
                    continue;
                }

                if (ally.Unit.Health >= ally.Unit.HealthMax)
                {
                    continue;
                }

                if (ally.DistanceSq(agent) >= 6 * 6)
                {
                    continue;
                }

                if (HealTargets.ContainsKey(agent.Unit.Tag))
                {
                    HealTargets[agent.Unit.Tag] = ally.Unit.Tag;
                }
                else
                {
                    HealTargets.Add(agent.Unit.Tag, ally.Unit.Tag);
                }

                agent.Order(386, ally.Unit.Tag);
                return(true);
            }

            agent.Order(Abilities.MOVE, target);
            return(true);
        }
Esempio n. 7
0
        public override bool DetermineAction(Agent agent, Point2D target)
        {
            if (agent.Unit.UnitType != UnitTypes.MOTHERSHIP)
            {
                return(false);
            }

            float dist       = 14 * 14;
            Unit  fleeTarget = null;

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

                float newDist = agent.DistanceSq(enemy);

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

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

            dist = 10 * 10;
            foreach (Unit enemy in Bot.Main.Enemies())
            {
                if (UnitTypes.CanAttackAir(enemy.UnitType))
                {
                    continue;
                }

                float newDist = agent.DistanceSq(enemy);

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

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

            return(false);
        }