use of ecgberht.UnitInfo in project Ecgberht by Jabbo16.
the class VesselAgent method kite.
private void kite() {
Set<UnitInfo> airThreats = airAttackers.stream().filter(u -> u.unitType == UnitType.Zerg_Scourge || u.unitType == UnitType.Zerg_Spore_Colony).collect(Collectors.toSet());
if (!airThreats.isEmpty()) {
Position kite = UtilMicro.kiteAway(unit, airThreats);
if (kite != null) {
UtilMicro.move(unit, kite);
return;
}
}
Position kite = UtilMicro.kiteAway(unit, airAttackers);
if (kite == null || !getGs().getGame().getBWMap().isValidPosition(kite))
return;
UtilMicro.move(unit, kite);
}
use of ecgberht.UnitInfo in project Ecgberht by Jabbo16.
the class WorkerScoutAgent method disrupt.
private void disrupt() {
if (disrupter == null) {
if (unit.getBuildUnit() != null) {
disrupter = (Building) unit.getBuildUnit();
return;
}
if (unit.getOrder() != Order.PlaceBuilding) {
unit.build(getGs().enemyNaturalBase.getLocation(), UnitType.Terran_Engineering_Bay);
}
} else if (disrupter.getRemainingBuildTime() <= 25) {
unit.haltConstruction();
finishedDisrupting = true;
stoppedDisrupting = true;
removedIndex = true;
} else if (!stoppedDisrupting) {
if (mySim.enemies.stream().anyMatch(u -> unitInfo.getDistance(u) <= 4 * 32)) {
if (mySim.enemies.stream().anyMatch(u -> u.unit instanceof Zergling)) {
unit.haltConstruction();
stoppedDisrupting = true;
if (!removedIndex) {
enemyBaseBorders.remove(enemyNaturalIndex);
enemyNaturalIndex = -1;
removedIndex = true;
}
return;
}
if (mySim.enemies.size() == 1) {
UnitInfo closest = mySim.enemies.iterator().next();
Area enemyArea = getGs().bwem.getMap().getArea(closest.tileposition);
if (closest.unit instanceof Drone && enemyArea != null && enemyArea.equals(getGs().enemyNaturalArea)) {
if (mySim.lose) {
unit.haltConstruction();
stoppedDisrupting = true;
if (!removedIndex) {
enemyBaseBorders.remove(enemyNaturalIndex);
enemyNaturalIndex = -1;
removedIndex = true;
}
}
}
}
}
} else if (mySim.enemies.isEmpty() && disrupter != null && !finishedDisrupting)
unit.resumeBuilding(disrupter);
else if (!mySim.enemies.isEmpty() && (unitInfo.attackers.isEmpty() || !mySim.lose)) {
UnitInfo target = Util.getRangedTarget(unitInfo, mySim.enemies);
if (target != null)
UtilMicro.attack(unitInfo, target);
else if (disrupter != null && !finishedDisrupting)
unit.resumeBuilding(disrupter);
}
if (disrupter != null && !finishedDisrupting)
unit.resumeBuilding(disrupter);
}
use of ecgberht.UnitInfo in project Ecgberht by Jabbo16.
the class WorkerScoutAgent method runAgent.
public boolean runAgent() {
if (unit == null || !unit.exists() || unitInfo == null || !getGs().firstScout) {
if (disrupter != null)
getGs().disrupterBuilding = disrupter;
getGs().firstScout = false;
if (getGs().proxyBuilding != null && !getGs().proxyBuilding.isCompleted())
getGs().proxyBuilding.cancelConstruction();
return true;
}
if (status == Status.EXPLORE && getGs().getStrat().proxy && mySim.allies.stream().anyMatch(u -> u.unit instanceof Marine)) {
getGs().myArmy.add(unitInfo);
getGs().firstScout = false;
if (getGs().proxyBuilding != null && !getGs().proxyBuilding.isCompleted())
getGs().proxyBuilding.cancelConstruction();
return true;
}
if (enemyBaseBorders.isEmpty())
updateBorders();
mySim = getGs().sim.getSimulation(unitInfo, SimInfo.SimType.GROUND);
if (enemyNaturalIndex != -1 && (IntelligenceAgency.getEnemyStrat() == IntelligenceAgency.EnemyStrats.EarlyPool || IntelligenceAgency.getEnemyStrat() == IntelligenceAgency.EnemyStrats.ZealotRush || getGs().learningManager.isNaughty() || getGs().basicCombatUnitsDetected(mySim.enemies) || IntelligenceAgency.getNumEnemyBases(getGs().getIH().enemy()) > 1)) {
enemyBaseBorders.remove(enemyNaturalIndex);
enemyNaturalIndex = -1;
removedIndex = true;
}
status = chooseNewStatus();
cancelDisrupter();
switch(status) {
case EXPLORE:
followPerimeter();
break;
case DISRUPTING:
disrupt();
break;
case PROXYING:
proxy();
case IDLE:
break;
}
if (disrupter != null)
getGs().getGame().getMapDrawer().drawTextMap(disrupter.getPosition().add(new Position(0, -16)), ColorUtil.formatText("BM!", ColorUtil.White));
return false;
}
use of ecgberht.UnitInfo in project Ecgberht by Jabbo16.
the class CheckBuildingFlames method execute.
@Override
public State execute() {
try {
List<SCV> toRemove = new ArrayList<>();
for (Entry<SCV, Mechanical> u : gameState.repairerTask.entrySet()) {
if (u.getValue().maxHitPoints() != u.getValue().getHitPoints()) {
if (u.getKey().getOrder() != Order.Follow && u.getKey().getOrder() != Order.Repair) {
u.getKey().rightClick(u.getValue(), false);
}
} else if (Util.countBuildingAll(UnitType.Terran_Command_Center) < 2 && u.getValue() instanceof Bunker && IntelligenceAgency.getEnemyStrat() == IntelligenceAgency.EnemyStrats.ZealotRush && gameState.frameCount >= 24 * 60 * 2.2) {
if (u.getKey().getDistance(u.getValue()) > 3 * 32)
u.getKey().move(u.getValue().getPosition());
} else if (Util.countBuildingAll(UnitType.Terran_Command_Center) == 2 && gameState.CCs.size() < 2 && u.getValue() instanceof Bunker) {
if (u.getKey().getDistance(u.getValue()) > 3 * 32)
u.getKey().move(u.getValue().getPosition());
} else {
u.getKey().stop(false);
gameState.workerIdle.add(u.getKey());
toRemove.add(u.getKey());
}
}
for (SCV s : toRemove) gameState.repairerTask.remove(s);
boolean isBeingRepaired;
boolean cheesed = IntelligenceAgency.getEnemyStrat() == IntelligenceAgency.EnemyStrats.ZealotRush && gameState.frameCount >= 24 * 60 * 2.2;
boolean fastExpanding = gameState.getStrat().name.contains("GreedyFE") && Util.countBuildingAll(UnitType.Terran_Command_Center) == 2 && gameState.CCs.size() < 2 && gameState.firstExpand;
for (Bunker w : gameState.DBs.keySet()) {
int count = 0;
if (UnitType.Terran_Bunker.maxHitPoints() != w.getHitPoints() || (cheesed && Util.countBuildingAll(UnitType.Terran_Command_Center) < 2) || fastExpanding) {
for (Mechanical r : gameState.repairerTask.values()) {
if (w.equals(r))
count++;
}
if (count < 2 && (gameState.defense || cheesed || fastExpanding)) {
gameState.chosenUnitRepair = w;
return State.SUCCESS;
}
if (count == 0) {
gameState.chosenUnitRepair = w;
return State.SUCCESS;
}
}
}
isBeingRepaired = false;
for (MissileTurret b : gameState.Ts) {
if (UnitType.Terran_Missile_Turret.maxHitPoints() != b.getHitPoints()) {
for (Mechanical r : gameState.repairerTask.values()) {
if (b.equals(r)) {
// TODO check to add break?
isBeingRepaired = true;
}
}
if (!isBeingRepaired) {
gameState.chosenUnitRepair = b;
return State.SUCCESS;
}
}
}
isBeingRepaired = false;
for (Squad s : gameState.sqManager.squads.values()) {
if (s.status != Squad.Status.IDLE)
continue;
for (UnitInfo u : s.members) {
if (u.unit instanceof Mechanical && u.health != u.unitType.maxHitPoints()) {
Area unitArea = gameState.bwem.getMap().getArea(u.tileposition);
for (Base b : gameState.CCs.keySet()) {
if (unitArea != null && b.getArea().equals(unitArea)) {
for (Mechanical r : gameState.repairerTask.values()) {
if (u.unit.equals(r)) {
isBeingRepaired = true;
}
}
if (!isBeingRepaired) {
gameState.chosenUnitRepair = (Mechanical) u.unit;
return State.SUCCESS;
}
}
}
}
}
}
if (!gameState.getStrat().proxy) {
isBeingRepaired = false;
for (Barracks b : gameState.MBs) {
if (UnitType.Terran_Barracks.maxHitPoints() != b.getHitPoints()) {
for (Mechanical r : gameState.repairerTask.values()) {
if (b.equals(r)) {
isBeingRepaired = true;
}
}
if (!isBeingRepaired) {
gameState.chosenUnitRepair = b;
return State.SUCCESS;
}
}
}
}
isBeingRepaired = false;
for (Factory b : gameState.Fs) {
if (b.equals(gameState.proxyBuilding))
continue;
if (UnitType.Terran_Factory.maxHitPoints() != b.getHitPoints()) {
for (Mechanical r : gameState.repairerTask.values()) {
if (b.equals(r)) {
isBeingRepaired = true;
}
}
if (!isBeingRepaired) {
gameState.chosenUnitRepair = b;
return State.SUCCESS;
}
}
}
isBeingRepaired = false;
for (ResearchingFacility b : gameState.UBs) {
if (b.getType().maxHitPoints() != b.getHitPoints()) {
for (Mechanical r : gameState.repairerTask.values()) {
if (b.equals(r)) {
isBeingRepaired = true;
}
}
if (!isBeingRepaired) {
gameState.chosenUnitRepair = (Mechanical) b;
return State.SUCCESS;
}
}
}
isBeingRepaired = false;
for (SupplyDepot b : gameState.SBs) {
if (UnitType.Terran_Supply_Depot.maxHitPoints() != b.getHitPoints()) {
for (Mechanical r : gameState.repairerTask.values()) {
if (b.equals(r)) {
isBeingRepaired = true;
}
}
if (!isBeingRepaired) {
gameState.chosenUnitRepair = b;
return State.SUCCESS;
}
}
}
isBeingRepaired = false;
for (CommandCenter b : gameState.CCs.values()) {
if (UnitType.Terran_Command_Center.maxHitPoints() != b.getHitPoints()) {
for (Mechanical r : gameState.repairerTask.values()) {
if (b.equals(r)) {
isBeingRepaired = true;
}
}
if (!isBeingRepaired) {
gameState.chosenUnitRepair = b;
return State.SUCCESS;
}
}
}
isBeingRepaired = false;
for (ComsatStation b : gameState.CSs) {
if (UnitType.Terran_Comsat_Station.maxHitPoints() != b.getHitPoints()) {
for (Mechanical r : gameState.repairerTask.values()) {
if (b.equals(r)) {
isBeingRepaired = true;
}
}
if (!isBeingRepaired) {
gameState.chosenUnitRepair = b;
return State.SUCCESS;
}
}
}
isBeingRepaired = false;
for (Starport b : gameState.Ps) {
if (UnitType.Terran_Starport.maxHitPoints() != b.getHitPoints()) {
for (Mechanical r : gameState.repairerTask.values()) {
if (b.equals(r)) {
isBeingRepaired = true;
}
}
if (!isBeingRepaired) {
gameState.chosenUnitRepair = b;
return State.SUCCESS;
}
}
}
return State.FAILURE;
} catch (Exception e) {
System.err.println(this.getClass().getSimpleName());
e.printStackTrace();
return State.ERROR;
}
}
use of ecgberht.UnitInfo in project Ecgberht by Jabbo16.
the class CheckEnemyBaseVisible method execute.
@Override
public State execute() {
try {
List<PlayerUnit> enemies = gameState.getGame().getUnits(gameState.getIH().enemy());
if (!enemies.isEmpty()) {
for (UnitInfo u : gameState.unitStorage.getEnemyUnits().values().stream().filter(u -> u.unitType.isBuilding()).collect(Collectors.toSet())) {
if (Util.broodWarDistance(gameState.chosenScout.getPosition(), u.lastPosition) <= 500) {
gameState.enemyMainBase = Util.getClosestBaseLocation(u.lastPosition);
gameState.scoutSLs = new HashSet<>();
if (!gameState.getStrat().name.equals("PlasmaWraithHell")) {
gameState.chosenHarasser = (Worker) gameState.chosenScout;
}
gameState.chosenScout = null;
Util.sendText("!");
gameState.playSound("gearthere.mp3");
if (gameState.enemyStartBase == null) {
gameState.enemyBLs.clear();
gameState.enemyBLs.addAll(gameState.BLs);
gameState.enemyBLs.sort(new BaseLocationComparator(gameState.enemyMainBase));
if (gameState.firstScout) {
gameState.enemyStartBase = gameState.enemyMainBase;
gameState.enemyMainArea = gameState.enemyStartBase.getArea();
gameState.enemyNaturalBase = gameState.enemyBLs.get(1);
gameState.enemyNaturalArea = gameState.enemyNaturalBase.getArea();
}
}
return State.SUCCESS;
}
}
}
return State.FAILURE;
} catch (Exception e) {
System.err.println(this.getClass().getSimpleName());
e.printStackTrace();
return State.ERROR;
}
}
Aggregations