if (entity.isCharging() || entity.isMakingDfa()) {
return null;
}
PhysicalOption best = null;
ToHitData odds;
double breach;
double breach_a;
double l_dmg;
double r_dmg;
double final_dmg;
int best_brush = PhysicalOption.NONE;
// If the attacker is a Mech
if (entity instanceof Mech) {
l_dmg = 0.0;
r_dmg = 0.0;
final_dmg = 0.0;
breach_a = 0.0;
// If the attacker is being swarmed
if (entity.getSwarmAttackerId() != Entity.NONE) {
// Check for left arm punch damage to self
odds = BrushOffAttackAction.toHit(game, entity.getId(), game
.getEntity(entity.getSwarmAttackerId()),
BrushOffAttackAction.LEFT);
if (odds.getValue() != TargetRoll.IMPOSSIBLE) {
l_dmg = BrushOffAttackAction.getDamageFor(entity,
BrushOffAttackAction.LEFT);
l_dmg *= 1.0 - Compute.oddsAbove(odds.getValue()) / 100.0;
breach = punchThroughMod(entity, ToHitData.HIT_PUNCH,
ToHitData.SIDE_FRONT, l_dmg, l_dmg);
if (breach < 1.5) {
best_brush = PhysicalOption.BRUSH_LEFT;
breach_a = breach;
final_dmg = BrushOffAttackAction.getDamageFor(entity,
BrushOffAttackAction.LEFT);
}
}
// Check for right arm punch damage to self
odds = BrushOffAttackAction.toHit(game, entity.getId(), game
.getEntity(entity.getSwarmAttackerId()),
BrushOffAttackAction.RIGHT);
if (odds.getValue() != TargetRoll.IMPOSSIBLE) {
// If chance of breaching armor is minimal set brush left
r_dmg = BrushOffAttackAction.getDamageFor(entity,
BrushOffAttackAction.RIGHT);
r_dmg *= 1.0 - Compute.oddsAbove(odds.getValue()) / 100.0;
breach = punchThroughMod(entity, ToHitData.HIT_PUNCH,
ToHitData.SIDE_FRONT, r_dmg, r_dmg);
if (breach < Math.min(breach_a, 1.5)) {
best_brush = PhysicalOption.BRUSH_RIGHT;
breach_a = breach;
final_dmg = BrushOffAttackAction.getDamageFor(entity,
BrushOffAttackAction.RIGHT);
}
}
// If both arms are capable of punching, check double punch
// damage
if ((l_dmg > 0) && (r_dmg > 0)) {
// If chance of breaching armor is minimal set double brush
breach = punchThroughMod(entity, ToHitData.HIT_PUNCH,
ToHitData.SIDE_FRONT, l_dmg + r_dmg,
(l_dmg + r_dmg) / 2.0);
if (breach < Math.min(breach_a, 1.5)) {
best_brush = PhysicalOption.BRUSH_BOTH;
breach_a = breach;
final_dmg = BrushOffAttackAction.getDamageFor(entity,
BrushOffAttackAction.LEFT);
final_dmg += BrushOffAttackAction.getDamageFor(entity,
BrushOffAttackAction.RIGHT);
}
}
// Construct and return Physical option
if (best_brush != PhysicalOption.NONE) {
return new PhysicalOption(entity, game.getEntity(entity
.getSwarmAttackerId()), final_dmg, best_brush, null);
}
}
// If the attacker has attached iNarc pods, assign
// a competing damage value for comparison with other
// attacks
if (entity.hasINarcPodsAttached()) {
double test_ranking;
double pod_ranking;
INarcPod test_pod;
INarcPod best_pod;
pod_ranking = 0.0;
Iterator<INarcPod> pod_list = entity.getINarcPodsAttached();
best_pod = pod_list.next();
for (pod_list = entity.getINarcPodsAttached(); pod_list
.hasNext();) {
test_ranking = 1.0;
test_pod = pod_list.next();
// If pod is homing and attacker has no ECM
if ((test_pod.getType() == INarcPod.HOMING)
&& !entity.hasActiveECM()) {
// Pod is +1
test_ranking += 1.0;
}
// If pod is ECM and attacker has C3 link
if ((test_pod.getType() == INarcPod.ECM)
&& (entity.hasC3() || entity.hasC3i())) {
// Pod is +2
test_ranking += 2.0;
}
// If pod is Nemesis
if (test_pod.getType() == INarcPod.NEMESIS) {
// Pod is +variable, based on movement
test_ranking += (entity.getWalkMP() + entity
.getJumpMP()) / 2.0;
}
// If this pod is best, retain it and its ranking
if (test_ranking > pod_ranking) {
pod_ranking = test_ranking;
best_pod = test_pod;
}
}
if (best_pod != null) {
// Check for left arm punch damage to self
odds = BrushOffAttackAction.toHit(game, entity.getId(),
best_pod, BrushOffAttackAction.LEFT);
if (odds.getValue() != TargetRoll.IMPOSSIBLE) {
l_dmg = BrushOffAttackAction.getDamageFor(entity,
BrushOffAttackAction.LEFT);
l_dmg *= 1.0 - Compute.oddsAbove(odds.getValue()) / 100.0;
breach = punchThroughMod(entity, ToHitData.HIT_PUNCH,
ToHitData.SIDE_FRONT, l_dmg, l_dmg);
if (breach < 1.5) {
best_brush = PhysicalOption.BRUSH_LEFT;
breach_a = breach;
final_dmg = BrushOffAttackAction.getDamageFor(
entity, BrushOffAttackAction.LEFT);
}
}
// Check for right arm punch damage to self
odds = BrushOffAttackAction.toHit(game, entity.getId(),
best_pod, BrushOffAttackAction.RIGHT);
if (odds.getValue() != TargetRoll.IMPOSSIBLE) {
// If chance of breaching armor is minimal set brush
// left
r_dmg = BrushOffAttackAction.getDamageFor(entity,
BrushOffAttackAction.RIGHT);
r_dmg *= 1.0 - Compute.oddsAbove(odds.getValue()) / 100.0;
breach = punchThroughMod(entity, ToHitData.HIT_PUNCH,
ToHitData.SIDE_FRONT, r_dmg, r_dmg);
if (breach < Math.min(breach_a, 1.5)) {
best_brush = PhysicalOption.BRUSH_RIGHT;
breach_a = breach;