public override void OnFrame(Bot bot) { Point2D targetLocation = GetTarget(); bool starportsRemain = false; /* * foreach (Unit unit in bot.Enemies()) * if (unit.UnitType == UnitTypes.STARPORT) * { * starportsRemain = true; * Search = true; * break; * } */ bot.DrawText("Search: " + Search); bot.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); bot.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); bot.DrawLine(agent.Unit.Pos, target.Pos); } else { agent.Order(Abilities.ATTACK, targetLocation); } } } }
public bool DetermineAction(Agent agent, Point2D target) { if (agent.Unit.WeaponCooldown == 0) { return(false); } Unit killTarget = PriorityTargetting.GetTarget(agent); if (killTarget == null) { agent.Order(Abilities.MOVE, target); return(true); } else if (MoveWhenNoTarget) { agent.Order(Abilities.ATTACK, killTarget.Tag); return(true); } return(false); }
public override void OnFrame(Tyr tyr) { ulong mineral = 0; if (tyr.BaseManager.Main.BaseLocation.MineralFields.Count > 0) { mineral = tyr.BaseManager.Main.BaseLocation.MineralFields[0].Tag; } foreach (Agent agent in units) { if (!regenerating.Contains(agent.Unit.Tag) && agent.Unit.Shield <= 3 && agent.Unit.UnitType == UnitTypes.PROBE) { regenerating.Add(agent.Unit.Tag); } else if (regenerating.Contains(agent.Unit.Tag) && agent.Unit.Shield == agent.Unit.ShieldMax) { regenerating.Remove(agent.Unit.Tag); } if (regenerating.Contains(agent.Unit.Tag)) { bool flee = false; foreach (Unit enemy in tyr.Observation.Observation.RawData.Units) { if (enemy.Alliance != Alliance.Enemy) { continue; } if (!UnitTypes.CombatUnitTypes.Contains(enemy.UnitType) && !UnitTypes.WorkerTypes.Contains(enemy.UnitType)) { continue; } if (SC2Util.DistanceSq(agent.Unit.Pos, enemy.Pos) <= 3 * 3) { flee = true; break; } } if (flee) { if (mineral == 0) { agent.Order(Abilities.MOVE, SC2Util.To2D(tyr.MapAnalyzer.StartLocation)); } else { agent.Order(Abilities.MOVE, mineral); } } else { agent.Order(Abilities.ATTACK, tyr.TargetManager.AttackTarget); } } else { Unit broodling = GetBroodling(agent); if (broodling != null) { if (mineral == 0) { agent.Order(Abilities.MOVE, SC2Util.To2D(tyr.MapAnalyzer.StartLocation)); } else { agent.Order(Abilities.MOVE, mineral); } continue; } Unit closeTarget = CloseTargetting.GetTarget(agent); if (closeTarget != null) { agent.Order(Abilities.ATTACK, closeTarget.Tag); continue; } Unit rangeTarget = RangedTargetting.GetTarget(agent); if (rangeTarget != null) { agent.Order(Abilities.ATTACK, rangeTarget.Tag); continue; } agent.Order(Abilities.ATTACK, tyr.TargetManager.AttackTarget); } } }
public override void OnFrame(Bot bot) { ulong mineral = 0; if (bot.BaseManager.Main.BaseLocation.MineralFields.Count > 0) { mineral = bot.BaseManager.Main.BaseLocation.MineralFields[0].Tag; } if (!Close) { foreach (Agent agent in units) { agent.Order(Abilities.MOVE, bot.TargetManager.AttackTarget); if (agent.DistanceSq(bot.TargetManager.AttackTarget) <= 15 * 15) { Close = true; } int closeEnemies = 0; foreach (Unit enemy in bot.Enemies()) { if (agent.DistanceSq(enemy) <= 10 * 10) { closeEnemies++; } } if (closeEnemies > 3) { Close = true; } } return; } foreach (Agent agent in units) { if (!regenerating.Contains(agent.Unit.Tag) && agent.Unit.Shield <= 3 && agent.Unit.UnitType == UnitTypes.PROBE) { regenerating.Add(agent.Unit.Tag); } else if (regenerating.Contains(agent.Unit.Tag) && agent.Unit.Shield == agent.Unit.ShieldMax) { regenerating.Remove(agent.Unit.Tag); } if (regenerating.Contains(agent.Unit.Tag)) { bool flee = false; foreach (Unit enemy in bot.Observation.Observation.RawData.Units) { if (enemy.Alliance != Alliance.Enemy) { continue; } if (!UnitTypes.CombatUnitTypes.Contains(enemy.UnitType) && !UnitTypes.WorkerTypes.Contains(enemy.UnitType)) { continue; } if (SC2Util.DistanceSq(agent.Unit.Pos, enemy.Pos) <= 3 * 3) { flee = true; break; } } if (flee) { if (mineral == 0) { agent.Order(Abilities.MOVE, SC2Util.To2D(bot.MapAnalyzer.StartLocation)); } else { agent.Order(Abilities.MOVE, mineral); } } else { agent.Order(Abilities.ATTACK, bot.TargetManager.AttackTarget); } } else { Unit broodling = GetBroodling(agent); if (broodling != null || agent.Unit.WeaponCooldown > 6) { if (mineral == 0) { agent.Order(Abilities.MOVE, SC2Util.To2D(bot.MapAnalyzer.StartLocation)); } else { agent.Order(Abilities.MOVE, mineral); } continue; } Unit closeTarget = CloseTargetting.GetTarget(agent); if (closeTarget != null && !UnitTypes.BuildingTypes.Contains(closeTarget.UnitType)) { //agent.Order(Abilities.ATTACK, closeTarget.Tag); agent.Order(Abilities.ATTACK, bot.TargetManager.AttackTarget); continue; } Unit rangeTarget = RangedTargetting.GetTarget(agent); if (rangeTarget != null && !UnitTypes.BuildingTypes.Contains(rangeTarget.UnitType)) { agent.Order(Abilities.ATTACK, rangeTarget.Tag); continue; } if (MoveCommandWhenSafe && MoveWhenSafeController.DetermineAction(agent, bot.TargetManager.AttackTarget)) { continue; } agent.Order(Abilities.ATTACK, bot.TargetManager.AttackTarget); } } }