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(); } }
/** * 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(); } }
@Override protected void addHeat() { if (!(toHit.getValue() == TargetRoll.IMPOSSIBLE)) { if (weapon.isRapidfire()) { ae.heatBuildup += nRapidDamHeatPerHit; } else { super.addHeat(); } } }
private void breakGrapple() { ToHitData toHit = BreakGrappleAttackAction.toHit(clientgui.getClient() .getGame(), cen, target); String title = Messages.getString( "PhysicalDisplay.BreakGrappleDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$ String message = Messages .getString( "PhysicalDisplay.BreakGrappleDialog.message", new Object[] { //$NON-NLS-1$ toHit.getValueAsString(), new Double( Compute.oddsAbove( toHit.getValue(), ce().hasAbility(OptionsConstants.PILOT_APTITUDE_PILOTING))), toHit.getDesc() }); if (clientgui.doYesNoDialog(title, message)) { disableButtons(); // declare searchlight, if possible if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) { doSearchlight(); } attacks.addElement(new BreakGrappleAttackAction(cen, target .getTargetType(), target.getTargetId())); ready(); } }
@Override protected void addHeat() { if (!(toHit.getValue() == TargetRoll.IMPOSSIBLE)) { if (weapon.isRapidfire()) { ae.heatBuildup += nDamPerHit; } else { super.addHeat(); } } }
/** * Trip that target! */ void trip() { ToHitData toHit = TripAttackAction.toHit(clientgui.getClient() .getGame(), cen, target); String title = Messages .getString( "PhysicalDisplay.TripDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$ String message = Messages .getString( "PhysicalDisplay.TripDialog.message", new Object[] { //$NON-NLS-1$ toHit.getValueAsString(), new Double( Compute.oddsAbove( toHit.getValue(), ce().hasAbility(OptionsConstants.PILOT_APTITUDE_PILOTING))), toHit.getDesc() }); if (clientgui.doYesNoDialog(title, message)) { disableButtons(); // declare searchlight, if possible if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) { doSearchlight(); } attacks.addElement(new TripAttackAction(cen, target.getTargetType(), target.getTargetId())); ready(); } }
public AttackHandler fire(WeaponAttackAction waa, IGame game, Server server) { ToHitData toHit = waa.toHit(game); // FIXME: SUPER DUPER EVIL HACK: swarm missile handlers must be returned // even // if the have an impossible to hit, because there might be other // targets // someone else please please figure out how to do this nice AttackHandler ah = getCorrectHandler(toHit, waa, game, server); if (ah instanceof LRMSwarmHandler || ah instanceof LRMSwarmIHandler) return ah; return toHit.getValue() == TargetRoll.IMPOSSIBLE ? null : ah; }
@Override protected void addHeat() { // Only add heat for first shot in strafe if (isStrafing && !isStrafingFirstShot()) { return; } if (!(toHit.getValue() == TargetRoll.IMPOSSIBLE)) { super.addHeat(); ae.heatBuildup += Compute.d6(); } }
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); }
@Override protected void addHeat() { // Only add heat for first shot in strafe if (isStrafing && !isStrafingFirstShot()) { return; } if (!(toHit.getValue() == TargetRoll.IMPOSSIBLE)) { super.addHeat(); ae.heatBuildup += Compute.d6()/2; } }
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()); } }
@Override protected void useAmmo() { checkAmmo(); if (ammo == null) {// Can't happen. w/o legal ammo, the weapon // *shouldn't* fire. System.out.println("Handler can't find any ammo! Oh no!"); } if (ammo.getUsableShotsLeft() <= 0) { ae.loadWeaponWithSameAmmo(weapon); ammo = weapon.getLinked(); } if (roll >= toHit.getValue()) { ammo.setShotsLeft(ammo.getBaseShotsLeft() - 1); if (wtype.hasFlag(WeaponType.F_ONESHOT)) { weapon.setFired(true); } setDone(); } }
@Override public boolean handle(IGame.Phase phase, Vector<Report> vPhaseReport) { Entity entityTarget = (Entity) target; // ... but only as their *only* attack action. if (toHit.getValue() == TargetRoll.IMPOSSIBLE) { Report r = new Report(3105); r.subject = subjectId; r.add(toHit.getDesc()); vPhaseReport.addElement(r); return false; } // swarming ended succesfully Report r = new Report(3110); r.subject = subjectId; vPhaseReport.addElement(r); // Only apply the "stop swarm 'attack'" to the swarmed Mek. if (ae.getSwarmTargetId() != target.getTargetId()) { Entity other = game.getEntity(ae.getSwarmTargetId()); other.setSwarmAttackerId(Entity.NONE); } else { entityTarget.setSwarmAttackerId(Entity.NONE); } ae.setSwarmTargetId(Entity.NONE); return false; } }
@Override protected void useAmmo() { // call super function if we are in IDF mode, since we don't have streak // there. if (streakInactive()) { super.useAmmo(); return; } checkAmmo(); if (ammo == null) {// Can't happen. w/o legal ammo, the weapon // *shouldn't* fire. System.out.println("Handler can't find any ammo! Oh no!"); } if (ammo.getUsableShotsLeft() <= 0) { ae.loadWeaponWithSameAmmo(weapon); ammo = weapon.getLinked(); } if (roll >= toHit.getValue()) { ammo.setShotsLeft(ammo.getBaseShotsLeft() - 1); if (wtype.hasFlag(WeaponType.F_ONESHOT)) { weapon.setFired(true); } setDone(); } }
/** * @param boardView1 * @param mp */ public MovementModifierEnvelopeSprite(BoardView1 boardView1, MovePath mp) { super(boardView1, mp.getFinalCoords()); facing = Facing.valueOfInt(mp.getFinalFacing()); int modi = Compute.getTargetMovementModifier(mp.getHexesMoved(), mp.isJumping(), mp.getEntity() instanceof VTOL, boardView1.game).getValue(); //Add evasion bonus for 'Mech with dual cockpit if (mp.getEntity().getCrew().getCrewType().equals(CrewType.DUAL) && mp.getEntity().getCrew().hasDedicatedPilot() && !mp.isJumping() && mp.getHexesMoved() > 0) { modi++; } float hue = 0.7f - 0.15f * modi; color = new Color(Color.HSBtoRGB(hue, 1, 1)); modifier = String.format("%+d", modi); }
protected void addHeat() { // Only add heat for first shot in strafe if (isStrafing && !isStrafingFirstShot()) { return; } if (!(toHit.getValue() == TargetRoll.IMPOSSIBLE)) { if (ae.usesWeaponBays() && !game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_HEAT_BY_BAY)) { int loc = weapon.getLocation(); boolean rearMount = weapon.isRearMounted(); if (!ae.hasArcFired(loc, rearMount)) { ae.heatBuildup += ae.getHeatInArc(loc, rearMount); ae.setArcFired(loc, rearMount); } } else { ae.heatBuildup += (weapon.getCurrentHeat()); } } }
@Override protected void addHeat() { // Only add heat for first shot in strafe if (isStrafing && !isStrafingFirstShot()) { return; } if (!(toHit.getValue() == TargetRoll.IMPOSSIBLE)) { if (game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_HEAT_BY_BAY)) { for (int wId : weapon.getBayWeapons()) { Mounted m = ae.getEquipment(wId); ae.heatBuildup += m.getCurrentHeat(); } } else { int loc = weapon.getLocation(); boolean rearMount = weapon.isRearMounted(); if (!ae.hasArcFired(loc, rearMount)) { ae.heatBuildup += ae.getHeatInArc(loc, rearMount); ae.setArcFired(loc, rearMount); } } } }
WeaponAttackAction getWeaponAttackAction() { final String METHOD_NAME = "getWeaponAttackAction(IGame)"; owner.methodBegin(getClass(), METHOD_NAME); try { if (null != getAction()) { return getAction(); } if (!getWeapon().getType().hasFlag(WeaponType.F_ARTILLERY)) { setAction(new WeaponAttackAction(getShooter().getId(), getTarget().getTargetId(), getShooter().getEquipmentNum(getWeapon()))); } else { setAction(new ArtilleryAttackAction(getShooter().getId(), getTarget().getTargetType(), getTarget().getTargetId(), getShooter().getEquipmentNum(getWeapon()), getGame())); } if (getAction() == null) { setProbabilityToHit(0); return null; } setProbabilityToHit(Compute.oddsAbove(getAction().toHit(getGame()).getValue(), getShooterState().hasNaturalAptGun()) / 100.0); return getAction(); } finally { owner.methodEnd(getClass(), METHOD_NAME); } }