Skip to content

Commit

Permalink
Also increase artillery lead somewhat
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleet01 committed Jul 18, 2024
1 parent d0ac9a0 commit a1e1363
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions megamek/src/megamek/common/Compute.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions megamek/unittests/megamek/common/ComputeArtilleryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit a1e1363

Please sign in to comment.