Search in sources :

Example 81 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class WanderAi method getWanderTargetCoordinatesCell.

public static Coordinates getWanderTargetCoordinatesCell(UnitAI ai, GOAL_TYPE type) {
    // List<? extends DC_Obj> cells = getWanderCells(ai);
    // ai.getStandingOrders(); TODO set target???
    // // from original coordinate? Or 'last'?
    // ai.getGroup().getWanderDistance();
    boolean follow = ai.getGroup().isFollowLeader() || isFollowLeader(type);
    if (follow) {
        if (isAheadOfLeader(ai)) {
            return null;
        }
    }
    DIRECTION direction = ai.getGroup().getWanderDirection();
    // DirectionMaster.getRelativeDirection(source, target);
    if (direction == null) {
        return null;
    }
    Coordinates c = ai.getUnit().getCoordinates().getAdjacentCoordinate(direction);
    return c;
// auto-turn if facing ain't right? take relative *position*
}
Also used : DIRECTION(main.game.bf.Coordinates.DIRECTION) FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) Coordinates(main.game.bf.Coordinates)

Example 82 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class Place method resetCoordinates.

public void resetCoordinates() {
    int x = getIntParam(MACRO_PARAMS.MAP_POS_X);
    int y = getIntParam(MACRO_PARAMS.MAP_POS_Y);
    setCoordinates(new Coordinates(true, x, y));
}
Also used : Coordinates(main.game.bf.Coordinates)

Example 83 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class Route method resetCoordinates.

@Override
public void resetCoordinates() {
    if (coordinates != null) {
        return;
    }
    Coordinates c1 = orig.getDefaultMapRenderPoint();
    Coordinates c2 = dest.getDefaultMapRenderPoint();
    // min max enforced from MapComp that knows display-state of Places?
    int displacement = 50;
    int perpendicularOffset;
    int index = 0;
    for (Route route : orig.getRoutes()) {
        if (route.isCoordinatesValid()) {
            if ((route.getOrigin() == dest || route.getOrigin() == orig) && (route.getDestination() == dest || route.getDestination() == orig)) {
                index++;
            }
        }
    }
    perpendicularOffset = index * MacroGuiManager.getRouteOffset();
    if (index % 2 == 0) {
        perpendicularOffset = -perpendicularOffset;
    }
    // TODO MIN_MAX
    if (isActive()) {
        MacroManager.getActiveParty().getCurrentDestination();
        displacement = MacroManager.getActiveParty().getIntParam(MACRO_PARAMS.ROUTE_PROGRESS_PERCENTAGE);
        if (isBackwards(MacroManager.getActiveParty())) {
            displacement = 100 - displacement;
        }
    }
    this.coordinates = CoordinatesMaster.getCoordinateBetween(c1, c2, displacement, perpendicularOffset);
    // active route would be {ROUTE_PROGRESS} dependent...
    // the rest, well, display them in the middle?
    // available routes should be 'at hand'
    // known routes should be selectable perhaps...
    setCoordinatesValid(true);
}
Also used : Coordinates(main.game.bf.Coordinates)

Example 84 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class PathChoiceMaster method getChoices.

List<Choice> getChoices(ActionPath path, Coordinates c_coordinate, Coordinates targetCoordinate, FACING_DIRECTION c_facing) {
    Chronos.mark("Finding choices for " + path);
    pathBuilder.adjustUnit();
    List<Choice> choices = new ArrayList<>();
    for (Coordinates c : getDefaultCoordinateTargets(path, c_coordinate)) {
        Choice stdMoveChoice = constructStdMoveChoice(c, c_coordinate, c_facing);
        if (stdMoveChoice != null) {
            choices.add(stdMoveChoice);
        }
    }
    Chronos.mark("Finding custom choices for " + path);
    List<Choice> specialChoices = new ArrayList<>();
    if (ListMaster.isNotEmpty(moveActions)) {
        for (DC_ActiveObj a : moveActions) {
            if (!a.canBeActivated()) {
                if (firstStep) {
                    if (!ReasonMaster.checkReasonCannotActivate(a, PARAMS.C_N_OF_ACTIONS.getName())) {
                        // exception for AP TODO
                        continue;
                    }
                }
            }
            if (path.hasAction(a)) {
                if (a.getIntParam(PARAMS.COOLDOWN) >= 0) {
                    continue;
                }
            }
            Targeting targeting = a.getTargeting();
            Collection<Obj> objects = null;
            if (targeting instanceof FixedTargeting) {
                Targeting t = a.getAbilities().getTargeting();
                if (t != null) {
                    objects = t.getFilter().getObjects(a.getRef());
                }
                Effect e = a.getAbilities().getEffects().getEffects().get(0);
                e.setRef(unit.getRef());
                if (e instanceof SelfMoveEffect) {
                    try {
                        Coordinates coordinates = ((SelfMoveEffect) e).getCoordinates();
                        if (coordinates != null) {
                            objects = new ArrayList<>(Arrays.asList(unit.getGame().getCellByCoordinate(coordinates)));
                        }
                    } catch (Exception ex) {
                        main.system.ExceptionMaster.printStackTrace(ex);
                    }
                }
            } else {
                pathBuilder.adjustUnit();
                objects = targeting.getFilter().getObjects(a.getRef());
            }
            if (objects != null) {
                List<Choice> choicesForAction = new ArrayList<>();
                for (Object obj : objects) {
                    if (obj instanceof DC_Cell) {
                        Coordinates coordinates = ((DC_Cell) obj).getCoordinates();
                        // if (a.getName().equals("Clumsy Leap"))
                        if (PositionMaster.getDistance(coordinates, c_coordinate) > Math.max(1, a.getIntParam(PARAMS.RANGE))) {
                            continue;
                        }
                        if (PositionMaster.getDistance(coordinates, targetCoordinate) > PositionMaster.getDistance(c_coordinate, targetCoordinate)) {
                            // TODO will this not eliminate good
                            continue;
                        }
                        // choices?
                        Ref ref = unit.getRef().getCopy();
                        ref.setTarget(((DC_Cell) obj).getId());
                        Choice choice = new Choice(coordinates, c_coordinate, new Action(a, ref));
                        choicesForAction.add(choice);
                    }
                }
                Chronos.mark("Filter custom choices for " + a);
                specialChoices.addAll(filterSpecialMoveChoices(choicesForAction, a, c_coordinate, path));
                Chronos.logTimeElapsedForMark("Filter custom choices for " + a);
            }
        // if (choices.size() > 1)
        }
    }
    Chronos.logTimeElapsedForMark("Finding custom choices for " + path);
    choices.addAll(specialChoices);
    Chronos.mark("Sort choices");
    sortChoices(choices);
    Chronos.logTimeElapsedForMark("Sort choices");
    // resetUnit();// TODO is that right?
    Chronos.logTimeElapsedForMark("Finding choices for " + path);
    // Chronos.logTimeElapsedForMark("Sorting choices for " + path);
    return choices;
}
Also used : Action(eidolons.game.battlecraft.ai.elements.actions.Action) DC_UnitAction(eidolons.entity.active.DC_UnitAction) FixedTargeting(main.elements.targeting.FixedTargeting) Targeting(main.elements.targeting.Targeting) Coordinates(main.game.bf.Coordinates) Ref(main.entity.Ref) FixedTargeting(main.elements.targeting.FixedTargeting) DC_Cell(eidolons.entity.obj.DC_Cell) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) SelfMoveEffect(eidolons.ability.effects.oneshot.move.SelfMoveEffect) SelfMoveEffect(eidolons.ability.effects.oneshot.move.SelfMoveEffect) Effect(main.ability.effects.Effect) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 85 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class PriorityManagerImpl method getRetreatPriority.

@Override
public int getRetreatPriority(ActionSequence as) {
    float cowardice_factor = getCowardiceFactor(as.getAi().getUnit());
    if (cowardice_factor == 0) {
        // panic?
        priority = 0;
        return priority;
    }
    if (getUnitAi().getBehaviorMode() == AiEnums.BEHAVIOR_MODE.PANIC) {
        cowardice_factor *= 2;
    }
    int currentMeleeDangerFactor = 0;
    try {
        currentMeleeDangerFactor = getSituationAnalyzer().getMeleeDangerFactor(getUnit(), false, false);
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
    if (currentMeleeDangerFactor == 0 && getUnitAi().getBehaviorMode() != AiEnums.BEHAVIOR_MODE.PANIC) {
        priority = 0;
        return priority;
    }
    Coordinates c = getUnit().getCoordinates();
    getUnit().setCoordinates(as.getLastAction().getTarget().getCoordinates());
    int meleeDangerFactor = 0;
    try {
        meleeDangerFactor = getSituationAnalyzer().getMeleeDangerFactor(getUnit(), false, false);
    // meleeDangerFactor =getDangerFactorByMemory(unit); TODO for panic!
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    } finally {
        getUnit().setCoordinates(c);
    }
    priority = currentMeleeDangerFactor - meleeDangerFactor;
    if (priority <= 0) {
        return 0;
    }
    if (getUnitAi().getBehaviorMode() == AiEnums.BEHAVIOR_MODE.PANIC) {
        addConstant(250, "Panic");
    }
    priority = MathMaster.round(priority * cowardice_factor * getConstInt(AiConst.RETREAT_PRIORITY_FACTOR));
    // preCheck ranged threat? hide behind obstacles...
    return priority;
}
Also used : Coordinates(main.game.bf.Coordinates)

Aggregations

Coordinates (main.game.bf.Coordinates)226 Unit (eidolons.entity.obj.unit.Unit)49 ObjType (main.entity.type.ObjType)30 ArrayList (java.util.ArrayList)29 Obj (main.entity.obj.Obj)28 DC_Obj (eidolons.entity.obj.DC_Obj)22 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)21 FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)21 DIRECTION (main.game.bf.Coordinates.DIRECTION)20 Ref (main.entity.Ref)15 MapBlock (eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)13 DC_Cell (eidolons.entity.obj.DC_Cell)12 Action (eidolons.game.battlecraft.ai.elements.actions.Action)11 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)9 BufferedImage (java.awt.image.BufferedImage)8 DequeImpl (main.system.datatypes.DequeImpl)8 Vector2 (com.badlogic.gdx.math.Vector2)7 DC_UnitAction (eidolons.entity.active.DC_UnitAction)7 ZCoordinates (main.game.bf.ZCoordinates)6 ObjAtCoordinate (main.entity.type.ObjAtCoordinate)5