Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - Black Ice terrain modification #4521

Merged
merged 24 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a924386
Add Black Ice terrain modification
pheonixstorm Jun 8, 2023
2fba4ac
Create option to use Black Ice outside Ice Storms when temp is less t…
pheonixstorm Jun 8, 2023
d835049
Added check for valid terrain and if PSR needed for terrain
pheonixstorm Jun 8, 2023
2223158
Added PSR modifier for reckless movement on Black Ice
pheonixstorm Jun 8, 2023
e4f3556
Add helper function for checking if isPavementStep contains black ice.
pheonixstorm Jun 9, 2023
0d107c7
Remove Black Ice if hex has been on fire for multiple turns.
pheonixstorm Jun 10, 2023
8674575
PSR check for jumping onto possible black ice hex.
pheonixstorm Jun 10, 2023
8b740ee
Adding reckless movement on pavement PSR check when Black Ice is in p…
pheonixstorm Jun 12, 2023
df2e4c8
Careful movement penalties apply to pavement when using Black Ice
pheonixstorm Jun 12, 2023
5ffe7b3
Add check for Black Ice on pavement in processMovement.
pheonixstorm Jun 12, 2023
da48262
Changed temp comparison structure.
pheonixstorm Jun 13, 2023
04ff8c1
Added entry for the Map Editor dropdown tile selector.
pheonixstorm Jun 16, 2023
85d544f
Add check for Black Ice in skid check.
pheonixstorm Jun 30, 2023
d23c893
Fixed issue where careful movement was not being applied.
pheonixstorm Jul 3, 2023
66027bf
Make sure black ice gets a melt check.
pheonixstorm Jul 3, 2023
c893843
Update roll target from testing value
pheonixstorm Jul 4, 2023
e61c965
Update megamek/i18n/megamek/common/options/messages.properties
pheonixstorm Jul 9, 2023
2fea933
Merge branch 'master' into Feature-BlackIce
pheonixstorm Jul 9, 2023
681ba3d
Add temp constant for black ice to planetary conditions
pheonixstorm Jul 12, 2023
9bbd484
Added missing null check
pheonixstorm Jul 12, 2023
85244c2
Removed minTemp for constant check.
pheonixstorm Jul 12, 2023
2076ffa
Merge branch 'master' into Feature-BlackIce
SJuliez Feb 1, 2024
34d7b4d
Merge branch 'master' into Feature-BlackIce
SJuliez Feb 15, 2024
1e5a950
Restore terrains numbering
SJuliez Feb 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions megamek/i18n/megamek/common/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ Terrains.editorName.swamp=Swamp
Terrains.editorName.mud=Mud
Terrains.editorName.rapids=Rapids
Terrains.editorName.ice=Ice
Terrains.editorName.black_ice=Black Ice
Terrains.editorName.snow=Snow
Terrains.editorName.fire=Fire
Terrains.editorName.smoke=Smoke
Expand Down Expand Up @@ -474,6 +475,7 @@ Terrains.editorTooltip.swamp=Swamp
Terrains.editorTooltip.mud=Mud
Terrains.editorTooltip.rapids=Rapids
Terrains.editorTooltip.ice=Ice
Terrains.editorTooltip.black_ice=Black Ice
Terrains.editorTooltip.snow=Snow
Terrains.editorTooltip.fire=Fire
Terrains.editorTooltip.smoke=Smoke
Expand Down
2 changes: 2 additions & 0 deletions megamek/i18n/megamek/common/options/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ GameOptionsInfo.option.minefields.displayableName=TacOps Minefields / BMM Minefi
GameOptionsInfo.option.minefields.description=If checked, minefields can be used.\nChecked by default.
GameOptionsInfo.option.hidden_units.displayableName=Hidden Units
GameOptionsInfo.option.hidden_units.description=If checked, players may deploy units hidden.
GameOptionsInfo.option.black_ice.displayableName=Black Ice
GameOptionsInfo.option.black_ice.description=If checked, Black Ice may form on pavement if temperatures are below -30C. TO:AR p38\nDoes not affect Black Ice forming due to Ice Storms. TO:AR p58
GameOptionsInfo.option.double_blind.displayableName=TacOps Double blind
GameOptionsInfo.option.single_blind_bots.displayableName=(Unofficial) Default bots to single blind, when using TacOps Double blind
GameOptionsInfo.option.double_blind.description=If checked, enemy units will only be visible if they are in line of sight of one or more of your units, or within sensor range. \nUnchecked by default.
Expand Down
8 changes: 8 additions & 0 deletions megamek/src/megamek/common/Compute.java
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,14 @@ public static boolean isPilotingSkillNeeded(Game game, int entityId,
return true;
}

// Check for black ice on pavement
if (destHex.containsTerrain(Terrains.BLACK_ICE)
&& !(entity.getElevation() > destHex.getLevel())
&& isPavementStep
&& (movementType != EntityMovementType.MOVE_JUMP)) {
return true;
}

// Check for water unless we're a hovercraft or naval or using a bridge
// or flying or QuadVee in vehicle mode.
if ((movementType != EntityMovementType.MOVE_JUMP)
Expand Down
48 changes: 45 additions & 3 deletions megamek/src/megamek/common/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7258,6 +7258,15 @@
// move path has ice
boolean isFoggy = game.getPlanetaryConditions().getFog() != PlanetaryConditions.FOG_NONE;
boolean isDark = game.getPlanetaryConditions().getLight() > PlanetaryConditions.L_DUSK;
boolean isBlackIce;

if ((game.getPlanetaryConditions().getWeather() == PlanetaryConditions.WE_ICE_STORM)
|| (game.getOptions().booleanOption(OptionsConstants.ADVANCED_BLACK_ICE)
&& game.getPlanetaryConditions().getTemperature() <= PlanetaryConditions.BLACK_ICE_TEMP)) {
isBlackIce = true;
} else {
isBlackIce = false;
}

// if we are jumping, then no worries
if (moveType == EntityMovementType.MOVE_JUMP) {
Expand All @@ -7282,6 +7291,10 @@
// ice conditions
} else if (curHex.containsTerrain(Terrains.ICE)) {
roll.append(new PilotingRollData(getId(), 0, "moving recklessly"));
} else if (curHex.containsTerrain(Terrains.BLACK_ICE)) {
roll.append(new PilotingRollData(getId(), 0, "moving recklessly"));
} else if (curHex.hasPavement() && isBlackIce) {
roll.append(new PilotingRollData(getId(), 0, "moving recklessly"));
} else {
roll.addModifier(TargetRoll.CHECK_FALSE, "not moving recklessly");
}
Expand Down Expand Up @@ -7381,6 +7394,26 @@
return roll;
}

/**
* Checks if the entity is landing (from a jump) on black ice.
*/
public PilotingRollData checkLandingOnBlackIce(
EntityMovementType overallMoveType, Hex curHex) {
PilotingRollData roll = getBasePilotingRoll(overallMoveType);

if (curHex.containsTerrain(Terrains.BLACK_ICE)) {
roll.append(new PilotingRollData(getId(), 0,
"landing on black ice"));
addPilotingModifierForTerrain(roll);
adjustDifficultTerrainPSRModifier(roll);
} else {
roll.addModifier(TargetRoll.CHECK_FALSE,
"hex is not covered by black ice");
}

return roll;
}

/**
* return a <code>PilotingRollData</code> checking for whether this Entity
* moved too fast due to low gravity
Expand Down Expand Up @@ -7435,6 +7468,7 @@

PilotingRollData roll = getBasePilotingRoll(overallMoveType);
// If we aren't traveling along a road, apply terrain modifiers
// Unless said pavement has black ice
if (!((prevStep == null || prevStep.isPavementStep()) && currStep.isPavementStep())) {
addPilotingModifierForTerrain(roll, lastPos);
}
Expand Down Expand Up @@ -7472,7 +7506,7 @@
if (prevStep != null) {
prevStepPavement = prevStep.isPavementStep();
} else {
prevStepPavement = prevHex.hasPavement();

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
prevHex
may be null at this access as suggested by
this
null guard.
Variable
prevHex
may be null at this access as suggested by
this
null guard.
}

// TODO: add check for elevation of pavement, road,
Expand All @@ -7487,9 +7521,17 @@
|| (game.getPlanetaryConditions()
.getWindStrength() >= PlanetaryConditions.WI_STORM))))
&& (prevFacing != curFacing) && !lastPos.equals(curPos)) {
roll.append(new PilotingRollData(getId(),
getMovementBeforeSkidPSRModifier(distance),
"turning on ice"));
roll.append(new PilotingRollData(getId(), getMovementBeforeSkidPSRModifier(distance), "turning on ice"));
adjustDifficultTerrainPSRModifier(roll);
return roll;
} else if ((prevHex != null) && prevHex.containsTerrain(Terrains.BLACK_ICE)
&& (((movementMode != EntityMovementMode.HOVER) && (movementMode != EntityMovementMode.WIGE))
|| (((movementMode == EntityMovementMode.HOVER) || (movementMode == EntityMovementMode.WIGE))
&& ((game.getPlanetaryConditions().getWeather() == PlanetaryConditions.WE_HEAVY_SNOW)
|| (game.getPlanetaryConditions().getWindStrength() >= PlanetaryConditions.WI_STORM))))
&& (prevFacing != curFacing) && !lastPos.equals(curPos)) {
addPilotingModifierForTerrain(roll, lastPos);
roll.append(new PilotingRollData(getId(), getMovementBeforeSkidPSRModifier(distance), "turning on black ice"));
adjustDifficultTerrainPSRModifier(roll);
return roll;
} else if ((prevStepPavement
Expand Down
22 changes: 22 additions & 0 deletions megamek/src/megamek/common/MoveStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -3018,6 +3018,28 @@ && getEntity().getPosition().equals(prev)
return;
}

// Be careful on pavement during cold weather, there may be black ice.
boolean useBlackIce = game.getOptions().booleanOption(OptionsConstants.ADVANCED_BLACK_ICE);
boolean goodTemp = game.getPlanetaryConditions().getTemperature() <= PlanetaryConditions.BLACK_ICE_TEMP;
boolean goodWeather = game.getPlanetaryConditions().getWeather() == PlanetaryConditions.WE_ICE_STORM;

if (isPavementStep && ((useBlackIce && goodTemp) || goodWeather)) {
if (destHex.containsTerrain(Terrains.BLACK_ICE)){
mp ++;
}
if (destHex.containsTerrain(Terrains.BLACK_ICE)
&& !isCareful()
&& (nDestEl == destHex.getLevel())) {
mp--;
}
if (isPavementStep
&& !destHex.containsTerrain(Terrains.BLACK_ICE)
&& isCareful()) {
mp++;
}

}

// Account for terrain, unless we're moving along a road.
if (!isPavementStep()) {

Expand Down
11 changes: 6 additions & 5 deletions megamek/src/megamek/common/PlanetaryConditions.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class PlanetaryConditions implements Serializable {
public static final int WE_HEAVY_HAIL = 13;// NYI
public static final int WE_LIGHTNING_STORM = 14;// NYI
// public static final int WE_BLIZZARD = 11; does not exist anymore
public static final int BLACK_ICE_TEMP = -30;
private static final String MSG_NAME_WEATHER_CLEAR = Messages.getString("PlanetaryConditions.DisplayableName.Weather.Clear");
private static final String MSG_NAME_WEATHER_LIGHTRAIN = Messages.getString("PlanetaryConditions.DisplayableName.Weather.Light Rain");
private static final String MSG_NAME_WEATHER_MODRAIN = Messages.getString("PlanetaryConditions.DisplayableName.Weather.Moderate Rain");
Expand Down Expand Up @@ -373,8 +374,8 @@ public int getLightHitPenalty(boolean isWeapon) {

return penalty;
}
/**

/**
* Returns true when the light conditions give a hit penalty and
* the hit penalty can be offset by a searchlight, i.e. in full moon,
* moonless and pitch black night.
Expand All @@ -397,11 +398,11 @@ public boolean isIlluminationEffective() {
public static boolean requiresLowTemp(int weather) {
return weather == WE_LIGHT_HAIL ||
weather == WE_HEAVY_HAIL ||
weather == WE_LIGHT_SNOW ||
weather == WE_LIGHT_SNOW ||
weather == WE_SLEET ||
weather == WE_SNOW_FLURRIES ||
weather == WE_HEAVY_SNOW ||
weather == WE_ICE_STORM ||
weather == WE_ICE_STORM ||
weather == WE_MOD_SNOW;
}

Expand Down Expand Up @@ -775,7 +776,7 @@ public int getVisualRange(Entity en, boolean targetIlluminated) {
isAero = (en.isAero()) && !isLargeCraft;
}
// anything else is infantry

// Beyond altitude 9, Aeros can't see. No need to repeat this test.
if (isAero && (en.getAltitude() > 9)) {
return 0;
Expand Down
8 changes: 8 additions & 0 deletions megamek/src/megamek/common/Terrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ public void pilotingModifier(EntityMovementMode moveMode, PilotingRollData roll,
roll.addModifier(4, "Ice");
}
break;
case Terrains.BLACK_ICE:
if ((moveMode != EntityMovementMode.HOVER) && (moveMode != EntityMovementMode.WIGE)) {
roll.addModifier(4, "Black Ice");
}
break;
case Terrains.INDUSTRIAL:
roll.addModifier(1, "Industrial Zone");
break;
Expand Down Expand Up @@ -498,6 +503,7 @@ public int movementCost(Entity e) {
}
return Math.max(0, mp);
case Terrains.ICE:
case Terrains.BLACK_ICE:
if ((moveMode == EntityMovementMode.HOVER) || (moveMode == EntityMovementMode.WIGE)) {
return 0;
}
Expand Down Expand Up @@ -664,6 +670,8 @@ public boolean isValid(StringBuffer errBuff) {
rv = false;
} else if (type == Terrains.ICE && level != 1) {
rv = false;
} else if (type == Terrains.BLACK_ICE && level != 1) {
rv = false;
} else if (type == Terrains.GEYSER && (level < 1 || level > 3)) {
rv = false;
} else if (type == Terrains.FORTIFIED && level != 1) {
Expand Down
Loading