if (null != coords) hex = game.board.getHex (coords);
if (null != coords) hex = game.getBoard().getHex (coords);
    private String criticalEntity(Entity en, int loc, int critMod, boolean rollNumber) {        CriticalSlot slot = null;        StringBuffer desc = new StringBuffer();        Coords coords = en.getPosition();        IHex hex = null;        int hits;        if (rollNumber) {            if (null != coords) hex = game.board.getHex (coords);            desc.append( "        Critical hit on " )                .append( en.getLocationAbbr(loc) )                .append( ". " );            hits = 0;            int roll = Compute.d6(2);            desc.append( "Roll = " );            if ( critMod != 0 ) {                desc.append( "(" ).append( roll );                if ( critMod > 0 ) {                    desc.append( "+" );                }                desc.append( critMod ).append( ") = " );                roll += critMod;            }            desc.append( roll ).append( ";" );            if (roll <= 7) {                desc.append( " no effect." );                return desc.toString();            } else if (roll >= 8 && roll <= 9) {                hits = 1;                desc.append( " 1 location." );            } else if (roll >= 10 && roll <= 11) {                hits = 2;                desc.append( " 2 locations." );            } else if (roll == 12) {                if (en instanceof Tank) {                    hits = 3;                    desc.append( " 3 locations." );                } else if (en instanceof Protomech) {                    hits=3;                    desc.append( " 3 locations" );                } else if (en.locationIsLeg(loc)) {                    desc.append( "<<<LIMB BLOWN OFF>>> " )                        .append( en.getLocationName(loc) )                        .append( " blown off." );                    if (en.getInternal(loc) > 0) {                        destroyLocation(en, loc);                    }                    if (null != hex) {                        if (!hex.containsTerrain (Terrains.LEGS)) {                            hex.addTerrain (Terrains.getTerrainFactory().createTerrain(Terrains.LEGS, 1));                        }                        else {                            hex.addTerrain (Terrains.getTerrainFactory().createTerrain                                            (Terrains.LEGS,                                             hex.terrainLevel(Terrains.LEGS)+1));                        }                    }                    sendChangedHex(en.getPosition());                    return desc.toString();                } else if (loc == Mech.LOC_RARM || loc == Mech.LOC_LARM) {                    desc.append( "<<<LIMB BLOWN OFF>>> " )                        .append( en.getLocationName(loc) )                        .append( " blown off." );                    destroyLocation(en, loc);                    if (null != hex) {                        if (!hex.containsTerrain( Terrains.ARMS)) {                            hex.addTerrain (Terrains.getTerrainFactory().createTerrain(Terrains.ARMS, 1));                        }                        else {                            hex.addTerrain (Terrains.getTerrainFactory().createTerrain                                            (Terrains.ARMS,                                             hex.terrainLevel(Terrains.ARMS)+1));                        }                    }                    sendChangedHex(en.getPosition());                    return desc.toString();                } else if (loc == Mech.LOC_HEAD) {                    desc.append( "<<<HEAD BLOWN OFF>>> " )                        .append( en.getLocationName(loc) )                        .append( " blown off." );                    destroyLocation(en, loc);                    // Don't kill a pilot multiple times.                    if ( Pilot.DEATH > en.getCrew().getHits() ) {                        en.crew.setDoomed(true);                        desc.append( "\n" )                            .append( destroyEntity(en, "pilot death", true) );                    }                    return desc.toString();                } else {                    // torso hit                    hits = 3;                    desc.append( " 3 locations." );                }            }        } else {            hits = 1;        }                    // vehicle handle crits in their own 'special' way        if (en instanceof Tank) {            Tank tank = (Tank)en;            for (int x = 0; x < hits; x++) {                slot = new CriticalSlot( CriticalSlot.TYPE_SYSTEM,                                         Compute.d6(1) );                desc.append( applyCriticalHit(en, Entity.NONE, slot, true) );            }        }        else {            // transfer criticals, if needed            while (hits > 0 && en.canTransferCriticals(loc)                   && en.getTransferLocation(loc) != Entity.LOC_DESTROYED) {                loc = en.getTransferLocation(loc);                desc.append( "\n            Location is empty, " )                    .append( "so criticals transfer to " )                    .append( en.getLocationAbbr(loc) )                    .append( "." );            }            // Roll critical hits in this location.            while (hits > 0) {                // Have we hit all available slots in this location?                if (en.getHittableCriticals(loc) <= 0) {                    desc.append( "\n            Location has no more " )                        .append( "hittable critical slots." );                    break;                }                // Randomly pick a slot to be hit.                int slotIndex = Compute.randomInt                    ( en.getNumberOfCriticals(loc) );                slot = en.getCritical(loc, slotIndex);                // Ignore empty or unhitable slots (this                // includes all previously hit slots).                if (slot != null && slot.isHittable()) {                    desc.append( applyCriticalHit(en, loc, slot, true) );                    hits--;                }            } // Hit another slot in this location.        }        return desc.toString();    }