public override void OnFrame(Tyr tyr) { if (Stopped || !UnderAttack()) { Clear(); return; } foreach (Agent agent in units) { bool enemyClose = false; foreach (Unit enemy in tyr.Enemies()) { if (!UnitTypes.CombatUnitTypes.Contains(enemy.UnitType)) { continue; } if (agent.DistanceSq(enemy) <= 12 * 12) { enemyClose = true; } } if (agent.Unit.WeaponCooldown > 0 && agent.DistanceSq(Target) >= 15 * 15 && !enemyClose) { agent.Order(Abilities.MOVE, SC2Util.To2D(Target.Pos)); } else { tyr.MicroController.Attack(agent, SC2Util.To2D(Target.Pos)); } } }
public override void OnFrame(Tyr tyr) { if (b.ResourceCenter == null) { Clear(); return; } foreach (Agent agent in units) { Unit defendEnemy = null; float dist = DefenseRadius * DefenseRadius; foreach (Unit enemy in tyr.Enemies()) { float newDist = SC2Util.DistanceSq(b.BaseLocation.Pos, enemy.Pos); if (newDist < dist) { defendEnemy = enemy; dist = newDist; } } if (defendEnemy != null) { Attack(agent, SC2Util.To2D(defendEnemy.Pos)); } else if (agent.DistanceSq(b.ResourceCenter) >= 7 * 7) { agent.Order(Abilities.MOVE, b.ResourceCenter.Unit.Tag); } else if (agent.Unit.Energy >= 23) { agent.Order(251, b.ResourceCenter.Unit.Tag); } } }
public override void OnFrame(Tyr tyr) { tyr.NexusAbilityManager.PriotitizedAbilities.Add(1568); if (Completed(UnitTypes.OBSERVER) > 0 && Completed(UnitTypes.IMMORTAL) == 0 && Count(UnitTypes.IMMORTAL) > 0) { TimingAttackTask.Task.RequiredSize = 20; TimingAttackTask.Task.RetreatSize = 4; } else if (Completed(UnitTypes.OBSERVER) == 0 && Count(UnitTypes.ROBOTICS_FACILITY) > 0) { TimingAttackTask.Task.RequiredSize = 20; TimingAttackTask.Task.RetreatSize = 4; } else { TimingAttackTask.Task.RequiredSize = RequiredSize; TimingAttackTask.Task.RetreatSize = 4; } ProxyFourGateTask.Task.Stopped = Count(UnitTypes.CYBERNETICS_CORE) == 0; if (ProxyFourGateTask.Task.Stopped) { ProxyFourGateTask.Task.Clear(); } if (UpgradeType.LookUp[UpgradeType.WarpGate].Progress() >= 0.5 && IdleTask.Task.OverrideTarget == null) { IdleTask.Task.OverrideTarget = tyr.MapAnalyzer.Walk(ProxyFourGateTask.Task.GetHideLocation(), tyr.MapAnalyzer.EnemyDistances, 10); } IdleTask.Task.AttackMove = tyr.Frame <= 22.4 * 60 * 4.5; if (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.WIDOW_MINE) >= 2) { ProxyFourGateTask.Task.BuildRobo = true; } if (Completed(UnitTypes.OBSERVER) > 0) { StalkerAttackNaturalController.Stopped = true; } if (!DefendReapers && tyr.EnemyStrategyAnalyzer.Count(UnitTypes.REAPER) > 0 && UpgradeType.LookUp[UpgradeType.WarpGate].Done()) { foreach (Unit enemy in tyr.Enemies()) { if (enemy.UnitType != UnitTypes.REAPER) { continue; } if (SC2Util.DistanceSq(enemy.Pos, tyr.MapAnalyzer.StartLocation) <= 30 * 30) { DefendReapers = true; ReaperDefenseTask.MaxDefenders = 1; break; } } } }
private void Cleanup(Tyr tyr) { HashSet <ulong> unburrowedMines = new HashSet <ulong>(); foreach (Unit enemy in tyr.Enemies()) { if (enemy.UnitType == UnitTypes.WIDOW_MINE) { unburrowedMines.Add(enemy.Tag); } } for (int i = Mines.Count - 1; i >= 0; i--) { UnitLocation mine = Mines[i]; if (unburrowedMines.Contains(mine.Tag)) { Remove(i); continue; } bool removed = false; foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.Unit.DetectRange <= 1) { continue; } if (agent.DistanceSq(mine.Pos) <= agent.Unit.DetectRange * agent.Unit.DetectRange - 4) { Remove(i); removed = true; break; } } if (removed) { continue; } foreach (SC2APIProtocol.Effect effect in tyr.Observation.Observation.RawData.Effects) { if (effect.EffectId != 6) { continue; } if (SC2Util.DistanceSq(effect.Pos[0], mine.Pos) <= 8 * 8) { Remove(i); removed = true; break; } } if (removed) { continue; } } }
public void Update(Tyr tyr) { Dictionary <ulong, UnitLocation> existingTanks = new Dictionary <ulong, UnitLocation>(); foreach (UnitLocation tank in Tanks) { existingTanks.Add(tank.Tag, tank); } HashSet <ulong> removeTanks = new HashSet <ulong>(); foreach (Unit enemy in tyr.Enemies()) { if (enemy.UnitType == UnitTypes.SIEGE_TANK) { if (SiegeFrame.ContainsKey(enemy.Tag)) { SiegeFrame[enemy.Tag] = tyr.Frame; } else { SiegeFrame.Add(enemy.Tag, tyr.Frame); } } if (existingTanks.ContainsKey(enemy.Tag)) { if (enemy.UnitType == UnitTypes.SIEGE_TANK_SIEGED) { existingTanks[enemy.Tag].Pos = enemy.Pos; existingTanks[enemy.Tag].LastSeenFrame = tyr.Frame; } else { removeTanks.Add(enemy.Tag); } continue; } if (enemy.UnitType != UnitTypes.SIEGE_TANK_SIEGED) { continue; } Tanks.Add(new UnitLocation() { Tag = enemy.Tag, UnitType = enemy.UnitType, LastSeenFrame = tyr.Frame, Pos = enemy.Pos }); } for (int i = Tanks.Count - 1; i >= 0; i--) { if (removeTanks.Contains(Tanks[i].Tag)) { Remove(i); } } }
public void Update(Tyr tyr) { Dictionary <ulong, UnitLocation> existingMines = new Dictionary <ulong, UnitLocation>(); foreach (UnitLocation mine in Mines) { existingMines.Add(mine.Tag, mine); } HashSet <ulong> removeMines = new HashSet <ulong>(); foreach (Unit enemy in tyr.Enemies()) { if (enemy.UnitType == UnitTypes.WIDOW_MINE) { if (BurrowFrame.ContainsKey(enemy.Tag)) { BurrowFrame[enemy.Tag] = tyr.Frame; } else { BurrowFrame.Add(enemy.Tag, tyr.Frame); } } if (existingMines.ContainsKey(enemy.Tag)) { if (enemy.UnitType == UnitTypes.WIDOW_MINE_BURROWED) { existingMines[enemy.Tag].Pos = enemy.Pos; existingMines[enemy.Tag].LastSeenFrame = tyr.Frame; } else { removeMines.Add(enemy.Tag); } continue; } if (enemy.UnitType != UnitTypes.WIDOW_MINE_BURROWED) { continue; } Mines.Add(new UnitLocation() { Tag = enemy.Tag, UnitType = enemy.UnitType, LastSeenFrame = tyr.Frame, Pos = enemy.Pos }); } for (int i = Mines.Count - 1; i >= 0; i--) { if (removeMines.Contains(Mines[i].Tag)) { Remove(i); } } }
public override void OnFrame(Tyr tyr) { UpdateEnemyBases(); if (units.Count == 0) { return; } Tyr.Bot.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 tyr.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); } } } }
public override void OnFrame(Tyr tyr) { tyr.buildingPlacer.BuildCompact = true; if (tyr.EnemyStrategyAnalyzer.CannonRushDetected) { VoidrayOnly = true; } if (VoidrayOnly) { DefenseTask.Stopped = true; } if ((tyr.EnemyRace == Race.Terran || tyr.EnemyRace == Race.Random) && ReaperDefenseCannonStep.DesiredPos == null) { foreach (Unit unit in tyr.Enemies()) { if (unit.UnitType == UnitTypes.REAPER && Tyr.Bot.MapAnalyzer.StartArea[(int)System.Math.Round(unit.Pos.X), (int)System.Math.Round(unit.Pos.Y)]) { Point2D dir = SC2Util.Point(unit.Pos.X - tyr.MapAnalyzer.StartLocation.X, unit.Pos.Y - tyr.MapAnalyzer.StartLocation.Y); float length = (float)System.Math.Sqrt(dir.X * dir.X + dir.Y * dir.Y); dir = SC2Util.Point(dir.X / length, dir.Y / length); ReaperDefenseCannonStep.DesiredPos = SC2Util.Point(tyr.MapAnalyzer.StartLocation.X + dir.X * 4f, tyr.MapAnalyzer.StartLocation.Y + dir.Y * 4f); break; } } } if (tyr.EnemyStrategyAnalyzer.LiftingDetected && tyr.EnemyManager.EnemyBuildings.Count == 0 && !ChasingLiftedBuildings) { ChasingLiftedBuildings = true; tyr.TaskManager.Add(new ElevatorChaserTask()); } if (gatewayBuilt && Count(UnitTypes.GATEWAY) == 0) { gatewayBuilt = false; } else if (!gatewayBuilt) { foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.Unit.UnitType == UnitTypes.GATEWAY) { gatewayBuilt = true; agent.Order(Abilities.MOVE, tyr.TargetManager.PotentialEnemyStartLocations[0]); break; } } } }
public override void OnFrame(Tyr tyr) { if (OverrideTarget != null) { Target = OverrideTarget; } else if (tyr.BaseManager.Natural.Owner == tyr.PlayerId) { Target = tyr.BaseManager.NaturalDefensePos; } else { Target = tyr.BaseManager.MainDefensePos; } foreach (Agent agent in units) { if (agent.Unit.UnitType == UnitTypes.LURKER && SC2Util.DistanceSq(agent.Unit.Pos, Target) < 3 * 3) { agent.Order(Abilities.BURROW_DOWN); continue; } if (FearEnemies && (agent.IsCombatUnit || agent.Unit.UnitType == UnitTypes.OVERSEER || agent.Unit.UnitType == UnitTypes.RAVEN)) { Unit fleeEnemy = null; float distance = 10 * 10; foreach (Unit enemy in tyr.Enemies()) { if (!UnitTypes.CombatUnitTypes.Contains(enemy.UnitType)) { continue; } float dist = agent.DistanceSq(enemy); if (dist < distance) { distance = dist; fleeEnemy = enemy; } } if (fleeEnemy != null) { PotentialHelper helper = new PotentialHelper(agent.Unit.Pos); helper.From(fleeEnemy.Pos); agent.Order(Abilities.MOVE, helper.Get()); continue; } } if ((agent.IsCombatUnit || agent.Unit.UnitType == UnitTypes.OVERSEER) && SC2Util.DistanceSq(agent.Unit.Pos, Target) >= 5 * 5) { agent.Order(Abilities.MOVE, Target); } } }
public override void OnFrame(Tyr tyr) { if (tyr.EnemyStrategyAnalyzer.LiftingDetected) { int surfaceEnemies = 0; foreach (Unit unit in tyr.Enemies()) { if (!unit.IsFlying) { surfaceEnemies++; } } if (surfaceEnemies < 3 && WorkerTask.Task.Units.Count < 16) { WorkerRushTask.Clear(); WorkerRushTask.Stopped = true; } } if (!MessageSent) { if (tyr.Enemies().Count > 0) { MessageSent = true; tyr.Chat("Prepare to be TICKLED! :D"); } } if (tyr.Frame - LastReinforcementsFrame >= 100 && WorkerTask.Task.Units.Count >= (tyr.EnemyStrategyAnalyzer.LiftingDetected ? 22 : 12) && !tyr.EnemyStrategyAnalyzer.LiftingDetected) { LastReinforcementsFrame = tyr.Frame; WorkerRushTask.TakeWorkers += 6; } }
public override void OnFrame(Tyr tyr) { foreach (Agent agent in units) { bool closeEnemy = false; if (RaiseWall != null) { foreach (WallBuilding building in RaiseWall.Wall) { if (SC2Util.DistanceSq(building.Pos, agent.Unit.Pos) < 2) { closeEnemy = true; break; } } } if (!closeEnemy) { foreach (Unit enemy in tyr.Enemies()) { if (agent.DistanceSq(enemy) <= 10 * 10 && !enemy.IsFlying && enemy.UnitType != UnitTypes.REAPER && enemy.UnitType != UnitTypes.ADEPT_PHASE_SHIFT && enemy.UnitType != UnitTypes.KD8_CHARGE && !UnitTypes.ChangelingTypes.Contains(enemy.UnitType) && !UnitTypes.WorkerTypes.Contains(enemy.UnitType)) { closeEnemy = true; break; } } } if (agent.Unit.UnitType == UnitTypes.SUPPLY_DEPOT && !closeEnemy) { agent.Order(556); } else if (agent.Unit.UnitType != UnitTypes.SUPPLY_DEPOT && closeEnemy) { agent.Order(558); } } }
public override void OnFrame(Tyr tyr) { if (units.Count <= RetreatSize) { Clear(); return; } Agent defendAgent = null; if (DefendOtherAgents) { foreach (Agent agent in units) { foreach (Unit enemy in tyr.Enemies()) { if (!UnitTypes.CombatUnitTypes.Contains(enemy.UnitType)) { continue; } if (SC2Util.DistanceSq(agent.Unit.Pos, enemy.Pos) <= 9 * 9) { defendAgent = agent; break; } } if (defendAgent != null) { break; } } } foreach (Agent agent in units) { if (defendAgent != null && SC2Util.DistanceSq(agent.Unit.Pos, defendAgent.Unit.Pos) >= 3 * 3 && SC2Util.DistanceSq(agent.Unit.Pos, defendAgent.Unit.Pos) <= 40 * 40) { tyr.MicroController.Attack(agent, SC2Util.To2D(defendAgent.Unit.Pos)); } else { tyr.MicroController.Attack(agent, tyr.TargetManager.AttackTarget); } } }
public override void OnFrame(Tyr tyr) { if (!MessageSent) { if (tyr.Enemies().Count > 0) { MessageSent = true; tyr.Chat("Prepare to be TICKLED! :D"); } } if (tyr.Frame - LastReinforcementsFrame >= 100 && WorkerTask.Task.Units.Count >= (tyr.EnemyStrategyAnalyzer.LiftingDetected ? 22 : 12) && !tyr.EnemyStrategyAnalyzer.LiftingDetected) { LastReinforcementsFrame = tyr.Frame; WorkerRushTask.TakeWorkers += 6; } }
public override void OnFrame(Tyr tyr) { if (mineral == null && tyr.BaseManager.Main.BaseLocation.MineralFields.Count > 0) { mineral = tyr.BaseManager.Main.BaseLocation.MineralFields[0]; } Unit closestEnemy = null; float distance = 10 * 10; float hp = 1000; foreach (Unit enemy in tyr.Enemies()) { float newDist = SC2Util.DistanceSq(mineral.Pos, enemy.Pos); if (newDist < 2 * 2) { if (enemy.Health < hp) { closestEnemy = enemy; distance = newDist; hp = enemy.Health; } } else if (newDist < distance) { closestEnemy = enemy; distance = newDist; } } foreach (Agent agent in Units) { if (closestEnemy != null && (agent.DistanceSq(closestEnemy) > 2 * 2 || agent.DistanceSq(mineral.Pos) <= 2 * 2)) { agent.Order(Abilities.ATTACK, closestEnemy.Tag); tyr.DrawLine(agent, closestEnemy.Pos); } else { agent.Order(Abilities.MOVE, mineral.Tag); } } }
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; } }
private void Cleanup(Tyr tyr) { HashSet <ulong> unsiegedTanks = new HashSet <ulong>(); foreach (Unit enemy in tyr.Enemies()) { if (enemy.UnitType == UnitTypes.SIEGE_TANK) { unsiegedTanks.Add(enemy.Tag); } } for (int i = Tanks.Count - 1; i >= 0; i--) { UnitLocation tank = Tanks[i]; if (unsiegedTanks.Contains(tank.Tag)) { Remove(i); continue; } bool removed = false; foreach (Agent agent in tyr.UnitManager.Agents.Values) { float sightRange = UnitTypes.LookUp[agent.Unit.UnitType].SightRange; if (agent.DistanceSq(tank.Pos) <= sightRange * sightRange - 4) { Remove(i); removed = true; break; } } if (removed) { continue; } } }
public override void OnFrame(Tyr tyr) { WorkerScoutTask.Task.ScoutNatural = true; WorkerScoutTask.Task.StartFrame = 224; if (!InitialAttackDone && TimingAttackTask.Task.AttackSent && Completed(UnitTypes.HELLBAT) + Completed(UnitTypes.HELLION) + Completed(UnitTypes.MARINE) <= 4) { InitialAttackDone = true; for (int i = 0; i < AttackMicroControllers.Count; i++) { if (AttackMicroControllers[i] is HellionHarassController) { AttackMicroControllers.RemoveAt(i); break; } } } if (!InitialAttackDone && (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.ROACH) > 0 || tyr.EnemyStrategyAnalyzer.Count(UnitTypes.HYDRALISK) >= 3 || tyr.EnemyStrategyAnalyzer.Count(UnitTypes.RAVAGER) > 0 || tyr.EnemyStrategyAnalyzer.Count(UnitTypes.BANELING) >= 2 || tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.QUEEN) >= 4) || LingRush) { InitialAttackDone = true; TimingAttackTask.Task.Clear(); for (int i = 0; i < AttackMicroControllers.Count; i++) { if (AttackMicroControllers[i] is HellionHarassController) { AttackMicroControllers.RemoveAt(i); break; } } } if (InitialAttackDone) { TimingAttackTask.Task.RequiredSize = 40; TimingAttackTask.Task.RetreatSize = 12; } else { TimingAttackTask.Task.RequiredSize = 8; TimingAttackTask.Task.RetreatSize = 3; } if (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.MUTALISK) > 0) { DesiredTanks = 0; } else if (DesiredTanks == 0) { foreach (Unit enemy in tyr.Enemies()) { if ( (enemy.UnitType == UnitTypes.QUEEN || enemy.UnitType == UnitTypes.SPINE_CRAWLER || enemy.UnitType == UnitTypes.SPINE_CRAWLER_UPROOTED) && SC2Util.DistanceSq(enemy.Pos, tyr.MapAnalyzer.StartLocation) <= 40 * 40) { DesiredTanks = 2; break; } } } if (!LingRush && tyr.Frame <= 22.4 * 150 && tyr.EnemyStrategyAnalyzer.Count(UnitTypes.ZERGLING) >= 5) { LingRush = true; } TimingAttackTask.Task.CustomControllers = AttackMicroControllers; DefenseTask.AirDefenseTask.ExpandDefenseRadius = 20; DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 20; DefenseTask.AirDefenseTask.MaxDefenseRadius = 120; DefenseTask.GroundDefenseTask.MaxDefenseRadius = 120; DefenseTask.AirDefenseTask.Priority = 4; RepairTask.Task.WallIn = WallIn; SupplyDepotTask.Task.RaiseWall = LingRush && Completed(UnitTypes.HELLION) + Completed(UnitTypes.HELLBAT) < 4 ? WallIn : null; TransformTask.Task.HellionsToHellbats(); MechDestroyExpandsTask.Task.Stopped = BlueFlameStarted < 0 || tyr.Frame < BlueFlameStarted + 22.4 * 20 || UltralisksDetected || DefendMutas || RoachHydra; if (!UltralisksDetected && tyr.EnemyStrategyAnalyzer.Count(UnitTypes.ULTRALISK) + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.ULTRALISK_CAVERN) > 0) { UltralisksDetected = true; } if (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.MUTALISK) > 0) { MinVikings = 6; MaxVikings = 6; DefendMutas = true; } else if (UltralisksDetected) { MinVikings = 3; MaxVikings = 3; } if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.ZERGLING) >= 15) { ManyLings = true; } if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.ROACH) + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.HYDRALISK) >= 10) { RoachHydra = true; } if (ManyLings && !DefendMutas && !RoachHydra) { MinimumHellbats = 12; } else if (!InitialAttackDone) { MinimumHellbats = 8; } else { MinimumHellbats = 0; } if (DefendMutas) { TimingAttackTask.Task.ExcludeUnitTypes.Add(UnitTypes.VIKING_FIGHTER); DistributedDefenseTask.AirDefenseTask.AllowedDefenderTypes.Add(UnitTypes.VIKING_FIGHTER); VikingController.StickToTanks = false; } if (DefendMutas && !TimingAttackTask.Task.IsNeeded()) { DefenseSquadTask.Enable(CycloneDefenseSquads, true, true); } else { foreach (DefenseSquadTask task in CycloneDefenseSquads) { task.Stopped = true; task.Clear(); } } if (Count(UnitTypes.SCV) < 10 || (Gas() >= 800 && Minerals() < 500)) { GasWorkerTask.WorkersPerGas = 0; } else if (Gas() >= 700 && Minerals() < 500) { GasWorkerTask.WorkersPerGas = 1; } else if (Gas() >= 600 && Minerals() < 500) { GasWorkerTask.WorkersPerGas = 2; } else { GasWorkerTask.WorkersPerGas = 3; } DistributeHellbatsTask.Stopped = Count(UnitTypes.COMMAND_CENTER) < 2 || Completed(UnitTypes.HELLBAT) < 2 * (Count(UnitTypes.COMMAND_CENTER) - 1); if (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.BANELING) > 0 || tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.MUTALISK) > 0) { DesiredMines = 6; } if (tyr.TargetManager.PotentialEnemyStartLocations.Count == 1 && !ScanTimingsSet) { ScanTimingsSet = true; tyr.OrbitalAbilityManager.SaveEnergy = 50; tyr.OrbitalAbilityManager.ScanCommands.Add(new ScanCommand() { Pos = tyr.TargetManager.PotentialEnemyStartLocations[0], FromFrame = (int)(22.4 * 60 * 8.5) }); tyr.OrbitalAbilityManager.ScanCommands.Add(new ScanCommand() { Pos = tyr.MapAnalyzer.GetEnemyNatural().Pos, FromFrame = (int)(22.4 * 60 * 8.5 + 22.4) }); } if (BlueFlameStarted < 0 && tyr.UnitManager.ActiveOrders.Contains(761)) { BlueFlameStarted = tyr.Frame; } }
public override void OnFrame(Tyr tyr) { tyr.NexusAbilityManager.PriotitizedAbilities.Add(948); tyr.NexusAbilityManager.PriotitizedAbilities.Add(950); tyr.buildingPlacer.BuildCompact = true; FlyerAttackTask.Task.RequiredSize = RequiredSize; IdleTask.Task.FearEnemies = true; DefenseTask.Task.IgnoreEnemyTypes.Add(UnitTypes.VIKING_FIGHTER); FlyerDestroyTask.Task.Stopped = !DefendReapers; FlyerAttackTask.Task.Stopped = DefendReapers; if (Count(UnitTypes.PROBE) <= 18) { BaseWorkers.WorkersPerGas = 0; } else { BaseWorkers.WorkersPerGas = 3; } if (tyr.EnemyRace == Race.Zerg) { Beyond2Cannons = tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ZERGLING) > 0 || Count(UnitTypes.STARGATE) >= 3; } if (tyr.Frame == 118) { tyr.Chat("Time for some monobattles!"); } if (tyr.Frame == 163) { if (BuildCarriers) { tyr.Chat("I choose Carriers! :D"); } else { tyr.Chat("I choose Skillrays! :D"); } } if (!LiftingDetected) { foreach (Unit unit in tyr.Enemies()) { if (unit.IsFlying && UnitTypes.BuildingTypes.Contains(unit.UnitType)) { LiftingDetected = true; } } } if (LiftingDetected && tyr.EnemyManager.EnemyBuildings.Count == 0 && !ChasingLiftedBuildings) { ChasingLiftedBuildings = true; tyr.TaskManager.Add(new ElevatorChaserTask()); } if (!DefendRush && tyr.Frame <= 4800 && Tyr.Bot.EnemyRace != Race.Zerg) { int enemyCount = 0; foreach (Unit enemy in tyr.Enemies()) { if (SC2Util.DistanceSq(enemy.Pos, tyr.MapAnalyzer.StartLocation) <= 40 * 40) { enemyCount++; } } if (enemyCount >= 3) { DefendRush = true; } } if ((tyr.EnemyRace == Race.Terran || tyr.EnemyRace == Race.Random) && ReaperDefenseCannonStep.DesiredPos == null && !SkipDefenses) { foreach (Unit unit in tyr.Enemies()) { if (unit.UnitType == UnitTypes.REAPER && Tyr.Bot.MapAnalyzer.StartArea[(int)System.Math.Round(unit.Pos.X), (int)System.Math.Round(unit.Pos.Y)]) { Point2D dir = SC2Util.Point(unit.Pos.X - tyr.MapAnalyzer.StartLocation.X, unit.Pos.Y - tyr.MapAnalyzer.StartLocation.Y); float length = (float)System.Math.Sqrt(dir.X * dir.X + dir.Y * dir.Y); dir = SC2Util.Point(dir.X / length, dir.Y / length); ReaperDefenseCannonStep.DesiredPos = SC2Util.Point(tyr.MapAnalyzer.StartLocation.X + dir.X * 4f, tyr.MapAnalyzer.StartLocation.Y + dir.Y * 4f); break; } } } if (!DefendReapers && tyr.EnemyStrategyAnalyzer.Count(UnitTypes.REAPER) >= 2) { FearVikingsController.Stopped = false; DefendReapers = true; tyr.buildingPlacer.SpreadCannons = false; tyr.buildingPlacer.BuildCompact = true; WorkerTask.Task.StopTransfers = true; HideBaseTask.Task.BuildNexus = true; IdleTask.Task.OverrideTarget = FarBase.BaseLocation.Pos; DefenseTask.Task.Stopped = true; RequiredSize = 8; Set = new BuildSet(); Set += HiddenBasePylons(); Set += HiddenBaseBuild(); } /* * if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.REAPER) >= 2 * && NaturalMirrorCannonStep.DesiredBase == null) * { * PotentialHelper helper = new PotentialHelper(tyr.BaseManager.Natural.BaseLocation.Pos); * helper.Magnitude = 8; * helper.From(tyr.BaseManager.NaturalDefensePos); * NaturalMirrorCannonStep.DesiredPos = helper.Get(); * NaturalMirrorPylonStep.DesiredPos = helper.Get(); * } */ }
public override void OnFrame(Tyr tyr) { Center = new Point2D(); foreach (Agent agent in Units) { Center.X += agent.Unit.Pos.X / Units.Count; Center.Y += agent.Unit.Pos.Y / Units.Count; } DetermineTarget(); CleanGravitonTargets(); int lifts = 0; foreach (Agent agent in Units) { lifts += (int)(agent.Unit.Energy / 50); } DetermineGravitonTargets(lifts); foreach (Agent agent in units) { bool lift = false; foreach (GravitonTarget gravitonTarget in GravitonTargets) { if (gravitonTarget.PhoenixTag == agent.Unit.Tag) { agent.Order(173, gravitonTarget.TargetTag); lift = true; break; } } if (lift) { continue; } bool attackLifted = false; foreach (GravitonTarget gravitonTarget in GravitonTargets) { Point2D targetLocation = gravitonTarget.GetTargetLocation(); if (agent.DistanceSq(targetLocation) <= 15 * 15) { if (agent.DistanceSq(targetLocation) > 3 * 3) { agent.Order(Abilities.MOVE, targetLocation); } attackLifted = true; break; } } if (attackLifted) { continue; } float dist = 15 * 15; Unit attackTarget = null; foreach (Unit enemy in tyr.Enemies()) { if (!enemy.IsFlying) { continue; } float newDist = agent.DistanceSq(enemy); if (newDist >= dist) { continue; } if (SC2Util.DistanceSq(enemy.Pos, Center) >= 20 * 20) { continue; } dist = newDist; attackTarget = enemy; } if (attackTarget != null) { if (agent.DistanceSq(attackTarget) > 3 * 3) { agent.Order(Abilities.MOVE, SC2Util.To2D(attackTarget.Pos)); } continue; } if (tyr.Frame % 5 == 0) { agent.Order(Abilities.MOVE, Target); } } }
public override void OnFrame(Tyr tyr) { DefendMarines = tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.BARRACKS) >= 3 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.REFINERY) == 0 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.REAPER) == 0 && false; if (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.REAPER) >= 3 && tyr.Frame <= 210 * 22.4) { DefendReapers = true; RequiredSize = 6; } if (RequiredSize > 6) { if (Completed(UnitTypes.CARRIER) >= 12) { RequiredSize = 6; } foreach (Unit enemy in tyr.Enemies()) { if ((enemy.UnitType == UnitTypes.MARAUDER || enemy.UnitType == UnitTypes.MARAUDER) && SC2Util.DistanceSq(tyr.MapAnalyzer.StartLocation, enemy.Pos) <= 40 * 40) { RequiredSize = 6; break; } } } foreach (Task task in WorkerDefenseTask.Tasks) { task.Stopped = true; } tyr.buildingPlacer.BuildCompact = true; WorkerTask.Task.StopTransfers = true; HideBaseTask.Task.MoveOutFrame = 672; ConstructionTask.Task.CancelBlockedBuildings = false; ConstructionTask.Task.OnlyCloseWorkers = false; ConstructionTask.Task.MaxWorkerDist = 30; tyr.NexusAbilityManager.PriotitizedAbilities.Add(948); tyr.NexusAbilityManager.PriotitizedAbilities.Add(950); tyr.DrawText("Required size: " + RequiredSize); FlyerAttackTask.Task.RequiredSize = RequiredSize; FlyerDestroyTask.Task.RequiredSize = RequiredSize; IdleTask.Task.FearEnemies = true; DefenseTask.AirDefenseTask.IgnoreEnemyTypes.Add(UnitTypes.VIKING_FIGHTER); if (Count(UnitTypes.PROBE) <= 6) { BaseWorkers.WorkersPerGas = 0; } else if (Count(UnitTypes.PROBE) <= 12) { BaseWorkers.WorkersPerGas = 1; } else if (Count(UnitTypes.PROBE) <= 18) { BaseWorkers.WorkersPerGas = 2; } else { BaseWorkers.WorkersPerGas = 3; } if (tyr.Frame == 118) { tyr.Chat("Time for some monobattles!"); } if (tyr.Frame == 163) { if (BuildCarriers) { tyr.Chat("I choose Carriers! :D"); } else { tyr.Chat("I choose Skillrays! :D"); } } if (!LiftingDetected) { foreach (Unit unit in tyr.Enemies()) { if (unit.IsFlying && UnitTypes.BuildingTypes.Contains(unit.UnitType)) { LiftingDetected = true; } } } if (LiftingDetected && tyr.EnemyManager.EnemyBuildings.Count == 0 && !ChasingLiftedBuildings) { ChasingLiftedBuildings = true; tyr.TaskManager.Add(new ElevatorChaserTask()); } if (!DefendRush && tyr.Frame <= 4800 && Tyr.Bot.EnemyRace != Race.Zerg) { int enemyCount = 0; foreach (Unit enemy in tyr.Enemies()) { if (SC2Util.DistanceSq(enemy.Pos, tyr.MapAnalyzer.StartLocation) <= 40 * 40) { enemyCount++; } } if (enemyCount >= 3) { DefendRush = true; } } if (Count(UnitTypes.STARGATE) > 0) { HideBaseTask.Task.BuildNexus = true; } }
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); } } } }
public override void OnFrame(Tyr tyr) { tyr.DrawText("HydraTransitionFrame: " + HydraTransitionFrame); int enemyNaturalWorkerCount = 0; BaseLocation enemyNatural = tyr.MapAnalyzer.GetEnemyNatural(); bool enemyNaturalRemains = enemyNatural == null; foreach (Unit enemy in tyr.Enemies()) { if (enemyNatural == null) { break; } if (UnitTypes.ResourceCenters.Contains(enemy.UnitType) && !enemy.IsFlying && SC2Util.DistanceSq(enemy.Pos, enemyNatural.Pos) < 2 * 2) { enemyNaturalRemains = true; continue; } if (!UnitTypes.WorkerTypes.Contains(enemy.UnitType)) { continue; } if (SC2Util.DistanceSq(enemy.Pos, enemyNatural.Pos) > 14 * 14) { continue; } enemyNaturalWorkerCount++; } bool zerglingInEnemyNatural = false; foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.Unit.UnitType == UnitTypes.ZERGLING && agent.DistanceSq(enemyNatural.Pos) <= 10 * 10) { zerglingInEnemyNatural = true; } } if (AllowHydraTransition && HydraTransitionFrame >= 1000000000 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.PHOTON_CANNON) >= 3) { HydraTransitionFrame = tyr.Frame; } if (AllowHydraTransition && HydraTransitionFrame >= 1000000000 && tyr.Frame >= 22.4 * 60 * 5.5) { HydraTransitionFrame = tyr.Frame; } if (AllowHydraTransition && HydraTransitionFrame >= 1000000000 && Count(UnitTypes.ZERGLING) >= 25 && zerglingInEnemyNatural && enemyNaturalWorkerCount == 0 && !enemyNaturalRemains) { HydraTransitionFrame = (int)(tyr.Frame + 22.4 * 10); } if (AllowHydraTransition && HydraTransitionFrame >= 1000000000 && Count(UnitTypes.ZERGLING) >= 25 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.REAPER) >= 2) { HydraTransitionFrame = (int)(tyr.Frame + 22.4 * 10); } if (DefendEnemyNaturalTask != null) { DefendEnemyNaturalTask.Stopped = tyr.EnemyStrategyAnalyzer.Count(UnitTypes.PHOTON_CANNON) < 3 || tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.COLOSUS) > 0; if (DefendEnemyNaturalTask.Stopped) { DefendEnemyNaturalTask.Clear(); } } if (HydraTransitionFrame < 1000000000 || tyr.EnemyRace != Race.Terran) { OverlordSuicideTask.Task.Stopped = true; OverlordSuicideTask.Task.Clear(); } else { OverlordSuicideTask.Task.Stopped = false; } if (TimingAttackTask.Task.AttackSent && !OverlordSuicideTask.Task.Suicide) { foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.Unit.UnitType == UnitTypes.ZERGLING && agent.DistanceSq(tyr.TargetManager.PotentialEnemyStartLocations[0]) <= 80 * 80) { OverlordSuicideTask.Task.Suicide = true; } } } if (tyr.TargetManager.PotentialEnemyStartLocations.Count <= 1) { WorkerScoutTask.Task.Stopped = true; } if (UpgradeType.LookUp[UpgradeType.MetabolicBoost].Done()) { SafeZerglingsFromReapersTask.Task.Stopped = true; SafeZerglingsFromReapersTask.Task.Clear(); } if (MeleeUpgrade == 0 && Tyr.Bot.Observation.Observation.RawData.Player.UpgradeIds.Contains(53)) { MeleeUpgrade = 1; } else if (MeleeUpgrade == 1 && Tyr.Bot.Observation.Observation.RawData.Player.UpgradeIds.Contains(54)) { MeleeUpgrade = 2; } else if (MeleeUpgrade == 2 && Tyr.Bot.Observation.Observation.RawData.Player.UpgradeIds.Contains(55)) { MeleeUpgrade = 3; } if (ArmorUpgrade == 0 && Tyr.Bot.Observation.Observation.RawData.Player.UpgradeIds.Contains(56)) { ArmorUpgrade = 1; } else if (ArmorUpgrade == 1 && Tyr.Bot.Observation.Observation.RawData.Player.UpgradeIds.Contains(57)) { ArmorUpgrade = 2; } else if (ArmorUpgrade == 2 && Tyr.Bot.Observation.Observation.RawData.Player.UpgradeIds.Contains(58)) { ArmorUpgrade = 3; } ResearchingUpgrades = 0; for (uint ability = 1186; ability <= 1191; ability++) { if (Tyr.Bot.UnitManager.ActiveOrders.Contains(ability)) { ResearchingUpgrades++; } } if (!Tyr.Bot.Observation.Observation.RawData.Player.UpgradeIds.Contains(66) && !Tyr.Bot.UnitManager.ActiveOrders.Contains(1253)) { if (Gas() < 92) { GasWorkerTask.WorkersPerGas = 3; } else if (Gas() < 96) { GasWorkerTask.WorkersPerGas = 2; } else if (Gas() < 100) { GasWorkerTask.WorkersPerGas = 1; } else if (Gas() >= 100) { GasWorkerTask.WorkersPerGas = 0; } } else if (TimingAttackTask.Task.AttackSent || tyr.Frame >= HydraTransitionFrame) { GasWorkerTask.WorkersPerGas = 3; } else { GasWorkerTask.WorkersPerGas = 0; } if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.PHOTON_CANNON) >= 3 && Completed(UnitTypes.HYDRALISK) < 20 && Completed(UnitTypes.ZERGLING) >= 40) { TimingAttackTask.Task.Clear(); TimingAttackTask.Task.Stopped = true; } else { TimingAttackTask.Task.Stopped = false; } if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.PHOTON_CANNON) >= 3 && Completed(UnitTypes.ZERGLING) >= 40) { TimingAttackTask.Task.RequiredSize = 70; TimingAttackTask.Task.RetreatSize = 5; } else if (tyr.Frame >= HydraTransitionFrame && Count(UnitTypes.HYDRALISK) < 20 && !UpgradeType.LookUp[UpgradeType.MetabolicBoost].Done()) { TimingAttackTask.Task.RequiredSize = 50; TimingAttackTask.Task.RetreatSize = 5; } else if (tyr.Frame >= HydraTransitionFrame && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.COLOSUS) > 0) { TimingAttackTask.Task.RequiredSize = 40; TimingAttackTask.Task.RetreatSize = 8; } else if (tyr.Frame >= HydraTransitionFrame) { TimingAttackTask.Task.RequiredSize = 30; TimingAttackTask.Task.RetreatSize = 5; } else if (TimingAttackTask.Task.AttackSent) { TimingAttackTask.Task.RequiredSize = 20; TimingAttackTask.Task.RetreatSize = 0; } else { TimingAttackTask.Task.RequiredSize = 50; TimingAttackTask.Task.RetreatSize = 0; } DefenseTask.GroundDefenseTask.MainDefenseRadius = 20; DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 18; DefenseTask.GroundDefenseTask.MaxDefenseRadius = 55; DefenseTask.AirDefenseTask.MainDefenseRadius = 20; DefenseTask.AirDefenseTask.ExpandDefenseRadius = 18; DefenseTask.AirDefenseTask.MaxDefenseRadius = 55; }
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; } } } }
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); } } } }
public void OnFrame(Tyr tyr) { if (PotentialEnemyStartLocations.Count > 1 && !enemyMainFound) { for (int i = PotentialEnemyStartLocations.Count - 1; i >= 0; i--) { foreach (Unit unit in tyr.Enemies()) { if (SC2Util.DistanceSq(unit.Pos, PotentialEnemyStartLocations[i]) <= 6 * 6) { for (; i > 0; i--) { PotentialEnemyStartLocations.RemoveAt(0); } while (PotentialEnemyStartLocations.Count > 1) { PotentialEnemyStartLocations.RemoveAt(PotentialEnemyStartLocations.Count - 1); } } } } } if (PotentialEnemyStartLocations.Count > 1) { for (int i = PotentialEnemyStartLocations.Count - 1; i >= 0; i--) { foreach (Unit unit in tyr.Observation.Observation.RawData.Units) { if (unit.Owner == tyr.PlayerId && SC2Util.DistanceGrid(unit.Pos, PotentialEnemyStartLocations[i]) <= 5) { PotentialEnemyStartLocations.RemoveAt(i); break; } } } } if (PotentialEnemyStartLocations.Count == 1) { enemyMainFound = true; } if (PotentialEnemyStartLocations.Count == 1) { float dist = -1; BuildingLocation target = null; foreach (BuildingLocation building in tyr.EnemyManager.EnemyBuildings.Values) { if (UnitTypes.ResourceCenters.Contains(building.Type)) { float newDist = SC2Util.DistanceSq(building.Pos, PotentialEnemyStartLocations[0]); if (newDist > dist) { dist = newDist; target = building; } } } if (target != null) { AttackTarget = SC2Util.To2D(target.Pos); targetUnitTag = target.Tag; } } Point2D lastTarget = AttackTarget; if (!tyr.EnemyManager.EnemyBuildings.ContainsKey(targetUnitTag)) { AttackTarget = null; targetUnitTag = 0; foreach (BuildingLocation enemyBuilding in tyr.EnemyManager.EnemyBuildings.Values) { AttackTarget = SC2Util.To2D(enemyBuilding.Pos); targetUnitTag = enemyBuilding.Tag; break; } if (AttackTarget == null) { float dist = 1000000; foreach (Point2D location in PotentialEnemyStartLocations) { if (lastTarget == null) { AttackTarget = location; break; } float newDist = SC2Util.DistanceSq(lastTarget, location); if (newDist < dist) { dist = newDist; AttackTarget = location; } } } } else { AttackTarget = SC2Util.To2D(tyr.EnemyManager.EnemyBuildings[targetUnitTag].Pos); } if (tyr.EnemyManager.EnemyBuildings.Count == 0 && PotentialEnemyStartLocations.Count == 1) { bool cleared = false; foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (SC2Util.DistanceSq(agent.Unit.Pos, PotentialEnemyStartLocations[0]) <= 6 * 6) { cleared = true; break; } } if (cleared) { PotentialEnemyStartLocations.RemoveAt(0); foreach (Base b in tyr.BaseManager.Bases) { PotentialEnemyStartLocations.Add(b.BaseLocation.Pos); } } } }
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)); } }
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; }
public void OnFrame(Tyr tyr) { foreach (Agent observer in tyr.Units()) { if (observer.Unit.UnitType != UnitTypes.OBSERVER) { continue; } if (BansheeLocation != null && Tyr.Bot.Frame - BansheeSeenFrame < 22.4 * 10 && observer.DistanceSq(BansheeLocation) <= 4 * 4) { BansheeSeenFrame = -1000000; } if (LastHitLocation != null && Tyr.Bot.Frame - LastHitFrame < 22.4 * 20 && observer.DistanceSq(LastHitLocation) <= 4 * 4) { LastHitFrame = -1000000; } } float dist = 40 * 40; if (Tyr.Bot.Frame - BansheeSeenFrame < 22.4 * 10) { dist = SC2Util.DistanceSq(BansheeLocation, tyr.MapAnalyzer.StartLocation); } foreach (Unit enemy in tyr.Enemies()) { if (enemy.UnitType != UnitTypes.BANSHEE) { continue; } float newDist = SC2Util.DistanceSq(enemy.Pos, tyr.MapAnalyzer.StartLocation); if (newDist > dist) { continue; } BansheeLocation = SC2Util.To2D(enemy.Pos); BansheeSeenFrame = tyr.Frame; dist = newDist; } foreach (Agent agent in tyr.Units()) { if (agent.PreviousUnit == null) { continue; } float damageTaken = agent.PreviousUnit.Health + agent.PreviousUnit.Shield - agent.Unit.Health - agent.Unit.Shield; if (damageTaken < 9) { continue; } if (agent.DistanceSq(Tyr.Bot.MapAnalyzer.StartLocation) > 50 * 50) { continue; } bool enemyClose = false; foreach (Unit enemy in Tyr.Bot.Enemies()) { if (!UnitTypes.CombatUnitTypes.Contains(enemy.UnitType)) { continue; } if (agent.DistanceSq(enemy) > 15.5 * 15.5) { continue; } enemyClose = true; break; } if (enemyClose) { continue; } LastHitLocation = SC2Util.To2D(agent.Unit.Pos); LastHitFrame = tyr.Frame; } }
public override void OnFrame(Tyr tyr) { if (units.Count == 0) { return; } Unit fleeEnemy = null; float dist = 10 * 10; foreach (Unit enemy in tyr.Enemies()) { if (!UnitTypes.AirAttackTypes.Contains(enemy.UnitType)) { continue; } float newDist = units[0].DistanceSq(enemy); if (newDist < dist) { fleeEnemy = enemy; dist = newDist; } } if (fleeEnemy != null) { PotentialHelper helper = new PotentialHelper(units[0].Unit.Pos); helper.Magnitude = 4; helper.From(fleeEnemy.Pos); units[0].Order(Abilities.MOVE, helper.Get()); tyr.DrawText("Raven fleeing!"); return; } if (tyr.Frame % 5 == 0) { return; } Point2D target = tyr.TargetManager.AttackTarget; Agent closest = null; dist = 1000000; foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (!UnitTypes.CombatUnitTypes.Contains(agent.Unit.UnitType)) { continue; } float newDist = agent.DistanceSq(target); if (newDist < dist) { closest = agent; dist = newDist; } } int bases = 0; foreach (Base b in tyr.BaseManager.Bases) { if (b.ResourceCenter != null) { bases++; } } Point2D defenseLocation; if (bases >= 2) { defenseLocation = tyr.BaseManager.NaturalDefensePos; } else { defenseLocation = tyr.BaseManager.MainDefensePos; } foreach (Agent agent in units) { if (closest == null) { tyr.DrawText("Raven returning!"); agent.Order(Abilities.MOVE, defenseLocation); } else { tyr.DrawText("Raven moving out!"); agent.Order(Abilities.MOVE, SC2Util.To2D(closest.Unit.Pos)); } } }
public override void OnFrame(Tyr tyr) { if (units.Count <= RetreatSize) { Clear(); return; } bool canAttackGround = false; foreach (Agent agent in Units) { if (agent.CanAttackGround()) { canAttackGround = true; } } if (!canAttackGround) { Clear(); return; } Agent defendAgent = null; if (DefendOtherAgents) { foreach (Agent agent in units) { foreach (Unit enemy in tyr.Enemies()) { if (!UnitTypes.CombatUnitTypes.Contains(enemy.UnitType)) { continue; } if (SC2Util.DistanceSq(agent.Unit.Pos, enemy.Pos) <= 9 * 9) { defendAgent = agent; break; } } if (defendAgent != null) { break; } } } foreach (Agent agent in units) { if (agent.Unit.UnitType == UnitTypes.MEDIVAC) { UpdateMedivacRetreatTarget(tyr); if (MedivacRetreatTarget != null) { Attack(agent, SC2Util.To2D(MedivacRetreatTarget.Unit.Pos)); continue; } } if (defendAgent != null && agent.DistanceSq(defendAgent) >= 3 * 3 && agent.DistanceSq(defendAgent) <= 40 * 40) { Attack(agent, SC2Util.To2D(defendAgent.Unit.Pos)); } else { Attack(agent, tyr.TargetManager.AttackTarget); } } }