diff --git a/megamek/src/megamek/common/Compute.java b/megamek/src/megamek/common/Compute.java index 9a4781fd69c..cf6aa33ebfe 100644 --- a/megamek/src/megamek/common/Compute.java +++ b/megamek/src/megamek/common/Compute.java @@ -2835,10 +2835,10 @@ public static ToHitData getTargetTerrainModifier(Game game, Targetable t, boolean isUnderwater = (entityTarget != null) && hex.containsTerrain(Terrains.WATER) && (hex.depth() > 0) && (entityTarget.getElevation() < hex.getLevel()); - boolean isAboveStructures = (entityTarget != null) && - ((entityTarget.relHeight() > hex.ceiling()) || + boolean isAboveStructures = (entityTarget != null) && + ((entityTarget.relHeight() > hex.ceiling()) || entityTarget.isAirborne()); - + // if we have in-building combat, it's a +1 if (attackerInSameBuilding) { @@ -7538,9 +7538,9 @@ public static Coords calculateArtilleryLead(Game game, Entity ae, Targetable tar // Try to keep the current position within the homing radius, unless they're real fast... if (homing) { - leadAmount = (mp * (turnsTilHit)) + HOMING_RADIUS; + leadAmount = (mp * (turnsTilHit + 1)) + HOMING_RADIUS; } else { - leadAmount = mp * (turnsTilHit + 1); + leadAmount = mp * (turnsTilHit + 2); } // Guess at the target's movement direction diff --git a/megamek/unittests/megamek/common/ComputeArtilleryTest.java b/megamek/unittests/megamek/common/ComputeArtilleryTest.java index 062e6b3be60..d93a1de5df1 100644 --- a/megamek/unittests/megamek/common/ComputeArtilleryTest.java +++ b/megamek/unittests/megamek/common/ComputeArtilleryTest.java @@ -107,27 +107,27 @@ public void testComplexCalculateLead() { setupTarget(target, new Coords(15, 17), new Coords(15, 21)); leadPos = Compute.calculateArtilleryLead(mockGame, shooter, target, false); assertEquals(15, leadPos.getX()); - assertEquals(13, leadPos.getY()); + assertEquals(9, leadPos.getY()); // Mobile target 1 map sheet away to the S (3) direction, speed 4, non-homing setupTarget(target, new Coords(15, 25), new Coords(15, 29)); leadPos = Compute.calculateArtilleryLead(mockGame, shooter, target, false); assertEquals(15, leadPos.getX()); - assertEquals(17, leadPos.getY()); + assertEquals(13, leadPos.getY()); // Mobile target 1 map sheet away to the S (3) direction, speed 4, homing, should be closer to shooter // for better chance to catch mobile unit in TAG-able area setupTarget(target, new Coords(15, 25), new Coords(15, 29)); leadPos = Compute.calculateArtilleryLead(mockGame, shooter, target, true); assertEquals(15, leadPos.getX()); - assertEquals(13, leadPos.getY()); + assertEquals(9, leadPos.getY()); // Mobile target 1 map sheet away to the NE (1) direction, speed 4, non-homing shooterPos = new Coords(0, 35); when(shooter.getPosition()).thenReturn(shooterPos); setupTarget(target, new Coords(32, 1), new Coords(36, 0)); leadPos = Compute.calculateArtilleryLead(mockGame, shooter, target, false); - assertEquals(24, leadPos.getX()); - assertEquals(5, leadPos.getY()); + assertEquals(20, leadPos.getX()); + assertEquals(7, leadPos.getY()); } }