use of eidolons.game.battlecraft.ai.tools.path.ActionPath in project Eidolons by IDemiurge.
the class ActionSequenceConstructor method getSequencesFromPaths.
public List<ActionSequence> getSequencesFromPaths(List<ActionPath> paths, Task task, Action action) {
List<ActionSequence> list = new ArrayList<>();
for (ActionPath path : paths) {
if (!TimeLimitMaster.checkTimeLimitForAi(getUnitAI()))
break;
ActionSequence sequence = new ActionSequence(path.getActions(), task, task.getAI());
if (action.getActive().isRanged()) {
List<Action> rangedAttackSequence = constructSingleAttackSequence(action, task);
if (rangedAttackSequence.isEmpty()) {
return list;
}
// TODO
sequence.getActions().addAll(rangedAttackSequence);
} else {
sequence.getActions().add(action);
}
list.add(sequence);
}
return list;
}
use of eidolons.game.battlecraft.ai.tools.path.ActionPath in project Eidolons by IDemiurge.
the class ActionSequenceConstructor method getSequencesWithPathsForAction.
private List<ActionSequence> getSequencesWithPathsForAction(Action action, Object arg, Task task) {
List<ActionSequence> list = new ArrayList<>();
game = action.getRef().getGame();
unit = action.getSource();
if (task.getAI().getBehaviorMode() == AiEnums.BEHAVIOR_MODE.PANIC) {
// target action = FLEE;
}
if (task.getType() == AiEnums.GOAL_TYPE.RETREAT) {
{
List<ActionSequence> sequencesFromPaths = getSequencesFromPaths(getPathSequenceConstructor().getRetreatPaths(arg), task, action);
return sequencesFromPaths;
}
// TODO
}
boolean singleAction = action.isSingle();
if (task.getType() == GOAL_TYPE.PROTECT) {
singleAction = action.getSource().getCoordinates().equals(action.getTarget().getCoordinates());
} else if (!singleAction) {
if (arg != null) {
singleAction = // .toString()));
TargetingMaster.canBeTargeted(action, true);
} else {
singleAction = (action).canBeActivated();
}
}
// if (ReasonMaster.getReasons(action).getOrCreate(0)==FILTER_REASON.FACING)
if (singleAction) {
ActionSequence sequence = constructSingleActionSequence(action, task);
if (sequence == null) {
return null;
}
list.add(sequence);
return list;
}
if (!task.isForced()) {
// TODO REFACTOR
if (task.getType() != GOAL_TYPE.PROTECT && task.getType() != AiEnums.GOAL_TYPE.ATTACK && task.getType() != AiEnums.GOAL_TYPE.RETREAT && task.getType() != AiEnums.GOAL_TYPE.SEARCH && task.getType() != AiEnums.GOAL_TYPE.MOVE && !task.getType().isBehavior()) {
return null;
}
}
if (task.getType() == AiEnums.GOAL_TYPE.SUMMONING) {
return null;
}
if (task.getType() == AiEnums.GOAL_TYPE.ZONE_DAMAGE) {
// TODO until pathing/cell-pr. is fixed
return null;
}
if (!task.isForced()) {
if (task.getAI().checkMod(AI_MODIFIERS.TRUE_BRUTE)) {
return null;
}
if (task.getAI().getBehaviorMode() == AiEnums.BEHAVIOR_MODE.BERSERK) {
return null;
}
// if (getAnalyzer().isRanged(task.getAI())) return null ;
// TODO if ((!action.getActive().isRanged() && task.getAI().getType() == AiEnums.AI_TYPE.ARCHER)
// || (task.getAI().getType() == AiEnums.AI_TYPE.CASTER && !unit.getSpells().isEmpty())) {
// return null;
// }
}
Unit unit = (Unit) action.getRef().getSourceObj();
List<DC_ActiveObj> moveActions = getMoveActions(action);
if (!ListMaster.isNotEmpty(moveActions)) {
// [QUICK FIX]
if (!unit.getAction(DC_ActionManager.STD_ACTIONS.Turn_Anticlockwise.name()).canBeActivated(action.getRef(), true) && !unit.getAction(DC_ActionManager.STD_ACTIONS.Move.name()).canBeActivated(action.getRef(), true)) {
return null;
}
} else {
// if (prioritizedCells == null)
// prioritizedCells = CellPrioritizer
// .getMeleePriorityCellsForUnit(unit.getUnitAI(),
// moveActions, action);
}
List<ActionPath> paths = getPathSequenceConstructor().getPathSequences(moveActions, action);
list = getSequencesFromPaths(paths, task, action);
// }
return list;
}
use of eidolons.game.battlecraft.ai.tools.path.ActionPath in project Eidolons by IDemiurge.
the class PathSequenceConstructor method getOptimalPathSequence.
public ActionPath getOptimalPathSequence(UnitAI ai, Coordinates targetCell) {
List<DC_ActiveObj> moves = AiUnitActionMaster.getMoveActions(ai.getUnit());
Action action = AiActionFactory.newAction("Move", ai);
List<Coordinates> coordinates = new ArrayList<>();
coordinates.add(targetCell);
List<ActionPath> paths = getPathSequences(moves, action, coordinates);
// });
return paths.get(0);
}
use of eidolons.game.battlecraft.ai.tools.path.ActionPath in project Eidolons by IDemiurge.
the class WanderAi method getOrders.
@Override
public ActionSequence getOrders(UnitAI ai) {
Coordinates c1 = null;
try {
WanderAi.checkWanderDirectionChange(ai.getGroup(), GOAL_TYPE.WANDER);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
try {
c1 = (getWanderTargetCoordinatesCell(ai, GOAL_TYPE.WANDER));
} catch (Exception e) {
c1 = (CoordinatesMaster.getRandomAdjacentCoordinate(ai.getUnit().getCoordinates()));
main.system.ExceptionMaster.printStackTrace(e);
}
c1 = Positioner.adjustCoordinate(ai.getUnit(), c1, ai.getUnit().getFacing(), getWanderPredicate(ai.getUnit(), ai.getUnit().getFacing(), c1));
Task task = new Task(ai, GOAL_TYPE.WANDER, null);
List<Action> turnSequence = getMaster(ai).getTurnSequenceConstructor().getTurnSequence(ai.getUnit(), c1);
if (ListMaster.isNotEmpty(turnSequence)) {
return new ActionSequence(turnSequence, task, ai);
}
List<Coordinates> c = new ArrayList<>();
c.add(c1);
getMaster(ai).setUnit(ai.getUnit());
// getMaster(ai).getPathBuilder().init(null, null);
// TimeLimitMaster.markTimeForAI(ai);
List<ActionPath> paths = new ArrayList<>();
// getMaster(ai).getPathBuilder().build(c);
Action action = null;
if (paths.isEmpty()) {
if (c.get(0) != null)
action = getMaster(ai).getAtomicAi().getAtomicMove(c.get(0), ai.getUnit());
else
action = getMaster(ai).getAtomicAi().getAtomicActionApproach(ai);
if (action != null)
return new ActionSequence(GOAL_TYPE.WANDER, action);
} else
action = paths.get(0).getActions().get(0);
if (action == null)
return null;
List<ActionSequence> sequences = getMaster(ai).getActionSequenceConstructor().getSequencesFromPaths(paths, task, action);
if (sequences.isEmpty())
return null;
return sequences.get(0);
}
Aggregations