use of org.openbw.bwapi4j.Position in project Ecgberht by Jabbo16.
the class CameraModule method isNearStartLocation.
private boolean isNearStartLocation(Position pos) {
int distance = 1000;
List<TilePosition> startLocations = game.getBWMap().getStartPositions();
for (TilePosition it : startLocations) {
Position startLocation = it.toPosition();
// if the start position is not our own home, and the start position is closer than distance
if (!isNearOwnStartLocation(startLocation) && startLocation.getDistance(pos) <= distance)
return true;
}
return false;
}
use of org.openbw.bwapi4j.Position in project Ecgberht by Jabbo16.
the class VesselAgent method hover.
private void hover() {
Position attack = follow.attack;
if (attack == null || !getGs().getGame().getBWMap().isValidPosition(attack))
return;
UtilMicro.move(unit, attack);
}
use of org.openbw.bwapi4j.Position 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 org.openbw.bwapi4j.Position in project Ecgberht by Jabbo16.
the class VesselAgent method retreat.
private void retreat() {
Position CC = getGs().getNearestCC(myUnit.getPosition(), true);
if (CC != null)
((MobileUnit) myUnit).move(CC);
else
((MobileUnit) myUnit).move(getGs().getPlayer().getStartLocation().toPosition());
attackPos = null;
attackUnit = null;
}
use of org.openbw.bwapi4j.Position 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;
}
Aggregations