Search in sources :

Example 41 with DC_Obj

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

the class SightMaster method resetUnitVision.

private void resetUnitVision(BattleFieldObject observer, Collection<? extends Obj> units) {
    int maxDistance = observer.getIntParam(PARAMS.SIGHT_RANGE) * 2 + 1;
    for (Obj obj : units) {
        DC_Obj unit = (DC_Obj) obj;
        if (PositionMaster.getDistance(observer, obj) > maxDistance) {
            master.getVisionController().getUnitVisionMapper().set(observer, unit, null);
            continue;
        }
        UNIT_VISION status = getUnitVisionStatusPrivate(unit, (Unit) observer);
        master.getVisionController().getUnitVisionMapper().set(observer, unit, status);
    }
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) UNIT_VISION(main.content.enums.rules.VisionEnums.UNIT_VISION) DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj)

Example 42 with DC_Obj

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

the class StealthRule method actionComplete.

public void actionComplete(ActiveObj active) {
    if (!isOn())
        return;
    // perhaps only moves?
    DC_ActiveObj action = (DC_ActiveObj) active;
    Unit source = action.getOwnerObj();
    List<? extends DC_Obj> list = Analyzer.getEnemies(source, false, false, false);
    list.removeIf(unit -> {
        double d = PositionMaster.getExactDistance(source, unit);
        if ((d > getMaxDistance(source, unit))) {
            return true;
        }
        if ((d > getMaxDistance((Unit) unit, source))) {
            return true;
        }
        return false;
    });
    for (DC_Obj sub : list) {
        Unit unit = (Unit) sub;
        double d = PositionMaster.getExactDistance(source, unit);
        if ((d <= getMaxDistance(unit, source))) {
            if (isSpotRollAllowed(unit, source)) {
                rollSpotted(unit, source);
            }
        }
        if ((d <= getMaxDistance(source, unit))) {
            if (isSpotRollAllowed(source, unit)) {
                rollSpotted(source, unit);
            }
        }
    }
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Unit(eidolons.entity.obj.unit.Unit)

Example 43 with DC_Obj

use of eidolons.entity.obj.DC_Obj 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 44 with DC_Obj

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

the class Unit method applySpecialEffects.

public void applySpecialEffects(SPECIAL_EFFECTS_CASE case_type, BattleFieldObject target, Ref REF, boolean offhand) {
    DC_Obj weapon = (DC_Obj) ref.getObj(offhand ? KEYS.OFFHAND : KEYS.WEAPON);
    if (weapon == null) {
        weapon = getWeapon(offhand);
    }
    if (weapon == null) {
        weapon = getNaturalWeapon(offhand);
    }
    if (weapon != null) {
        weapon.applySpecialEffects(case_type, target, REF);
    }
    DC_Obj action = (DC_Obj) ref.getActive();
    if (action != null) {
        action.applySpecialEffects(case_type, target, REF);
    }
    super.applySpecialEffects(case_type, target, REF);
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj)

Example 45 with DC_Obj

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

the class Analyzer method getLastSeenEnemyCells.

public static List<DC_Cell> getLastSeenEnemyCells(UnitAI ai) {
    List<DC_Cell> list = new ArrayList<>();
    for (DC_Obj obj : ai.getUnit().getOwner().getLastSeenCache().keySet()) {
        if (isEnemy(obj, ai.getUnit())) {
            Coordinates coordinates = ai.getUnit().getOwner().getLastSeenCache().get(obj);
            list.add(obj.getGame().getCellByCoordinate(coordinates));
        }
    }
    return list;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) DC_Cell(eidolons.entity.obj.DC_Cell) Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList)

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