Search in sources :

Example 1 with XList

use of main.data.XList in project Eidolons by IDemiurge.

the class AiUnitActionMaster method getFullActionList.

// returns all of unit's active that we want to preCheck for execution
public static List<DC_ActiveObj> getFullActionList(GOAL_TYPE type, Unit unit) {
    // cache
    List<DC_ActiveObj> actions = new XList<>();
    switch(type) {
        case PROTECT:
            actions.add(AiActionFactory.getUnitAction(unit, "Guard Mode"));
            break;
        case PATROL:
        case WANDER:
        case RETREAT:
        case MOVE:
        case APPROACH:
            // dummy action!
            actions.add(AiActionFactory.getUnitAction(unit, "Move"));
            break;
        case ATTACK:
            if (unit.getActionMap().get(ActionEnums.ACTION_TYPE.SPECIAL_ATTACK) != null) {
                actions.addAll(unit.getActionMap().get(ActionEnums.ACTION_TYPE.STANDARD_ATTACK));
            }
            if (unit.getActionMap().get(ActionEnums.ACTION_TYPE.SPECIAL_ATTACK) != null) {
                actions.addAll(unit.getActionMap().get(ActionEnums.ACTION_TYPE.SPECIAL_ATTACK));
            }
            actions.remove(AiActionFactory.getUnitAction(unit, DC_ActionManager.OFFHAND_ATTACK));
            DC_UnitAction action = unit.getAction("Throw", false);
            actions.remove(action);
            action = unit.getAction("Throw", false);
            actions.remove(action);
            break;
        case DEFEND:
            actions.add(AiActionFactory.getUnitAction(unit, STD_MODE_ACTIONS.Defend.name()));
            actions.add(AiActionFactory.getUnitAction(unit, STD_MODE_ACTIONS.On_Alert.name()));
            break;
        case COWER:
            actions.add(AiActionFactory.getUnitAction(unit, "Cower"));
            break;
        case AMBUSH:
            if (!checkAddStealth(true, unit, actions)) {
                actions.add(AiActionFactory.getUnitAction(unit, STD_MODE_ACTIONS.On_Alert.name()));
            }
            break;
        case STALK:
            if (!checkAddStealth(false, unit, actions)) {
                actions.add(AiActionFactory.getUnitAction(unit, "Move"));
            }
            break;
        case STEALTH:
            checkAddStealth(false, unit, actions);
            break;
        case // can it be MOVE?
        SEARCH:
            if (unit.getBuff("Search Mode") == null) {
                actions.add(AiActionFactory.getUnitAction(unit, "Search Mode"));
            } else {
                actions.add(AiActionFactory.getUnitAction(unit, "Move"));
            }
            break;
        case WAIT:
            actions.add(AiActionFactory.getUnitAction(unit, "Wait"));
            break;
        case PREPARE:
            actions.addAll(unit.getActionMap().get(ActionEnums.ACTION_TYPE.MODE));
            if (!unit.isLiving()) {
                actions.remove(AiActionFactory.getUnitAction(unit, STD_MODE_ACTIONS.Defend.name()));
            }
            actions.remove(AiActionFactory.getUnitAction(unit, STD_MODE_ACTIONS.Defend.name()));
            actions.remove(AiActionFactory.getUnitAction(unit, STD_MODE_ACTIONS.On_Alert.name()));
            break;
    }
    actions.addAll(ActionFilter.filterActives(type, (unit.getSpells())));
    actions.addAll(ActionFilter.filterActives(type, (unit.getQuickItemActives())));
    if (type.isFilterByCanActivate()) {
        actions = ActionFilter.filterByCanActivate(unit, actions);
    }
    return actions;
}
Also used : XList(main.data.XList) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) DC_UnitAction(eidolons.entity.active.DC_UnitAction)

Example 2 with XList

use of main.data.XList in project Eidolons by IDemiurge.

the class LE_MapMaster method clearArea.

public void clearArea(List<Coordinates> coordinates, boolean ignoreBlockChoice) {
    if (!ignoreBlockChoice) {
        ArrayList<MapBlock> blocks = new ArrayList<>();
        for (Coordinates c : CoordinatesMaster.getCornerCoordinates(coordinates)) {
            MapBlock b = getLevel().getBlockForCoordinate(c, true, blocks);
            if (b != null) {
                if (!blocks.contains(b)) {
                    blocks.add(b);
                }
            }
        }
        if (blocks.size() > 1) {
            XList<Object> list = new XList<>(blocks.toArray());
            list.add(0, "New");
            list.add("Fit for each");
            int i = DialogMaster.optionChoice(list.toArray(), "Which block to add coordinates to?");
            if (i > 0 && i != list.size() - 1) {
                setBlock(blocks.get(i - 1));
            } else {
                if (i == 0) {
                    if (DialogMaster.confirm("Create new block?")) {
                        newRoom(coordinates);
                    }
                }
            }
        }
    }
    try {
        LE_ObjMaster.removeObjects(coordinates);
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    } finally {
        setBlock(null);
    }
}
Also used : Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) XList(main.data.XList) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 3 with XList

use of main.data.XList in project Eidolons by IDemiurge.

the class TestSpawner method initGroup.

private void initGroup(Wave group) {
    GroupAI groupAi = new GroupAI(group);
    groupAi.setLeader(group.getParty().getLeader());
    groupAi.setWanderDirection(FacingMaster.getRandomFacing().getDirection());
    group.setAi(groupAi);
    if (getGame().getGameMode() == GAME_MODES.DUNGEON_CRAWL) {
        XList<MapBlock> permittedBlocks = new XList<>();
        permittedBlocks.addAllUnique(group.getBlock().getConnectedBlocks().keySet());
        int wanderBlockDistance = 1;
        for (int i = 0; i < wanderBlockDistance; i++) {
            for (MapBlock b : group.getBlock().getConnectedBlocks().keySet()) {
                permittedBlocks.addAllUnique(b.getConnectedBlocks().keySet());
            }
        }
        groupAi.setPermittedBlocks(permittedBlocks);
    }
}
Also used : GroupAI(eidolons.game.battlecraft.ai.GroupAI) XList(main.data.XList) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 4 with XList

use of main.data.XList in project Eidolons by IDemiurge.

the class DC_PositionMaster method getRectangle.

public static List<Coordinates> getRectangle(boolean allowInvalid, FACING_DIRECTION lengthDirection, FACING_DIRECTION widthDirection, Coordinates baseCoordinate, int length, int width) {
    XList<Coordinates> list = new XList();
    length--;
    if (length < 0) {
        return list;
    }
    width--;
    if (width < 0) {
        return list;
    }
    List<Coordinates> line = getLine(allowInvalid, lengthDirection.getDirection(), baseCoordinate, length);
    list.addAllUnique(line);
    for (Coordinates c : line) {
        list.addAllUnique(getLine(allowInvalid, widthDirection.getDirection(), c, width));
    }
    return list;
}
Also used : Coordinates(main.game.bf.Coordinates) XList(main.data.XList)

Example 5 with XList

use of main.data.XList in project Eidolons by IDemiurge.

the class TaskManager method getTasks.

public List<Task> getTasks(GOAL_TYPE goal, UnitAI ai, boolean forced, DC_ActiveObj action) {
    List<Task> list = new XList<>();
    if (ai.getCurrentOrder() != null)
        if (ai.getCurrentOrder().getArg() != null)
            return new ArrayList<>(Arrays.asList(new Task(ai, goal, ai.getCurrentOrder().getArg())));
    List<Integer> ids = new ArrayList<>();
    List<? extends DC_Obj> targets = new ArrayList<>();
    List<? extends DC_Obj> targets2 = new ArrayList<>();
    BEHAVIOR_MODE behaviorMode = ai.getBehaviorMode();
    // ai.getGroup().getKnownEnemyCoordinatesMap();
    switch(goal) {
        case STAND_GUARD:
        case AMBUSH:
        // preCheck engagement level, default prefs
        case SELF:
        case STEALTH:
            list.add(new Task(forced, ai, goal, ai.getUnit().getId()));
            break;
        // SPEC MODE - KIND OF ON ALERT...
        case PATROL:
            targets = Analyzer.getWanderCells(ai);
            break;
        case // RANDOM DESTINATION MOVEMENT, BLOCK SPECIAL MOVES
        WANDER:
            // limit max distance from original spawning position
            // TODO sometimes in chosen direction
            targets = Analyzer.getWanderCells(ai);
            break;
        case STALK:
            // ai.getGroup().getKnownEnemies
            break;
        case APPROACH:
            targets = getCellPrioritizer().getApproachCells(ai);
            break;
        case SEARCH:
            // or maybe the last-seen enemies?
            if (!forced) {
                if (ai.getUnit().getBuff("Search Mode") == null) {
                    list.add(new Task(forced, ai, goal, ai.getUnit().getId()));
                    break;
                }
            }
            targets = Analyzer.getSearchCells(ai);
            break;
        case RETREAT:
            if (ai.getBehaviorMode() == AiEnums.BEHAVIOR_MODE.PANIC) {
            // only border cells => flee
            }
            targets = Analyzer.getSafeCells(ai);
            break;
        case MOVE:
            targets = Analyzer.getMoveTargetCells(ai);
            break;
        case CUSTOM_HOSTILE:
            targets = Analyzer.getVisibleEnemies(ai);
            checkPrune(targets, goal, ai, action);
            break;
        case CUSTOM_SUPPORT:
            targets = Analyzer.getAllies(ai);
            checkPrune(targets, goal, ai, action);
            break;
        case ZONE_DAMAGE:
            targets = Analyzer.getZoneDamageCells(ai.getUnit());
            targets2 = Analyzer.getAdjacentEnemies(ai.getUnit(), false);
            checkPrune(targets, goal, ai, action);
            break;
        case SUMMONING:
            targets = Analyzer.getSummonCells(ai, action);
            break;
        case DEBILITATE:
        case DEBUFF:
        case ATTACK:
            if (behaviorMode == AiEnums.BEHAVIOR_MODE.BERSERK || behaviorMode == AiEnums.BEHAVIOR_MODE.CONFUSED) {
                targets = (Analyzer.getUnits(ai, true, true, true, false));
            } else {
                // if (forced)
                // targets = (Analyzer.getUnits(ai, false, true, true,
                // false, true));
                // else
                // TODO detected!
                targets = Analyzer.getVisibleEnemies(ai);
            }
            checkPrune(targets, goal, ai, action);
            break;
        case AUTO_DAMAGE:
        case AUTO_DEBUFF:
        case AUTO_BUFF:
        // list.add(new Task(ai, goal, null));
        case RESTORE:
        case BUFF:
            targets = Analyzer.getAllies(ai);
            checkPrune(targets, goal, ai, action);
            break;
        case WAIT:
            if (!DC_Engine.isAtbMode())
                targets = Analyzer.getWaitUnits(ai);
            break;
        case PROTECT:
            if (RuleMaster.isRuleOn(RULE.GUARD))
                if (GuardRule.on)
                    targets = Analyzer.getProtectCells(ai);
            break;
        case COATING:
            Set<Obj> objects = action.getTargeting().getFilter().getObjects(action.getRef());
            for (Obj q : objects) {
                if (q.getRef().getSourceObj() == getUnit()) {
                    // q.isOwnedBy(ai.getUnit().getOwner())
                    ids.add(q.getId());
                }
            }
            break;
        default:
            list.add(new Task(forced, ai, goal, null));
            break;
    }
    if (targets.isEmpty()) {
        return new ArrayList<>();
    }
    if (behaviorMode == AiEnums.BEHAVIOR_MODE.CONFUSED) {
        DC_Obj target = targets.get(new RandomWizard<>().getRandomListIndex(targets));
        List<Task> tasks = new ArrayList<>();
        tasks.add(new Task(forced, ai, goal, target.getId()));
        return tasks;
    }
    if (list.isEmpty()) {
        for (DC_Obj obj : targets) {
            list.add(new Task(forced, ai, goal, obj.getId()));
        }
        for (DC_Obj obj : targets2) {
            list.add(new Task(forced, ai, goal, obj.getId()));
        }
        for (Integer id : ids) {
            list.add(new Task(forced, ai, goal, id));
        }
    }
    return list;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) DC_Obj(eidolons.entity.obj.DC_Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) RandomWizard(main.system.auxiliary.RandomWizard) ArrayList(java.util.ArrayList) XList(main.data.XList) BEHAVIOR_MODE(main.content.enums.system.AiEnums.BEHAVIOR_MODE)

Aggregations

XList (main.data.XList)5 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)2 MapBlock (eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)2 ArrayList (java.util.ArrayList)2 Coordinates (main.game.bf.Coordinates)2 DC_UnitAction (eidolons.entity.active.DC_UnitAction)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 GroupAI (eidolons.game.battlecraft.ai.GroupAI)1 BEHAVIOR_MODE (main.content.enums.system.AiEnums.BEHAVIOR_MODE)1 Obj (main.entity.obj.Obj)1 RandomWizard (main.system.auxiliary.RandomWizard)1