Search in sources :

Example 31 with Action

use of eidolons.game.battlecraft.ai.elements.actions.Action in project Eidolons by IDemiurge.

the class GuardAi method getOrders.

@Override
public ActionSequence getOrders(UnitAI ai) {
    if (isEnabled(ai))
        return null;
    // check mode
    Coordinates target = CoordinatesMaster.getRandomAdjacentCoordinate(ai.getUnit().getCoordinates());
    List<Action> list = getMaster(ai).getTurnSequenceConstructor().getTurnSequence(FACING_SINGLE.IN_FRONT, ai.getUnit(), target);
    return new ActionSequence(GOAL_TYPE.PROTECT, list.toArray(new Action[list.size()]));
}
Also used : Action(eidolons.game.battlecraft.ai.elements.actions.Action) ActionSequence(eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence) Coordinates(main.game.bf.Coordinates)

Example 32 with Action

use of eidolons.game.battlecraft.ai.elements.actions.Action 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);
}
Also used : Task(eidolons.game.battlecraft.ai.elements.task.Task) Action(eidolons.game.battlecraft.ai.elements.actions.Action) ActionSequence(eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence) Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) ActionPath(eidolons.game.battlecraft.ai.tools.path.ActionPath)

Aggregations

Action (eidolons.game.battlecraft.ai.elements.actions.Action)32 DC_UnitAction (eidolons.entity.active.DC_UnitAction)16 Coordinates (main.game.bf.Coordinates)11 Unit (eidolons.entity.obj.unit.Unit)9 ArrayList (java.util.ArrayList)9 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)8 AiQuickItemAction (eidolons.game.battlecraft.ai.elements.actions.AiQuickItemAction)7 ActionSequence (eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence)7 ActionPath (eidolons.game.battlecraft.ai.tools.path.ActionPath)7 Ref (main.entity.Ref)6 DC_QuickItemAction (eidolons.entity.active.DC_QuickItemAction)4 FACING_SINGLE (main.content.enums.entity.UnitEnums.FACING_SINGLE)3 GOAL_TYPE (main.content.enums.system.AiEnums.GOAL_TYPE)3 Obj (main.entity.obj.Obj)3 DC_Cell (eidolons.entity.obj.DC_Cell)2 DC_Obj (eidolons.entity.obj.DC_Obj)2 UnitAI (eidolons.game.battlecraft.ai.UnitAI)2 Task (eidolons.game.battlecraft.ai.elements.task.Task)2 Effect (main.ability.effects.Effect)2 Context (main.game.logic.action.context.Context)2