Search in sources :

Example 1 with DC_ActiveObj

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

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

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

the class AutoAttackEffect method pickAutomatically.

private DC_ActiveObj pickAutomatically(List<DC_ActiveObj> subActions) {
    DC_ActiveObj pick = null;
    int max = 0;
    for (DC_ActiveObj attack : subActions) {
        int priority = calculatePriority(attack, getTarget());
        if (priority > max) {
            pick = attack;
            max = priority;
        }
    }
    return pick;
}
Also used : DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 4 with DC_ActiveObj

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

the class AutoAttackEffect method applyThis.

// boolean offhand; auto!
@Override
public boolean applyThis() {
    // auto-select action
    // getUnit().getAction(action)
    DC_ActiveObj attack = pickAttack();
    if (attack == null) {
        return false;
    }
    boolean result = attack.activatedOn(ref);
    if (result) {
        if (getActiveObj().getParentAction() != null) {
            getActiveObj().getParentAction().setLastSubaction(attack);
            getActiveObj().getParentAction().getRef().setTarget(ref.getTarget());
        }
    } else {
        return false;
    }
    // getRef().getActive()
    return true;
}
Also used : DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 5 with DC_ActiveObj

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

the class ChangeRefEffect method applyThis.

@Override
public boolean applyThis() {
    // so I need the active to have ref with the ammo as AMMO, not weapon?
    Ref REF = this.ref;
    if (keyWhoseRefToModify != null) {
        REF = REF.getObj(keyWhoseRefToModify).getRef();
    } else {
    // for (KEYS key :
    // add_remove ? autoCheckedKeysAdd : autoCheckedKeysRemove)
    // {
    // if (REF.getObj(key)!=null )
    // if (REF.getObj(key).getRef().getId(this.keyToAddOrRemoveForRef) != null) {
    // REF = ref.getObj(key).getRef();
    // break;
    // }
    // }
    }
    Integer id = REF.getId(keyToAddOrRemoveForRef);
    if (id == null) {
        if (ref.getActive() instanceof DC_ActiveObj) {
            DC_ActiveObj activeObj = (DC_ActiveObj) ref.getActive();
            if (activeObj.getParentAction() != null) {
                id = activeObj.getParentAction().getRef().getId(keyToAddOrRemoveForRef);
            }
        }
    }
    if (add_remove) {
        REF.getTargetObj().getRef().setID(keyToAddOrRemoveForRef, id);
    } else {
        REF.removeValue(keyToAddOrRemoveForRef);
    }
    return true;
}
Also used : Ref(main.entity.Ref) 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