/** To-hit number for the mech to push another mech */ public static ToHitData toHit(IGame game, int attackerId, Targetable target) { final Entity ae = game.getEntity(attackerId); int targetId = Entity.NONE; Entity te = null; if (target.getTargetType() == Targetable.TYPE_ENTITY) { te = (Entity) target; targetId = target.getTargetId(); } if (ae == null) return new ToHitData(ToHitData.IMPOSSIBLE, "You can't attack from a null entity!"); if (te == null) return new ToHitData(ToHitData.IMPOSSIBLE, "You can't target a null entity!"); IHex attHex = game.getBoard().getHex(ae.getPosition()); IHex targHex = game.getBoard().getHex(te.getPosition()); final int attackerElevation = ae.getElevation() + attHex.getElevation(); final int targetElevation = target.getElevation() + targHex.getElevation(); final boolean targetInBuilding = Compute.isInBuilding(game, te); Building bldg = null; if (targetInBuilding) { bldg = game.getBoard().getBuildingAt(te.getPosition()); } ToHitData toHit = null; // arguments legal? if (ae == null || target == null) { throw new IllegalArgumentException("Attacker or target not valid"); } // can't target yourself if (ae.equals(te)) { return new ToHitData(ToHitData.IMPOSSIBLE, "You can't target yourself"); } // non-mechs can't push if (!(ae instanceof Mech)) { return new ToHitData(ToHitData.IMPOSSIBLE, "Non-mechs can't push"); } // Quads can't push if (ae.entityIsQuad()) { return new ToHitData(ToHitData.IMPOSSIBLE, "Attacker is a quad"); } // can't make physical attacks while spotting if (ae.isSpotting()) { return new ToHitData(ToHitData.IMPOSSIBLE, "Attacker is spotting this turn"); } // Can only push mechs if (te != null && !(te instanceof Mech)) { return new ToHitData(ToHitData.IMPOSSIBLE, "Target is not a mech"); } // Can't push with flipped arms if (ae.getArmsFlipped()) { return new ToHitData(ToHitData.IMPOSSIBLE, "Arms are flipped to the rear. Can not push."); } // Can't target a transported entity. if (te != null && Entity.NONE != te.getTransportId()) { return new ToHitData(ToHitData.IMPOSSIBLE, "Target is a passenger."); } // Can't target a entity conducting a swarm attack. if (te != null && Entity.NONE != te.getSwarmTargetId()) { return new ToHitData(ToHitData.IMPOSSIBLE, "Target is swarming a Mek."); } // check if both arms are present if (ae.isLocationBad(Mech.LOC_RARM) || ae.isLocationBad(Mech.LOC_LARM)) { return new ToHitData(ToHitData.IMPOSSIBLE, "Arm missing"); } // check if attacker has fired arm-mounted weapons if (ae.weaponFiredFrom(Mech.LOC_RARM) || ae.weaponFiredFrom(Mech.LOC_LARM)) { return new ToHitData(ToHitData.IMPOSSIBLE, "Weapons fired from arm this turn"); } // check range if (ae.getPosition().distance(target.getPosition()) > 1) { return new ToHitData(ToHitData.IMPOSSIBLE, "Target not in range"); } // target must be at same elevation if (attackerElevation != targetElevation) { return new ToHitData(ToHitData.IMPOSSIBLE, "Target not at same elevation"); } // can't push mech making non-pushing displacement attack if (te != null && te.hasDisplacementAttack() && !te.isPushing()) { return new ToHitData(ToHitData.IMPOSSIBLE, "Target is making a charge/DFA attack"); } // can't push mech pushing another, different mech if (te != null && te.isPushing() && te.getDisplacementAttack().getTargetId() != ae.getId()) { return new ToHitData(ToHitData.IMPOSSIBLE, "Target is pushing another mech"); } // can't do anything but counter-push if the target of another attack if (ae.isTargetOfDisplacementAttack() && ae.findTargetedDisplacement().getEntityId() != target.getTargetId()) { return new ToHitData( ToHitData.IMPOSSIBLE, "Attacker is the target of another push/charge/DFA"); } // can't attack the target of another displacement attack if (te != null && te.isTargetOfDisplacementAttack() && te.findTargetedDisplacement().getEntityId() != ae.getId()) { return new ToHitData(ToHitData.IMPOSSIBLE, "Target is the target of another push/charge/DFA"); } // check facing if (!target.getPosition().equals(ae.getPosition().translated(ae.getFacing()))) { return new ToHitData(ToHitData.IMPOSSIBLE, "Target not directly ahead of feet"); } // can't push while prone if (ae.isProne()) { return new ToHitData(ToHitData.IMPOSSIBLE, "Attacker is prone"); } // can't push prone mechs if (te != null && te.isProne()) { return new ToHitData(ToHitData.IMPOSSIBLE, "Target is prone"); } // Can't target units in buildings (from the outside). if (targetInBuilding) { if (!Compute.isInBuilding(game, ae)) { return new ToHitData(ToHitData.IMPOSSIBLE, "Target is inside building"); } else if (!game.getBoard().getBuildingAt(ae.getPosition()).equals(bldg)) { return new ToHitData(ToHitData.IMPOSSIBLE, "Target is inside differnt building"); } } // Attacks against adjacent buildings automatically hit. if ((target.getTargetType() == Targetable.TYPE_BUILDING) || (target.getTargetType() == Targetable.TYPE_FUEL_TANK)) { return new ToHitData( ToHitData.IMPOSSIBLE, "You can not push a building (well, you can, but it won't do anything)."); } // Can't target woods or ignite a building with a physical. if (target.getTargetType() == Targetable.TYPE_BLDG_IGNITE || target.getTargetType() == Targetable.TYPE_HEX_CLEAR || target.getTargetType() == Targetable.TYPE_HEX_IGNITE) { return new ToHitData(ToHitData.IMPOSSIBLE, "Invalid attack"); } // Set the base BTH int base = 4; if (game.getOptions().booleanOption("maxtech_physical_BTH")) { base = ae.getCrew().getPiloting() - 1; } toHit = new ToHitData(base, "base"); // attacker movement toHit.append(Compute.getAttackerMovementModifier(game, attackerId)); // target movement toHit.append(Compute.getTargetMovementModifier(game, targetId)); // attacker terrain toHit.append(Compute.getAttackerTerrainModifier(game, attackerId)); // target terrain toHit.append(Compute.getTargetTerrainModifier(game, te)); // damaged or missing actuators if (!ae.hasWorkingSystem(Mech.ACTUATOR_SHOULDER, Mech.LOC_RARM)) { toHit.addModifier(2, "Right Shoulder destroyed"); } if (!ae.hasWorkingSystem(Mech.ACTUATOR_SHOULDER, Mech.LOC_LARM)) { toHit.addModifier(2, "Left Shoulder destroyed"); } // water partial cover? if (te.height() > 0 && te.getElevation() == -1 && targHex.terrainLevel(Terrains.WATER) == te.height()) { toHit.addModifier(3, "target has partial cover"); } // target immobile toHit.append(Compute.getImmobileMod(te)); Compute.modifyPhysicalBTHForAdvantages(ae, te, toHit, game); toHit.append(nightModifiers(game, target, null, ae)); // side and elevation shouldn't matter // If it has a torso-mounted cockpit and two head sensor hits or three sensor hits... // It gets a =4 penalty for being blind! if (((Mech) ae).getCockpitType() == Mech.COCKPIT_TORSO_MOUNTED) { int sensorHits = ae.getBadCriticals(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_SENSORS, Mech.LOC_HEAD); int sensorHits2 = ae.getBadCriticals(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_SENSORS, Mech.LOC_CT); if ((sensorHits + sensorHits2) == 3) { return new ToHitData( ToHitData.IMPOSSIBLE, "Sensors Completely Destroyed for Torso-Mounted Cockpit"); } else if (sensorHits == 2) { toHit.addModifier(4, "Head Sensors Destroyed for Torso-Mounted Cockpit"); } } // done! return toHit; }
/** * Creates the sprite for this entity. Fortunately it is no longer an extra pain to create * transparent images in AWT. */ @Override public void prepare() { final IBoard board = bv.game.getBoard(); // recalculate bounds & label getBounds(); // create image for buffer GraphicsConfiguration config = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice() .getDefaultConfiguration(); image = config.createCompatibleImage(bounds.width, bounds.height, Transparency.TRANSLUCENT); Graphics2D graph = (Graphics2D) image.getGraphics(); GUIPreferences.AntiAliasifSet(graph); // translate everything (=correction for label placement) graph.translate(-hexOrigin.x, -hexOrigin.y); if (!bv.useIsometric()) { // The entity sprite is drawn when the hexes are rendered. // So do not include the sprite info here. if (onlyDetectedBySensors()) { graph.drawImage(bv.getScaledImage(radarBlipImage, true), 0, 0, this); } else { // draw the unit icon translucent if: // hidden from the enemy (and activated graphics setting); or // submerged boolean translucentHiddenUnits = GUIPreferences.getInstance() .getBoolean(GUIPreferences.ADVANCED_TRANSLUCENT_HIDDEN_UNITS); boolean shouldBeTranslucent = (trackThisEntitiesVisibilityInfo(entity) && !entity.isVisibleToEnemy()) || entity.isHidden(); if ((shouldBeTranslucent && translucentHiddenUnits) || (entity.relHeight() < 0)) { graph.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f)); } graph.drawImage( bv.getScaledImage(bv.tileManager.imageFor(entity, secondaryPos), true), 0, 0, this); graph.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f)); } } // scale the following draws according to board zoom graph.scale(bv.scale, bv.scale); boolean isInfantry = (entity instanceof Infantry); boolean isAero = (entity instanceof Aero); if ((isAero && ((Aero) entity).isSpheroid() && !board.inSpace()) && (secondaryPos == 1)) { graph.setColor(Color.WHITE); graph.draw(bv.facingPolys[entity.getFacing()]); } if ((secondaryPos == -1) || (secondaryPos == 6)) { // Gather unit conditions ArrayList<Status> stStr = new ArrayList<Status>(); criticalStatus = false; // Determine if the entity has a locked turret, // and if it is a gun emplacement boolean turretLocked = false; int crewStunned = 0; boolean ge = false; if (entity instanceof Tank) { turretLocked = !((Tank) entity).hasNoTurret() && !entity.canChangeSecondaryFacing(); crewStunned = ((Tank) entity).getStunnedTurns(); ge = entity instanceof GunEmplacement; } // draw elevation/altitude if non-zero if (entity.isAirborne()) { if (!board.inSpace()) { stStr.add(new Status(Color.CYAN, "A", SMALL)); stStr.add(new Status(Color.CYAN, Integer.toString(entity.getAltitude()), SMALL)); } } else if (entity.getElevation() != 0) { stStr.add(new Status(Color.CYAN, Integer.toString(entity.getElevation()), SMALL)); } // Shutdown if (entity.isManualShutdown()) { stStr.add(new Status(Color.YELLOW, "SHUTDOWN")); } else if (entity.isShutDown()) { stStr.add(new Status(Color.RED, "SHUTDOWN")); } // Prone, Hulldown, Stuck, Immobile, Jammed if (entity.isProne()) stStr.add(new Status(Color.RED, "PRONE")); if (entity.isHiddenActivating()) stStr.add(new Status(Color.RED, "ACTIVATING")); if (entity.isHidden()) stStr.add(new Status(Color.RED, "HIDDEN")); if (entity.isHullDown()) stStr.add(new Status(Color.ORANGE, "HULLDOWN")); if ((entity.isStuck())) stStr.add(new Status(Color.ORANGE, "STUCK")); if (!ge && entity.isImmobile()) stStr.add(new Status(Color.RED, "IMMOBILE")); if (isAffectedByECM()) stStr.add(new Status(Color.YELLOW, "Jammed")); // Turret Lock if (turretLocked) stStr.add(new Status(Color.YELLOW, "LOCKED")); // Grappling & Swarming if (entity.getGrappled() != Entity.NONE) { if (entity.isGrappleAttacker()) { stStr.add(new Status(Color.YELLOW, "GRAPPLER")); } else { stStr.add(new Status(Color.RED, "GRAPPLED")); } } if (entity.getSwarmAttackerId() != Entity.NONE) { stStr.add(new Status(Color.RED, "SWARMED")); } // Transporting if ((entity.getLoadedUnits()).size() > 0) { stStr.add(new Status(Color.YELLOW, "T", SMALL)); } // Hidden, Unseen Unit if (trackThisEntitiesVisibilityInfo(entity)) { if (!entity.isEverSeenByEnemy()) { stStr.add(new Status(Color.GREEN, "U", SMALL)); } else if (!entity.isVisibleToEnemy()) { stStr.add(new Status(Color.GREEN, "H", SMALL)); } } // Crew if (entity.getCrew().isDead()) stStr.add(new Status(Color.RED, "CrewDead")); if (crewStunned > 0) { stStr.add(new Status(Color.YELLOW, "STUNNED", new Object[] {crewStunned})); } // Infantry if (isInfantry) { int dig = ((Infantry) entity).getDugIn(); if (dig == Infantry.DUG_IN_COMPLETE) { stStr.add(new Status(Color.PINK, "D", SMALL)); } else if (dig != Infantry.DUG_IN_NONE) { stStr.add(new Status(Color.YELLOW, "Working", DIRECT)); stStr.add(new Status(Color.PINK, "D", SMALL)); } else if (((Infantry) entity).isTakingCover()) { stStr.add(new Status(Color.YELLOW, "TakingCover")); } } // Aero if (isAero) { Aero a = (Aero) entity; if (a.isRolled()) stStr.add(new Status(Color.YELLOW, "ROLLED")); if (a.getFuel() <= 0) stStr.add(new Status(Color.RED, "FUEL")); if (a.isEvading()) stStr.add(new Status(Color.GREEN, "EVADE")); if (a.isOutControlTotal() & a.isRandomMove()) { stStr.add(new Status(Color.RED, "RANDOM")); } else if (a.isOutControlTotal()) { stStr.add(new Status(Color.RED, "CONTROL")); } } if (GUIPreferences.getInstance().getShowDamageLevel()) { Color damageColor = getDamageColor(); if (damageColor != null) { stStr.add(new Status(damageColor, 0, SMALL)); } } // Unit Label // no scaling for the label, its size is changed by varying // the font size directly => better control graph.scale(1 / bv.scale, 1 / bv.scale); // Label background if (criticalStatus) { graph.setColor(LABEL_CRITICAL_BACK); } else { graph.setColor(LABEL_BACK); } graph.fillRoundRect(labelRect.x, labelRect.y, labelRect.width, labelRect.height, 5, 10); // Label text graph.setFont(labelFont); Color textColor = LABEL_TEXT_COLOR; if (!entity.isDone() && !onlyDetectedBySensors()) { textColor = GUIPreferences.getInstance().getColor(GUIPreferences.ADVANCED_UNITOVERVIEW_VALID_COLOR); } if (isSelected) { textColor = GUIPreferences.getInstance() .getColor(GUIPreferences.ADVANCED_UNITOVERVIEW_SELECTED_COLOR); } bv.drawCenteredText( graph, getAdjShortName(), labelRect.x + labelRect.width / 2, labelRect.y + labelRect.height / 2 - 1, textColor, (entity.isDone() && !onlyDetectedBySensors())); // Past here, everything is drawing status that shouldn't be seen // on a sensor return, so we'll just quit here if (onlyDetectedBySensors()) { graph.dispose(); return; } // Draw all the status information now drawStatusStrings(graph, stStr); // from here, scale the following draws according to board zoom graph.scale(bv.scale, bv.scale); // draw facing graph.setColor(Color.white); if ((entity.getFacing() != -1) && !(isInfantry && !((Infantry) entity).hasFieldGun() && !((Infantry) entity).isTakingCover()) && !(isAero && ((Aero) entity).isSpheroid() && !board.inSpace())) { graph.draw(bv.facingPolys[entity.getFacing()]); } // determine secondary facing for non-mechs & flipped arms int secFacing = entity.getFacing(); if (!((entity instanceof Mech) || (entity instanceof Protomech))) { secFacing = entity.getSecondaryFacing(); } else if (entity.getArmsFlipped()) { secFacing = (entity.getFacing() + 3) % 6; } // draw red secondary facing arrow if necessary if ((secFacing != -1) && (secFacing != entity.getFacing())) { graph.setColor(Color.red); graph.draw(bv.facingPolys[secFacing]); } if ((entity instanceof Aero) && this.bv.game.useVectorMove()) { for (int head : entity.getHeading()) { graph.setColor(Color.red); graph.draw(bv.facingPolys[head]); } } // armor and internal status bars int baseBarLength = 23; int barLength = 0; double percentRemaining = 0.00; percentRemaining = entity.getArmorRemainingPercent(); barLength = (int) (baseBarLength * percentRemaining); graph.setColor(Color.darkGray); graph.fillRect(56, 7, 23, 3); graph.setColor(Color.lightGray); graph.fillRect(55, 6, 23, 3); graph.setColor(getStatusBarColor(percentRemaining)); graph.fillRect(55, 6, barLength, 3); if (!ge) { // Gun emplacements don't have internal structure percentRemaining = entity.getInternalRemainingPercent(); barLength = (int) (baseBarLength * percentRemaining); graph.setColor(Color.darkGray); graph.fillRect(56, 11, 23, 3); graph.setColor(Color.lightGray); graph.fillRect(55, 10, 23, 3); graph.setColor(getStatusBarColor(percentRemaining)); graph.fillRect(55, 10, barLength, 3); } } graph.dispose(); }
/** To-hit number for a death from above attack, assuming that movement has been handled */ public static ToHitData toHit(IGame game, int attackerId, Targetable target, Coords src) { final Entity ae = game.getEntity(attackerId); // arguments legal? if (ae == null) { throw new IllegalArgumentException("Attacker is null"); } // Do to pretreatment of physical attacks, the target may be null. if (target == null) { return new ToHitData(TargetRoll.IMPOSSIBLE, "Target is null"); } int targetId = Entity.NONE; Entity te = null; if (target.getTargetType() == Targetable.TYPE_ENTITY) { te = (Entity) target; targetId = target.getTargetId(); } else { return new ToHitData(TargetRoll.IMPOSSIBLE, "Invalid Target"); } if (!game.getOptions().booleanOption("friendly_fire")) { // a friendly unit can never be the target of a direct attack. if ((target.getTargetType() == Targetable.TYPE_ENTITY) && ((((Entity) target).getOwnerId() == ae.getOwnerId()) || ((((Entity) target).getOwner().getTeam() != IPlayer.TEAM_NONE) && (ae.getOwner().getTeam() != IPlayer.TEAM_NONE) && (ae.getOwner().getTeam() == ((Entity) target).getOwner().getTeam())))) { return new ToHitData( TargetRoll.IMPOSSIBLE, "A friendly unit can never be the target of a direct attack."); } } final boolean targetInBuilding = Compute.isInBuilding(game, te); ToHitData toHit = null; final int attackerElevation = ae.getElevation() + game.getBoard().getHex(ae.getPosition()).getLevel(); final int targetElevation = target.getElevation() + game.getBoard().getHex(target.getPosition()).getLevel(); final int attackerHeight = attackerElevation + ae.getHeight(); // check elevation of target flying VTOL if (target.isAirborneVTOLorWIGE()) { if ((targetElevation - attackerHeight) > ae.getJumpMP()) { return new ToHitData(TargetRoll.IMPOSSIBLE, "Elevation difference to high"); } } // can't target yourself if (ae.equals(te)) { return new ToHitData(TargetRoll.IMPOSSIBLE, "You can't target yourself"); } // Infantry CAN'T dfa!!! if (ae instanceof Infantry) { return new ToHitData(TargetRoll.IMPOSSIBLE, "Infantry can't dfa"); } // Can't target a transported entity. if ((Entity.NONE != te.getTransportId())) { return new ToHitData(TargetRoll.IMPOSSIBLE, "Target is a passenger."); } // Can't target a entity conducting a swarm attack. if ((Entity.NONE != te.getSwarmTargetId())) { return new ToHitData(TargetRoll.IMPOSSIBLE, "Target is swarming a Mek."); } // check range if (src.distance(target.getPosition()) > 1) { return new ToHitData(TargetRoll.IMPOSSIBLE, "Target not in range"); } // can't dfa while prone, even if you somehow did manage to jump if (ae.isProne()) { return new ToHitData(TargetRoll.IMPOSSIBLE, "Attacker is prone"); } // can't attack mech making a different displacement attack if (te.hasDisplacementAttack()) { return new ToHitData(TargetRoll.IMPOSSIBLE, "Target is already making a charge/DFA attack"); } // can't attack the target of another displacement attack if (te.isTargetOfDisplacementAttack() && (te.findTargetedDisplacement().getEntityId() != ae.getId())) { return new ToHitData(TargetRoll.IMPOSSIBLE, "Target is the target of another charge/DFA"); } // Can't target units in buildings (from the outside). if (targetInBuilding) { return new ToHitData(TargetRoll.IMPOSSIBLE, "Target is inside building"); } // Attacks against adjacent buildings automatically hit. if ((target.getTargetType() == Targetable.TYPE_BUILDING) || (target.getTargetType() == Targetable.TYPE_FUEL_TANK) || (target instanceof GunEmplacement)) { return new ToHitData(TargetRoll.AUTOMATIC_SUCCESS, "Targeting adjacent building."); } // Can't target woods or ignite a building with a physical. if ((target.getTargetType() == Targetable.TYPE_BLDG_IGNITE) || (target.getTargetType() == Targetable.TYPE_HEX_CLEAR) || (target.getTargetType() == Targetable.TYPE_HEX_IGNITE)) { return new ToHitData(TargetRoll.IMPOSSIBLE, "Invalid attack"); } // Set the base BTH int base = ae.getCrew().getPiloting(); toHit = new ToHitData(base, "base"); // BMR(r), page 33. +3 modifier for DFA on infantry. if (te instanceof Infantry) { toHit.addModifier(3, "Infantry target"); } // Battle Armor targets are hard for Meks and Tanks to hit. if (te instanceof BattleArmor) { toHit.addModifier(1, "battle armor target"); } if ((ae instanceof Mech) && ((Mech) ae).isSuperHeavy()) { toHit.addModifier(1, "attacker is superheavy mech"); } // attacker movement toHit.append( Compute.getAttackerMovementModifier(game, attackerId, EntityMovementType.MOVE_JUMP)); // target movement toHit.append(Compute.getTargetMovementModifier(game, targetId)); // piloting skill differential if ((ae.getCrew().getPiloting() != te.getCrew().getPiloting())) { toHit.addModifier( ae.getCrew().getPiloting() - te.getCrew().getPiloting(), "piloting skill differential"); } // attacker is spotting if (ae.isSpotting()) { toHit.addModifier(+1, "attacker is spotting"); } // target prone if (te.isProne()) { toHit.addModifier(-2, "target prone and adjacent"); } // If it has a torso-mounted cockpit and two head sensor hits or three // sensor hits... // It gets a =4 penalty for being blind! if ((ae instanceof Mech) && (((Mech) ae).getCockpitType() == Mech.COCKPIT_TORSO_MOUNTED)) { int sensorHits = ae.getBadCriticals(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_SENSORS, Mech.LOC_HEAD); int sensorHits2 = ae.getBadCriticals(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_SENSORS, Mech.LOC_CT); if ((sensorHits + sensorHits2) == 3) { return new ToHitData( TargetRoll.IMPOSSIBLE, "Sensors Completely Destroyed for Torso-Mounted Cockpit"); } else if (sensorHits == 2) { toHit.addModifier(4, "Head Sensors Destroyed for Torso-Mounted Cockpit"); } } // target immobile toHit.append(Compute.getImmobileMod(te)); toHit.append(AbstractAttackAction.nightModifiers(game, target, null, ae, false)); Compute.modifyPhysicalBTHForAdvantages(ae, te, toHit, game); // evading bonuses ( if (te.isEvading()) { toHit.addModifier(te.getEvasionBonus(), "target is evading"); } if (te instanceof Tank) { toHit.setSideTable(ToHitData.SIDE_FRONT); toHit.setHitTable(ToHitData.HIT_NORMAL); } else if (te.isProne()) { toHit.setSideTable(ToHitData.SIDE_REAR); toHit.setHitTable(ToHitData.HIT_NORMAL); } else { toHit.setSideTable(te.sideTable(src)); toHit.setHitTable(ToHitData.HIT_PUNCH); } // Attacking Weight Class Modifier. if (game.getOptions().booleanOption(OptionsConstants.AGM_TAC_OPS_PHYSICAL_ATTACK_PSR)) { if (ae.getWeightClass() == EntityWeightClass.WEIGHT_LIGHT) { toHit.addModifier(-2, "Weight Class Attack Modifier"); } else if (ae.getWeightClass() == EntityWeightClass.WEIGHT_MEDIUM) { toHit.addModifier(-1, "Weight Class Attack Modifier"); } } if ((ae instanceof Mech) && ((Mech) ae).hasIndustrialTSM()) { toHit.addModifier(2, "industrial TSM"); } // done! return toHit; }