void updateTarget() {
// dis/enable physical attach buttons
if ((cen != Entity.NONE) && (target != null)) {
if (target.getTargetType() != Targetable.TYPE_INARC_POD) {
// punch?
final ToHitData leftArm = PunchAttackAction.toHit(client.game,
cen, target, PunchAttackAction.LEFT);
final ToHitData rightArm = PunchAttackAction.toHit(client.game,
cen, target, PunchAttackAction.RIGHT);
boolean canPunch = (leftArm.getValue() != TargetRoll.IMPOSSIBLE)
|| (rightArm.getValue() != TargetRoll.IMPOSSIBLE);
setPunchEnabled(canPunch);
// kick?
ToHitData leftLeg = KickAttackAction.toHit(client.game, cen,
target, KickAttackAction.LEFT);
ToHitData rightLeg = KickAttackAction.toHit(client.game, cen,
target, KickAttackAction.RIGHT);
boolean canKick = (leftLeg.getValue() != TargetRoll.IMPOSSIBLE)
|| (rightLeg.getValue() != TargetRoll.IMPOSSIBLE);
ToHitData rightRearLeg = KickAttackAction.toHit(client.game,
cen, target, KickAttackAction.RIGHTMULE);
ToHitData leftRearLeg = KickAttackAction.toHit(client.game,
cen, target, KickAttackAction.LEFTMULE);
canKick |= (leftRearLeg.getValue() != TargetRoll.IMPOSSIBLE)
|| (rightRearLeg.getValue() != TargetRoll.IMPOSSIBLE);
setKickEnabled(canKick);
// how about push?
ToHitData push = PushAttackAction.toHit(client.game, cen,
target);
setPushEnabled(push.getValue() != TargetRoll.IMPOSSIBLE);
// how about trip?
ToHitData trip = TripAttackAction.toHit(client.game, cen,
target);
setTripEnabled(trip.getValue() != TargetRoll.IMPOSSIBLE);
// how about grapple?
ToHitData grap = GrappleAttackAction.toHit(client.game, cen,
target);
ToHitData bgrap = BreakGrappleAttackAction.toHit(client.game,
cen, target);
setGrappleEnabled((grap.getValue() != TargetRoll.IMPOSSIBLE)
|| (bgrap.getValue() != TargetRoll.IMPOSSIBLE));
// how about JJ?
ToHitData jjl = JumpJetAttackAction.toHit(client.game, cen,
target, JumpJetAttackAction.LEFT);
ToHitData jjr = JumpJetAttackAction.toHit(client.game, cen,
target, JumpJetAttackAction.RIGHT);
ToHitData jjb = JumpJetAttackAction.toHit(client.game, cen,
target, JumpJetAttackAction.BOTH);
setJumpJetEnabled(!((jjl.getValue() == TargetRoll.IMPOSSIBLE)
&& (jjr.getValue() == TargetRoll.IMPOSSIBLE) && (jjb
.getValue() == TargetRoll.IMPOSSIBLE)));
// clubbing?
boolean canClub = false;
boolean canAim = false;
for (Iterator<Mounted> clubs = ce().getClubs().iterator(); clubs
.hasNext();) {
Mounted club = clubs.next();
if (club != null) {
ToHitData clubToHit = ClubAttackAction.toHit(
client.game, cen, target, club, ash
.getAimTable());
canClub |= (clubToHit.getValue() != TargetRoll.IMPOSSIBLE);
// assuming S7 vibroswords count as swords and maces
// count as hatchets
if (club.getType().hasSubType(MiscType.S_SWORD)
|| club.getType()
.hasSubType(MiscType.S_HATCHET)
|| club.getType().hasSubType(
MiscType.S_VIBRO_SMALL)
|| club.getType().hasSubType(
MiscType.S_VIBRO_MEDIUM)
|| club.getType().hasSubType(
MiscType.S_VIBRO_LARGE)
|| club.getType().hasSubType(MiscType.S_MACE)
|| club.getType().hasSubType(
MiscType.S_MACE_THB)
|| club.getType().hasSubType(MiscType.S_LANCE)
|| club.getType().hasSubType(MiscType.S_CHAIN_WHIP)
|| club.getType().hasSubType(
MiscType.S_RETRACTABLE_BLADE)) {
canAim = true;
}
}
}
setClubEnabled(canClub);
ash.setCanAim(canAim);
// Thrash at infantry?
ToHitData thrash = new ThrashAttackAction(cen, target)
.toHit(client.game);
setThrashEnabled(thrash.getValue() != TargetRoll.IMPOSSIBLE);
// make a Protomech physical attack?
ToHitData proto = ProtomechPhysicalAttackAction.toHit(
client.game, cen, target);
setProtoEnabled(proto.getValue() != TargetRoll.IMPOSSIBLE);
ToHitData explo = LayExplosivesAttackAction.toHit(client.game,
cen, target);
setExplosivesEnabled(explo.getValue() != TargetRoll.IMPOSSIBLE);
//vibro attack?
ToHitData vibro = BAVibroClawAttackAction.toHit(clientgui.getClient().game, cen, target);
setVibroEnabled(vibro.getValue() != TargetRoll.IMPOSSIBLE);
}
// Brush off swarming infantry or iNarcPods?
ToHitData brushRight = BrushOffAttackAction.toHit(client.game, cen,
target, BrushOffAttackAction.RIGHT);
ToHitData brushLeft = BrushOffAttackAction.toHit(client.game, cen,
target, BrushOffAttackAction.LEFT);
boolean canBrush = ((brushRight.getValue() != TargetRoll.IMPOSSIBLE) || (brushLeft
.getValue() != TargetRoll.IMPOSSIBLE));
setBrushOffEnabled(canBrush);
} else {
setPunchEnabled(false);
setPushEnabled(false);