Search in sources :

Example 91 with Obj

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

the class ClearShotCondition method check.

@Override
public boolean check(Ref ref) {
    Obj obj = game.getObjectById(ref.getId(str2));
    if (!(obj instanceof DC_Obj)) {
        return false;
    }
    DC_Obj target = (DC_Obj) game.getObjectById(ref.getId(str2));
    if (target == null) {
        return false;
    }
    Coordinates c2 = target.getCoordinates();
    if (c2 == null)
        return false;
    BattleFieldObject source = (BattleFieldObject) game.getObjectById(ref.getId(str1));
    if (source == null)
        return false;
    if (c2.equals(source.getCoordinates()))
        return true;
    if (target.isOverlaying()) {
        if (target instanceof BattleFieldObject) {
            DIRECTION d = ((BattleFieldObject) target).getDirection();
            DIRECTION d1 = DirectionMaster.getRelativeDirection(target, source);
            if (d != null) {
                if (d1 != d) {
                    if (Math.abs(d.getDegrees() - d1.getDegrees()) > 90)
                        return false;
                }
            }
        }
    }
    wallObstruction = false;
    Coordinates c1 = source.getCoordinates();
    boolean toCheck = true;
    boolean result = true;
    if (PositionMaster.inLine(c1, c2)) {
        result = PositionMaster.noObstaclesInLine(source, target, game.getBattleField().getGrid());
        toCheck = false;
        if (!result)
            return cacheResult(source, target, result);
    } else {
        // TODO TRANSPARENT FOR VISION!
        if (PositionMaster.inLineDiagonally(c1, c2)) {
            result = PositionMaster.noObstaclesInDiagonal(c1, c2, game.getBattleField().getGrid(), source);
            if (!result)
                return cacheResult(source, target, result);
            List<Coordinates> list = new ArrayList<>();
            if (!c2.isAdjacent(source.getCoordinates())) {
                DIRECTION direction = DirectionMaster.getRelativeDirection(source, target);
                list = (DC_PositionMaster.getLine(false, direction, source.getCoordinates(), // PositionMaster.getDistance(source,
                Math.abs(source.getX() - target.getX())));
            } else {
                list.add(target.getCoordinates());
            }
            for (Coordinates c : list) {
                if (checkWallObstruction(source, target, c))
                    return cacheResult(source, target, false);
            }
            return cacheResult(source, target, true);
        }
    }
    if (!result)
        return cacheResult(source, target, result);
    if (!toCheck)
        return cacheResult(source, target, result);
    result = checkClearShot(source, target);
    return cacheResult(source, target, result);
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION) ArrayList(java.util.ArrayList)

Example 92 with Obj

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

the class DungeonBuilder method initDynamicObjData.

protected void initDynamicObjData(Location location, DungeonPlan plan) {
    int z = location.getIntParam(G_PARAMS.Z_LEVEL);
    for (MapBlock b : plan.getBlocks()) {
        ArrayList<Obj> objects = new ArrayList<>(b.getObjects());
        for (Obj obj : objects) {
            // TODO of course - the issue was that I added an object to
            // block too! ... init?
            BattleFieldObject unit = (BattleFieldObject) obj;
            if (z != 0) {
                unit.setZ(z);
            }
        }
    }
    for (MapZone zone : plan.getZones()) {
        ObjType wallType = DataManager.getType(zone.getFillerType(), DC_TYPE.BF_OBJ);
        if (wallType == null)
            continue;
        List<Coordinates> list = zone.getCoordinates();
        for (MapBlock b : zone.getBlocks()) {
            list.removeAll(b.getCoordinates());
        }
        for (Coordinates c : list) {
            getGame().getManager().getObjCreator().createUnit(wallType, c.x, c.y, Player.NEUTRAL, new Ref(game));
        }
    }
    for (Obj obj : plan.getWallObjects()) {
        BattleFieldObject unit = (BattleFieldObject) obj;
        if (z != 0) {
            unit.setZ(z);
        }
    }
    if (plan.getDirectionMap() != null) {
        try {
            DC_ObjInitializer.initDirectionMap(z, plan.getDirectionMap());
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    if (plan.getFlipMap() != null) {
        try {
            DC_ObjInitializer.initFlipMap(z, plan.getFlipMap());
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
}
Also used : MapZone(eidolons.game.battlecraft.logic.dungeon.location.building.MapZone) Ref(main.entity.Ref) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) ObjType(main.entity.type.ObjType) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 93 with Obj

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

the class MapBlock method getXml.

public String getXml() {
    resetObjects();
    xml = "";
    xml += XML_Converter.openXmlFormatted(getShortName());
    xml += XML_Converter.wrapLeaf(LocationBuilder.BLOCK_TYPE_NODE, type.getName());
    if (roomType != null) {
        xml += XML_Converter.wrapLeaf(LocationBuilder.ROOM_TYPE_NODE, roomType.toString());
    }
    xml += XML_Converter.openXmlFormatted(LocationBuilder.COORDINATES_NODE);
    for (Coordinates c : coordinates) {
        xml += c.toString() + ";";
    }
    xml += XML_Converter.closeXmlFormatted(LocationBuilder.COORDINATES_NODE);
    xml += XML_Converter.openXmlFormatted(LocationBuilder.OBJ_NODE);
    for (Coordinates c : map.keySet()) {
        Obj obj = map.get(c);
        String name = obj.getName();
        Integer chance = obj.getIntParam(G_PARAMS.CHANCE);
        if (chance > 0) {
            name += StringMaster.wrapInParenthesis(chance + "%");
        }
        xml += c + "=" + name + ",";
    }
    // ++ random objects
    xml += XML_Converter.closeXmlFormatted(LocationBuilder.OBJ_NODE);
    xml += XML_Converter.closeXmlFormatted(getShortName());
    // objects?
    return xml;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj) ZCoordinates(main.game.bf.ZCoordinates) Coordinates(main.game.bf.Coordinates)

Example 94 with Obj

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

the class BfAnalyzer method getClosestCell.

public Obj getClosestCell(Obj targetUnit, boolean canMove) {
    Obj cell = checkAdjacentCell(targetUnit, canMove);
    if (cell != null) {
        return cell;
    }
    for (int i = 2; i < getMaxDistance(); i++) {
        cell = checkCells(targetUnit, movementManager.getCellsInRadius(targetUnit, i), canMove);
        if (cell != null) {
            break;
        }
    }
    if (cell == null) {
        LogMaster.log(LogMaster.AI_DEBUG, "failed to find a cell for : " + getAi().getUnit() + " to attack " + targetUnit);
    // throw new RuntimeException();
    }
    LogMaster.log(LogMaster.AI_DEBUG, cell + " is the closest cell to " + targetUnit);
    return cell;
}
Also used : Obj(main.entity.obj.Obj)

Example 95 with Obj

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

the class GameState method removeObject.

public void removeObject(Integer id) {
    Obj obj = objMap.get(id);
    LogMaster.log(LogMaster.CORE_DEBUG_1, "Obj removed: " + obj);
    objMap.remove(id);
    removed(obj);
}
Also used : Obj(main.entity.obj.Obj)

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