final IHex hex = game.getBoard().getHex(t.getPosition());
    public static ToHitData getTargetTerrainModifier(IGame game, Targetable t) {        Entity entityTarget = null;        if (t.getTargetType() == Targetable.TYPE_ENTITY) {            entityTarget = (Entity) t;        }        final IHex hex = game.getBoard().getHex(t.getPosition());        boolean isVTOL = ((entityTarget != null) && (hex != null)) ? (entityTarget                .getElevation() >= hex.ceiling())                : false;        ToHitData toHit = new ToHitData();        // Smoke and woods. With L3, the effects STACK.        if (!game.getOptions().booleanOption("maxtech_fire")) { // L2            if (hex.containsTerrain(Terrains.SMOKE)) {                toHit.addModifier(2, "target in smoke");            }            if (!isVTOL                    && !(t.getTargetType() == Targetable.TYPE_HEX_CLEAR                            || t.getTargetType() == Targetable.TYPE_HEX_IGNITE                            || t.getTargetType() == Targetable.TYPE_HEX_BOMB                            || t.getTargetType() == Targetable.TYPE_HEX_ARTILLERY                            || t.getTargetType() == Targetable.TYPE_HEX_FASCAM                            || t.getTargetType() == Targetable.TYPE_HEX_INFERNO_IV                            || t.getTargetType() == Targetable.TYPE_HEX_VIBRABOMB_IV || t                            .getTargetType() == Targetable.TYPE_MINEFIELD_DELIVER)) {                if (hex.terrainLevel(Terrains.WOODS) == 1) {                    toHit.addModifier(1, "target in light woods");                } else if (hex.terrainLevel(Terrains.WOODS) > 1) {                    toHit.addModifier(2, "target in heavy woods");                }            }        } else { // L3            if (hex.terrainLevel(Terrains.SMOKE) == 1) {                toHit.addModifier(1, "target in light smoke");            } else if (hex.terrainLevel(Terrains.SMOKE) > 1) {                toHit.addModifier(2, "target in heavy smoke");            }            if (!isVTOL                    && !(t.getTargetType() == Targetable.TYPE_HEX_CLEAR                            || t.getTargetType() == Targetable.TYPE_HEX_IGNITE                            || t.getTargetType() == Targetable.TYPE_HEX_BOMB                            || t.getTargetType() == Targetable.TYPE_HEX_ARTILLERY                            || t.getTargetType() == Targetable.TYPE_HEX_FASCAM                            || t.getTargetType() == Targetable.TYPE_HEX_INFERNO_IV                            || t.getTargetType() == Targetable.TYPE_HEX_VIBRABOMB_IV || t                            .getTargetType() == Targetable.TYPE_MINEFIELD_DELIVER)) {                if (hex.terrainLevel(Terrains.WOODS) == 1) {                    toHit.addModifier(1, "target in light woods");                } else if (hex.terrainLevel(Terrains.WOODS) > 1) {                    toHit.addModifier(2, "target in heavy woods");                }            }        }        // only entities get remaining terrain bonuses        // TODO: should this be changed for buildings???        if (entityTarget == null) {            return toHit;        } else if (entityTarget.isMakingDfa()) {            // you don't get terrain modifiers in midair            // should be abstracted more into a 'not on the ground'            // flag for vtols and such            return toHit;        }        // -1 bonus only against BattleMechs in water!        if (hex.terrainLevel(Terrains.WATER) > 0                && (entityTarget instanceof Mech)) {            toHit.addModifier(-1, "target in water");        }        if (entityTarget.isStuck()) {            toHit.addModifier(-2, "target stuck in swamp");        }        return toHit;    }