if (hit.getLocation() == Mech.LOC_RLEG || hit.getLocation() == Mech.LOC_LLEG) { pilotRolls.addElement(new PilotingRollData(te.getId(), PilotingRollData.AUTOMATIC_FALL, "leg destroyed")); }
    private String damageEntity(Entity te, HitData hit, int damage) {        String desc = new String();        int crits = hit.getEffect() == HitData.EFFECT_CRITICAL ? 1 : 0;        //int loc = hit.getLocation();        HitData nextHit = null;        while (damage > 0 && !te.isDestroyed() && !te.isDoomed()) {            // let's resolve some damage!            desc += "\n        " + te.getDisplayName() + " takes " + damage + " damage to " + te.getLocationAbbr(hit) + ".";            // is there armor in the location hit?            if (te.getArmor(hit) > 0) {                if (te.getArmor(hit) > damage) {                    // armor absorbs all damage                    te.setArmor(te.getArmor(hit) - damage, hit);                    te.damageThisPhase += damage;                    damage = 0;                    desc += " " + te.getArmor(hit) + " Armor remaining";                } else {                    // damage goes on to internal                    int absorbed = Math.max(te.getArmor(hit), 0);                    te.setArmor(Entity.ARMOR_DESTROYED, hit);                    te.damageThisPhase += absorbed;                    damage -= absorbed;                    desc += " Armor destroyed,";                }            }            // is there damage remaining?            if (damage > 0) {                // is there internal structure in the location hit?                if (te.getInternal(hit) > 0) {                    // triggers a critical hit                    crits++;                    if (te.getInternal(hit) > damage) {                        // internal structure absorbs all damage                        te.setInternal(te.getInternal(hit) - damage, hit);                        te.damageThisPhase += damage;                        damage = 0;                        desc += " " + te.getInternal(hit) + " Internal Structure remaining";                    } else {                        // damage transfers, maybe                        int absorbed = Math.max(te.getInternal(hit), 0);                        te.setInternal(Entity.ARMOR_DESTROYED, hit);                        te.damageThisPhase += absorbed;                        damage -= absorbed;                        desc += " <<<SECTION DESTROYED>>>,";                    }                }                // is the internal structure gone?                if (te.getInternal(hit) <= 0) {                    destroyLocation(te, hit.getLocation());                    nextHit = te.getTransferLocation(hit);                    if (nextHit.getLocation() == Entity.LOC_DESTROYED) {                        // entity destroyed.                        desc += " Entity destroyed!\n";                        desc += "*** " + te.getDisplayName() + " DESTROYED! ***";                        te.setDoomed(true);                        // no need for further damage                        damage = 0;                        crits = 0;                    } else {                        // remaining damage transfers                         desc += " " + damage + " damage transfers to "                            + te.getLocationAbbr(nextHit) + ".";                    }                }            }            // roll all critical hits against this location            for (int i = 0; i < crits; i++) {                desc += "\n" + criticalEntity(te, hit.getLocation());            }            crits = 0;            if (hit.getLocation() == Mech.LOC_HEAD) {                desc += "\n" + damageCrew(te, 1);            }            // loop to next location            hit = nextHit;        }        return desc;    }