From 799518932f7a143c4e981a4caf8510789e8e6b43 Mon Sep 17 00:00:00 2001 From: sleet01 Date: Wed, 24 Jul 2024 14:12:12 -0700 Subject: [PATCH 1/2] Revert unnecessary change that broke Princess bombing; add safety around diveBombing plans --- megamek/src/megamek/client/bot/princess/FireControl.java | 6 +++++- megamek/src/megamek/common/Entity.java | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/megamek/src/megamek/client/bot/princess/FireControl.java b/megamek/src/megamek/client/bot/princess/FireControl.java index e0c696cfc4e..6537e7dd7cb 100644 --- a/megamek/src/megamek/client/bot/princess/FireControl.java +++ b/megamek/src/megamek/client/bot/princess/FireControl.java @@ -1933,9 +1933,13 @@ private FiringPlan getDiveBombPlan(final Entity shooter, guess, bombPayloads); diveBombPlan.add(diveBomb); + // Hack to prevent adding more than one dive bomb action to the plan + // TODO: find out why too many actions are getting added + // Having more than one DiveBomb in the plan invalidates the whole plane + // (see WeaponAttackAction.java:2033 + break; } } - return diveBombPlan; } diff --git a/megamek/src/megamek/common/Entity.java b/megamek/src/megamek/common/Entity.java index bbbcd483e08..a42d4d7b6e4 100644 --- a/megamek/src/megamek/common/Entity.java +++ b/megamek/src/megamek/common/Entity.java @@ -4313,7 +4313,7 @@ protected void resetBombAttacks() { weaponBayList.removeAll(bombAttacksToRemove); boolean foundSpaceBomb = false; - int numGroundBombs = 0; + int addedBombAttacks = 0; for (BombMounted m : getBombs()) { // Add the space bomb attack @@ -4338,7 +4338,7 @@ && isBomber() && m.getType().hasFlag(AmmoType.F_GROUND_BOMB) && !((this instanceof LandAirMech) && (getConversionMode() == LandAirMech.CONV_MODE_MECH))) { - if (numGroundBombs <= 1) { + if (addedBombAttacks < 1) { try { WeaponMounted bomb = (WeaponMounted) addEquipment(diveBomb, m.getLocation(), false); if (hasETypeFlag(ETYPE_FIGHTER_SQUADRON)) { @@ -4350,7 +4350,7 @@ && isBomber() } } - if ((numGroundBombs <= 10) && isBomber()) { + if ((addedBombAttacks < 10) && isBomber()) { try { WeaponMounted bomb = (WeaponMounted) addEquipment(altBomb, m.getLocation(), false); if (hasETypeFlag(ETYPE_FIGHTER_SQUADRON)) { @@ -4361,7 +4361,7 @@ && isBomber() } } - numGroundBombs++; + addedBombAttacks++; } } } From d101f3c0bbdfb245e916e4525574dbf5a9d21f9b Mon Sep 17 00:00:00 2001 From: sleet01 Date: Wed, 24 Jul 2024 14:27:12 -0700 Subject: [PATCH 2/2] Remove note to self --- megamek/src/megamek/client/bot/princess/FireControl.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/megamek/src/megamek/client/bot/princess/FireControl.java b/megamek/src/megamek/client/bot/princess/FireControl.java index 6537e7dd7cb..8b5cc0254d2 100644 --- a/megamek/src/megamek/client/bot/princess/FireControl.java +++ b/megamek/src/megamek/client/bot/princess/FireControl.java @@ -1933,10 +1933,7 @@ private FiringPlan getDiveBombPlan(final Entity shooter, guess, bombPayloads); diveBombPlan.add(diveBomb); - // Hack to prevent adding more than one dive bomb action to the plan - // TODO: find out why too many actions are getting added - // Having more than one DiveBomb in the plan invalidates the whole plane - // (see WeaponAttackAction.java:2033 + //To prevent adding more than one dive bomb action to the plan break; } }