Search in sources :

Example 11 with ActionSequence

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

the class ExplorePartyMaster method checkNewGoal.

public void checkNewGoal(Unit unit) {
    DC_ActiveObj active = lastAction.getAction();
    if (active.getActionGroup() == ACTION_TYPE_GROUPS.MODE) {
        Goal goal = getNewGoal(active, unit.getAI());
        if (goal != null) {
            master.getGame().getAiManager().setUnit(unit);
            List<ActionSequence> sequences = master.getGame().getAiManager().getActionSequenceConstructor().createActionSequencesForGoal(goal, unit.getAI());
            if (!sequences.isEmpty()) {
                ActionSequence sequence = master.getGame().getAiManager().getPriorityManager().chooseByPriority(sequences);
                unit.getAI().setStandingOrders(sequence);
            }
        }
    }
// if (mainHero.getMode()!=null ){
// }
}
Also used : Goal(eidolons.game.battlecraft.ai.elements.goal.Goal) ActionSequence(eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 12 with ActionSequence

use of eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence 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 13 with ActionSequence

use of eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence 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

ActionSequence (eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence)13 Action (eidolons.game.battlecraft.ai.elements.actions.Action)7 DC_UnitAction (eidolons.entity.active.DC_UnitAction)5 Coordinates (main.game.bf.Coordinates)5 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)3 ArrayList (java.util.ArrayList)3 GOAL_TYPE (main.content.enums.system.AiEnums.GOAL_TYPE)3 Unit (eidolons.entity.obj.unit.Unit)2 UnitAI (eidolons.game.battlecraft.ai.UnitAI)2 Goal (eidolons.game.battlecraft.ai.elements.goal.Goal)2 Task (eidolons.game.battlecraft.ai.elements.task.Task)2 ActionPath (eidolons.game.battlecraft.ai.tools.path.ActionPath)2 Obj (main.entity.obj.Obj)2 DC_QuickItemAction (eidolons.entity.active.DC_QuickItemAction)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 Order (eidolons.game.battlecraft.ai.advanced.companion.Order)1 AiActionFactory (eidolons.game.battlecraft.ai.elements.actions.AiActionFactory)1 AiQuickItemAction (eidolons.game.battlecraft.ai.elements.actions.AiQuickItemAction)1 AiHandler (eidolons.game.battlecraft.ai.elements.generic.AiHandler)1 AiMaster (eidolons.game.battlecraft.ai.elements.generic.AiMaster)1