use of eidolons.game.battlecraft.ai.elements.actions.Action in project Eidolons by IDemiurge.
the class PathBuilder method checkAddFaceTurn.
private void checkAddFaceTurn() {
unit.setFacing(c_facing);
unit.setCoordinates(c_coordinate);
if (ReasonMaster.checkReasonCannotTarget(FILTER_REASON.FACING, targetAction)) {
List<Action> sequence = getTurnSequenceConstructor().getTurnSequence(targetAction);
for (Action a : sequence) {
path.add(new Choice(c_coordinate, a));
}
}
unit.setFacing(originalFacing);
unit.setCoordinates(originalCoordinate);
}
use of eidolons.game.battlecraft.ai.elements.actions.Action in project Eidolons by IDemiurge.
the class PriorityManagerImpl method applyConvergingPathsPriorities.
public void applyConvergingPathsPriorities(List<ActionSequence> actions) {
// TODO make sure that they are not pruned at path-building phase!
// split into groups and for each group, add bonus per group member!
Map<Action, List<ActionSequence>> asGroups = new HashMap<>();
for (ActionSequence as : actions) {
Action firstAction = as.get(0);
List<ActionSequence> group = asGroups.get(firstAction);
if (group == null) {
group = new ArrayList<>();
asGroups.put(firstAction, group);
}
group.add(as);
}
for (Action firstAction : asGroups.keySet()) {
for (ActionSequence as : asGroups.get(firstAction)) {
for (ActionSequence as2 : asGroups.get(firstAction)) {
if (as2 == as) {
continue;
}
if (as2.getLastAction().getTarget() != null) {
if (as2.getLastAction().getTarget().equals(as.getLastAction().getTarget())) {
continue;
}
}
int bonus = MathMaster.round(as2.getPriority() / asGroups.get(firstAction).size() * (getConstInt(AiConst.CONVERGING_FACTOR)));
LogMaster.log(getLogChannel(), bonus + " Converging Paths bonus added to " + as.getPriority() + as.getActions() + " from " + as2.getPriority() + as2.getActions());
as.setPriority(as.getPriority() + bonus);
}
}
}
}
use of eidolons.game.battlecraft.ai.elements.actions.Action in project Eidolons by IDemiurge.
the class DC_MovementManager method buildPath.
public List<ActionPath> buildPath(Unit unit, Coordinates coordinates) {
List<DC_ActiveObj> moves = getMoves(unit);
PathBuilder builder = PathBuilder.getInstance().init(moves, new Action(unit.getAction("Move")));
List<ActionPath> paths = builder.build(new ListMaster<Coordinates>().getList(coordinates));
if (paths.isEmpty()) {
return null;
}
return paths;
}
use of eidolons.game.battlecraft.ai.elements.actions.Action in project Eidolons by IDemiurge.
the class CellPrioritizer method getPriorityForCell.
/*
* Perhaps one could feed an action to this method!.. Or actions...
*/
public int getPriorityForCell(Unit unit, Obj cell, DC_ActiveObj targetAcsdftion) {
/*
* getOrCreate attack priority for each adjacent enemy...
*/
/*
* I could exclude paths for zone spells, let the range be the limit for
* now
*/
int priority = 0;
List<ActionPath> paths = pathMap.get(cell.getCoordinates());
if (paths == null) {
paths = getPathBuilder().init(moves, targetAction).build(new ListMaster<Coordinates>().getList(cell.getCoordinates()));
pathMap.put(cell.getCoordinates(), paths);
}
if (!ListMaster.isNotEmpty(paths)) {
return 0;
}
int path_priority = paths.get(0).getPriority();
for (Coordinates c : cell.getCoordinates().getAdjacentCoordinates()) {
Obj targetObj = unit.getGame().getObjectByCoordinate(c, false);
if (targetObj != null) {
if (targetObj.getOBJ_TYPE_ENUM() != DC_TYPE.BF_OBJ) {
if (Analyzer.isEnemy(targetObj, unit)) {
Integer cell_priority = enemyPriorityMap.get(targetObj);
if (cell_priority != null) {
priority += cell_priority;
continue;
}
Unit enemy = (Unit) targetObj;
cell_priority = DC_PriorityManager.getUnitPriority(targetObj);
// "now"?
cell_priority -= DC_PriorityManager.getMeleeThreat(enemy);
// should all AI-units *be afraid*? :) Maybe memory map
// will do nicely here?
// if ()
Action action = new Action(unit.getAction("attack"), enemy);
// if (melee )
// PriorityManager.getDamagePriority(action, targetObj,
// false);
priority += DC_PriorityManager.getAttackPriority(new ActionSequence(action));
DC_UnitAction offhand_attack = unit.getAction("offhand attack");
// use its priority?
if (offhand_attack != null) {
action = new Action(offhand_attack, enemy);
priority += DC_PriorityManager.getAttackPriority(new ActionSequence(action));
}
// do we calculate move costs before or after?
enemyPriorityMap.put(targetObj, cell_priority);
priority += cell_priority;
}
}
}
}
priority += priority * path_priority / 100;
return priority;
}
use of eidolons.game.battlecraft.ai.elements.actions.Action in project Eidolons by IDemiurge.
the class Choice method getTurns.
public Boolean[] getTurns() {
if (actions.size() == 1 || turns != null) {
return turns;
}
try {
List<Boolean> list = new ArrayList<>();
for (Action a : actions) {
DC_ActiveObj active = a.getActive();
if (active.getName().contains("lockwise")) {
if (!active.isConstructed()) {
active.construct();
}
for (Effect e : active.getAbilities().getEffects()) {
if (e instanceof ChangeFacingEffect) {
list.add(((ChangeFacingEffect) e).isClockwise());
}
}
}
}
turns = list.toArray(new Boolean[list.size()]);
return turns;
} catch (Exception e) {
}
return null;
}
Aggregations