Search in sources :

Example 61 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.

the class TargetingMaster method findTargeting.

public static Targeting findTargeting(ActiveObj active, Class<SelectiveTargeting> CLASS) {
    Targeting t = active.getTargeting();
    if (checkTargeting(CLASS, t)) {
        return t;
    }
    t = findTargetingInAbils(active, CLASS);
    if (t != null) {
        return t;
    }
    for (ActiveObj a : active.getActives()) {
        if (// 2 layers maximum, i hope
        active instanceof DC_ActiveObj) {
            t = findTargeting(a, CLASS);
        }
        if (t != null) {
            return t;
        } else {
            for (ActiveObj a2 : a.getActives()) {
                t = findTargetingInAbils(a2, CLASS);
                if (t != null) {
                    return t;
                }
            }
        }
    }
    return null;
}
Also used : ActiveObj(main.entity.obj.ActiveObj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Targeting(main.elements.targeting.Targeting) SelectiveTargeting(main.elements.targeting.SelectiveTargeting) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 62 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.

the class UnitViewTooltipFactory method supplier.

@Override
protected Supplier<List<ValueContainer>> supplier(BattleFieldObject hero) {
    return () -> {
        List<ValueContainer> values = new ArrayList<>();
        if (hero.checkSelectHighlighted()) {
            String actionTargetingTooltip = "";
            DC_ActiveObj action = (DC_ActiveObj) hero.getGame().getManager().getActivatingAction();
            try {
                actionTargetingTooltip = ToolTipMaster.getActionTargetingTooltip(hero, action);
            } catch (Exception e) {
                if (!action.isBroken()) {
                    main.system.ExceptionMaster.printStackTrace(e);
                } else {
                    action.setBroken(true);
                }
            }
            if (!StringMaster.isEmpty(actionTargetingTooltip)) {
                final ValueContainer activationTooltip = new ValueContainer(actionTargetingTooltip, "");
                activationTooltip.setNameAlignment(Align.left);
                values.add(activationTooltip);
            }
        }
        if (!hero.isMine())
            if (!hero.getGame().isDebugMode())
                if (hero.getVisibilityLevelForPlayer() != VISIBILITY_LEVEL.CLEAR_SIGHT) {
                    final ValueContainer nameContainer = new ValueContainer(hero.getToolTip(), "");
                    nameContainer.setNameAlignment(Align.left);
                    values.add(nameContainer);
                    if (hero.getGame().isStarted())
                        if (hero.getUnitVisionStatus() != null) {
                            final ValueContainer valueContainer = new ValueContainer(StringMaster.getWellFormattedString(hero.getUnitVisionStatus().name()), "");
                            valueContainer.setNameAlignment(Align.left);
                            values.add(valueContainer);
                        }
                    String text = hero.getGame().getVisionMaster().getHintMaster().getHintsString(hero);
                    TextureRegion texture = TextureCache.getOrCreateR(VISUALS.QUESTION.getImgPath());
                    final ValueContainer hintsContainer = new ValueContainer(texture, text);
                    hintsContainer.setNameAlignment(Align.left);
                    hintsContainer.setValueAlignment(Align.right);
                    values.add(hintsContainer);
                    return values;
                }
        final ValueContainer nameContainer = new ValueContainer(hero.getToolTip(), "");
        nameContainer.setNameAlignment(Align.left);
        values.add(nameContainer);
        INFO_LEVEL info_level = new EnumMaster<INFO_LEVEL>().retrieveEnumConst(INFO_LEVEL.class, OptionsMaster.getGameplayOptions().getValue(GAMEPLAY_OPTION.INFO_DETAIL_LEVEL));
        values.add(getValueContainer(hero, PARAMS.C_TOUGHNESS, PARAMS.TOUGHNESS));
        values.add(getValueContainer(hero, PARAMS.C_ENDURANCE, PARAMS.ENDURANCE));
        if (info_level != null)
            switch(info_level) {
                case VERBOSE:
                    values.add(getValueContainer(hero, PARAMS.C_STAMINA, PARAMS.STAMINA));
                    values.add(getValueContainer(hero, PARAMS.C_FOCUS, PARAMS.FOCUS));
                    values.add(getValueContainer(hero, PARAMS.C_MORALE, PARAMS.MORALE));
                    values.add(getValueContainer(hero, PARAMS.C_ESSENCE, PARAMS.ESSENCE));
                case NORMAL:
                    addParamStringToValues(hero, values, PARAMS.ARMOR);
                    addParamStringToValues(hero, values, PARAMS.RESISTANCE);
                case BASIC:
                    addParamStringToValues(hero, values, PARAMS.DAMAGE);
                    addParamStringToValues(hero, values, PARAMS.ATTACK);
                    addParamStringToValues(hero, values, PARAMS.DEFENSE);
            }
        if (hero.getIntParam(PARAMS.N_OF_ACTIONS) > 0) {
            values.add(getValueContainer(hero, PARAMS.C_N_OF_ACTIONS, PARAMS.N_OF_ACTIONS));
        }
        if (hero.getIntParam(PARAMS.N_OF_COUNTERS) > 0) {
            values.add(getValueContainer(hero, PARAMS.C_N_OF_COUNTERS, PARAMS.N_OF_COUNTERS));
        }
        if (hero.getGame().isDebugMode()) {
            ValueContainer valueContainer = new ValueContainer("coord:", hero.getCoordinates().toString());
            valueContainer.setNameAlignment(Align.left);
            valueContainer.setValueAlignment(Align.right);
            values.add(valueContainer);
            if (hero.getFacing() != null || hero.getDirection() != null) {
                final String name = "direction: " + (hero.getFacing() != null ? hero.getFacing().getDirection() : hero.getDirection());
                valueContainer = new ValueContainer(name, hero.getCoordinates().toString());
                valueContainer.setNameAlignment(Align.left);
                valueContainer.setValueAlignment(Align.right);
                values.add(valueContainer);
            }
        }
        if (hero instanceof Unit) {
            addPropStringToValues(hero, values, G_PROPS.MODE);
            addPropStringToValues(hero, values, G_PROPS.STATUS);
        }
        if (hero.getCustomParamMap() != null) {
            hero.getCustomParamMap().keySet().forEach(counter -> {
                final String name = StringMaster.getWellFormattedString(counter);
                String img = CounterMaster.getImagePath(counter);
                if (img != null) {
                    TextureRegion texture = TextureCache.getOrCreateR(img);
                    final ValueContainer valueContainer = (texture == null) ? new ValueContainer(name, hero.getCustomParamMap().get(counter)) : new ValueContainer(texture, name, hero.getCustomParamMap().get(counter));
                    valueContainer.setNameAlignment(Align.left);
                    valueContainer.setValueAlignment(Align.right);
                    values.add(valueContainer);
                }
            });
        }
        // if (VisionManager.isVisibilityOn()){
        if (RuleMaster.isRuleOn(RULE.VISIBILITY) || Eidolons.game.isDebugMode()) {
            addParamStringToValues(hero, values, PARAMS.LIGHT_EMISSION);
            addParamStringToValues(hero, values, PARAMS.ILLUMINATION);
            addParamStringToValues(hero, values, PARAMS.CONCEALMENT);
        // addKeyAndValue("Gamma", ""+hero.getGame().getVisionMaster().
        // getGammaMaster().
        // getGamma(false, hero.getGame().getManager().getActiveObj(), hero), values);
        }
        if (hero.getGame().isDebugMode()) {
            final ValueContainer outlineContainer = new ValueContainer(StringMaster.getWellFormattedString(hero.getOutlineTypeForPlayer() + ""), "");
            outlineContainer.setNameAlignment(Align.left);
            values.add(outlineContainer);
            final ValueContainer outlineContainer2 = new ValueContainer(StringMaster.getWellFormattedString(hero.getVisibilityLevel() + ""), "");
            outlineContainer.setNameAlignment(Align.left);
            values.add(outlineContainer);
        }
        return values;
    };
}
Also used : Arrays(java.util.Arrays) ToolTipMaster(eidolons.system.text.ToolTipMaster) PARAMS(eidolons.content.PARAMS) Supplier(java.util.function.Supplier) StringMaster(main.system.auxiliary.StringMaster) CounterMaster(main.system.entity.CounterMaster) ArrayList(java.util.ArrayList) RULE(eidolons.game.battlecraft.rules.RuleMaster.RULE) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) OptionsMaster(eidolons.system.options.OptionsMaster) G_PROPS(main.content.values.properties.G_PROPS) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) Align(com.badlogic.gdx.utils.Align) VISIBILITY_LEVEL(main.content.enums.rules.VisionEnums.VISIBILITY_LEVEL) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) List(java.util.List) TextureCache(eidolons.libgdx.texture.TextureCache) Eidolons(eidolons.game.core.Eidolons) GAMEPLAY_OPTION(eidolons.system.options.GameplayOptions.GAMEPLAY_OPTION) BaseView(eidolons.libgdx.bf.grid.BaseView) RuleMaster(eidolons.game.battlecraft.rules.RuleMaster) VISUALS(main.swing.generic.components.G_Panel.VISUALS) Unit(eidolons.entity.obj.unit.Unit) EnumMaster(main.system.auxiliary.EnumMaster) INFO_LEVEL(main.content.enums.rules.VisionEnums.INFO_LEVEL) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) EnumMaster(main.system.auxiliary.EnumMaster) INFO_LEVEL(main.content.enums.rules.VisionEnums.INFO_LEVEL) ArrayList(java.util.ArrayList) List(java.util.List) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Unit(eidolons.entity.obj.unit.Unit)

Example 63 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.

the class ActionSequenceConstructor method createActionSequencesForGoal.

public List<ActionSequence> createActionSequencesForGoal(Goal goal, UnitAI ai) {
    List<ActionSequence> actionSequences = new ArrayList<>();
    List<DC_ActiveObj> actions = AiUnitActionMaster.getFullActionList(goal.getTYPE(), ai.getUnit());
    actions.addAll(addSubactions(actions));
    for (DC_ActiveObj action : actions) {
        if (!TimeLimitMaster.checkTimeLimitForAi(getUnitAI()))
            break;
        Chronos.mark(getChronosPrefix() + action);
        List<Task> tasks = getTaskManager().getTasks(goal.getTYPE(), ai, goal.isForced(), action);
        for (Task task : tasks) {
            if (task.isBlocked()) {
                continue;
            }
            if (actionSequences.size() > 0) {
                long time = TimeLimitMaster.getTimeLimitForAction();
                if (Chronos.getTimeElapsedForMark(getChronosPrefix() + action) > time) {
                    LogMaster.log(1, "*********** TIME ELAPSED FOR  " + action + StringMaster.wrapInParenthesis(time + ""));
                    break;
                }
            }
            String string = task.toString();
            Obj obj = action.getGame().getObjectById((Integer) task.getArg());
            if (obj != null) {
                string = obj.getName();
            }
            try {
                // Chronos.mark(getChronosPrefix() + string);
                actionSequences.addAll(getSequences(task, action));
            // Chronos.logTimeElapsedForMark(getChronosPrefix() + string);
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
        }
        Chronos.logTimeElapsedForMark(getChronosPrefix() + action);
    }
    return actionSequences;
}
Also used : Task(eidolons.game.battlecraft.ai.elements.task.Task) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) ArrayList(java.util.ArrayList) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 64 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.

the class ActionSequenceConstructor method getSequencesWithPathsForAction.

private List<ActionSequence> getSequencesWithPathsForAction(Action action, Object arg, Task task) {
    List<ActionSequence> list = new ArrayList<>();
    game = action.getRef().getGame();
    unit = action.getSource();
    if (task.getAI().getBehaviorMode() == AiEnums.BEHAVIOR_MODE.PANIC) {
    // target action = FLEE;
    }
    if (task.getType() == AiEnums.GOAL_TYPE.RETREAT) {
        {
            List<ActionSequence> sequencesFromPaths = getSequencesFromPaths(getPathSequenceConstructor().getRetreatPaths(arg), task, action);
            return sequencesFromPaths;
        }
    // TODO
    }
    boolean singleAction = action.isSingle();
    if (task.getType() == GOAL_TYPE.PROTECT) {
        singleAction = action.getSource().getCoordinates().equals(action.getTarget().getCoordinates());
    } else if (!singleAction) {
        if (arg != null) {
            singleAction = // .toString()));
            TargetingMaster.canBeTargeted(action, true);
        } else {
            singleAction = (action).canBeActivated();
        }
    }
    // if (ReasonMaster.getReasons(action).getOrCreate(0)==FILTER_REASON.FACING)
    if (singleAction) {
        ActionSequence sequence = constructSingleActionSequence(action, task);
        if (sequence == null) {
            return null;
        }
        list.add(sequence);
        return list;
    }
    if (!task.isForced()) {
        // TODO REFACTOR
        if (task.getType() != GOAL_TYPE.PROTECT && task.getType() != AiEnums.GOAL_TYPE.ATTACK && task.getType() != AiEnums.GOAL_TYPE.RETREAT && task.getType() != AiEnums.GOAL_TYPE.SEARCH && task.getType() != AiEnums.GOAL_TYPE.MOVE && !task.getType().isBehavior()) {
            return null;
        }
    }
    if (task.getType() == AiEnums.GOAL_TYPE.SUMMONING) {
        return null;
    }
    if (task.getType() == AiEnums.GOAL_TYPE.ZONE_DAMAGE) {
        // TODO until pathing/cell-pr. is fixed
        return null;
    }
    if (!task.isForced()) {
        if (task.getAI().checkMod(AI_MODIFIERS.TRUE_BRUTE)) {
            return null;
        }
        if (task.getAI().getBehaviorMode() == AiEnums.BEHAVIOR_MODE.BERSERK) {
            return null;
        }
    // if (getAnalyzer().isRanged(task.getAI())) return null ;
    // TODO   if ((!action.getActive().isRanged() && task.getAI().getType() == AiEnums.AI_TYPE.ARCHER)
    // || (task.getAI().getType() == AiEnums.AI_TYPE.CASTER && !unit.getSpells().isEmpty())) {
    // return null;
    // }
    }
    Unit unit = (Unit) action.getRef().getSourceObj();
    List<DC_ActiveObj> moveActions = getMoveActions(action);
    if (!ListMaster.isNotEmpty(moveActions)) {
        // [QUICK FIX]
        if (!unit.getAction(DC_ActionManager.STD_ACTIONS.Turn_Anticlockwise.name()).canBeActivated(action.getRef(), true) && !unit.getAction(DC_ActionManager.STD_ACTIONS.Move.name()).canBeActivated(action.getRef(), true)) {
            return null;
        }
    } else {
    // if (prioritizedCells == null)
    // prioritizedCells = CellPrioritizer
    // .getMeleePriorityCellsForUnit(unit.getUnitAI(),
    // moveActions, action);
    }
    List<ActionPath> paths = getPathSequenceConstructor().getPathSequences(moveActions, action);
    list = getSequencesFromPaths(paths, task, action);
    // }
    return list;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ActionPath(eidolons.game.battlecraft.ai.tools.path.ActionPath) Unit(eidolons.entity.obj.unit.Unit) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 65 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.

the class PathSequenceConstructor method getOptimalPathSequence.

public ActionPath getOptimalPathSequence(UnitAI ai, Coordinates targetCell) {
    List<DC_ActiveObj> moves = AiUnitActionMaster.getMoveActions(ai.getUnit());
    Action action = AiActionFactory.newAction("Move", ai);
    List<Coordinates> coordinates = new ArrayList<>();
    coordinates.add(targetCell);
    List<ActionPath> paths = getPathSequences(moves, action, coordinates);
    // });
    return paths.get(0);
}
Also used : Action(eidolons.game.battlecraft.ai.elements.actions.Action) Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) ActionPath(eidolons.game.battlecraft.ai.tools.path.ActionPath) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Aggregations

DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)73 Unit (eidolons.entity.obj.unit.Unit)22 ArrayList (java.util.ArrayList)17 Obj (main.entity.obj.Obj)15 DC_UnitAction (eidolons.entity.active.DC_UnitAction)12 DC_Obj (eidolons.entity.obj.DC_Obj)12 Ref (main.entity.Ref)9 Action (eidolons.game.battlecraft.ai.elements.actions.Action)8 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)7 ActiveObj (main.entity.obj.ActiveObj)7 Effect (main.ability.effects.Effect)5 SelectiveTargeting (main.elements.targeting.SelectiveTargeting)5 Targeting (main.elements.targeting.Targeting)5 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)4 DC_SpellObj (eidolons.entity.active.DC_SpellObj)4 ActionPath (eidolons.game.battlecraft.ai.tools.path.ActionPath)4 FixedTargeting (main.elements.targeting.FixedTargeting)4 Coordinates (main.game.bf.Coordinates)4 RollEffect (eidolons.ability.effects.oneshot.mechanic.RollEffect)3 ActionSequence (eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence)3