Skip to content

Commit

Permalink
Issue 6303: RFE - Hazardous Liquid Pools - Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
psikomonkie committed Feb 1, 2025
1 parent 5268ccd commit 8e2c673
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 26 deletions.
10 changes: 5 additions & 5 deletions megamek/i18n/megamek/common/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,8 @@ 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
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
6 changes: 2 additions & 4 deletions megamek/src/megamek/client/bot/princess/BasicPathRanker.java
Original file line number Diff line number Diff line change
Expand Up @@ -1362,10 +1362,8 @@ private double calcHazardousLiquidHazard(Hex hex, boolean endHex, boolean jumpLa
}
hazardValue += (UNIT_DESTRUCTION_FACTOR * (dmg / Math.max(exposedArmor, 1)));

// Multiply total hazard value by the chance of getting stuck for 1 or more
// additional turns
logger.trace("Total hazard = {}", hazardValue * psrFactor);
return Math.round(hazardValue * psrFactor);
logger.trace("Total hazard = {}", hazardValue);
return Math.round(hazardValue);
}

private double calcBogDownFactor(String name, boolean endHex, boolean jumpLanding, int pilotSkill, int modifier) {
Expand Down
3 changes: 0 additions & 3 deletions megamek/src/megamek/common/Terrains.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ public class Terrains implements Serializable {
public static final int SMOKE = 20; // 1: light smoke 2: heavy smoke 3:light
// LI smoke 4: Heavy LI smoke
public static final int GEYSER = 21; // 1: dormant 2: active 3: magma vent



// unimplemented
// Bug Storm
// Extreme Depths
Expand Down
16 changes: 14 additions & 2 deletions megamek/src/megamek/common/util/HazardousLiquidPoolUtil.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/*
* Copyright (c) 2025 - The MegaMek Team. All Rights Reserved.
*
* This program 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 2 of the License, or (at your option)
* any later version.
*
* This program 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.
*/
package megamek.common.util;

import megamek.common.*;
Expand Down Expand Up @@ -72,9 +85,8 @@ public static List<Report> getHazardousLiquidDamage(Entity entity, boolean erupt


// A standing Mek is only hit in its legs, unless it's in deep spicy juice
boolean isMek = entity instanceof Mek;
int toHitTable = ToHitData.HIT_NORMAL;
if ((isMek && !entity.isProne() && !eruption)
if ((entity instanceof Mek && !entity.isProne() && !eruption)
|| depth > 1) {
toHitTable = ToHitData.HIT_BELOW;
}
Expand Down
34 changes: 22 additions & 12 deletions megamek/src/megamek/server/totalwarfare/TWGameManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -31180,6 +31180,23 @@ void doAllAssaultDrops() {
}
}

/**
* Airborne ground units aren't effected by dangerous terrain, unless it's an erupton
* @param en
* @param eruption
* @return true if the unit should be damaged by dangerous grund (magma, hazardous liquid pool)
*/
private boolean isEffectedByHazardousGround(Entity en, boolean eruption) {
if ((((en.getMovementMode() == EntityMovementMode.VTOL) && (en.getElevation() > 0))
|| (en.getMovementMode() == EntityMovementMode.HOVER)
|| ((en.getMovementMode() == EntityMovementMode.WIGE)
&& (en.getOriginalWalkMP() > 0) && !eruption))
&& !en.isImmobile()) {
return false;
}
return true;
}

/**
* do damage from magma
*
Expand All @@ -31189,13 +31206,10 @@ void doAllAssaultDrops() {
* of an eruption
*/
public void doMagmaDamage(Entity en, boolean eruption) {
if ((((en.getMovementMode() == EntityMovementMode.VTOL) && (en.getElevation() > 0))
|| (en.getMovementMode() == EntityMovementMode.HOVER)
|| ((en.getMovementMode() == EntityMovementMode.WIGE)
&& (en.getOriginalWalkMP() > 0) && !eruption))
&& !en.isImmobile()) {
if (!isEffectedByHazardousGround(en, eruption)) {
return;
}

Report r;
boolean isMek = en instanceof Mek;
if (isMek) {
Expand All @@ -31221,20 +31235,16 @@ public void doMagmaDamage(Entity en, boolean eruption) {
}

/**
* do damage from magma
* do damage from hazardous liquids
*
* @param en the affected <code>Entity</code>
* @param eruption <code>boolean</code> indicating whether or not this is
* because
* of an eruption
* of an eruption (geyser)
* @param depth How deep is the hazardous liquid?
*/
public void doHazardousLiquidDamage(Entity en, boolean eruption, int depth) {
if ((((en.getMovementMode() == EntityMovementMode.VTOL) && (en.getElevation() > 0))
|| (en.getMovementMode() == EntityMovementMode.HOVER)
|| ((en.getMovementMode() == EntityMovementMode.WIGE)
&& (en.getOriginalWalkMP() > 0) && !eruption))
&& !en.isImmobile()) {
if (!isEffectedByHazardousGround(en, eruption)) {
return;
}

Expand Down

0 comments on commit 8e2c673

Please sign in to comment.