Examples of IHex


Examples of megamek.common.IHex

                addReport(damageEntity(entity, h, 1));
                addNewLines();
            }
        }
        // set entity to expected elevation
        IHex hex = game.getBoard().getHex(entity.getPosition());
        entity.setElevation(entity.elevationOccupied(hex) - hex.floor());
        // finally, check for any stacking violations
        Entity violated = Compute.stackingViolation(game, entity, entity.getPosition(), null);
        if (violated != null) {
            // handle this as accidental fall from above
            entity.setElevation(violated.getElevation() + 2);
View Full Code Here

Examples of megamek.common.IHex

     * @param altitude
     *            Absolute altitude for flak attack
     */
    void artilleryDamageHex(Coords coords, Coords attackSource, int damage, AmmoType ammo, int subjectId, Entity killer, Entity exclude, boolean flak, int altitude, Vector<Report> vPhaseReport) {

        IHex hex = game.getBoard().getHex(coords);
        if (hex == null) {
            return; // not on board.
        }

        int flakElevation = altitude - hex.surface();

        Report r;

        if (!flak) {
            vPhaseReport.addAll(tryClearHex(coords, damage * 2, subjectId));
        }
        Building bldg = game.getBoard().getBuildingAt(coords);
        int bldgAbsorbs = 0;
        if ((bldg != null) && !(flak && (flakElevation > hex.terrainLevel(Terrains.BLDG_ELEV)))) {
            bldgAbsorbs = bldg.getPhaseCF(coords) / 10;
            if (!((ammo != null) && (ammo.getMunitionType() == AmmoType.M_FLECHETTE))) {
                // damage the building
                Vector<Report> buildingReport = damageBuilding(bldg, damage, coords);
                for (Report report : buildingReport) {
                    report.subject = subjectId;
                }
                vPhaseReport.addAll(buildingReport);
                addNewLines();
            }
        }

        if (flak && ((flakElevation <= 0) || (flakElevation <= hex.terrainLevel(Terrains.BLDG_ELEV)) || (flakElevation == hex.terrainLevel(Terrains.BRIDGE_ELEV)))) {
            // Flak in this hex would only hit landed units
            return;
        }

        // get units in hex
        for (Enumeration<Entity> impactHexHits = game.getEntities(coords); impactHexHits.hasMoreElements();) {
            Entity entity = impactHexHits.nextElement();
            int hits = damage;
            ToHitData toHit = new ToHitData();
            int cluster = 5;

            // Check: is entity excluded?
            if (entity == exclude) {
                continue;
            }

            // Check: is entity inside building?
            if ((bldg != null) && (bldgAbsorbs > 0) && (entity.getElevation() < hex.terrainLevel(Terrains.BLDG_ELEV))) {
                cluster -= bldgAbsorbs;
                if (entity instanceof Infantry) {
                    continue; // took its damage already from building damage
                } else if (cluster <= 0) {
                    // entity takes no damage
                    r = new Report(6426);
                    r.subject = subjectId;
                    r.addDesc(entity);
                    vPhaseReport.add(r);
                    continue;
                } else {
                    r = new Report(6425);
                    r.subject = subjectId;
                    r.add(bldgAbsorbs);
                    vPhaseReport.add(r);
                }
            }

            if (flak) {
                // Check: is entity not a VTOL in flight
                if (!((entity instanceof VTOL) || (entity.getMovementMode() == IEntityMovementMode.VTOL))) {
                    continue;
                }
                // Check: is entity at correct elevation?
                if (entity.getElevation() != flakElevation) {
                    continue;
                }
            } else {
                // Check: is entity a VTOL in flight?
                if ((entity instanceof VTOL) || (entity.getMovementMode() == IEntityMovementMode.VTOL)) {
                    // VTOLs take no damage from normal artillery unless landed
                    if ((entity.getElevation() != 0) && (entity.getElevation() != hex.terrainLevel(Terrains.BLDG_ELEV)) && (entity.getElevation() != hex.terrainLevel(Terrains.BRIDGE_ELEV))) {
                        continue;
                    }
                }
            }

            // Work out hit table to use
            if (attackSource != null) {
                toHit.setSideTable(entity.sideTable(attackSource));
                if ((ammo != null) && (ammo.getMunitionType() == AmmoType.M_CLUSTER) && attackSource.equals(coords)) {
                    if (entity instanceof Mech) {
                        toHit.setHitTable(ToHitData.HIT_ABOVE);
                    } else if (entity instanceof Tank) {
                        toHit.setSideTable(ToHitData.SIDE_FRONT);
                        toHit.addModifier(2, "cluster artillery hitting a Tank");
                    }
                }
            }

            // convention infantry take x2 damage from AE weapons
            if ((entity instanceof Infantry) && !(entity instanceof BattleArmor)) {
                hits *= 2;
            }

            // Entity/ammo specific damage modifiers
            if (ammo != null) {
                if (ammo.getMunitionType() == AmmoType.M_CLUSTER) {
                    if (hex.containsTerrain(Terrains.FORTIFIED) && (entity instanceof Infantry) && !(entity instanceof BattleArmor)) {
                        hits *= 2;
                    }
                } else if (ammo.getMunitionType() == AmmoType.M_FLECHETTE) {
                    // wheeled and hover tanks take movement critical
                    if ((entity instanceof Tank) && ((entity.getMovementMode() == IEntityMovementMode.WHEELED) || (entity.getMovementMode() == IEntityMovementMode.HOVER))) {
View Full Code Here

Examples of megamek.common.IHex

        for (C3LinkModel m : remove) c3links.remove(m);
    }

    private void update(Entity entity, EntityModel em) {
        if (em != null) em.detach();
        IHex hex = game.getBoard().getHex(entity.getPosition());
        if (hex != null) {
            removeC3LinksFor(entity);
            addChild(new EntityModel(entity, tileManager, currentView, game));
            if (entity.hasC3() || entity.hasC3i()) addC3LinksFor(entity, null);
        }
View Full Code Here

Examples of megamek.common.IHex

                    r.addDesc(inf);
                    r.add(c.getBoardNum());
                    r.subject = inf.getId();
                    addReport(r);
                    // fortification complete - add to map
                    IHex hex = game.getBoard().getHex(c);
                    hex.addTerrain(Terrains.getTerrainFactory().createTerrain(Terrains.FORTIFIED, 1));
                    sendChangedHex(c);
                    // Clear the dig in for any units in same hex, since they
                    // get it for free by fort
                    for (Enumeration<Entity> e = game.getEntities(c); e.hasMoreElements();) {
                        Entity ent2 = e.nextElement();
View Full Code Here

Examples of megamek.common.IHex

     * remove a cloud from the map
     * @param cloud
     */
    public void removeSmokeTerrain(SmokeCloud cloud){
        for ( Coords coords : cloud.getCoordsList() ){
            IHex nextHex = game.getBoard().getHex(coords);
            if ((nextHex != null) && nextHex.containsTerrain(Terrains.SMOKE)) {
                nextHex.removeTerrain(Terrains.SMOKE);
                sendChangedHex(coords);
            }
        }
    }
View Full Code Here

Examples of megamek.common.IHex

     *            value is Entity.NONE, then the roll attempt will not be
     *            included in the report.
     */
    public boolean checkIgnition(Coords c, TargetRoll roll, boolean bInferno, int entityId, Vector<Report> vPhaseReport) {

        IHex hex = game.getBoard().getHex(c);

        // The hex might be null due to spreadFire translation
        // goes outside of the board limit.
        if (null == hex) {
            return false;
        }

        // The hex may already be on fire.
        if (hex.containsTerrain(Terrains.FIRE)) {
            return false;
        }

        if (!bInferno && !hex.isIgnitable()) {
            return false;
        }

        int fireRoll = Compute.d6(2);
        Report r = null;
View Full Code Here

Examples of megamek.common.IHex

            r.type = Report.PUBLIC;
            vReport.add(r);
            return;
        }

        IHex hex = game.getBoard().getHex(c);
        if(null == hex) {
            return;
        }

        Report r = new Report(3005);
        r.indent(2);
        r.add(c.getBoardNum());
        r.type = Report.PUBLIC;

        //type of fire. We use level 2 for infernos
        int type = 1;
        if(bInferno) {
            type = type + 1;
            r.messageId = 3006;

        }

        //report it
        if(null != vReport) {
            vReport.add(r);
        }
        hex.addTerrain(Terrains.getTerrainFactory().createTerrain(Terrains.FIRE, type));
        sendChangedHex(c);
    }
View Full Code Here

Examples of megamek.common.IHex

        return height;
    }

    public EntityModel(Entity entity, TileTextureManager tilesetManager, ViewTransform view, IGame game) {
        Coords c = entity.getPosition();
        IHex hex = game.getBoard().getHex(c);

        int elevation = entity.getElevation();
        int dir = entity.getFacing();
        if (dir == -1) dir = 0;
        int sdir = entity.getSecondaryFacing();
View Full Code Here

Examples of megamek.common.IHex

        Point3f zero = new Point3f();
        final Entity prev = (Entity)getUserData();
        final int mpos = (prev.isProne()?1:knots);
        final float pitchA = (float)-pitch(prev), pitchB = (float)-pitch(entity);
        final Point3f scaleA = new Point3f(scale(prev)), scaleB = new Point3f(scale(entity));
        IHex hex = gboard.getHex(prev.getPosition());
        int dir = prev.getFacing();
        if (dir == -1) dir = 0;
        keyframes1[pos] = new KBKeyFrame(
            pos*1.0f/knots,
            0,
View Full Code Here

Examples of megamek.common.IHex

     * @param x
     * @param y
     * @param hex
     */
    public void removeFire(Coords fireCoords, String reason) {
        IHex hex = game.getBoard().getHex(fireCoords);
        if(null == hex) {
            return;
        }
        hex.removeTerrain(Terrains.FIRE);
        hex.resetFireTurn();
        sendChangedHex(fireCoords);
        // fire goes out
        Report r = new Report(5170, Report.PUBLIC);
        r.add(fireCoords.getBoardNum());
        r.add(reason);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.