Skip to content

Commit

Permalink
Merge branch 'master' into feat/refactor-flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Scoppio authored Feb 5, 2025
2 parents f35fd35 + 4cc98ff commit 17a88fa
Show file tree
Hide file tree
Showing 28 changed files with 789 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Standard Hazard Liquid Pools

super * "hazardous_liquid:*;water:1" "" "hazardous_liquid/green2_toxic_water.png"
super * "hazardous_liquid:*;water:*" "" "hazardous_liquid/green1_toxic_water.png"
super * "hazardous_liquid:*;" "" "hazardous_liquid/green2_toxic_water.png"
2 changes: 2 additions & 0 deletions megamek/data/images/hexes/atmospheric.tileset
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ include "StandardIncludes/StandardThemes.tileinc"

include "StandardIncludes/StandardSpace.tileinc"

include "StandardIncludes/StandardHazardousLiquid.tileinc"

super * "water:0" "" "transparent/blue_water_1.png"

super * "swamp:1" "" "swamp/swamp_0.png;swamp/swamp_1.png;swamp/swamp_2.png;swamp/swamp_3.png"
Expand Down
2 changes: 2 additions & 0 deletions megamek/data/images/hexes/bw_atmospheric.tileset
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ base -6 "" "volcano" "largeTextures/textureVolcano-6.jpg"

include "StandardIncludes/StandardThemes.tileinc"

include "StandardIncludes/StandardHazardousLiquid.tileinc"

super * "water:0" "" "bloodwolf/hq_boring/blue_water_0.png;bloodwolf/hq_boring/blue_water_0.png(0,72-84,-72);bloodwolf/hq_boring/blue_water_0.png(84,0--84,72);bloodwolf/hq_boring/blue_water_0.png(84,72--84,-72)"

super * "swamp:1" "desert" "bloodwolf/hq_boring/swamp_0.png;bloodwolf/hq_boring/swamp_0.png(0,72-84,-72);bloodwolf/hq_boring/swamp_0.png(84,0--84,72);bloodwolf/hq_boring/swamp_0.png(84,72--84,-72)"
Expand Down
2 changes: 2 additions & 0 deletions megamek/data/images/hexes/classic.tileset
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ include "StandardIncludes/StandardThemes.tileinc"

include "StandardIncludes/StandardSpace.tileinc"

include "StandardIncludes/StandardHazardousLiquid.tileinc"

super * "water:0" "" "boring/blue_water_1.gif"

super * "fortified:1" "" "boring/sandbags.gif"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions megamek/data/images/hexes/hq_atmospheric.tileset
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ include "StandardIncludes/StandardThemes.tileinc"

include "StandardIncludes/StandardSpace.tileinc"

include "StandardIncludes/StandardHazardousLiquid.tileinc"

super * "water:0" "" "transparent/anim_water_1.gif"

super * "swamp:1" "" "swamp/swamp_0.png;swamp/swamp_1.png;swamp/swamp_2.png;swamp/swamp_3.png"
Expand Down
2 changes: 2 additions & 0 deletions megamek/data/images/hexes/hq_isometric.tileset
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ include "StandardIncludes/StandardThemes.tileinc"

include "StandardIncludes/StandardSpace.tileinc"

include "StandardIncludes/StandardHazardousLiquid.tileinc"

super * "water:0" "" "transparent/anim_water_1.gif"

super * "swamp:1" "" "swamp/swamp_0.png;swamp/swamp_1.png;swamp/swamp_2.png;swamp/swamp_3.png"
Expand Down
2 changes: 2 additions & 0 deletions megamek/data/images/hexes/hq_saxarba.tileset
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ super 8 "sand:*" "" "saxarba/base/base_sand_8.png"
super 9 "sand:*" "" "saxarba/base/base_sand_9.png"
super 10 "sand:*" "" "saxarba/base/base_sand_10.png"

include "StandardIncludes/StandardHazardousLiquid.tileinc"

#MARS THEME WATER
super * "water:0" "mars" "saxarba/theme_mars/water_anim_mars_0.gif"

Expand Down
2 changes: 2 additions & 0 deletions megamek/data/images/hexes/isometric.tileset
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ include "StandardIncludes/StandardThemes.tileinc"

include "StandardIncludes/StandardSpace.tileinc"

include "StandardIncludes/StandardHazardousLiquid.tileinc"

super * "water:0" "" "transparent/blue_water_1.png"

super * "swamp:1" "" "swamp/swamp_0.png;swamp/swamp_1.png;swamp/swamp_2.png;swamp/swamp_3.png"
Expand Down
1 change: 1 addition & 0 deletions megamek/data/images/hexes/largeTextures.tileset
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ base -6 "" "" "Ahne/iLarge_Textures/BigPlains-6.jpg"

base 0 "space:1" "" "largeTextures/BigSpace.jpg"

include "StandardIncludes/StandardHazardousLiquid.tileinc"

#base 1 "water:*" "" "Ahne/iLarge_Textures/BigWater.jpg(0,72-84,-72);Ahne/iLarge_Textures/BigWater.jpg(84,0--84,72);Ahne/iLarge_Textures/BigWater.jpg(84,72--84,-72)"
#base -1 "water:*" "" "Ahne/iLarge_Textures/BigWater2.jpg(0,72-84,-72);Ahne/iLarge_Textures/BigWater2.jpg(84,0--84,72);Ahne/iLarge_Textures/BigWater2.jpg(84,72--84,-72)"
Expand Down
2 changes: 2 additions & 0 deletions megamek/data/images/hexes/saxarba.tileset
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ super 8 "sand:*" "" "saxarba/base/base_sand_8.png"
super 9 "sand:*" "" "saxarba/base/base_sand_9.png"
super 10 "sand:*" "" "saxarba/base/base_sand_10.png"

include "StandardIncludes/StandardHazardousLiquid.tileinc"

#MARS THEME WATER
super * "water:0" "mars" "saxarba/theme_mars/water_mars_0.png"

Expand Down
4 changes: 4 additions & 0 deletions megamek/docs/history.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
MEGAMEK VERSION HISTORY:
----------------
0.50.04-SNAPSHOT
+ PR #6494: Cap splashscreen button width
+ PR #6489: PPC Capacitors must all be linked to a PPC
+ PR #6500: Issue 6499: Better nudging for aeros that fail maneuvers and scatter off board
+ PR #6476: Issue 6303: RFE - Hazardous Liquid Pool

0.50.03 (2025-02-02 2030 UTC)
+ PR #6335: default the directory filter to Select All in Advanced Board Search
Expand Down
1 change: 1 addition & 0 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,7 @@ MovementDisplay.ConfirmLaunch=Launching this many units will exceed this bay's l
MovementDisplay.MagmaCrustMoving=Crossing magma crust will break through on 6+ on 1d6.\n
MovementDisplay.MagmaCrustJumpLanding=Jumping onto magma crust will break through on 4+ on 1d6.\n
MovementDisplay.MagmaLiquidMoving=Red hot molten lava melts armour and destroys non-meks!\n
MovementDisplay.HazardousLiquidMoving=Caustic hazardous liquids may damage units!\n
MovementDisplay.ManeuverDialog.title=Choose Maneuver
MovementDisplay.MicroliteMove.message=Microlite VTOL units must enter a new hex each turn to remain in flight.\n
MovementDisplay.MicroliteMove.title=Microlite VTOL movement
Expand Down
8 changes: 8 additions & 0 deletions megamek/i18n/megamek/common/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ Terrains.editorName.incline_high_top=High Incline Top
Terrains.editorName.incline_high_bottom=High Incline Bottom
Terrains.editorName.cliff_bottom=Cliff Bottom
Terrains.editorName.deployment_zone=Deployment Zone
Terrains.editorName.hazardous_liquid=Hazardous Liquid

Terrains.editorTooltip.woods=Woods
Terrains.editorTooltip.water=Water
Expand Down Expand Up @@ -477,6 +478,7 @@ Terrains.editorTooltip.ground_fluff=Special ground images
Terrains.editorTooltip.water_fluff=Special water images
Terrains.editorTooltip.foliage_elev=Defines how tall the woods/jungle is (required)
Terrains.editorTooltip.deployment_zone=A custom deployment zone (level is group #)
Terrains.editorTooltip.hazardous_liquid=A modifier to water that damages units (level is if wind or water flow effect it)

WeaponType.DirectFire=Direct fire
WeaponType.BallisticCluster=Ballistic Cluster
Expand Down Expand Up @@ -778,3 +780,9 @@ AutoResolveDialog.victory=Victory!
AutoResolveDialog.defeat=Defeat!
ResolveDialog.control.title=Control of Battlefield?
ResolveDialog.control.message=Did your side control the battlefield at the end of the scenario?

HazardousLiquidPoolUtil.CLASS_0.text=Class 0: Normal
HazardousLiquidPoolUtil.CLASS_1.text=Class 1: Slightly Hazardous
HazardousLiquidPoolUtil.CLASS_2.text=Class 2: Hazardous
HazardousLiquidPoolUtil.CLASS_3.text=Class 3: Extreme Danger
HazardousLiquidPoolUtil.DEADLY.text=Deadly
2 changes: 2 additions & 0 deletions megamek/i18n/megamek/common/report-messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@
2515=<data> is dropped to the ground. Needs <data>, rolls <data> : <msg:2516,2517>
2516=<span class='success'>success</span> - cargo remains intact.
2517=<span class='warning'>failure</span> - cargo destroyed!
2520=<data> (<data>) enters hazardous liquid, rolls <data> : <data>
2524=<data> (<data>) is damaged by the caustic liquid!

3000=<newline><B>Weapon Attack Phase</B><newline>-------------------
3003=Inferno fire (bombs) started in hex <data>.
Expand Down
66 changes: 65 additions & 1 deletion megamek/src/megamek/client/bot/princess/BasicPathRanker.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import megamek.common.*;
import megamek.common.options.OptionsConstants;
import megamek.common.planetaryconditions.PlanetaryConditions;
import megamek.common.util.HazardousLiquidPoolUtil;
import megamek.logging.MMLogger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -885,6 +886,9 @@ private double checkHexForHazards(Hex hex, Entity movingUnit, boolean endHex, Mo
// 1 in 3 chance to hit Black Ice on any given Pavement hex
hazardValue += calcIceHazard(movingUnit, hex, step, movePath, jumpLanding) / 3.0;
break;
case Terrains.HAZARDOUS_LIQUID:
hazardValue += calcHazardousLiquidHazard(hex, endHex, movingUnit, step);
break;
}
}

Expand All @@ -903,7 +907,8 @@ private double checkHexForHazards(Hex hex, Entity movingUnit, boolean endHex, Mo
Terrains.SNOW,
Terrains.SWAMP,
Terrains.MUD,
Terrains.TUNDRA));
Terrains.TUNDRA,
Terrains.HAZARDOUS_LIQUID));
private static final Set<Integer> HAZARDS_WITH_BLACK_ICE = new HashSet<>();
static {
HAZARDS_WITH_BLACK_ICE.addAll(HAZARDS);
Expand Down Expand Up @@ -1288,6 +1293,65 @@ private double calcLavaHazard(boolean endHex, boolean jumpLanding, Entity moving
return Math.round(hazardValue * psrFactor);
}

private double calcHazardousLiquidHazard(Hex hex, boolean endHex, Entity movingUnit, MoveStep step) {
logger.trace("Calculating hazardous liquid hazard.");
int unitDamageLevel = movingUnit.getDamageLevel();
double dmg;

// Hovers/VTOLs are unaffected _unless_ they end on the hex and are in danger of
// losing mobility.
if (EntityMovementMode.HOVER == movingUnit.getMovementMode()
|| EntityMovementMode.WIGE == movingUnit.getMovementMode()) {
if (!endHex) {
logger.trace("Hovering/VTOL while traversing hazardous liquids (0).");
return 0;
} else {
// Estimate chance of being disabled or immobilized over open lava; this is
// fatal!
// Calc expected damage as ((current damage level [0 ~ 4]) / 4) *
// UNIT_DESTRUCTION_FACTOR
dmg = (unitDamageLevel / 4.0) * UNIT_DESTRUCTION_FACTOR;
logger.trace("Ending hover/VTOL movement over lava ({}).", dmg);
return dmg;
}
}

dmg = (HazardousLiquidPoolUtil.AVERAGE_DAMAGE_HAZARDOUS_LIQUID_POOL * HazardousLiquidPoolUtil.getHazardousLiquidPoolDamageMultiplierForUnsealed(movingUnit))
/ (HazardousLiquidPoolUtil.getHazardousLiquidPoolDamageDivisorForInfantry(movingUnit));

// After all that math let's make sure we do at least 1 damage
// (.6 repeating when normalized for the HLP doing no damage 1/3 of the time)
dmg = Math.max(dmg, 2.0/3.0);

// Factor in potential to suffer fatal damage.
// Dependent on expected average damage / exposed remaining armor *
// UNIT_DESTRUCTION_FACTOR
int exposedArmor;
double hazardValue = 0;
if (step.isProne() || (hex.containsTerrain(Terrains.WATER) && hex.terrainLevel(Terrains.WATER) > 1)) {
exposedArmor = movingUnit.getTotalArmor();
logger.trace("Fully Submerged damage = {}, exposed armor = {}", dmg, exposedArmor);
} else if (movingUnit instanceof BipedMek) {
exposedArmor = Stream.of(Mek.LOC_LLEG, Mek.LOC_RLEG).mapToInt(movingUnit::getArmor).sum();
logger.trace("Biped Mek damage = {}, exposed armor = {}", dmg, exposedArmor);
} else if (movingUnit instanceof TripodMek) {
exposedArmor = Stream.of(Mek.LOC_LLEG, Mek.LOC_RLEG, Mek.LOC_CLEG)
.mapToInt(movingUnit::getArmor).sum();
logger.trace("Tripod Mek damage = {}, exposed armor = {}", dmg, exposedArmor);
} else if (movingUnit instanceof QuadMek){
exposedArmor = Stream.of(Mek.LOC_LLEG, Mek.LOC_RLEG, Mek.LOC_LARM, Mek.LOC_RARM)
.mapToInt(movingUnit::getArmor).sum();
logger.trace("Quad Mek damage = {}, exposed armor = {}", dmg, exposedArmor);
} else {
exposedArmor = movingUnit.getTotalArmor();
logger.trace("Fully Submerged non-mek damage = {}, exposed armor = {}", dmg, exposedArmor);
}
hazardValue += (UNIT_DESTRUCTION_FACTOR * (dmg / Math.max(exposedArmor, 1)));

logger.trace("Total hazard = {}", hazardValue);
return Math.round(hazardValue);
}

private double calcBogDownFactor(String name, boolean endHex, boolean jumpLanding, int pilotSkill, int modifier) {
return calcBogDownFactor(name, endHex, jumpLanding, pilotSkill, modifier, true);
}
Expand Down
16 changes: 16 additions & 0 deletions megamek/src/megamek/client/ui/SharedUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import megamek.common.*;
import megamek.common.MovePath.MoveStepType;
import megamek.common.annotations.Nullable;
import megamek.common.internationalization.Internationalization;
import megamek.common.options.OptionsConstants;
import megamek.logging.MMLogger;
import megamek.server.totalwarfare.TWGameManager;
Expand Down Expand Up @@ -346,6 +347,16 @@ private static Object doPSRCheck(MovePath md, boolean stringResult) {
.getString("MovementDisplay.MagmaLiquidMoving"));
}

// Check for Hazardous Liquid
if (curHex.containsTerrain(Terrains.HAZARDOUS_LIQUID) && (step.getElevation() <= 0)
&& (moveType != EntityMovementType.MOVE_JUMP)
&& (entity.getMovementMode() != EntityMovementMode.HOVER)
&& (entity.getMovementMode() != EntityMovementMode.WIGE)
&& !(curPos.equals(lastPos))) {
nagReport.append(Internationalization
.getTextAt("megamek.client.messages", "MovementDisplay.HazardousLiquidMoving"));
}

// check for sideslip
if ((entity instanceof VTOL)
|| (entity.getMovementMode() == EntityMovementMode.HOVER)
Expand Down Expand Up @@ -600,6 +611,11 @@ private static Object doPSRCheck(MovePath md, boolean stringResult) {
} else if ((level == 2) && (lastElevation == 0)) {
nagReport.append(Messages.getString("MovementDisplay.MagmaLiquidMoving"));
}

if ((hex.containsTerrain(Terrains.HAZARDOUS_LIQUID)) && (lastElevation == 0)) {
nagReport.append(Internationalization
.getTextAt("megamek.client.messages", "MovementDisplay.HazardousLiquidMoving"));
}
}

if (entity.isAirborne() && entity.isAero()) {
Expand Down
5 changes: 5 additions & 0 deletions megamek/src/megamek/client/ui/swing/MegaMekGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ private void showMainMenu() {
// the button width "look" reasonable.
int maximumWidth = (int) (0.9 * scaledMonitorSize.width) - splash.getPreferredSize().width;

//no more than 50% of image width
if (maximumWidth > (int) (0.5 * splash.getPreferredSize().width)) {
maximumWidth = (int) (0.5 * splash.getPreferredSize().width);
}

Dimension minButtonDim = new Dimension((int) (maximumWidth / 1.618), 25);
if (textDim.getWidth() > minButtonDim.getWidth()) {
minButtonDim = textDim;
Expand Down
2 changes: 2 additions & 0 deletions megamek/src/megamek/common/Terrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ public boolean isValid(@Nullable List<String> errors) {
valid = false;
} else if ((type == BRIDGE_ELEV) && (level < 0)) {
valid = false;
} else if ((type == HAZARDOUS_LIQUID) && (level < 0 || level > 3)) {
valid = false;
}

if (!valid && (errors != null)) {
Expand Down
18 changes: 16 additions & 2 deletions megamek/src/megamek/common/Terrains.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.HashSet;
import java.util.Hashtable;

import megamek.common.enums.HazardousLiquidPoolType;
import megamek.server.SmokeCloud;

public class Terrains implements Serializable {
Expand Down Expand Up @@ -63,7 +64,6 @@ public class Terrains implements Serializable {
// unimplemented
// Bug Storm
// Extreme Depths
// Hazardous Liquid Pools
// Rail
// Dirt Roads, Gravel Roads
// Water Flow
Expand Down Expand Up @@ -153,6 +153,8 @@ public class Terrains implements Serializable {

public static final int DEPLOYMENT_ZONE = 57;

public static final int HAZARDOUS_LIQUID = 58;

/**
* Keeps track of the different type of terrains that can have exits.
*/
Expand All @@ -165,7 +167,7 @@ public class Terrains implements Serializable {
"fuel_tank_magn", "impassable", "elevator", "fortified", "screen", "fluff", "arms", "legs", "metal_deposit",
"bldg_base_collapsed", "bldg_fluff", "road_fluff", "ground_fluff", "water_fluff", "cliff_top", "cliff_bottom",
"incline_top", "incline_bottom", "incline_high_top", "incline_high_bottom", "foliage_elev", "black_ice", "sky",
"deployment_zone" };
"deployment_zone", "hazardous_liquid" };

/** Terrains in this set are hidden in the Editor, not saved to board files and handled internally. */
public static final HashSet<Integer> AUTOMATIC = new HashSet<>(Arrays.asList(
Expand Down Expand Up @@ -397,6 +399,18 @@ public static String getDisplayName(int type, int level) {
}
case DEPLOYMENT_ZONE:
return "Deployment Zone";
case HAZARDOUS_LIQUID:
HazardousLiquidPoolType hazardousLiquidPoolType = HazardousLiquidPoolType.getType(level);
switch (hazardousLiquidPoolType) {
case WIND_BLOWN:
return "Hazardous Liquid (Wind Blown)";
case FLOWS:
return "Hazardous Liquid (Flows)";
case FLOWS_AND_WIND_BLOWN:
return "Hazardous Liquid (Flows and Wind Blown)";
default:
return "Hazardous Liquid";
}
default:
return null;
}
Expand Down
49 changes: 49 additions & 0 deletions megamek/src/megamek/common/enums/HazardousLiquidPoolType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2025 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MegaMek.
*
* MegaMek is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MegaMek is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MegaMek. If not, see <http://www.gnu.org/licenses/>.
*/

package megamek.common.enums;

import java.util.Arrays;

/**
* A hazardous liquid pool can be wind-blown, pushed by water flow, both, or neither.
*/
public enum HazardousLiquidPoolType {
// Wind blown hazardous is for MapPack Alien Worlds' Wind Blown Hazardous Liquid rules
// Wind blown (MP: Alien Rules) isn't implemented
// Water flow (TO:AR 47 for Hazardous Pools rules) isn't implemented
NORMAL(0),
WIND_BLOWN(1),
FLOWS(2),
FLOWS_AND_WIND_BLOWN(3);

private final Integer terrainLevel;

HazardousLiquidPoolType(final Integer terrainLevel) {
this.terrainLevel = terrainLevel;
}

public int getTerrainLevel() {
return this.terrainLevel;
}

public static HazardousLiquidPoolType getType(final int ordinal) {
return Arrays.stream(HazardousLiquidPoolType.values()).filter(type -> type.ordinal() == ordinal).findFirst().orElse(NORMAL);
}
}
Loading

0 comments on commit 17a88fa

Please sign in to comment.