Search in sources :

Example 21 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class MiniObjComp method clicked.

public void clicked(Point point) {
    if (getObjects().size() < 2) {
        obj.getGame().getManager().objClicked(obj);
        return;
    }
    if (point.x < getWidth() / 3) {
        if (point.y < getHeight() / 3) {
            // CYCLE THRU OBJs
            Obj choice = DialogMaster.objChoice("Which object?", getObjects().toArray(new Obj[getObjects().size()]));
            if (choice != null) {
                obj = (DC_Obj) choice;
                obj.getGame().getManager().objClicked(obj);
            }
            return;
        }
    }
    obj.getGame().getManager().objClicked(obj);
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj)

Example 22 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class WanderAi method getWanderCells.

public static List<? extends DC_Obj> getWanderCells(UnitAI ai) {
    DIRECTION d = ai.getGroup().getWanderDirection();
    // permittedCells = ai.getGroup().getWanderBlocks();
    List<DC_Obj> list = new ArrayList<>();
    for (DC_Cell cell : Analyzer.getCells(ai, false, false, true)) {
        if (d != null) {
            if (DirectionMaster.getRelativeDirection(cell, ai.getUnit()) != d) {
                continue;
            }
        }
        if (PositionMaster.getDistance(cell, ai.getUnit()) <= ai.getMaxWanderDistance()) {
            list.add(cell);
        }
    }
    if (list.isEmpty()) {
    // change direction?
    }
    return list;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) DC_Cell(eidolons.entity.obj.DC_Cell) DIRECTION(main.game.bf.Coordinates.DIRECTION) FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) ArrayList(java.util.ArrayList)

Example 23 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class ParamPriorityAnalyzer method getResistanceFactor.

public static int getResistanceFactor(Action action) {
    DC_ActiveObj active = action.getActive();
    DC_Obj target = action.getTarget();
    Integer resistance = target.getIntParam(PARAMS.RESISTANCE);
    resistance -= action.getSource().getIntParam(PARAMS.RESISTANCE_PENETRATION);
    Integer mod = active.getIntParam(PARAMS.RESISTANCE_MODIFIER);
    if (mod > 0) {
        resistance = resistance * mod / 100;
    }
    return Math.min(0, -resistance);
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 24 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class PruneMaster method pruneTargetsForAction.

public void pruneTargetsForAction(List<? extends DC_Obj> targets, GOAL_TYPE goal, UnitAI ai, DC_ActiveObj action) {
    /*
         * cache for each goal?
		 *
		 * the 'pruneSize' must be a minimum of targets to prune... and beyond
		 * that, there should be some default prune logic
		 */
    for (DC_Obj e : targets) {
        if (!(e instanceof Unit)) {
            // another method?
            return;
        }
    }
    int size = targets.size();
    // getPruneSize(goal);
    int toPrune = size - 1;
    if (// this is only the max size, how to ensure pruning of
    toPrune <= 0) // 'valid' targets too?
    {
        if (action.isRanged() || action instanceof DC_SpellObj) {
            // TODO sometimes it's not the size, but the distance!
            return;
        }
    }
    // for melee...
    Boolean byCapacity = true;
    Boolean byHealth = true;
    Boolean byDistance = true;
    Boolean byDanger = false;
    Boolean byPower = true;
    Boolean byType = false;
    switch(goal) {
        case RESTORE:
            byHealth = false;
            break;
        case ATTACK:
            byHealth = false;
            byDanger = true;
            break;
        case BUFF:
            // TODO ignore near-dead and 'surrounded'
            byDanger = true;
            // enemies ready to fall
            break;
        case CUSTOM_HOSTILE:
        case CUSTOM_SUPPORT:
    }
    Boolean enemy = GoalManager.isGoalVsEnemies(goal);
    int minDistance = // TODO for ALLIES?
    getAnalyzer().getClosestEnemyDistance(ai.getUnit());
    List<DC_Obj> pruneList = new ArrayList<>();
    // TODO sort() first? to be sure to cut off the tail...
    int maxPower = ParamAnalyzer.getMaxParam(PARAMS.POWER, new ArrayList<>(targets));
    int limit = 0;
    boolean first = true;
    pruneLoop: while ((first || pruneList.size() < toPrune) && limit < 5) {
        first = false;
        for (DC_Obj t : targets) {
            if (pruneList.contains(t)) {
                continue;
            }
            boolean result = false;
            while (true) {
                if (byDistance) {
                    int distance = PositionMaster.getDistance(t, ai.getUnit());
                    // if (distance < minDistance) {
                    // minDistance = distance;
                    // } else {
                    result = (getDistancePruneFactor(limit, t, ai, action)) < distance - minDistance;
                    // }
                    if (result) {
                        break;
                    }
                }
                if (byCapacity) {
                    float capacity = DC_PriorityManager.getCapacity((Unit) t);
                    if (result) {
                        break;
                    }
                }
                if (byHealth) {
                    // ?
                    int health = DC_PriorityManager.getHealthFactor(t, byHealth);
                    result = (health < getHeathPruneFactor(limit, t, ai, action));
                    if (result) {
                        break;
                    }
                }
                if (byPower) {
                    result = t.getIntParam(PARAMS.POWER) * 100 / maxPower < getPowerFactor(limit, ai, action);
                    if (result) {
                        break;
                    }
                }
                // by danger
                break;
            }
            if (result) {
                pruneList.add(t);
                continue pruneLoop;
            }
        }
        // if nobody was pruned, increase limits
        limit++;
    }
    main.system.auxiliary.log.LogMaster.log(LOG_CHANNEL.AI_DEBUG, "PRUNING FOR " + action + " : " + pruneList);
    for (DC_Obj t : pruneList) {
        targets.remove(t);
    }
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) ArrayList(java.util.ArrayList) DC_SpellObj(eidolons.entity.active.DC_SpellObj) Unit(eidolons.entity.obj.unit.Unit)

Example 25 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class DC_BattleFieldManager method resetVisibleWallMap.

private void resetVisibleWallMap() {
    visibleWallMap = new MapMaster().cloneHashMap(wallMap);
    visibleWallMap.keySet().removeIf((sub) -> {
        DC_Obj obj = (DC_Obj) game.getObjectByCoordinate(sub);
        if (obj == null) {
            return false;
        }
        // return !VisionManager.checkVisible(obj, false);
        return !VisionManager.getMaster().getDetectionMaster().checkKnownForPlayer(obj);
    });
    visibleDiagonalJoints = new MapMaster().cloneHashMap(diagonalJoints);
    visibleDiagonalJoints.keySet().removeIf((sub) -> !visibleWallMap.containsKey(sub));
// for (Coordinates sub: wallMap.keySet()){
// DC_Obj obj = (DC_Obj) game.getObjectByCoordinate(sub);
// if (VisionManager.checkVisible(obj, false)){
// visibleWallMap.put(sub, wallMap.get(sub));
// }
// }
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) MapMaster(main.system.auxiliary.data.MapMaster)

Aggregations

DC_Obj (eidolons.entity.obj.DC_Obj)49 Unit (eidolons.entity.obj.unit.Unit)13 Obj (main.entity.obj.Obj)13 Coordinates (main.game.bf.Coordinates)12 ArrayList (java.util.ArrayList)11 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)9 DIRECTION (main.game.bf.Coordinates.DIRECTION)7 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)5 DC_Cell (eidolons.entity.obj.DC_Cell)4 BufferedImage (java.awt.image.BufferedImage)4 List (java.util.List)3 ModifyCounterEffect (eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect)2 DC_UnitAction (eidolons.entity.active.DC_UnitAction)2 HashMap (java.util.HashMap)2 PARAMETER (main.content.values.parameters.PARAMETER)2 Ref (main.entity.Ref)2 BuffObj (main.entity.obj.BuffObj)2 Pair (org.apache.commons.lang3.tuple.Pair)2 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)1