}
}
// Aeros may suffer from criticals
if (ae instanceof Aero) {
Aero aero = (Aero) ae;
// sensor hits
int sensors = aero.getSensorHits();
if(!aero.isCapitalFighter()) {
if ((sensors > 0) && (sensors < 3)) {
toHit.addModifier(sensors, "sensor damage");
}
if (sensors > 2) {
toHit.addModifier(+5, "sensors destroyed");
}
}
// FCS hits
int fcs = aero.getFCSHits();
if ((fcs > 0) && !aero.isCapitalFighter()) {
toHit.addModifier(fcs * 2, "fcs damage");
}
// pilot hits
int pilothits = aero.getCrew().getHits();
if ((pilothits > 0) && !aero.isCapitalFighter()) {
toHit.addModifier(pilothits, "pilot hits");
}
// out of control
if (aero.isOutControlTotal()) {
toHit.addModifier(+2, "out-of-control");
}
if (aero instanceof Jumpship) {
Jumpship js = (Jumpship) aero;
int cic = js.getCICHits();
if (cic > 0) {
toHit.addModifier(cic * 2, "CIC damage");
}
}
// targeting mods for evasive action by large craft
if (aero.isEvading()) {
toHit.addModifier(+2, "attacker is evading");
}
// check for heavy gauss rifle on fighter of small craft
if ((weapon.getType() instanceof ISHGaussRifle) && (ae instanceof Aero)
&& !(ae instanceof Dropship) && !(ae instanceof Jumpship)) {
toHit.addModifier(+1, "weapon to-hit modifier");
}
// check for NOE
// if the target is NOE in atmosphere
if (game.getBoard().inAtmosphere()
&& (1 == (ae.getElevation() - game.getBoard().getHex(
ae.getPosition()).ceiling()))) {
if (ae.isOmni()) {
toHit.addModifier(+1, "attacker is flying at NOE (omni)");
} else {
toHit.addModifier(+2, "attacker is flying at NOE");
}
}
// check for particular kinds of weapons in weapon bays
if (ae.usesWeaponBays()) {
// any heavy lasers
if (wtype.getAtClass() == WeaponType.CLASS_LASER) {
for (int wId : weapon.getBayWeapons()) {
Mounted bweap = ae.getEquipment(wId);
WeaponType bwtype = (WeaponType) bweap.getType();
if ((bwtype.getInternalName().indexOf("Heavy") != -1)
&& (bwtype.getInternalName().indexOf("Laser") != -1)) {
toHit.addModifier(+1, "bay contains heavy laser");
break;
}
}
}
// barracuda and piranha missiles
else if (wtype.getAtClass() == WeaponType.CLASS_CAPITAL_MISSILE) {
boolean onlyBarracuda = true;
boolean onlyPiranha = true;
for (int wId : weapon.getBayWeapons()) {
Mounted bweap = ae.getEquipment(wId);
Mounted bammo = bweap.getLinked();
if (bammo != null) {
AmmoType batype = (AmmoType) bammo.getType();
if (batype.getAmmoType() != AmmoType.T_BARRACUDA) {
onlyBarracuda = false;
}
if ((batype.getAmmoType() != AmmoType.T_PIRANHA) && (batype.getAmmoType() != AmmoType.T_BARRACUDA)) {
onlyPiranha = false;
}
}
}
if (onlyBarracuda) {
toHit.addModifier(-2, "barracuda missile");
} else if (onlyPiranha) {
toHit.addModifier(-1, "piranha missile");
}
}
// barracuda missiles in an AR10 launcher (must all be
// barracuda)
else if (wtype.getAtClass() == WeaponType.CLASS_AR10) {
boolean onlyBarracuda = true;
for (int wId : weapon.getBayWeapons()) {
Mounted bweap = ae.getEquipment(wId);
Mounted bammo = bweap.getLinked();
if (bammo != null) {
AmmoType batype = (AmmoType) bammo.getType();
if (!batype.hasFlag(AmmoType.F_AR10_BARRACUDA)) {
onlyBarracuda = false;
}
}
}
if (onlyBarracuda) {
toHit.addModifier(-2, "barracuda missile");
}
}
// LBX cluster
else if (wtype.getAtClass() == WeaponType.CLASS_LBX_AC) {
boolean onlyCluster = true;
for (int wId : weapon.getBayWeapons()) {
Mounted bweap = ae.getEquipment(wId);
Mounted bammo = bweap.getLinked();
if (bammo != null) {
AmmoType batype = (AmmoType) bammo.getType();
if (batype.getMunitionType() != AmmoType.M_CLUSTER) {
onlyCluster = false;
break;
}
}
}
if (onlyCluster) {
toHit.addModifier(-1, "cluster ammo");
}
}
}
}
if(wtype.hasFlag(WeaponType.F_ANTI_SHIP) && (target instanceof Entity) && (te.getWeight() < 500)) {
toHit.addModifier(4, "Anti-ship missile at a small target");
}
if (target instanceof Aero) {
Aero a = (Aero) target;
// is the target at zero velocity
if (a.getCurrentVelocity() == 0) {
toHit.addModifier(-2, "target is not moving");
}
// capital weapon (except missiles) penalties at small targets
if (wtype.isCapital()
&& (wtype.getAtClass() != WeaponType.CLASS_CAPITAL_MISSILE)
&& (wtype.getAtClass() != WeaponType.CLASS_AR10)
&& !te.isLargeCraft()) {
//check to see if we are using AAA mode
int aaaMod = 0;
if(wtype.hasModes() && weapon.curMode().equals("AAA")) {
aaaMod = 2;
}
if(wtype.isSubCapital()) {
toHit.addModifier(3-aaaMod, "sub-capital weapon at small target");
} else {
toHit.addModifier(5-aaaMod, "capital weapon at small target");
}
}
//AAA mode makes targeting large craft more difficult
if(wtype.hasModes() && weapon.curMode().equals("AAA") && te.isLargeCraft()) {
toHit.addModifier(+1, "AAA mode at large craft");
}
//check for bracketing mode
if(wtype.hasModes() && weapon.curMode().equals("Bracket 80%")) {
toHit.addModifier(-1, "Bracketing 80%");
}
if(wtype.hasModes() && weapon.curMode().equals("Bracket 60%")) {
toHit.addModifier(-2, "Bracketing 60%");
}
if(wtype.hasModes() && weapon.curMode().equals("Bracket 40%")) {
toHit.addModifier(-3, "Bracketing 40%");
}
//sensor shadows
if(game.getOptions().booleanOption("stratops_sensor_shadow") && game.getBoard().inSpace()) {
for(Entity en : Compute.getAdjacentEntitiesAlongAttack(ae.getPosition(), target.getPosition(), game)) {
if(!en.isEnemyOf(a) && en.isLargeCraft()
&& ((en.getWeight() - a.getWeight()) >= -100000.0)) {
toHit.addModifier(+1, "Sensor Shadow");
break;
}
}
for (Enumeration<Entity> i = game.getEntities(target.getPosition()); i.hasMoreElements();) {
Entity en = i.nextElement();
if(!en.isEnemyOf(a) && en.isLargeCraft() && !en.equals(a)
&& ((en.getWeight() - a.getWeight()) >= -100000.0)) {
toHit.addModifier(+1, "Sensor Shadow");
break;
}
}
}