public override void OnFrame(Tyr tyr) { BuildingType barracksType = BuildingType.LookUp[UnitTypes.BARRACKS]; if (Tyr.Bot.UnitManager.Count(UnitTypes.BARRACKS) < 2 && tyr.Minerals() >= 150 && BuildRequests.Count == 0) { Point2D placement = ProxyBuildingPlacer.FindPlacement(GetHideLocation(), barracksType.Size, UnitTypes.BARRACKS); BuildRequests.Add(new BuildRequest() { Type = UnitTypes.BARRACKS, Pos = placement }); } else if (Tyr.Bot.UnitManager.Count(UnitTypes.BUNKER) < 2 && tyr.Minerals() >= 100 && BuildRequests.Count == 0 && tyr.UnitManager.Completed(UnitTypes.BARRACKS) > 0 && tyr.UnitManager.Count(UnitTypes.BARRACKS) >= 2) { PotentialHelper helper = new PotentialHelper(tyr.MapAnalyzer.GetEnemyNatural().Pos); helper.Magnitude = 4; helper.From(tyr.MapAnalyzer.GetEnemyRamp(), 1); Point2D placement = ProxyBuildingPlacer.FindPlacement(helper.Get(), barracksType.Size, UnitTypes.BUNKER); BuildRequests.Add(new BuildRequest() { Type = UnitTypes.BUNKER, Pos = placement }); } else if (Tyr.Bot.UnitManager.Count(UnitTypes.BUNKER) >= 2 && tyr.Minerals() >= 100 && BuildRequests.Count == 0 && tyr.UnitManager.Count(UnitTypes.SIEGE_TANK) >= 2 && tyr.UnitManager.Count(UnitTypes.BARRACKS) >= 2 && tyr.UnitManager.Completed(UnitTypes.ENGINEERING_BAY) >= 1 && tyr.UnitManager.Count(UnitTypes.MISSILE_TURRET) < 2) { PotentialHelper helper = new PotentialHelper(tyr.MapAnalyzer.GetEnemyNatural().Pos); helper.Magnitude = 4; helper.From(tyr.MapAnalyzer.GetEnemyRamp(), 1); Point2D placement = ProxyBuildingPlacer.FindPlacement(helper.Get(), new Point2D() { X = 2, Y = 2 }, UnitTypes.MISSILE_TURRET); BuildRequests.Add(new BuildRequest() { Type = UnitTypes.MISSILE_TURRET, Pos = placement }); } List <BuildRequest> doneRequests = new List <BuildRequest>(); foreach (BuildRequest request in BuildRequests) { if (request.worker != null && !Tyr.Bot.UnitManager.Agents.ContainsKey(request.worker.Unit.Tag)) { request.worker = null; } if (request.worker == null) { foreach (Agent agent in Units) { if (BuildingType.BuildingAbilities.Contains((int)agent.CurrentAbility())) { continue; } request.worker = agent; break; } } if (!ProxyBuildingPlacer.CheckPlacement(request.Pos, BuildingType.LookUp[request.Type].Size, request.Type, null, true)) { doneRequests.Add(request); continue; } foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.Unit.UnitType == request.Type && agent.DistanceSq(request.Pos) < 4) { doneRequests.Add(request); break; } } } foreach (BuildRequest request in doneRequests) { BuildRequests.Remove(request); } Agent bunker = null; foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.Unit.UnitType != UnitTypes.BUNKER) { continue; } if (agent.Unit.BuildProgress < 0.99) { continue; } if (bunker == null || agent.Unit.Health < agent.Unit.HealthMax) { bunker = agent; } } Agent bc = null; foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.Unit.UnitType != UnitTypes.BATTLECRUISER) { continue; } if (bunker == null || agent.DistanceSq(bunker.Unit.Pos) >= 5 * 5) { continue; } if (agent.Unit.Health < agent.Unit.HealthMax) { bc = agent; } } foreach (Agent agent in Units) { bool building = false; foreach (BuildRequest request in BuildRequests) { if (request.worker == null || request.worker.Unit.Tag != agent.Unit.Tag) { continue; } building = true; agent.Order(BuildingType.LookUp[request.Type].Ability, request.Pos); break; } if (building) { continue; } if (bunker != null) { if (bunker.Unit.Health < bunker.Unit.HealthMax) { agent.Order(Abilities.REPAIR, bunker.Unit.Tag); } else if (bc != null) { agent.Order(Abilities.REPAIR, bc.Unit.Tag); } else { agent.Order(Abilities.MOVE, bunker.From(tyr.TargetManager.PotentialEnemyStartLocations[0], 3)); } continue; } if (agent.DistanceSq(GetHideLocation()) >= 4 * 4) { agent.Order(Abilities.MOVE, GetHideLocation()); continue; } } }
public override void OnFrame(Tyr tyr) { BuildingType pylonType = BuildingType.LookUp[UnitTypes.PYLON]; BuildingType gatewayType = BuildingType.LookUp[UnitTypes.GATEWAY]; Point2D hideLocation = GetHideLocation(); if (hideLocation == null) { return; } Agent pylon = null; Agent gateway = null; int gatewayCount = 0; foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.Unit.UnitType != UnitTypes.PYLON && agent.Unit.UnitType != UnitTypes.GATEWAY && agent.Unit.UnitType != UnitTypes.WARP_GATE) { continue; } if (agent.DistanceSq(HideLocation) > 20 * 20) { continue; } if (agent.Unit.UnitType == UnitTypes.PYLON) { pylon = agent; } else if (agent.Unit.UnitType == UnitTypes.GATEWAY || agent.Unit.UnitType == UnitTypes.WARP_GATE) { gatewayCount++; gateway = agent; } } if (pylon == null && tyr.Minerals() >= 100 && BuildRequests.Count == 0) { Point2D placement = ProxyBuildingPlacer.FindPlacement(GetHideLocation(), pylonType.Size, UnitTypes.PYLON); if (placement != null) { BuildRequests.Add(new BuildRequest() { Type = UnitTypes.PYLON, Pos = placement }); } } else if (gatewayCount < 2 && pylon != null && pylon.Unit.BuildProgress > 0.99 && tyr.Minerals() >= 150) { Point2D placement = ProxyBuildingPlacer.FindPlacement(GetHideLocation(), gatewayType.Size, UnitTypes.GATEWAY); if (placement != null) { BuildRequests.Add(new BuildRequest() { Type = UnitTypes.GATEWAY, Pos = placement }); } } List <BuildRequest> doneRequests = new List <BuildRequest>(); foreach (BuildRequest request in BuildRequests) { if (request.worker != null && !Tyr.Bot.UnitManager.Agents.ContainsKey(request.worker.Unit.Tag)) { request.worker = null; } if (request.worker == null) { foreach (Agent agent in Units) { if (BuildingType.BuildingAbilities.Contains((int)agent.CurrentAbility())) { continue; } request.worker = agent; break; } } if (!ProxyBuildingPlacer.CheckPlacement(request.Pos, BuildingType.LookUp[request.Type].Size, request.Type, null, true)) { doneRequests.Add(request); continue; } foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.Unit.UnitType == request.Type && agent.DistanceSq(request.Pos) < 4) { doneRequests.Add(request); break; } } } foreach (BuildRequest request in doneRequests) { BuildRequests.Remove(request); } foreach (Agent agent in Units) { bool building = false; foreach (BuildRequest request in BuildRequests) { if (request.worker == null || request.worker.Unit.Tag != agent.Unit.Tag) { continue; } building = true; if (agent.DistanceSq(request.Pos) <= 10 * 10) { agent.Order(BuildingType.LookUp[request.Type].Ability, request.Pos); } else { agent.Order(Abilities.MOVE, request.Pos); } break; } if (building) { continue; } if (agent.DistanceSq(GetHideLocation()) >= 4 * 4) { agent.Order(Abilities.MOVE, GetHideLocation()); continue; } } }