MegaMek / megamek

MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight using giant robots, tanks, and/or infantry on a hex-based map.
http://www.megamek.org
GNU General Public License v2.0
296 stars 286 forks source link

Artillery Weapon To-Hits Not Affected by SPAs or Weapon Quirks - 0.49.14-SNAPSHOT #4524

Closed BLR-IIC closed 1 year ago

BLR-IIC commented 1 year ago

It appears that all artillery weapons (Sniper, Thumper, Long Tom, Arrow IV anyway) aren't getting their to-hit numbers modified by quirks or SPAs. I tested the Weapon Specialist SPA and the Accurate Weapon quirk for these weapons and they aren't being considered in the Indirect Attack Phase or the Weapon Attack Phase.

Sleet01 commented 1 year ago

I'm already looking at this for the Anti-Air quirk; it looks like Direct/Indirect Artillery handling got split out from standard attacks some time before I started working on the code and does not currently contain Quirk handling.

I'll see if there's a quick and simple way to refactor the existing quirk handling without disrupting much code; if so, I'll wrap the fix for this into the work I'm doing for #3870 .

Sleet01 commented 1 year ago

It appears that all artillery weapons (Sniper, Thumper, Long Tom, Arrow IV anyway) aren't getting their to-hit numbers modified by quirks or SPAs. I tested the Weapon Specialist SPA and the Accurate Weapon quirk for these weapons and they aren't being considered in the Indirect Attack Phase or the Weapon Attack Phase.

Can you provide a save game for a quick repro? That'll make testing this fix easier.

Sleet01 commented 1 year ago

NM, I was able to set up a repro without much issue.

I'm looking at refactoring how Quirks and Attacker / Defender SPAs are applied. This will change the order, but I think we can treat everything the same by creating new functions for each of the above types.

I made a Pollux ADA heavy tank with these quirks and SPAs:

Versus a Trireme Support VTOL, the LBX-10 attacks get these mods:

To Hit: 4 (92%) = 4 (gunnery skill) + 2 (target moved 5-6 hexes) + 1 (target VTOL used MPs) - 1 (target is large support unit) - 2 (anti-air targeting system vs airborne unit) - 1 (Ballistic Specialization) + 4 (long range) - 2 (flak to-hit modifier) - 1 (ammunition to-hit modifier)

The Sniper shots get these mods:

To Hit: 1 (100%) = 4 (gunnery skill) - 2 (anti-air targeting system vs airborne unit) - 2 (weapon specialist) + 3 (artillery flak attack) - 2 (flak to-hit modifier)

Which I believe is correct.

Looking at Arrow IV (with and without ADA), I've got a Longbow LGB-8V versus a Sparrowhawk with Shaky Stick, using:

Left launcher, ADA looks like:

To Hit: 3 (97%) = 3 (gunnery skill) - 2 (anti-air targeting system vs airborne unit) + 1 (inaccurate weapon) + 1 (Shaky Stick) - 2 (flak to-hit modifier) + 2 (attacker ran) + 0 (ADA range brackets (+0/+2/+4))

Regular Arrow IV and Cluster Arrow IV show:

To Hit: 5 (83%) = 3 (gunnery skill) - 2 (anti-air targeting system vs airborne unit) + 1 (inaccurate weapon) + 1 (Shaky Stick) + 3 (artillery flak attack) - 2 (flak to-hit modifier) + 1 (airborne aerospace at altitude 4-6)

Right launcher, ADA looks like:

To Hit: 1 (100%) = 3 (gunnery skill) - 2 (anti-air targeting system vs airborne unit) - 1 (stabilized weapon) + 1 (Shaky Stick) - 2 (flak to-hit modifier) + 2 (attacker ran) + 0 (ADA range brackets (+0/+2/+4))

Regular Arrow IV and Cluster Arrow IV show:

To Hit: 3 (97%) = 3 (gunnery skill) - 2 (anti-air targeting system vs airborne unit) - 1 (stabilized weapon) + 1 (Shaky Stick) + 3 (artillery flak attack) - 2 (flak to-hit modifier) + 1 (airborne aerospace at altitude 4-6)

All of which looks to be correct.