Search in sources :

Example 1 with FACING_SINGLE

use of main.content.enums.entity.UnitEnums.FACING_SINGLE in project Eidolons by IDemiurge.

the class AtomicAi method checkAtomicActionTurn.

private boolean checkAtomicActionTurn(UnitAI ai) {
    // check that only enemy actions are needed
    boolean result = false;
    if (!ai.getType().isCaster()) {
        // FacingMaster.getOptimalFacingTowardsUnits()
        BattleFieldObject enemy = getAnalyzer().getClosestEnemy(ai.getUnit());
        // for (BattleFieldObject enemy : Analyzer.getVisibleEnemies(ai))
        FACING_DIRECTION facing = ai.getUnit().getFacing();
        FACING_SINGLE relative = FacingMaster.getSingleFacing(facing, ai.getUnit(), enemy);
        if (relative == FACING_SINGLE.BEHIND) {
            return true;
        } else if (relative == FACING_SINGLE.TO_THE_SIDE) {
            if (!ai.getUnit().checkPassive(STANDARD_PASSIVES.BROAD_REACH))
                result = true;
        } else
            result = false;
        // if we need to get to a cell that is not 'facing' the target?!
        if (!result)
            return false;
        if (!game.getVisionMaster().getSightMaster().getClearShotCondition().check(getUnit(), enemy))
            return false;
    }
    return result;
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) FACING_SINGLE(main.content.enums.entity.UnitEnums.FACING_SINGLE)

Example 2 with FACING_SINGLE

use of main.content.enums.entity.UnitEnums.FACING_SINGLE in project Eidolons by IDemiurge.

the class TurnSequenceConstructor method getTurnSequence.

public List<Action> getTurnSequence(Action action) {
    Conditions conditions = (action.getTargeting().getFilter().getConditions());
    FacingCondition condition = null;
    FACING_SINGLE template = null;
    DC_Obj target = action.getTarget();
    Unit source = (Unit) action.getRef().getSourceObj();
    for (Condition c : conditions) {
        if (c instanceof FacingCondition) {
            condition = (FacingCondition) c;
            break;
        }
        List<Object> list = ClassMaster.getInstances(c, FacingCondition.class);
        if (!list.isEmpty()) {
            List<Action> front_sequence = getTurnSequence(FACING_SINGLE.IN_FRONT, source, target.getCoordinates());
            List<Action> side_sequence = null;
            if (action.getSource().hasBroadReach() || action.getActive().checkPassive(UnitEnums.STANDARD_PASSIVES.BROAD_REACH)) // front_sequence.remove(front_sequence.size() - 1);
            {
                side_sequence = getTurnSequence(FACING_SINGLE.TO_THE_SIDE, source, target.getCoordinates());
            }
            List<Action> hind_sequence = null;
            if (action.getSource().hasHindReach() || action.getActive().checkPassive(UnitEnums.STANDARD_PASSIVES.HIND_REACH)) {
                hind_sequence = getTurnSequence(FACING_SINGLE.BEHIND, source, target.getCoordinates());
            }
            return new ListMaster<Action>().getSmallest(front_sequence, hind_sequence, side_sequence);
        }
    }
    // }
    if (condition == null) {
        return new ArrayList<>();
    }
    if (ArrayMaster.isNotEmpty(condition.getTemplate())) {
        template = condition.getTemplate()[0];
    }
    return getTurnSequence(template, source, target.getCoordinates());
}
Also used : FacingCondition(eidolons.ability.conditions.FacingCondition) Condition(main.elements.conditions.Condition) DC_Obj(eidolons.entity.obj.DC_Obj) Action(eidolons.game.battlecraft.ai.elements.actions.Action) DC_UnitAction(eidolons.entity.active.DC_UnitAction) ArrayList(java.util.ArrayList) FacingCondition(eidolons.ability.conditions.FacingCondition) Unit(eidolons.entity.obj.unit.Unit) Conditions(main.elements.conditions.Conditions) FACING_SINGLE(main.content.enums.entity.UnitEnums.FACING_SINGLE)

Example 3 with FACING_SINGLE

use of main.content.enums.entity.UnitEnums.FACING_SINGLE in project Eidolons by IDemiurge.

the class Unit method getSightRangeTowards.

public int getSightRangeTowards(Coordinates coordinates) {
    int sight = getIntParam(PARAMS.SIGHT_RANGE);
    FACING_SINGLE singleFacing = FacingMaster.getSingleFacing(this.getFacing(), this.getCoordinates(), coordinates);
    if (singleFacing == UnitEnums.FACING_SINGLE.BEHIND) {
        sight = getIntParam(PARAMS.BEHIND_SIGHT_BONUS);
    } else if (singleFacing == UnitEnums.FACING_SINGLE.TO_THE_SIDE) {
        sight -= getIntParam(PARAMS.SIDE_SIGHT_PENALTY);
    }
    return sight;
}
Also used : FACING_SINGLE(main.content.enums.entity.UnitEnums.FACING_SINGLE)

Example 4 with FACING_SINGLE

use of main.content.enums.entity.UnitEnums.FACING_SINGLE in project Eidolons by IDemiurge.

the class DC_ConditionMaster method getSelectiveTargetingTemplateConditions.

public static Conditions getSelectiveTargetingTemplateConditions(SELECTIVE_TARGETING_TEMPLATES template) {
    Conditions c = new Conditions();
    if ((template.isDependentOnZ())) {
        // source and match?
        c.add(new ZLevelCondition(true));
    }
    switch(template) {
        case ANY_ARMOR:
            {
                c.add(new ObjTypeComparison(DC_TYPE.ARMOR));
                break;
            }
        case ANY_WEAPON:
            {
                c.add(new NotCondition(new PropCondition(G_PROPS.WEAPON_TYPE, ItemEnums.WEAPON_TYPE.NATURAL.toString())));
                c.add(new OrConditions(new ObjTypeComparison(DC_TYPE.WEAPONS), new Conditions(new PropCondition(G_PROPS.STD_BOOLS, GenericEnums.STD_BOOLS.WRAPPED_ITEM), new ObjTypeComparison(DC_TYPE.ITEMS))));
                break;
            }
        case ANY_ITEM:
            {
                c.add(new ObjTypeComparison(DC_TYPE.ITEMS));
                break;
            }
        case ENEMY_ARMOR:
            {
                c.add(new ObjTypeComparison(DC_TYPE.ARMOR));
                c.add(ConditionMaster.getEnemyCondition());
                break;
            }
        case ENEMY_ITEM:
            {
                c.add(new ObjTypeComparison(DC_TYPE.ITEMS));
                c.add(ConditionMaster.getEnemyCondition());
                break;
            }
        case ENEMY_WEAPON:
            {
                c.add(new NotCondition(new PropCondition(G_PROPS.WEAPON_TYPE, ItemEnums.WEAPON_TYPE.NATURAL.toString())));
                c.add(new OrConditions(new ObjTypeComparison(DC_TYPE.ITEMS), new ObjTypeComparison(DC_TYPE.WEAPONS)));
                c.add(ConditionMaster.getEnemyCondition());
                break;
            }
        case MY_ITEM:
            {
                c.add(new ObjTypeComparison(DC_TYPE.ITEMS));
                break;
            }
        case MY_SPELLBOOK:
            c.add(ConditionMaster.getTYPECondition(DC_TYPE.SPELLS));
            c.add(new SpellCondition(SPELL_CHECK.ACTIVE));
            c.add(new RefCondition(KEYS.MATCH_SOURCE, KEYS.SOURCE));
            break;
        case MY_ARMOR:
            {
                // c.add(new ObjTypeComparison(OBJ_TYPES.ARMOR));
                c.add(new RefCondition(KEYS.ARMOR, KEYS.MATCH));
                break;
            }
        case MY_WEAPON:
            {
                c.add(new NotCondition(new PropCondition(G_PROPS.WEAPON_TYPE, ItemEnums.WEAPON_TYPE.NATURAL.toString())));
                c.add(new OrConditions(new ObjTypeComparison(DC_TYPE.WEAPONS), new Conditions(new PropCondition(G_PROPS.STD_BOOLS, GenericEnums.STD_BOOLS.WRAPPED_ITEM), new ObjTypeComparison(DC_TYPE.ITEMS))));
                // c.add(new RefCondition(KEYS.WEAPON, KEYS.MATCH));
                break;
            }
        case CELL:
            {
                c.add(ConditionMaster.getTYPECondition(DC_TYPE.TERRAIN));
                c.add(getRangeCondition());
                c.add(new CellCondition(true));
                break;
            }
        case BLAST:
            {
                c.add(ConditionMaster.getUnit_Char_BfObj_TerrainTypeCondition());
                c.add(getRangeCondition());
                c.add(new FacingCondition(UnitEnums.FACING_SINGLE.IN_FRONT));
                c.add(new NotCondition(ConditionMaster.getSelfFilterCondition()));
                break;
            }
        case BLIND_SHOT:
        case SHOT:
            c.add(ConditionMaster.getUnit_Char_BfObjTypeCondition());
            c.add(new NotCondition(ConditionMaster.getSelfFilterCondition()));
            c.add(new FacingCondition(UnitEnums.FACING_SINGLE.IN_FRONT));
            c.add(getRangeCondition());
            c.add(new OrConditions(new StdPassiveCondition(UnitEnums.STANDARD_PASSIVES.DARKVISION), new NotCondition(new VisibilityCondition(UNIT_VISION.CONCEALED))));
            // 
            c.add(getClearShotCondition(KEYS.MATCH.name()));
            // ALL SHOT LIKE THIS!
            break;
        case PRECISE_SHOT:
            c.add(new VisibilityCondition(UNIT_VISION.IN_PLAIN_SIGHT));
            break;
        case UNOBSTRUCTED_SHOT:
            c.add(new NotCondition(ConditionMaster.getSelfFilterCondition()));
            c.add(getRangeCondition());
            break;
        case RAY:
            c.add(ConditionMaster.getDistanceFilterCondition(Ref.KEYS.SOURCE.name(), 1));
            break;
        case MOVE:
            c.add(DC_ConditionMaster.getMoveFilterCondition());
            break;
        case BF_OBJ:
            c.add(ConditionMaster.getTYPECondition(DC_TYPE.BF_OBJ));
            break;
        case ANY_ALLY:
            c.add(ConditionMaster.getUnit_CharTypeCondition());
            c.add(ConditionMaster.getOwnershipFilterCondition(Ref.KEYS.SOURCE.name(), true));
            break;
        case ANY_ENEMY:
            c.add(ConditionMaster.getUnit_CharTypeCondition());
            c.add(ConditionMaster.getOwnershipFilterCondition(Ref.KEYS.SOURCE.name(), false));
            break;
        case ANY_UNIT:
            c.add(ConditionMaster.getUnit_CharTypeCondition());
            break;
        case KEY:
            c.add(new OrConditions(new PropCondition(G_PROPS.BF_OBJECT_GROUP, BF_OBJECT_GROUP.LOCK.toString(), true), new PropCondition(G_PROPS.BF_OBJECT_GROUP, BF_OBJECT_GROUP.DOOR.toString(), true)));
        case ATTACK:
            c.add(new VisibilityCondition(UNIT_VISION.IN_SIGHT));
            List<FACING_SINGLE> list = new ArrayList<>();
            list.add(UnitEnums.FACING_SINGLE.IN_FRONT);
            c.add(new OrConditions(new FacingCondition(UnitEnums.FACING_SINGLE.IN_FRONT), new Conditions(new FacingCondition(UnitEnums.FACING_SINGLE.IN_FRONT, UnitEnums.FACING_SINGLE.BEHIND), new StringComparison(StringMaster.getValueRef(KEYS.SOURCE, G_PROPS.STANDARD_PASSIVES), UnitEnums.STANDARD_PASSIVES.HIND_REACH + "", false)), new Conditions(new FacingCondition(UnitEnums.FACING_SINGLE.IN_FRONT, UnitEnums.FACING_SINGLE.TO_THE_SIDE), new StringComparison(StringMaster.getValueRef(KEYS.SOURCE, G_PROPS.STANDARD_PASSIVES), UnitEnums.STANDARD_PASSIVES.BROAD_REACH + "", false))));
            c.add(ConditionMaster.getAttackConditions());
            c.add(getClearShotCondition(KEYS.MATCH.name()));
            // c.add(AirborneRule.getMeleeAttackCondition()); TODO
            break;
        case GRAVE_CELL:
            c.add(new GraveCondition());
            break;
        case CLAIM:
            {
                c.add(new NotCondition(new StatusCheckCondition(UnitEnums.STATUS.CHANNELED)));
                c.add(new NotCondition(new OwnershipCondition(KEYS.SOURCE, KEYS.MATCH)));
                c.add(ConditionMaster.getTYPECondition(DC_TYPE.BF_OBJ));
                c.add(ConditionMaster.getDistanceFilterCondition(Ref.KEYS.SOURCE.name(), "{ACTIVE_RANGE}"));
                break;
            }
        case ENEMY_SPELLBOOK:
            break;
        default:
            break;
    }
    return c;
}
Also used : OwnershipCondition(main.elements.conditions.standard.OwnershipCondition) StatusCheckCondition(eidolons.ability.conditions.StatusCheckCondition) ArrayList(java.util.ArrayList) CellCondition(eidolons.ability.conditions.req.CellCondition) VisibilityCondition(eidolons.ability.conditions.VisibilityCondition) FACING_SINGLE(main.content.enums.entity.UnitEnums.FACING_SINGLE) ZLevelCondition(main.elements.conditions.standard.ZLevelCondition) StdPassiveCondition(eidolons.ability.conditions.shortcut.StdPassiveCondition) FacingCondition(eidolons.ability.conditions.FacingCondition)

Example 5 with FACING_SINGLE

use of main.content.enums.entity.UnitEnums.FACING_SINGLE in project Eidolons by IDemiurge.

the class InstantAttackRule method getInstantAttackType.

private static INSTANT_ATTACK_TYPE getInstantAttackType(Unit unit, DC_ActiveObj action) {
    Coordinates c = DC_MovementManager.getMovementDestinationCoordinate(action);
    Coordinates c1 = action.getOwnerObj().getCoordinates();
    if (c.equals(c1)) {
        return INSTANT_ATTACK_TYPE.ENGAGEMENT;
    }
    FACING_SINGLE singleFacing = FacingMaster.getSingleFacing(unit.getFacing(), c, c1);
    if (singleFacing == UnitEnums.FACING_SINGLE.BEHIND) {
        return INSTANT_ATTACK_TYPE.PASSAGE;
    }
    if (singleFacing == UnitEnums.FACING_SINGLE.IN_FRONT) {
        singleFacing = FacingMaster.getSingleFacing(action.getOwnerObj().getFacing(), c1, c);
        if (singleFacing == UnitEnums.FACING_SINGLE.BEHIND) {
            // 'turned your back on the
            return INSTANT_ATTACK_TYPE.FLIGHT;
        }
        // controlled retreat
        return INSTANT_ATTACK_TYPE.DISENGAGEMENT;
    // backwards, facing
    // forward
    }
    return INSTANT_ATTACK_TYPE.STUMBLE;
}
Also used : Coordinates(main.game.bf.Coordinates) FACING_SINGLE(main.content.enums.entity.UnitEnums.FACING_SINGLE)

Aggregations

FACING_SINGLE (main.content.enums.entity.UnitEnums.FACING_SINGLE)11 ArrayList (java.util.ArrayList)3 Coordinates (main.game.bf.Coordinates)3 FacingCondition (eidolons.ability.conditions.FacingCondition)2 CellCondition (eidolons.ability.conditions.req.CellCondition)2 DC_UnitAction (eidolons.entity.active.DC_UnitAction)2 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)2 DC_Obj (eidolons.entity.obj.DC_Obj)2 Action (eidolons.game.battlecraft.ai.elements.actions.Action)2 DIRECTION (main.game.bf.Coordinates.DIRECTION)2 FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)2 RotateByAction (com.badlogic.gdx.scenes.scene2d.actions.RotateByAction)1 StatusCheckCondition (eidolons.ability.conditions.StatusCheckCondition)1 VisibilityCondition (eidolons.ability.conditions.VisibilityCondition)1 StdPassiveCondition (eidolons.ability.conditions.shortcut.StdPassiveCondition)1 DC_HeroSlotItem (eidolons.entity.item.DC_HeroSlotItem)1 DC_UnitModel (eidolons.entity.obj.unit.DC_UnitModel)1 Unit (eidolons.entity.obj.unit.Unit)1 TreeMap (java.util.TreeMap)1 Condition (main.elements.conditions.Condition)1