/** * Returns the odds that a certain number or above will be rolled on 2d6. */ public static double oddsAbove(int n) { return oddsAbove(n, false); }
private double calcBuildingHazard(MoveStep step, Entity movingUnit, boolean jumpLanding, IBoard board, StringBuilder logMsg) { logMsg.append("\n\tCalculating building hazard: "); // Protos, BA and Infantry move through buildings freely. if (movingUnit instanceof Protomech || movingUnit instanceof Infantry) { logMsg.append("Safe for infantry and protos."); return 0; } // Jumping onto a building is handled in PathRanker validatePaths. if (jumpLanding) { return 0; } // Get the odds of failing the piloting roll while moving through the building. double odds = (1.0 - (Compute.oddsAbove(movingUnit.getCrew() .getPiloting()) / 100)); logMsg.append("\n\t\tChance to fail piloting roll: ") .append(LOG_PERCENT.format(odds)); // Hazard is based on potential damage taken. double dmg = board.getBuildingAt(step.getPosition()) .getCurrentCF(step.getPosition()) / 10D; logMsg.append("\n\t\tPotential building damage: ") .append(LOG_DECIMAL.format(dmg)); double hazard = dmg * odds; logMsg.append("\n\t\tHazard value (") .append(LOG_DECIMAL.format(hazard)).append(")."); return hazard; }
double odds = Compute.oddsAbove(roll.getValue(), naturalAptPilot) / 100; msg.append(" (").append(NumberFormat.getPercentInstance().format(odds)).append(")"); successProbability *= odds; msg.append(target); double odds = Compute.oddsAbove(target) / 100; msg.append(" (").append(NumberFormat.getPercentInstance().format(odds)).append(")"); successProbability *= odds;
/** * Calculates the Falling damage after a successful To-Hit. * * @param odds * @param ent The entity that is falling * @return */ private static double calculateFallingDamage(double odds, Entity ent) { double dmg = odds; dmg *= 1.0 - (Compute.oddsAbove(ent.getBasePilotingRoll().getValue(), ent.hasAbility(OptionsConstants.PILOT_APTITUDE_PILOTING)) / 100.0); dmg *= ent.getWeight() * 0.1; return dmg; }
private double potentialBuildingDamage(int x, int y, Entity entity) { Coords coords = new Coords(x, y); Building building = game.getBoard().getBuildingAt(coords); if (building == null) { return 0; } int potentialDmg = (int) Math.ceil((double) building.getCurrentCF(coords) / 10); boolean aptGunnery = entity.hasAbility(OptionsConstants.PILOT_APTITUDE_GUNNERY); double oddsTakeDmg = 1 - (Compute.oddsAbove(entity.getCrew().getPiloting(), aptGunnery) / 100); return potentialDmg * oddsTakeDmg; }
coll_damage = calculateFallingDamage(Compute.oddsAbove(odds.getValue(), toAptPiloting) / 100.0, to); dmg = (Compute.oddsAbove(odds.getValue(), fromAptPiloting) / 100.0) * damage; self_damage = calculateFallingDamage(1.0 - (Compute.oddsAbove(odds.getValue(), fromAptPiloting) / 100.0), from); if (from.getWalkMP() > 0) { self_damage = self_damage
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(); } }
boolean aptPiloting = getEntity().hasAbility(OptionsConstants.PILOT_APTITUDE_PILOTING); for (TargetRoll roll : psrList) { double multiple = Compute.oddsAbove(roll.getValue(), aptPiloting) / 100; retVal *= (multiple > 0) ? multiple : 0.01;
/** * 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(); } }
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(); } }
hitOdds = 1.0; } else { hitOdds = Compute.oddsAbove(artySkill + ARTILLERY_ATTACK_MODIFIER);
/** * Thrash at the target, unless the player cancels the action. */ void thrash() { ThrashAttackAction act = new ThrashAttackAction(cen, target.getTargetType(), target.getTargetId()); ToHitData toHit = act.toHit(clientgui.getClient().getGame()); String title = Messages .getString( "PhysicalDisplay.TrashDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$ String message = Messages .getString( "PhysicalDisplay.TrashDialog.message", new Object[] {//$NON-NLS-1$ toHit.getValueAsString(), new Double( Compute.oddsAbove( toHit.getValue(), ce().hasAbility(OptionsConstants.PILOT_APTITUDE_PILOTING))), toHit.getDesc(), ThrashAttackAction.getDamageFor(ce()) + toHit.getTableDesc() }); // Give the user to cancel the attack. if (clientgui.doYesNoDialog(title, message)) { disableButtons(); attacks.addElement(act); ready(); } }
/** * 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(); } }
/** * Push that target! */ void push() { ToHitData toHit = PushAttackAction.toHit(clientgui.getClient() .getGame(), cen, target); String title = Messages .getString( "PhysicalDisplay.PushDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$ String message = Messages .getString( "PhysicalDisplay.PushDialog.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 PushAttackAction(cen, target.getTargetType(), target.getTargetId(), target .getPosition())); ready(); } }
int d_right = JumpJetAttackAction.getDamageFor(ce(), JumpJetAttackAction.RIGHT); if ((d_left * Compute.oddsAbove( left.getValue(), ce().hasAbility(OptionsConstants.PILOT_APTITUDE_PILOTING))) > (d_right * Compute .oddsAbove( right.getValue(), ce().hasAbility(OptionsConstants.PILOT_APTITUDE_PILOTING)))) { toHit.getValueAsString(), new Double( Compute.oddsAbove( toHit.getValue(), ce().hasAbility(OptionsConstants.PILOT_APTITUDE_PILOTING))),
proto.getValueAsString(), new Double( Compute.oddsAbove( proto.getValue(), ce().hasAbility(OptionsConstants.PILOT_APTITUDE_PILOTING))),
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); } }
} else { str += " To hit: " + toHit.getValueAsString() + " (" + Compute.oddsAbove(toHit.getValue(), ce().hasAbility(OptionsConstants.PILOT_APTITUDE_GUNNERY)) + "%)";