protected int applyGravityEffectsOnMP(int MP) { int result = MP; if (game != null) { float fMP = MP / game.getPlanetaryConditions().getGravity(); fMP = (Math.abs((Math.round(fMP) - fMP)) == 0.5) ? (float) Math .floor(fMP) : Math.round(fMP); // the // rule // requires // rounding down on .5 result = (int) fMP; } return result; }
public static int getVisualRange(IGame game, Entity ae, LosEffects los, boolean teIlluminated) { int visualRange = game.getPlanetaryConditions().getVisualRange(ae, teIlluminated); visualRange -= los.getLightSmoke(); visualRange -= 2 * los.getHeavySmoke(); visualRange = Math.max(1, visualRange); return visualRange; }
private Image createBlurredShadow(Image orig) { if ((orig == null) || orig.getWidth(this) < 0 || orig.getHeight(this) < 0) { return null; } BufferedImage mask = shadowImageCache.get(orig.hashCode()); if (mask == null) { GraphicsConfiguration config = GraphicsEnvironment .getLocalGraphicsEnvironment().getDefaultScreenDevice() .getDefaultConfiguration(); // a slightly bigger image to give room for blurring mask = config.createCompatibleImage(orig.getWidth(this)+4, orig.getHeight(this)+4, Transparency.TRANSLUCENT); Graphics g = mask.getGraphics(); g.drawImage(orig,2,2,null); g.dispose(); mask = createShadowMask(mask); mask = blurOp.filter(mask, null); if (game.getPlanetaryConditions().getLight() != PlanetaryConditions.L_DAY) { mask = blurOp.filter(mask, null); } shadowImageCache.put(orig.hashCode(), mask); } return mask; }
@Override public void updateTurnsTilHit(IGame game) { int distance = Compute.effectiveDistance(game, getEntity(game), getTarget(game)); // adjust distance for gravity distance = (int)Math.floor((double)distance/game.getPlanetaryConditions().getGravity()); this.turnsTilHit = (int) (distance / launchVelocity); }
/** * This is the same as getWalkMP, but does not divide by 2 when grounded * * @return */ @Override public int getCurrentThrust() { int j = getOriginalWalkMP(); j = Math.max(0, j - getCargoMpReduction(this)); if (null != game) { int weatherMod = game.getPlanetaryConditions().getMovementMods(this); if (weatherMod != 0) { j = Math.max(j + weatherMod, 0); } } // get bomb load j = Math.max(0, j - (int) Math.ceil(getBombPoints() / 5.0)); if (hasModularArmor()) { j--; } return j; }
public int getWalkMP(boolean gravity, boolean ignoreheat, boolean ignoremodulararmor) { int mp = getOriginalWalkMP(); if (!ignoreheat) { mp = Math.max(0, mp - getHeatMPReduction()); } mp = Math.max(mp - getCargoMpReduction(this), 0); if (null != game) { int weatherMod = game.getPlanetaryConditions() .getMovementMods(this); if (weatherMod != 0) { mp = Math.max(mp + weatherMod, 0); } } if (gravity) { mp = applyGravityEffectsOnMP(mp); } return mp; }
/** Creates new PlanetaryConditionsDialog */ public PlanetaryConditionsDialog(ClientGUI client) { super(client.frame, Messages .getString("PlanetaryConditionsDialog.title"), true); //$NON-NLS-1$ this.client = client; init(client.frame, client.getClient().getGame().getPlanetaryConditions()); }
@Override public boolean canSpot() { // per a recent ruling on the official forums, aero units can't spot // for indirect LRM fire, unless they have a recon cam, an infrared or // hyperspec imager, or a high-res imager and it's not night if (!isAirborne() || hasWorkingMisc(MiscType.F_RECON_CAMERA) || hasWorkingMisc(MiscType.F_INFRARED_IMAGER) || hasWorkingMisc(MiscType.F_HYPERSPECTRAL_IMAGER) || (hasWorkingMisc(MiscType.F_HIRES_IMAGER) && ((game.getPlanetaryConditions().getLight() == PlanetaryConditions.L_DAY) || (game.getPlanetaryConditions().getLight() == PlanetaryConditions.L_DUSK)))) { return true; } else { return false; } }
@Override public int getCurrentThrust() { // Cannot fly in atmosphere with missing side torso if (!isSpaceborne() && (isLocationBad(LOC_RT) || isLocationBad(LOC_LT))) { return 0; } int j = getJumpMP(); if (null != game) { int weatherMod = game.getPlanetaryConditions().getMovementMods(this); if (weatherMod != 0) { j = Math.max(j + weatherMod, 0); } } return j; }
@Override public boolean canSpot() { if (getConversionMode() == CONV_MODE_FIGHTER) { return !isAirborne() || hasWorkingMisc(MiscType.F_RECON_CAMERA) || hasWorkingMisc(MiscType.F_INFRARED_IMAGER) || hasWorkingMisc(MiscType.F_HYPERSPECTRAL_IMAGER) || (hasWorkingMisc(MiscType.F_HIRES_IMAGER) && ((game.getPlanetaryConditions().getLight() == PlanetaryConditions.L_DAY) || (game.getPlanetaryConditions().getLight() == PlanetaryConditions.L_DUSK))); } else { return super.canSpot(); } }
public boolean isOnAtmosphericGroundMap() { return ((getGame().getPlanetaryConditions().getAtmosphere() != PlanetaryConditions.ATMO_VACUUM) || (getGame().getPlanetaryConditions().getAtmosphere() != PlanetaryConditions.ATMO_TRACE)) && (getGame().getBoard().onGround() || // doesn't make sense in english, but "atmospheric" map actually // covers maps that are within a planet's gravity well getGame().getBoard().inAtmosphere()); }
@Override public boolean doomedInExtremeTemp() { if (getArmorKit() != null) { if (getArmorKit().hasSubType(MiscType.S_XCT_VACUUM)) { return false; } else if (getArmorKit().hasSubType(MiscType.S_COLD_WEATHER) && (game.getPlanetaryConditions().getTemperature() < -30)) { return false; } else if (getArmorKit().hasSubType(MiscType.S_HOT_WEATHER) && (game.getPlanetaryConditions().getTemperature() > 50)) { return false; } else { return true; } } if (hasSpaceSuit() || isMechanized()) { return false; } return true; }
/** * Should we treat this movement as if it is occuring for an aerodyne unit * flying in atmosphere? */ boolean useAeroAtmosphere(IGame game, Entity en) { if (!en.isAero()) { return false; } if (((IAero) en).isSpheroid()) { return false; } // are we in space? if (game.getBoard().inSpace()) { return false; } // are we airborne in non-vacuum? return en.isAirborne() && !game.getPlanetaryConditions().isVacuum(); }
&& (game.getPlanetaryConditions().getLight() > PlanetaryConditions.L_DAY)) { for (int x = 0; x < scaledImage.getWidth(null); ++x) { for (int y = 0; y < scaledImage.getHeight(); ++y) {
/** * Should we treat this movement as if it is occurring for a spheroid unit * flying in atmosphere? * * @param game * @param en * @return */ private boolean useSpheroidAtmosphere(IGame game, Entity en) { if (en.isAero()) { return false; } // are we in space? if (game.getBoard().inSpace()) { return false; } // aerodyne's will operate like spheroids in vacuum if (!((IAero) en).isSpheroid() && !game.getPlanetaryConditions().isVacuum()) { return false; } // are we in atmosphere? return en.isAirborne(); }
PlanetaryConditions conditions = game.getPlanetaryConditions();
/** * check for atmosphere and adjust buttons */ private void checkAtmosphere() { final Entity ce = ce(); if (null == ce) { return; } if (!ce.isAero()) { return; } IAero a = (IAero) ce; if (!clientgui.getClient().getGame().getBoard().inSpace()) { if (a.isSpheroid() || clientgui.getClient().getGame().getPlanetaryConditions() .isVacuum()) { getBtn(MoveCommand.MOVE_ACC).setEnabled(false); getBtn(MoveCommand.MOVE_DEC).setEnabled(false); getBtn(MoveCommand.MOVE_ACCN).setEnabled(false); getBtn(MoveCommand.MOVE_DECN).setEnabled(false); } } return; }
@Override public boolean handle(IGame.Phase phase, Vector<Report> vPhaseReport) { if (game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_TACOPS_START_FIRE) && (game.getPlanetaryConditions().getAtmosphere() >= PlanetaryConditions.ATMO_TRACE)) { int rear = (ae.getFacing() + 3 + (weapon.isMechTurretMounted() ? weapon .getFacing() : 0)) % 6; Coords src = ae.getPosition(); Coords rearCoords = src.translated(rear); IBoard board = game.getBoard(); IHex currentHex = board.getHex(src); if (!board.contains(rearCoords)) { rearCoords = src; } else if (board.getHex(rearCoords).getLevel() > currentHex .getLevel() + 4) { rearCoords = src; } else if ((board.getBuildingAt(rearCoords) != null) && (board.getHex(rearCoords).terrainLevel( Terrains.BLDG_ELEV) + board.getHex(rearCoords).getLevel() > currentHex .getLevel() + 4)) { rearCoords = src; } server.createSmoke(rearCoords, SmokeCloud.SMOKE_HEAVY, 2); } return super.handle(phase, vPhaseReport); }
@Override public boolean handle(IGame.Phase phase, Vector<Report> vPhaseReport) { if (game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_TACOPS_START_FIRE) && (game.getPlanetaryConditions().getAtmosphere() >= PlanetaryConditions.ATMO_TRACE)) { int rear = (ae.getFacing() + 3 + (weapon.isMechTurretMounted() ? weapon .getFacing() : 0)) % 6; Coords src = ae.getPosition(); Coords rearCoords = src.translated(rear); IBoard board = game.getBoard(); IHex currentHex = board.getHex(src); if (!board.contains(rearCoords)) { rearCoords = src; } else if (board.getHex(rearCoords).getLevel() > currentHex .getLevel()) { rearCoords = src; } else if ((board.getBuildingAt(rearCoords) != null) && ((board.getHex(rearCoords).terrainLevel( Terrains.BLDG_ELEV) + board.getHex(rearCoords) .getLevel()) > currentHex.getLevel())) { rearCoords = src; } server.createSmoke(rearCoords, SmokeCloud.SMOKE_HEAVY, 2); } return super.handle(phase, vPhaseReport); }
private void updateAeroButtons() { if (ce() != null && ce().isAero()) { getBtn(MoveCommand.MOVE_THRUST).setEnabled(true); getBtn(MoveCommand.MOVE_YAW).setEnabled(true); getBtn(MoveCommand.MOVE_END_OVER).setEnabled(true); getBtn(MoveCommand.MOVE_TURN_LEFT).setEnabled(true); getBtn(MoveCommand.MOVE_TURN_RIGHT).setEnabled(true); setEvadeAeroEnabled(cmd != null && !cmd.contains(MoveStepType.EVADE)); setEjectEnabled(true); // no turning for spheroids in atmosphere if ((((IAero) ce()).isSpheroid() || clientgui.getClient().getGame() .getPlanetaryConditions().isVacuum()) && !clientgui.getClient().getGame().getBoard().inSpace()) { setTurnEnabled(false); } } }