Search in sources :

Example 66 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj 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)

Example 67 with DC_ActiveObj

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

the class DC_UnitModel method getToolTip.

@Override
public String getToolTip() {
    if (!game.isSimulation())
        return super.getToolTip();
    else {
        if (checkSelectHighlighted()) {
            String actionTargetingTooltip = "";
            DC_ActiveObj action = (DC_ActiveObj) getGame().getManager().getActivatingAction();
            try {
                actionTargetingTooltip = ToolTipMaster.getActionTargetingTooltip(this, action);
            } catch (Exception e) {
                if (!action.isBroken()) {
                    main.system.ExceptionMaster.printStackTrace(e);
                } else {
                    action.setBroken(true);
                }
            }
            if (!StringMaster.isEmpty(actionTargetingTooltip)) {
                return actionTargetingTooltip;
            }
        }
    }
    // }
    return getNameIfKnown();
}
Also used : DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 68 with DC_ActiveObj

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

the class DoorMaster method getActions.

public List<DC_ActiveObj> getActions(DungeonObj door, Unit unit) {
    if (!(door instanceof Door))
        return new ArrayList<>();
    if (!checkUnitCanHandleActions(unit)) {
        return new ArrayList<>();
    }
    // check intelligence, mastery
    List<DC_ActiveObj> list = new ArrayList<>();
    DC_UnitAction action = null;
    for (DOOR_ACTION sub : DOOR_ACTION.values()) {
        if (checkAction(unit, (Door) door, sub)) {
            action = createAction(sub, unit, door);
            if (action != null) {
                list.add(action);
            }
        }
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) DC_UnitAction(eidolons.entity.active.DC_UnitAction) DOOR_ACTION(eidolons.game.module.dungeoncrawl.objects.DoorMaster.DOOR_ACTION)

Example 69 with DC_ActiveObj

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

the class HungItemMaster method getActions.

public List<DC_ActiveObj> getActions(DungeonObj obj, Unit unit) {
    if (!(obj instanceof HungItem))
        return new ArrayList<>();
    // check intelligence, mastery
    List<DC_ActiveObj> list = new ArrayList<>();
    DC_UnitAction action = null;
    for (HUNG_ITEM_ACTION sub : HUNG_ITEM_ACTION.values()) {
        if (checkAction(unit, (HungItem) obj, sub)) {
            String name = StringMaster.getWellFormattedString(sub.name()) + " Door";
            action = unit.getAction(name);
            if (action == null)
                action = createAction(sub, unit, name, obj);
            if (action != null) {
                list.add(action);
            }
        }
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) DC_UnitAction(eidolons.entity.active.DC_UnitAction) HUNG_ITEM_ACTION(eidolons.game.module.dungeoncrawl.objects.HungItemMaster.HUNG_ITEM_ACTION)

Example 70 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj 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)

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