if (sensorHits > 0) {
if ((attacker instanceof Mech) && ((Mech)attacker).getCockpitType() == Mech.COCKPIT_TORSO_MOUNTED) { sensorHits += attacker.getBadCriticals(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_SENSORS, Mech.LOC_CT); if (sensorHits > 1) { mods.addModifier(4, "attacker sensors badly damaged"); } else if (sensorHits > 0) { mods.addModifier(2, "attacker sensors damaged"); } } else if (sensorHits > 0) {
    public static ToHitData getDamageWeaponMods(Entity attacker, Mounted weapon) {        ToHitData mods = new ToHitData();        if (attacker instanceof Protomech) {            // Head criticals add to target number of all weapons.            int hits = ((Protomech) attacker).getCritsHit(Protomech.LOC_HEAD);            if (hits > 0) {                mods.addModifier(hits, hits + " head critical(s)");            }            // Arm mounted (and main gun) weapons get DRMs from arm crits.            switch (weapon.getLocation()) {                case Protomech.LOC_LARM:                case Protomech.LOC_RARM:                    hits = ((Protomech) attacker).getCritsHit(weapon                            .getLocation());                    if (hits > 0) {                        mods.addModifier(hits, hits + " arm critical(s)");                    }                    break;                case Protomech.LOC_MAINGUN:                    // Main gun is affected by crits in *both* arms.                    hits = ((Protomech) attacker)                            .getCritsHit(Protomech.LOC_LARM);                    hits += ((Protomech) attacker)                            .getCritsHit(Protomech.LOC_RARM);                    if (4 == hits) {                        mods.addModifier(ToHitData.IMPOSSIBLE,                                "Cannot fire main gun with no arms.");                    } else if (hits > 0) {                        mods.addModifier(hits, hits + " arm critical(s)");                    }                    break;            }        } // End attacker-is-Protomech        // Is the shoulder destroyed?        else if (attacker.getBadCriticals(CriticalSlot.TYPE_SYSTEM,                Mech.ACTUATOR_SHOULDER, weapon.getLocation()) > 0) {            mods.addModifier(4, "shoulder actuator destroyed");        } else {            // no shoulder hits, add other arm hits            int actuatorHits = 0;            if (attacker.getBadCriticals(CriticalSlot.TYPE_SYSTEM,                    Mech.ACTUATOR_UPPER_ARM, weapon.getLocation()) > 0) {                actuatorHits++;            }            if (attacker.getBadCriticals(CriticalSlot.TYPE_SYSTEM,                    Mech.ACTUATOR_LOWER_ARM, weapon.getLocation()) > 0) {                actuatorHits++;            }            if (actuatorHits > 0) {                mods.addModifier(actuatorHits, actuatorHits                        + " destroyed arm actuators");            }        }        // sensors critical hit to attacker        int sensorHits = attacker.getBadCriticals(CriticalSlot.TYPE_SYSTEM,                Mech.SYSTEM_SENSORS, Mech.LOC_HEAD);        if (sensorHits > 0) {            mods.addModifier(2, "attacker sensors damaged");        }        return mods;    }