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

Fix 5590: princess firing on 13s due to intervening trees, etc. #6477

Conversation

Sleet01
Copy link
Collaborator

@Sleet01 Sleet01 commented Feb 1, 2025

This patch adds a few bits of extra knowledge to Princess in order to avoid her wasting shots where she shouldn't.

The key issues it fixes are:

  • Princess doesn't know about intervening woods and smoke;
  • Princess will switch to ammo that makes her miss;
  • Princess pumps cluster rounds into trees with TacOps woods cover enabled.

In more detail:

  1. The fast attack "guessing" code used by the FireControl.java class previously only checked if a given hex was in woods, jungle, or smoke for determining its defensive properties (for enemies or allies). This would often put Princess in a position that was defensively good but not optimal, or offensively useless because it actually had no LOS to a target that Princess thought she could just see.
    The fix here was to add a single light-weight LOS modifier check prior to the more in-depth calculations to get better LOS data but allow a fast exit if LOS is blocked.
    Princess should now have a better idea of LOS mods from trees and smoke when predicting all units' turns.
  2. Princess will switch to ammo that makes her miss because we do a last-chance "ammo efficacy" check after all attacks have been declared, due to the way we assess attacks and where the legacy code lives.
    This means that, e.g., an LB-10X shot might be switched from cluster to solid in attempt to bypass special armor, but in doing so the shot goes from a 12 to hit up to a 13 due to the Cluster bonus being lost.
    The fix is to clone the existing WeaponAttackAction, give it the suggested new ammo, confirm that it does not have a higher to-hit number, and only then load the new WAA into the queue of attacks to be sent to the server.
  3. Princess has no knowledge currently of the TacOps cover rules that allow trees to absorb low-damage shots completely.
    The fix is to add a new section in the WeaponFireInfo class (responsible for assessing potential attack effectiveness) to mark such attacks as dealing zero damage if the rule is enabled. This is a fast but not comprehensive check, and may need updating for full coverage in the future.

Note:
It appears that there is still the possibility for Princess to be forced to take impossible shots, when ammo usage during the Attack Phase causes one ammo bin to go bingo and the replacement ammo has different to-hit characteristics.
The chief offender is IS LRM Dead-Fire, where switching from D-F rounds to normal rounds at range 1 adds a +5 penalty for minimum range.
Unfortunately I don't see a way to fix this without adding a lot of extra ammo bin checks prior to attacks.

Testing:

  • Ran many bot-on-bot matches with tons of smoke and trees.
  • Ran all 3 projects' unit tests.

Close #5590

Copy link

codecov bot commented Feb 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 28.58%. Comparing base (54e363b) to head (36ca78c).
Report is 54 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6477      +/-   ##
============================================
- Coverage     28.59%   28.58%   -0.01%     
- Complexity    14377    14405      +28     
============================================
  Files          2798     2798              
  Lines        274895   275141     +246     
  Branches      48630    48676      +46     
============================================
+ Hits          78593    78636      +43     
- Misses       191669   191831     +162     
- Partials       4633     4674      +41     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Sleet01 Sleet01 requested a review from Scoppio February 1, 2025 01:01
Copy link
Collaborator

@rjhancock rjhancock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks fine. For logging methods I think we should be moving to I18n messages using varargs for passing in data.

Not needed for this change as I'm not sure we have I18n proper and refined in place just yet.

Comment on lines +2857 to +2859
logger.warn(shooter.getDisplayName() + " tried to load "
+ currentWeapon.getName() + " with ammo " +
mountedAmmo.getDesc() + " but this would have caused it to miss; skipping.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warn should support varargs with %s.

Copy link
Member

@HammerGS HammerGS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had both Co-Pilot and IDEA AI check this and they see no issues. GOing to include in .03

@rjhancock rjhancock merged commit 673b2d5 into MegaMek:master Feb 1, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

49.20 Nightly - AC5s shooting on 13s.
3 participants