Skip to content

Commit

Permalink
Dirt Road - Rain/Mud Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
psikomonkie committed Dec 22, 2024
1 parent 8f0496b commit 4d0db44
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions megamek/src/megamek/common/util/BoardUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public static Board generateRandom(MapSettings mapSettings) {
mapSettings.getMinForestSize(),
mapSettings.getMaxForestSize(), reverseHex, true);
}

// Add foliage (1 elevation high woods)
count = mapSettings.getMinFoliageSpots();
if (mapSettings.getMaxFoliageSpots() > 0) {
Expand All @@ -220,7 +220,7 @@ public static Board generateRandom(MapSettings mapSettings) {
mapSettings.getMinJungleSize(),
mapSettings.getMaxJungleSize(), reverseHex, true);
}

// Add the rough
count = mapSettings.getMinRoughSpots();
if (mapSettings.getMaxRoughSpots() > 0) {
Expand Down Expand Up @@ -559,7 +559,7 @@ private static void growTreesIfNecessary(Hex field, int terrainType, int terrain
field.addTerrain(new Terrain(Terrains.FOLIAGE_ELEV, 3));
}
}

/**
* Places randomly some connected foliage.
*
Expand Down Expand Up @@ -609,7 +609,7 @@ protected static void placeFoliage(Board board, int terrainType, int probMore, i
findAllUnused(board, terrainType, alreadyUsed, unUsed, field, reverseHex);
}


}

/**
Expand Down Expand Up @@ -1121,24 +1121,28 @@ public static void addWeatherConditions(Board board, Weather weatherCond, Wind w
Coords c = new Coords(x, y);
Hex hex = board.getHex(c);

//moderate rain - mud in clear hexes, depth 0 water, and dirt roads (not implemented yet)
//moderate rain - mud in clear hexes, depth 0 water, and dirt roads
if (weatherCond.isModerateRainOrLightningStorm()) {
if ((hex.terrainsPresent() == 0) || (hex.containsTerrain(Terrains.WATER) && (hex.depth() == 0))) {
if ((hex.terrainsPresent() == 0)
|| (hex.containsTerrain(Terrains.WATER) && (hex.depth() == 0))
|| (hex.containsTerrain(Terrains.ROAD) && hex.terrainLevel(Terrains.ROAD) == Terrains.ROAD_LVL_DIRT)) {
hex.addTerrain(new Terrain(Terrains.MUD, 1));
if (hex.containsTerrain(Terrains.WATER)) {
hex.removeTerrain(Terrains.WATER);
}
}
}

//heavy rain - mud in all hexes except buildings, depth 1+ water, and non-dirt roads
//heavy rain - mud in all hexes except buildings, depth 1+ water, pavement, and standard roads
//rapids in all depth 1+ water
if (weatherCond.isHeavyRainOrGustingRain()) {
if (hex.containsTerrain(Terrains.WATER) && !hex.containsTerrain(Terrains.RAPIDS) && (hex.depth() > 0)) {
hex.addTerrain(new Terrain(Terrains.RAPIDS, 1));
} else if (!hex.containsTerrain(Terrains.BUILDING)
&& !hex.containsTerrain(Terrains.PAVEMENT)
&& !hex.containsTerrain(Terrains.ROAD)) {
&& ( !hex.containsTerrain(Terrains.ROAD)
|| hex.terrainLevel(Terrains.ROAD) == Terrains.ROAD_LVL_GRAVEL
|| hex.terrainLevel(Terrains.ROAD) == Terrains.ROAD_LVL_DIRT)) {
hex.addTerrain(new Terrain(Terrains.MUD, 1));
if (hex.containsTerrain(Terrains.WATER)) {
hex.removeTerrain(Terrains.WATER);
Expand All @@ -1156,7 +1160,9 @@ public static void addWeatherConditions(Board board, Weather weatherCond, Wind w
hex.removeTerrain(Terrains.WATER);
} else if (!hex.containsTerrain(Terrains.BUILDING)
&& !hex.containsTerrain(Terrains.PAVEMENT)
&& !hex.containsTerrain(Terrains.ROAD)) {
&& ( !hex.containsTerrain(Terrains.ROAD)
|| hex.terrainLevel(Terrains.ROAD) == Terrains.ROAD_LVL_GRAVEL
|| hex.terrainLevel(Terrains.ROAD) == Terrains.ROAD_LVL_DIRT)) {
hex.addTerrain(new Terrain(Terrains.MUD, 1));
}
}
Expand Down Expand Up @@ -1699,7 +1705,7 @@ public static CardinalEdge getClosestEdge(Entity entity) {
return closerNorthThanSouth ? CardinalEdge.NORTH : CardinalEdge.SOUTH;
}
}

/**
* Figures out the "opposite" edge for the given entity.
* @param entity Entity to evaluate
Expand Down

0 comments on commit 4d0db44

Please sign in to comment.