return new ToHitData(TH_PHY_NOT_MECH); return new ToHitData(TH_PHY_TOO_FAR); final ToHitData toHitData = new ToHitData(); toHitData.append(guessToHitModifierHelperForAnyAttack(shooter, shooterState, target, targetState, distance, game)); if (TargetRoll.IMPOSSIBLE == toHitData.getValue() || TargetRoll.AUTOMATIC_FAIL == toHitData.getValue()) { return toHitData; return new ToHitData(TH_PHY_NOT_IN_ARC); if (attackType.isPunch()) { if (shooter.hasQuirk(OptionsConstants.QUIRK_NEG_NO_ARMS)) { return new ToHitData(TH_PHY_P_NO_ARMS_QUIRK); return new ToHitData(TH_PHY_TOO_MUCH_ELEVATION); return new ToHitData(TH_PHY_P_TAR_PRONE); return new ToHitData(TH_PHY_P_TAR_INF); return new ToHitData(TH_PHY_P_NO_ARM); return new ToHitData(TH_PHY_P_NO_SHOULDER); toHitData.addModifier(shooter.getCrew().getPiloting(), TH_PHY_BASE); if (!shooter.hasWorkingSystem(Mech.ACTUATOR_UPPER_ARM, armLocation)) { toHitData.addModifier(TH_PHY_P_UPPER_ARM);
private void explosives() { ToHitData explo = LayExplosivesAttackAction.toHit(clientgui.getClient() .getGame(), cen, target); String title = Messages.getString( "PhysicalDisplay.LayExplosivesAttackDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$ String message = Messages .getString( "PhysicalDisplay.LayExplosivesAttackDialog.message", new Object[] {//$NON-NLS-1$ explo.getValueAsString(), new Double(Compute.oddsAbove(explo.getValue())), explo.getDesc() }); if (clientgui.doYesNoDialog(title, message)) { disableButtons(); attacks.addElement(new LayExplosivesAttackAction(cen, target .getTargetType(), target.getTargetId())); ready(); } }
int entityId, EntityMovementType movement) { final Entity entity = game.getEntity(entityId); ToHitData toHit = new ToHitData(); toHit.addModifier(3, "attacker used UMUs"); } else if (entity instanceof LandAirMech && movement == EntityMovementType.MOVE_VTOL_WALK) { toHit.addModifier(3, "attacker cruised"); } else if (entity instanceof LandAirMech && movement == EntityMovementType.MOVE_VTOL_RUN) { toHit.addModifier(4, "attacker flanked"); } else if ((movement == EntityMovementType.MOVE_WALK) || (movement == EntityMovementType.MOVE_VTOL_WALK) || (movement == EntityMovementType.MOVE_CAREFUL_STAND)) { toHit.addModifier(1, "attacker walked"); } else if ((movement == EntityMovementType.MOVE_RUN) || (movement == EntityMovementType.MOVE_VTOL_RUN)) { toHit.addModifier(2, "attacker ran"); } else if (movement == EntityMovementType.MOVE_SKID) { toHit.addModifier(3, "attacker ran and skidded"); } else if (movement == EntityMovementType.MOVE_JUMP) { if (entity.hasAbility(OptionsConstants.PILOT_JUMPING_JACK)) { toHit.addModifier(1, "attacker jumped"); } else if (entity.hasAbility(OptionsConstants.PILOT_HOPPING_JACK)) { toHit.addModifier(2, "attacker jumped"); } else { toHit.addModifier(3, "attacker jumped"); return new ToHitData(TargetRoll.AUTOMATIC_FAIL, "attacker sprinted"); if (toHit.getValue() != TargetRoll.AUTOMATIC_FAIL && entity instanceof Mech && ((Mech)entity).getCockpitType() == Mech.COCKPIT_DUAL && entity.getCrew().hasDedicatedGunner()) {
/** * Modifier to attacks due to spotter movement */ public static ToHitData getSpotterMovementModifier(IGame game, int entityId, EntityMovementType movement) { ToHitData toHit = new ToHitData(); Entity e = game.getEntity(entityId); if ((e != null) && (e instanceof Infantry)) { return toHit; } if ((movement == EntityMovementType.MOVE_WALK) || (movement == EntityMovementType.MOVE_VTOL_WALK)) { toHit.addModifier(1, "spotter walked"); } else if ((movement == EntityMovementType.MOVE_RUN) || (movement == EntityMovementType.MOVE_VTOL_RUN) || (movement == EntityMovementType.MOVE_SKID)) { toHit.addModifier(2, "spotter ran"); } else if (movement == EntityMovementType.MOVE_JUMP) { toHit.addModifier(3, "spotter jumped"); } else if (movement == EntityMovementType.MOVE_SPRINT || movement == EntityMovementType.MOVE_VTOL_SPRINT) { return new ToHitData(TargetRoll.IMPOSSIBLE, "spotter sprinted"); } return toHit; }
public FiringSolutionSprite(BoardView1 boardView1, final FiringSolution fsoln) { super(boardView1, fsoln.getToHitData().getLocation()); updateBounds(); this.fsoln = fsoln; // modifier int thm = fsoln.getToHitData().getValue(); toHitMod = Integer.toString(thm); if (thm >= 0) toHitMod = "+" + toHitMod; if ((thm == TargetRoll.IMPOSSIBLE) || (thm == TargetRoll.AUTOMATIC_FAIL)) noHitPossible = true; // range int r = fsoln.getToHitData().getRange(); range = Integer.toString(r); // create the small hex shape AffineTransform at = AffineTransform.getTranslateInstance((r > 9) ? 25 : 30, secondLine.y + 2); at.scale(0.17, 0.17); at.translate(-BoardView1.HEX_W/2, -BoardView1.HEX_H/2); finalHex = at.createTransformedShape(BoardView1.hexPoly); }
ToHitData toHit = new ToHitData(0, "base"); toHit.addModifier(1, "Taser feedback"); toHit.addModifier(ae.getTaserInterference(), "Taser interference"); toHit.addModifier(+1, "attacker is spotting for indirect LRM fire"); toHit.addModifier(-1, "target is superheavy mech"); toHit.addModifier(1, "fatigue"); toHit.addModifier(+2, "electromagnetic interference"); toHit.addModifier(te.getEvasionBonus(), "target is evading"); toHit.addModifier(ecm, "ECM"); if (eccm > 0) { toHit.addModifier(-1 * Math.min(ecm, eccm), "ECCM"); toHit.addModifier(+1, "target is NOE"); } else { toHit.addModifier(+3, "target is NOE"); toHit.addModifier(vMod, "velocity"); toHit.addModifier(pilothits, "pilot hits"); toHit.addModifier(+2, "out-of-control");
ToHitData typeModifiedToHit = new ToHitData(); typeModifiedToHit.append(toHit); typeModifiedToHit.setHitTable(toHit.getHitTable()); typeModifiedToHit.setSideTable(toHit.getSideTable()); for (TagInfo ti : game.getTagInfo()) { if (target.getTargetId() == ti.target.getTargetId()) { typeModifiedToHit.addModifier(-2, "laser-guided bomb against tagged target"); laserGuided = true; if (typeModifiedToHit.getValue() == TargetRoll.IMPOSSIBLE) { r = new Report(3135); r.subject = subjectId; r.add(typeModifiedToHit.getDesc()); vPhaseReport.addElement(r); return false; } else if (typeModifiedToHit.getValue() == TargetRoll.AUTOMATIC_FAIL) { r = new Report(3140); r.newlines = 0; r.subject = subjectId; r.add(typeModifiedToHit.getDesc()); vPhaseReport.addElement(r); } else if (typeModifiedToHit.getValue() == TargetRoll.AUTOMATIC_SUCCESS) { r = new Report(3145); r.newlines = 0; r.subject = subjectId; r.add(typeModifiedToHit.getDesc()); vPhaseReport.addElement(r);
r = new Report(3405); r.subject = subjectId; r.add(toHit.getTableDesc()); r.add(entityTarget.getLocationAbbr(pcHit)); vPhaseReport.addElement(r); if ((toHit.getCover() == LosEffects.COVER_75RIGHT || toHit.getCover() == LosEffects.COVER_75LEFT) || (toHit.getCover() == LosEffects.COVER_HORIZONTAL && toHit .getDamagableCoverTypeSecondary() != LosEffects.DAMAGABLE_COVER_NONE)) { damagableCoverType = toHit.getDamagableCoverTypePrimary(); coverBuilding = toHit.getCoverBuildingPrimary(); coverDropship = toHit.getCoverDropshipPrimary(); coverLoc = toHit.getCoverLocPrimary(); } else { damagableCoverType = toHit.getDamagableCoverTypeSecondary(); coverBuilding = toHit.getCoverBuildingSecondary(); coverDropship = toHit.getCoverDropshipSecondary(); coverLoc = toHit.getCoverLocSecondary(); damagableCoverType = toHit.getDamagableCoverTypePrimary(); coverBuilding = toHit.getCoverBuildingPrimary(); coverDropship = toHit.getCoverDropshipPrimary(); coverLoc = toHit.getCoverLocPrimary(); toHit = new ToHitData(0, "", ToHitData.HIT_NORMAL,
&& (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 IHex targHex = game.getBoard().getHex(target.getPosition()); if ((attHex == null) || (targHex == null)) { return new ToHitData(TargetRoll.IMPOSSIBLE, "off board"); return new ToHitData(TargetRoll.IMPOSSIBLE, "You can't target yourself"); return new ToHitData(TargetRoll.IMPOSSIBLE, "Non-BA can't make vibroclaw-physicalattacks"); return new ToHitData(TargetRoll.IMPOSSIBLE, "can't target non-infantry"); return new ToHitData(TargetRoll.IMPOSSIBLE, "no vibro claws mounted"); return new ToHitData(TargetRoll.IMPOSSIBLE, "Target is a passenger."); return new ToHitData(TargetRoll.IMPOSSIBLE, "Target is swarming a Mek."); return new ToHitData(TargetRoll.IMPOSSIBLE, "Target not in range"); return new ToHitData(TargetRoll.IMPOSSIBLE,
AmmoType atype = (AmmoType) weapon.getLinked().getType(); int nDamage; HitData hit = entityTarget.rollHitLocation(toHit.getHitTable(), toHit.getSideTable(), waa.getAimedLocation(), waa.getAimingMode(), toHit.getCover()); hit.setGeneralDamageType(generalDamageType); hit.setAttackerId(getAttackerId()); if (entityTarget.removePartialCoverHits(hit.getLocation(), toHit .getCover(), Compute.targetSideTable(ae, entityTarget, weapon .getCalledShot().getCall()))) { r.add(toHit.getTableDesc()); r.add(entityTarget.getLocationAbbr(hit)); vPhaseReport.addElement(r); if (bDirect && (!(target instanceof Infantry) || (target instanceof BattleArmor))) { hit.makeDirectBlow(toHit.getMoS() / 3); critModifer -= 2; } else if (bDirect) { critModifer += toHit.getMoS() / 3;
/** * slice 'em up with your vibroclaws */ public void vibroclawatt() { BAVibroClawAttackAction act = new BAVibroClawAttackAction(cen, target.getTargetType(), target.getTargetId()); ToHitData toHit = act.toHit(clientgui.getClient().getGame()); String title = Messages .getString( "PhysicalDisplay.BAVibroClawDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$ String message = Messages .getString( "PhysicalDisplay.BAVibroClawDialog.message", new Object[] {//$NON-NLS-1$ toHit.getValueAsString(), new Double( Compute.oddsAbove( toHit.getValue(), ce().hasAbility(OptionsConstants.PILOT_APTITUDE_PILOTING))), toHit.getDesc(), ce().getVibroClaws() + toHit.getTableDesc() }); // Give the user to cancel the attack. if (clientgui.doYesNoDialog(title, message)) { disableButtons(); attacks.addElement(act); ready(); } }
r.add(target.getDisplayName(), true); vPhaseReport.addElement(r); if (toHit.getValue() == TargetRoll.IMPOSSIBLE) { r = new Report(3135); r.subject = subjectId; r.add(toHit.getDesc()); vPhaseReport.addElement(r); return false; } else if (toHit.getValue() == TargetRoll.AUTOMATIC_FAIL) { r = new Report(3140); r.newlines = 0; r.subject = subjectId; r.add(toHit.getDesc()); vPhaseReport.addElement(r); } else if (toHit.getValue() == TargetRoll.AUTOMATIC_SUCCESS) { r = new Report(3145); r.newlines = 0; r.subject = subjectId; r.add(toHit.getDesc()); vPhaseReport.addElement(r); entity.getSubEntities().ifPresent(ents -> ents.forEach( ent -> { ToHitData squadronToHit = new ToHitData(); squadronToHit.setHitTable(ToHitData.HIT_NORMAL); HitData hit = ent.rollHitLocation(squadronToHit.getHitTable(), ToHitData.SIDE_FRONT); hit.setCapital(false); vPhaseReport.addAll(server.damageEntity(ent, hit, attackValue));
if (toHit.getValue() == TargetRoll.IMPOSSIBLE) { r = new Report(3135); r.subject = subjectId; r.add(toHit.getDesc()); vPhaseReport.addElement(r); return false; } else if (toHit.getValue() == TargetRoll.AUTOMATIC_FAIL) { r = new Report(3140); r.newlines = 0; r.subject = subjectId; r.add(toHit.getDesc()); vPhaseReport.addElement(r); } else if (toHit.getValue() == TargetRoll.AUTOMATIC_SUCCESS) { r = new Report(3145); r.newlines = 0; r.subject = subjectId; r.add(toHit.getDesc()); vPhaseReport.addElement(r); } else { r.newlines = 0; r.subject = subjectId; r.add(toHit.getValue()); vPhaseReport.addElement(r); bMissed = roll < toHit.getValue(); toHit.setMoS(roll - Math.max(2, toHit.getValue()));
if (toHit.getValue() == TargetRoll.IMPOSSIBLE) { r = new Report(3135); r.subject = subjectId; r.add(toHit.getDesc()); vPhaseReport.addElement(r); return false; } else if (toHit.getValue() == TargetRoll.AUTOMATIC_FAIL) { r = new Report(3140); r.newlines = 0; r.subject = subjectId; r.add(toHit.getDesc()); vPhaseReport.addElement(r); } else if (toHit.getValue() == TargetRoll.AUTOMATIC_SUCCESS) { r = new Report(3145); r.newlines = 0; r.subject = subjectId; r.add(toHit.getDesc()); vPhaseReport.addElement(r); } else { r.newlines = 0; r.subject = subjectId; r.add(toHit.getValue()); vPhaseReport.addElement(r); bMissed = roll < toHit.getValue(); if (roll == toHit.getValue()) { bGlancing = true;
if (guessInfo.getHitData().getValue() != accurateInfo.getHitData().getValue()) { ret += "Incorrect To Hit prediction, physical attack " + attackType.name() + ":\n"; ret += " Guess: " + Integer.toString(guessInfo.getHitData().getValue()) + " " + guessInfo.getHitData() .getDesc() + "\n"; ret += " Real: " + Integer.toString(accurateInfo.getHitData().getValue()) + " " + accurateInfo.getHitData().getDesc() + "\n";
toHit.addModifier(1, "battle armor target"); toHit.addModifier(1, "infantry squad target"); toHit.addModifier(2, "ejected MechWarrior target"); toHit.append(Compute.getAttackerMovementModifier(game, attackerId)); toHit.append(Compute.getAttackerTerrainModifier(game, attackerId)); toHit.append(Compute.getTargetTerrainModifier(game, target, 0, inSameBuilding)); toHit.addModifier(1, "Modular Armor"); toHit.addModifier(1, "attacker is superheavy mech"); Mech.SYSTEM_SENSORS, Mech.LOC_CT); if ((sensorHits + sensorHits2) == 3) { toHit = new ToHitData(TargetRoll.IMPOSSIBLE, "Sensors Completely Destroyed for Torso-Mounted Cockpit"); return; } else if (sensorHits == 2) { toHit.addModifier(4, "Head Sensors Destroyed for Torso-Mounted Cockpit"); toHit.addModifier(+1, "attacker is spotting for indirect LRM fire"); toHit.append(Compute.getImmobileMod(target));
.getDisplayName()); ash.setPartialCover(toHit.getCover()); } else { toHit = WeaponAttackAction.toHit(game, cen, target, weaponId, } else if (toHit.getValue() == TargetRoll.IMPOSSIBLE) { clientgui.mechD.wPan.wToHitR.setText(toHit.getValueAsString()); setFireEnabled(false); } else if (toHit.getValue() == TargetRoll.AUTOMATIC_FAIL) { clientgui.mechD.wPan.wToHitR.setText(toHit.getValueAsString()); setFireEnabled(true); } else { boolean natAptGunnery = ce().hasAbility(OptionsConstants.PILOT_APTITUDE_GUNNERY); clientgui.mechD.wPan.wToHitR.setText(toHit.getValueAsString() + " (" + Compute.oddsAbove(toHit.getValue(), natAptGunnery) + "%)"); //$NON-NLS-1$ clientgui.mechD.wPan.toHitText.setText(toHit.getDesc()); setSkipEnabled(true); } else {
toReturn = new ToHitData(inf.getCrew().getPiloting(), "anti-mech skill", ToHitData.HIT_KICK, ToHitData.SIDE_FRONT); int men = inf.getShootingStrength(); modifier = 7; toReturn.addModifier(modifier, men + " trooper(s) active"); } else if (attacker instanceof Infantry) { toReturn = new ToHitData(inf.getCrew().getPiloting(), "anti-mech skill", ToHitData.HIT_KICK, ToHitData.SIDE_FRONT); int men = inf.getShootingStrength(); modifier = 7; toReturn.addModifier(modifier, men + " trooper(s) active"); toReturn.addModifier(-2, "has tracks"); toReturn = new ToHitData(TargetRoll.IMPOSSIBLE, reason.toString(), ToHitData.HIT_KICK, ToHitData.SIDE_FRONT); if (toReturn.getValue() == TargetRoll.IMPOSSIBLE) { return toReturn;
private void assertToHitDataEquals(final ToHitData expected, final Object actual) { Assert.assertNotNull(actual); Assert.assertTrue("actual: " + actual.getClass().getName(), actual instanceof ToHitData); final ToHitData actualTHD = (ToHitData) actual; final StringBuilder failure = new StringBuilder(); if (expected.getValue() != actualTHD.getValue()) { failure.append("\nExpected: ").append(expected.getValue()); failure.append("\nActual: ").append(actualTHD.getValue()); } final Set<TargetRollModifier> expectedMods = new HashSet<>(expected.getModifiers()); final Set<TargetRollModifier> actualMods = new HashSet<>(actualTHD.getModifiers()); if (!expectedMods.equals(actualMods)) { failure.append("\nExpected: ").append(expected.getDesc()); failure.append("\nActual: ").append(actualTHD.getDesc()); } if (!StringUtil.isNullOrEmpty(failure.toString())) { Assert.fail(failure.toString()); } }
return new ToHitData(); && !entity.isImmobile() && !((entity instanceof Infantry) || (entity instanceof VTOL) || (entity instanceof GunEmplacement))) { ToHitData toHit = new ToHitData(); toHit.addModifier(-1, "target didn't move"); return toHit; ToHitData toHit = new ToHitData(); toHit.addModifier(3, "target is assault dropping"); return toHit; && entity instanceof Mech && ((Mech)entity).getCockpitType() == Mech.COCKPIT_DUAL && entity.getCrew().hasDedicatedPilot()) { if (toHit.getModifiers().isEmpty()) { toHit.addModifier(1, "target moved 1-2 hexes"); } else { toHit.getModifiers().get(0).setValue(toHit.getModifiers().get(0).getValue() + 1); toHit.addModifier(2, "target skidded"); toHit.addModifier(1, "target is airborne"); toHit.addModifier(-1, "target sprinted");