use of main.game.bf.pathing.Path in project Eidolons by IDemiurge.
the class BfAnalyzer method checkCells.
public Obj checkCells(Obj targetUnit, Collection<Obj> set, boolean canMove) {
double cost = Double.MAX_VALUE;
Obj cell = null;
for (Obj adjCell : set) {
if (canMove) {
if (!movementManager.canMove(getAi().getUnit(), adjCell)) {
LogMaster.log(LogMaster.AI_DEBUG, ai.getLogic().getUnit() + " can't move to " + adjCell);
continue;
}
}
Path path = movementManager.getPath(targetUnit, adjCell);
if (path == null) {
LogMaster.log(LogMaster.AI_DEBUG, ai.getLogic().getUnit() + " has no path to " + adjCell);
continue;
}
if (cost > path.getCost()) {
cost = path.getCost();
cell = adjCell;
}
}
return cell;
}
use of main.game.bf.pathing.Path in project Eidolons by IDemiurge.
the class DC_MovementManager method canMove.
@Deprecated
public boolean canMove(Obj obj, Obj cell) {
Unit unit = (Unit) obj;
int moves = 0;
int actions = unit.getIntParam(PARAMS.C_N_OF_ACTIONS);
if (moves == 0 || actions == 0) {
return false;
}
Path path = getPath(unit, cell);
if (path == null) {
return false;
}
double cost = path.getCost();
if (cost == PathingManager.NO_PATH) {
return false;
}
return Math.min(moves, actions) >= getIntegerCost(cost);
// return cost
// Coordinates objP = new Coordinates(unit.getX(), unit.getY());
// Coordinates cellP = new Coordinates(cell.getX(), cell.getY());
//
// // straight line only
// if (!PositionMaster.inLine(unit, cell))
// if (!unit.isAgile())
// return false;
//
// if (PositionMaster.inLine(unit, cell))
// if (!noObstacles(objP, cellP))
// if (!unit.isFlying())
// return false;
//
// if (Math.min(moves, actions) < PositionMaster.getDistance(unit,
// cell))
// return false;
// return true;
}
use of main.game.bf.pathing.Path in project Eidolons by IDemiurge.
the class DC_Bf_Analyzer method getClosestAttackTarget.
@Override
public Obj getClosestAttackTarget() {
DC_UnitModel unit = (DC_UnitModel) ai.getLogic().getUnit();
Obj enemy_unit = null;
int cost = Integer.MAX_VALUE;
for (Obj obj : getEnemy().getControlledUnits()) {
DC_UnitModel enemyUnit = (DC_UnitModel) obj;
Obj cell = getClosestCell(enemyUnit, false);
if (cell == null) {
continue;
}
Path path = movementManager.getPath(unit, cell);
if (path == null) {
continue;
}
if (cost > path.getIntegerCost()) {
enemy_unit = enemyUnit;
}
}
if (enemy_unit == null) {
enemy_unit = enemy.getHeroObj();
}
LogMaster.log(LogMaster.AI_DEBUG, enemy_unit + " has been picked as closest target for " + ai.getLogic().getUnit());
return enemy_unit;
}
Aggregations