Search in sources :

Example 51 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class DroppedItemManager method pickUp.

public boolean pickUp(Unit hero, Entity type) {
    Obj cell = game.getCellByCoordinate(hero.getCoordinates());
    DC_HeroItemObj item = (DC_HeroItemObj) ObjUtilities.findObjByType(type, getDroppedItems(cell));
    if (item == null) {
        return false;
    }
    pickUp(cell, item);
    return true;
}
Also used : Obj(main.entity.obj.Obj) DC_HeroItemObj(eidolons.entity.item.DC_HeroItemObj) DC_HeroItemObj(eidolons.entity.item.DC_HeroItemObj)

Example 52 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class FacingMaster method getOptimalFacingTowardsUnits.

public static FACING_DIRECTION getOptimalFacingTowardsUnits(Coordinates c, Collection<? extends Obj> units, Function<Entity, Integer> function) {
    HashMap<FACING_DIRECTION, Double> map = new LinkedHashMap<>();
    for (FACING_DIRECTION facing : FACING_DIRECTION.values()) for (Obj member : units) {
        if (FacingMaster.getSingleFacing(facing, c, member.getCoordinates()) != FACING_SINGLE.IN_FRONT) {
            continue;
        }
        double x = ((Unit) member).calculatePower() / PositionMaster.getExactDistance(member.getCoordinates(), c);
        Double i = map.get(facing);
        if (i == null) {
            i = 0.0;
        }
        i += function.apply(member) * x;
        map.put(facing, i);
    }
    FACING_DIRECTION pick = null;
    Double max = 0.0;
    for (FACING_DIRECTION fac : map.keySet()) {
        if (map.get(fac) > max) {
            max = map.get(fac);
            pick = fac;
        }
    }
    return pick;
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) Obj(main.entity.obj.Obj) BfObj(main.entity.obj.BfObj) Unit(eidolons.entity.obj.unit.Unit)

Example 53 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class TargetingMaster method selectTargetForAction.

public static Integer selectTargetForAction(DC_ActiveObj a) {
    /*
         * getOrCreate possible targets init goal type prioritize
		 */
    GOAL_TYPE type = GoalManager.getGoalFromAction(a);
    Obj target = null;
    int max_priority = Integer.MIN_VALUE;
    Set<Obj> objects = null;
    a.getTargeting().getFilter().setRef(a.getRef());
    try {
        objects = a.getTargeting().getFilter().getObjects();
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
    for (Obj obj : objects) {
        ActionSequence sequence = new ActionSequence(type, new Action(a, obj));
        sequence.setAi(a.getOwnerObj().getUnitAI());
        sequence.setType(type);
        int priority = DC_PriorityManager.getPriority(sequence);
        if (priority > max_priority) {
            target = obj;
            max_priority = priority;
        }
    }
    if (target == null) {
        return null;
    }
    return target.getId();
}
Also used : Action(eidolons.game.battlecraft.ai.elements.actions.Action) ActionSequence(eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence) ActiveObj(main.entity.obj.ActiveObj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) GOAL_TYPE(main.content.enums.system.AiEnums.GOAL_TYPE)

Example 54 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class ArenaBattleConstructor method pickSpawnCoordinateForWave.

private Coordinates pickSpawnCoordinateForWave(ENCOUNTER_TYPE type, Integer round, ObjType waveType, boolean recursion) {
    if (sideSpawnTestMode) {
        return null;
    }
    int minDistance = Integer.MAX_VALUE;
    int maxDistance = 0;
    Map<Coordinates, Point> map = new HashMap<>();
    for (String substring : StringMaster.open(getDungeon().getProperty(PROPS.ENCOUNTER_SPAWN_POINTS))) {
        Coordinates coordinates = new Coordinates(substring);
        if (usedSpawnCoordinates.contains(coordinates)) {
            continue;
        }
        for (Obj member : game.getPlayer(true).getControlledUnits()) {
            // summoned?
            int distance = PositionMaster.getDistance(member.getCoordinates(), coordinates);
            if (distance > maxDistance) {
                maxDistance = distance;
            }
            if (distance < minDistance) {
                minDistance = distance;
            }
        }
        map.put(coordinates, new Point(minDistance, maxDistance));
    }
    if (map.isEmpty()) {
        if (recursion) {
            return getDefaultSpawnCoordinate(type, round, waveType);
        }
        usedSpawnCoordinates.clear();
        return pickSpawnCoordinateForWave(type, round, waveType, true);
    }
    Coordinates pick = null;
    int minDistanceToOptimal = Integer.MAX_VALUE;
    for (Coordinates coordinates : map.keySet()) {
        minDistance = map.get(coordinates).x;
        maxDistance = map.get(coordinates).y;
        int distanceToOptimal = Math.max(0, getOptimalMinDistance() - minDistance);
        distanceToOptimal += Math.max(0, maxDistance - getOptimalMaxDistance());
        if (distanceToOptimal < minDistanceToOptimal) {
            minDistanceToOptimal = distanceToOptimal;
            pick = coordinates;
        }
    }
    usedSpawnCoordinates.add(pick);
    return pick;
}
Also used : HashMap(java.util.HashMap) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates)

Example 55 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class GammaMaster method getAlphaForShadowMapCell.

public float getAlphaForShadowMapCell(int x, int y, SHADE_LIGHT type) {
    if (type == SHADE_LIGHT.BLACKOUT) {
        return getBlackoutAlpha(x, y);
    }
    if (type == SHADE_LIGHT.HIGLIGHT) {
        return getHiglightAlpha(x, y);
    }
    Unit unit = Eidolons.game.getManager().getMainHero();
    if (unit == null) {
        unit = Eidolons.game.getManager().getActiveObj();
    }
    if (unit == null) {
        switch(type) {
            case GAMMA_SHADOW:
                return 1;
        }
        return 0;
    }
    float alpha = 0;
    float gamma = getGammaForCell(x, y);
    switch(type) {
        case GAMMA_SHADOW:
            if (VisionManager.isVisionHacked()) {
                return 0;
            }
            if (gamma >= 1)
                return 0;
            if (gamma < 0)
                alpha = 1;
            else
                alpha = 1 - gamma;
            if (unit.getX() == x && unit.getY() == y) {
                alpha = alpha / 2;
            }
            break;
        case GAMMA_LIGHT:
            if (gamma < 0)
                return 0;
            alpha = (float) Math.min(Math.sqrt(gamma * 2), gamma / 3);
            alpha = Math.min(alpha, 0.5f);
            break;
        case LIGHT_EMITTER:
            for (Obj sub : DC_Game.game.getRules().getIlluminationRule().getEffectCache().keySet()) {
                if (sub instanceof Unit)
                    // TODO illuminate some other way for units...
                    continue;
                if (sub.getCoordinates().x == x)
                    if (sub.getCoordinates().y == y)
                        if (((DC_Obj) sub).getPlayerVisionStatus(false) == PLAYER_VISION.DETECTED) {
                            alpha += LIGHT_EMITTER_ALPHA_FACTOR * master.getGame().getRules().getIlluminationRule().getLightEmission((DC_Obj) sub);
                        }
            }
            if (alpha > 0) {
                break;
            }
            break;
        case CONCEALMENT:
            alpha = // PARAMS.CONCEALMENT)*CONCEALMENT_ALPHA_FACTOR;
            master.getIlluminationMaster().getConcealment(unit, Eidolons.game.getCellByCoordinate(new Coordinates(x, y))) * CONCEALMENT_ALPHA_FACTOR;
            if (alpha > 0)
                alpha += getAlphaForShadowMapCell(x, y, SHADE_LIGHT.LIGHT_EMITTER) / 3;
            break;
    }
    return MathMaster.minMax(alpha, 0, 1);
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit)

Aggregations

Obj (main.entity.obj.Obj)127 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)34 DC_Obj (eidolons.entity.obj.DC_Obj)30 Coordinates (main.game.bf.Coordinates)27 Unit (eidolons.entity.obj.unit.Unit)24 ArrayList (java.util.ArrayList)19 Ref (main.entity.Ref)15 DC_SpellObj (eidolons.entity.active.DC_SpellObj)14 BuffObj (main.entity.obj.BuffObj)13 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)12 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)11 ActiveObj (main.entity.obj.ActiveObj)10 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)9 PassiveAbilityObj (main.ability.PassiveAbilityObj)9 ObjType (main.entity.type.ObjType)8 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)7 DC_BuffObj (eidolons.entity.obj.attach.DC_BuffObj)7 PARAMETER (main.content.values.parameters.PARAMETER)7 Conditions (main.elements.conditions.Conditions)6 MicroObj (main.entity.obj.MicroObj)6