Search in sources :

Example 6 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class GoalManager method getGoalsForUnit.

public static List<GOAL_TYPE> getGoalsForUnit(UnitAI ai) {
    Unit unit = ai.getUnit();
    List<GOAL_TYPE> list = getBehaviorGoals(unit);
    if (list != null) {
        return list;
    }
    if (ai.getCurrentOrder() != null)
        if (ai.getCurrentOrder().getStrictPriority() != null)
            return new ArrayList<>(Arrays.asList(ai.getCurrentOrder().getStrictPriority().getGoalTypes()));
    list = new ArrayList<>();
    if (unit.getAiType() == AiEnums.AI_TYPE.SNEAK) {
        list.add(AiEnums.GOAL_TYPE.STEALTH);
    }
    if (Analyzer.getVisibleEnemies(unit.getUnitAI()).isEmpty()) {
        list = new ListMaster<GOAL_TYPE>().getList(AiEnums.GOAL_TYPE.SEARCH);
        addNonEnemyGoals(list);
        return list;
    }
    if (unit.checkAiMod(AI_MODIFIERS.TRUE_BRUTE)) {
        return new ListMaster<GOAL_TYPE>().getList(AiEnums.GOAL_TYPE.ATTACK);
    }
    list.addAll(getDefaultGoals());
    if (unit.getAiType() == AiEnums.AI_TYPE.CASTER || unit.getAiType() == AiEnums.AI_TYPE.ARCHER) {
        if (!unit.checkPassive(UnitEnums.STANDARD_PASSIVES.FEARLESS)) {
            if (DC_PriorityManager.getMeleeDangerFactor(unit) > 0) {
                list.add(AiEnums.GOAL_TYPE.RETREAT);
            }
        }
    }
    if (Analyzer.hasAnySpecialActions(unit)) {
        addNonEnemyGoals(list);
        addEnemyGoals(list);
    }
    list.sort(getSorter(ai));
    // FLEE
    return list;
}
Also used : ArrayList(java.util.ArrayList) GOAL_TYPE(main.content.enums.system.AiEnums.GOAL_TYPE) ListMaster(main.system.auxiliary.data.ListMaster) Unit(eidolons.entity.obj.unit.Unit)

Example 7 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class AI_Manager method resetGroups.

private void resetGroups() {
    // }
    if (groups == null)
        groups = new ArrayList<>();
    for (Object sub : game.getBattleMaster().getPlayerManager().getPlayers()) {
        DC_Player player = (DC_Player) sub;
        for (Unit unit : player.getControlledUnits_()) {
            GroupAI group = unit.getAI().getGroup();
            if (group == null)
                group = new GroupAI(unit);
            for (Unit unit1 : player.getControlledUnits_()) {
                if (unit1.getAI().getGroup() != null)
                    continue;
                if (unit1.equals(unit))
                    continue;
                double max_distance = 2.5;
                if (PositionMaster.getExactDistance(unit1.getCoordinates(), unit.getCoordinates()) >= max_distance)
                    continue;
                if (!game.getVisionMaster().getSightMaster().getClearShotCondition().check(unit, unit1))
                    continue;
                group.add(unit1);
            }
            if (!groups.contains(group))
                groups.add(group);
        }
    }
    if (!groups.isEmpty())
        return;
    else
        return;
}
Also used : ArrayList(java.util.ArrayList) Unit(eidolons.entity.obj.unit.Unit) DC_Player(eidolons.game.battlecraft.logic.battle.universal.DC_Player)

Example 8 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class AI_Manager method chooseEnemyToEngage.

public static Unit chooseEnemyToEngage(Unit obj, List<Unit> units) {
    if (obj.getAiType() == AiEnums.AI_TYPE.CASTER) {
        return null;
    }
    if (obj.getAiType() == AiEnums.AI_TYPE.ARCHER) {
        return null;
    }
    if (obj.getAiType() == AiEnums.AI_TYPE.SNEAK) {
        return null;
    }
    Unit topPriorityUnit = null;
    int topPriority = -1;
    for (Unit u : units) {
        int priority = DC_PriorityManager.getUnitPriority(u, true);
        if (priority > topPriority) {
            topPriority = priority;
            topPriorityUnit = u;
        }
    }
    return topPriorityUnit;
}
Also used : Unit(eidolons.entity.obj.unit.Unit)

Example 9 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class BehaviorMaster method getAction.

private Action getAction(GOAL_TYPE type, UnitAI ai) {
    String action = null;
    Integer target = null;
    // doesn't the group have standing orders as a whole?..
    Unit unit = ai.getUnit();
    Ref ref = new Ref(unit);
    GroupAI group = ai.getGroup();
    // checkBehaviorChange(group); where does that happen?
    switch(type) {
        case AMBUSH:
            break;
        case STALK:
            break;
        case STAND_GUARD:
        case PATROL:
            PatrolMaster.getPatrolAction(ai);
        // having already turned on the Mode
        case SEARCH:
        case WANDER:
            if (ai.isLeader()) {
                Boolean change = WanderAi.checkWanderDirectionChange(group, type);
                if (change == null) {
                    action = getIdleAction(ai, type);
                    change = true;
                }
                // maybe go meet leader if blocked... or something like it
                if (change) {
                    group.getWanderStepCoordinateStack().push(group.getLeader().getCoordinates());
                    WanderAi.changeGroupMoveDirection(group, type);
                }
            }
            boolean wait = false;
            // ActionSequenceConstructor.getSequence(targetAction, task)
            Coordinates targetCoordinates = WanderAi.getCoordinates(type, ai);
            if (targetCoordinates == null) {
                wait = true;
            // if (!recursion)
            // return null;
            // recursion = true;
            // return getAction(type, ai);
            } else {
                action = STD_ACTIONS.Move.name();
                // if (!unit.getAction(action).canBeActivated()) {
                // }
                ActionPath path = getPathBuilder().init(new ListMaster<DC_ActiveObj>().getList(unit.getAction(action)), new Action(unit.getAction(action), new Ref(unit))).getPathByPriority(new ListMaster<Coordinates>().getList(targetCoordinates));
                if (path == null) {
                    // TODO preCheck if path
                    ai.setPathBlocked(true);
                // appropriate
                } else {
                    ai.setPathBlocked(false);
                    return path.getActions().get(0);
                }
            }
            if (wait) {
                action = getIdleAction(ai, type);
            } else {
            // if (change) {
            // targetCoordinates = WanderMaster.getCoordinates(type,
            // ai);
            // }
            // return path.getActions().getOrCreate(0);
            }
    }
    DC_ActiveObj active = unit.getAction(action);
    ref.setTarget(target);
    recursion = false;
    return new Action(active, ref);
}
Also used : Action(eidolons.game.battlecraft.ai.elements.actions.Action) Coordinates(main.game.bf.Coordinates) ActionPath(eidolons.game.battlecraft.ai.tools.path.ActionPath) ListMaster(main.system.auxiliary.data.ListMaster) Unit(eidolons.entity.obj.unit.Unit) Ref(main.entity.Ref) GroupAI(eidolons.game.battlecraft.ai.GroupAI) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 10 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class ActionManager method checkWaitForBlockingAlly.

private Integer checkWaitForBlockingAlly() {
    Coordinates c = getUnit().getCoordinates().getAdjacentCoordinate(getUnit().getFacing().getDirection());
    Obj obj = getUnit().getGame().getObjectVisibleByCoordinate(c);
    if (obj instanceof Unit) {
        if (((Unit) obj).canActNow()) // if (!((DC_HeroObj) obj).checkStatus(STATUS.WAITING))
        {
            return obj.getId();
        }
    }
    return null;
}
Also used : Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit)

Aggregations

Unit (eidolons.entity.obj.unit.Unit)258 Coordinates (main.game.bf.Coordinates)53 Ref (main.entity.Ref)33 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)30 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)26 DC_Obj (eidolons.entity.obj.DC_Obj)26 ArrayList (java.util.ArrayList)26 Obj (main.entity.obj.Obj)26 ObjType (main.entity.type.ObjType)23 DC_SpellObj (eidolons.entity.active.DC_SpellObj)13 DC_Cell (eidolons.entity.obj.DC_Cell)11 Event (main.game.logic.event.Event)11 DC_UnitAction (eidolons.entity.active.DC_UnitAction)10 List (java.util.List)10 DC_Game (eidolons.game.core.game.DC_Game)9 Action (eidolons.game.battlecraft.ai.elements.actions.Action)8 DequeImpl (main.system.datatypes.DequeImpl)8 OUTLINE_TYPE (main.content.enums.rules.VisionEnums.OUTLINE_TYPE)7 Entity (main.entity.Entity)7 DIRECTION (main.game.bf.Coordinates.DIRECTION)7