Search in sources :

Example 1 with ListMaster

use of main.system.auxiliary.data.ListMaster in project Eidolons by IDemiurge.

the class PathSequenceConstructor method getTargetCells.

private List<Coordinates> getTargetCells(Action targetAction) {
    if (targetAction.isDummy()) {
        return new ListMaster<Coordinates>().getList(targetAction.getTarget().getCoordinates());
    }
    if (targetAction.getActive().getName().equalsIgnoreCase(StringMaster.getWellFormattedString(STD_SPEC_ACTIONS.Guard_Mode.toString()))) {
        return new ListMaster<Coordinates>().toList_(targetAction.getTask().getObjArg().getCoordinates());
    }
    Boolean fastPickClosestToTargetOrSelf = null;
    if (TimeLimitMaster.isFastPickCell()) {
        if (targetAction.getActive().isRanged()) {
            fastPickClosestToTargetOrSelf = false;
        }
        if (targetAction.getActive().isMelee()) {
            // if (targetAction.getSource().getAiType()!= AI_TYPE.SNEAK) TODO just behind!
            fastPickClosestToTargetOrSelf = true;
        }
    }
    Coordinates originalCoordinate = getUnit().getCoordinates();
    List<Coordinates> list = cellsCache.get(targetAction.getTargeting());
    if (list != null) {
        return list;
    }
    list = new ArrayList<>();
    try {
        if (fastPickClosestToTargetOrSelf != null) {
            double min = Integer.MAX_VALUE;
            DC_Obj center = fastPickClosestToTargetOrSelf ? targetAction.getTarget() : targetAction.getSource();
            for (Coordinates c : center.getCoordinates().getAdjacentCoordinates()) {
                if (// TODO
                !TargetingMaster.isValidTargetingCell(targetAction, c, getUnit())) {
                    continue;
                }
                double distance = PositionMaster.getExactDistance(c, originalCoordinate);
                if (distance <= min) {
                    list = new ListMaster<Coordinates>().getList(c);
                    min = distance;
                }
            }
        }
        if (list.isEmpty()) {
            // TODO prioritizedCells;
            List<Coordinates> coordinatesList = null;
            if (!ListMaster.isNotEmpty(coordinatesList)) {
                coordinatesList = getUnit().getGame().getBattleField().getGrid().getCoordinatesList();
            }
            // prune by distance/direction from target?
            for (Coordinates c : coordinatesList) {
                if (!TargetingMaster.isValidTargetingCell(targetAction, c, getUnit())) {
                    continue;
                }
                // TODO causes visuals!
                getUnit().setCoordinates(c);
                if (TargetingMaster.canBeTargeted(targetAction, true, true)) {
                    list.add(c);
                }
            }
        }
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    } finally {
        getUnit().setCoordinates(originalCoordinate);
    }
    if (list.size() > 1) {
        list = getPruneMaster().pruneTargetCells(targetAction, list);
    }
    if (getUnit().getUnitAI().getLogLevel() > UnitAI.LOG_LEVEL_BASIC) {
        LogMaster.log(LOG_CHANNEL.AI_DEBUG, "***" + targetAction + " has target cells for PB: " + list);
    }
    cellsCache.put(targetAction.getTargeting(), list);
    return list;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) Coordinates(main.game.bf.Coordinates) ListMaster(main.system.auxiliary.data.ListMaster)

Example 2 with ListMaster

use of main.system.auxiliary.data.ListMaster 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 3 with ListMaster

use of main.system.auxiliary.data.ListMaster 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 4 with ListMaster

use of main.system.auxiliary.data.ListMaster in project Eidolons by IDemiurge.

the class TavernMaster method buyDrinks.

public static void buyDrinks(Tavern tavern, MacroParty party) {
    /*
         *
		 */
    Boolean result = DialogMaster.askAndWait("I'll buy a drink for...", true, "all patrons!", "all of us", "myself");
    // int quality = tavern.getIntParam(MACRO_PARAMS.DRINK_QUALITY);
    List<Unit> drinkers = party.getMembers();
    if (result) {
        tavern.getHeroesForHire();
    } else {
        drinkers = new ListMaster<Unit>().getList(party.getLeader());
    }
    for (Unit member : drinkers) {
    // member.modifyParamByPercent(MACRO_PARAMS.COMBAT_READINESS,
    // quality - 100);
    }
// tavern.getIntParam(MACRO_PARAMS.DRINK_QUALITY);
// tavern.getIntParam(MACRO_PARAMS.DRINK_COST);
// dialog message
// reduce battle readiness, increase morale and loyalty (up to a limit)
}
Also used : ListMaster(main.system.auxiliary.data.ListMaster) Unit(eidolons.entity.obj.unit.Unit)

Example 5 with ListMaster

use of main.system.auxiliary.data.ListMaster in project Eidolons by IDemiurge.

the class PlayerManager method initializePlayers.

public void initializePlayers() {
    players = new ArrayList<>();
    if (getMaster().getGame().getDataKeeper().getPlayerData() != null) {
    // TODO init data from preset
    }
    if (data == null) {
        data = generateDefaultPlayerData();
    }
    unusedPlayerColorsList = new ListMaster<FLAG_COLOR>().getList(playerColors);
    int i = 0;
    for (String substring : StringMaster.open(data)) {
        DC_Player player = initPlayerFromString(substring);
        if (player.getAllegiance() == ALLEGIENCE.NEUTRAL)
            Player.NEUTRAL = player;
        // else
        players.add(player);
        if (player.isEnemy())
            player.setAi(true);
        initUnitData(player, i);
        FLAG_COLOR color = getRandomColorFlag(player.isEnemy());
        player.setFlagColor(color);
        i++;
    }
    if (Player.NEUTRAL == null) {
        Player.NEUTRAL = new DC_Player("Neutral", FLAG_COLOR.BROWN, "", "", ALLEGIENCE.NEUTRAL);
        DC_Player.NEUTRAL = (DC_Player) Player.NEUTRAL;
        players.add(DC_Player.NEUTRAL);
    }
}
Also used : ListMaster(main.system.auxiliary.data.ListMaster) FLAG_COLOR(main.system.graphics.ColorManager.FLAG_COLOR)

Aggregations

ListMaster (main.system.auxiliary.data.ListMaster)9 Unit (eidolons.entity.obj.unit.Unit)3 ArrayList (java.util.ArrayList)3 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)2 Action (eidolons.game.battlecraft.ai.elements.actions.Action)2 ActionPath (eidolons.game.battlecraft.ai.tools.path.ActionPath)2 Coordinates (main.game.bf.Coordinates)2 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)1 ModifyPropertyEffect (eidolons.ability.effects.common.ModifyPropertyEffect)1 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)1 AttackEffect (eidolons.ability.effects.oneshot.attack.AttackEffect)1 RollEffect (eidolons.ability.effects.oneshot.mechanic.RollEffect)1 VALUE_GROUP (eidolons.content.DC_ValueManager.VALUE_GROUP)1 DC_UnitAction (eidolons.entity.active.DC_UnitAction)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 GroupAI (eidolons.game.battlecraft.ai.GroupAI)1 PathBuilder (eidolons.game.battlecraft.ai.tools.path.PathBuilder)1 List (java.util.List)1 ContainerEffect (main.ability.effects.ContainerEffect)1 Effect (main.ability.effects.Effect)1