MegaMek / mekhq

MekHQ is a java helper program for the MegaMek game that allows users to load a list of entities from an XML file, perform repairs and customizations, and then save the new entities to another XML file that can be loaded into MegaMek.
http://megamek.org
131 stars 169 forks source link

[RFE] Keep Clan Mechs out of Unit Market in early IS games if Clan Purchasing is Off #4975

Open WeaverThree opened 1 week ago

WeaverThree commented 1 week ago

Prerequisites and Pre-Issue Checklist

RFE Details *

This is an improvement to an existing feature

Brief Description *

Occasionally a clan mech will show up in the Unit Market, even when you're playing as IS in the 3020s with purchasing clan equipment turned off. Turning off clan purchasing should keep this from happening.

4379 Involves adding clan mechs to the unit market for IS players after a certain date; it's the only other one I found related to this issue.

(Atma asked me to file this RFE based on conversation between her and Illiani in Discord))

MekHQ Suite Version *

v0.50.0

Attach Files

No response

Final Checklist

repligator commented 1 week ago

Just to clarify, are we talking about fully clan tech meks or mixed tech base IS that include clan parts?

WeaverThree commented 1 week ago

Just to clarify, are we talking about fully clan tech meks or mixed tech base IS that include clan parts?

We've seen a Gladiator, at least. So full clan mechs. Mixed tech shouldn't show up before 3050-something-ish either though.

repligator commented 6 days ago

Can you provide any more information? Which faction you were playing, who your employer was, what part of the galaxy you were in, etc? A save file and logs would be much appreciated as well.

repligator commented 6 days ago

By changing a couple lines of mekhq/campaign/market/unitMarket/AtBMonthlyUnitMarket.java, I made it so the market never wipes, and new meks are added every day instead of every month. All tests were done in 3025 as unemployed mercs.

Couple months worth of meks on York (the clan one), with purchasable clan tech on: Clan meks (obviously) 30 years worth of meks on Galatia, with purchasable clan tech off: No Clan meks 15 years worth of meks while on Granda, with purchasable clan tech on: No Clan meks 1 year worth of meks while on Galatia, with purchasable clan tech on: No Clan meks 7 years worth of meks while on Rasalhague, with purchasable clan tech on: No Clan meks 2 years worth of meks while on The Rock, with purchasable clan tech on: No Clan meks

Either this bug is tied in some way to date/employer or it is exceptionally rare. Even with purchasable clan tech on I can't get Clan meks to generate in the IS.

IllianiCBT commented 6 days ago

So what’s happening, I suspect, is that the Black Market (which, iirc, picks a random faction) can roll a Clan faction resulting in Clan units appearing in the black market.

repligator commented 6 days ago

Unless I'm reading this wrong, black market items can only be from one the controllers of the system the player is on, on the current date


        // Black Market
        if (!campaign.getFaction().isClan()) {
            faction = ObjectUtility.getRandomItem(campaign.getCurrentSystem()
                    .getFactionSet(campaign.getLocalDate()));
IllianiCBT commented 6 days ago

No, I think you're reading it right and I was just misremembering.

SuperStucco commented 6 days ago

This will require some spelunking for confirmation, but I suspect it is coming from the RAT Generator and how it incorporates the concept of salvage.

When a RAT table is generated, some of the RAT entries are categorized as 'salvage', using an entry with a generic faction rather than than a specific chassis/model. This is based on percentages in the top section of each era availability XML file, like this: https://github.com/MegaMek/mekhq/blob/036d7bea06aa05b4e65424baa02bf8b67d5c78f3/MekHQ/data/forcegenerator/3039.xml#L265-L267

At the time of generation, if the 'salvage' entry is chosen it uses the specified faction to generate a model/chassis. Some of these may result in salvage from Wolf's Dragoons (MERC.WD), which in pre-Invasion eras do have some access to Clan tech. For example, in 3039, the Warhammer C 3: https://github.com/MegaMek/mekhq/blob/036d7bea06aa05b4e65424baa02bf8b67d5c78f3/MekHQ/data/forcegenerator/3039.xml#L6942-L6946

It would help if there was a detailed list of which chassis/models come up, and the specific year of the campaign, which could help confirm or exclude this as a possibility.

While the Dragoons did not have publicly facing Clan gear, they did have some squirreled away 'just in case'. So removing availability of Clan-equipped units from this faction may not be warranted for the game in general, but could be an interim solution for individual players.

repligator commented 5 days ago

Did some spelunking.

Logs, save files, and/or screenshots would be greatly appreciated.

SuperStucco commented 5 days ago

I have seen this phenomenon for myself, they are incredibly rare. Typically it is Clan conversions like the Shadow Hawk C, or more rarely a IIC remake. I can't entirely discount your theory on the Gladiator omni vs. primitive, but it is available to MERC.WD IN 3049: https://github.com/MegaMek/mekhq/blob/976204bfa54b995b2d45159b080d13dba8a16ee5/MekHQ/data/forcegenerator/3049.xml#L3502
I think your testing year range may be a bit off, in my experience you don't see it until later, typically in the decade before the Clans arrive in the IS. There might be a mis-remembering by the OP for their specific instance. Which brings up the other point.

When generating availability for years between the era availability XMLs, these are interpolated between the two values, with 'not present' being equivalent to 0 (not available). For example, a quick check shows the Atlas C available to the Lyrans, Fed Suns, and FedCom in 3049: https://github.com/MegaMek/mekhq/blob/393f85ae99bf2ca1214f4aba65502ad1dbd403d0/MekHQ/data/forcegenerator/3049.xml#L1174-L1176

In 3039, it's only available to Clan factions: https://github.com/MegaMek/mekhq/blob/79c3c2b55849dae6e0372e991833cce3e5fbd9bf/MekHQ/data/forcegenerator/3039.xml#L929-L931

Using the interpolation process, in 3044 the availability for LA (Lyran Commonwealth) is considered to be 1: halfway between the two years, so halfway between the two values. That produces a very low rate of selection, one which might even slip by your test process. But I would still ask you to redo it, using a range of 3044-3048 as a test period for verification.

The value could (and maybe should) be adjusted later with a date modifier such as LA:2:3051, to represent hasty refits from available salvage. But there would still be the interpolation issue for earlier years.

HammerGS commented 5 days ago

Part of the issue with the C is capturing the early Clan years around Klondike. Where in canon they where refiting some of those old designs with early Clan Weapons. We'd have to be careful about blocking those units from those time.

Sometimes I think a harder code block would be handy.

If year is <3052 and faction isn't Clan, prohibit Tech Base Clan and Mixed

repligator commented 5 days ago

Testing 30+ years of unit markets in the year 3044 with purchasable clan tek on gave me the following for Clan tek 2 Dasher (Fire Moth Prime) - Merc Auction 1 Great Wyrm - Merc Auction 1 Griffin IIC - Merc Auction 1 Highlander IIC - Merc Auction 1 Kingfisher - Merc Auction 2 Man O' War (Gargoyle) - Open Market 1 Peregrine (Horned Owl) 2 - Merc Auction 1 Puma (Adder) - Open Market 2 Ryoken (Stormcrow) - Open Market 1 Ryoken (Stormcrow) - Merc Auction 1 Shadow Hawk IIC - Open Market 1 Stooping Hawk - Open Market 1 Storm Giant - Open Market 1 Vixen (Incubus) - Open Market 1 Vulture (Mad Dog) - Open Market

I repeated the above test, but with purchasable clan tek off for 3045,3046 and 3048 No clan tek at all.

Seems like Clan Purchase on/off is working as intended, I can replicate the issue when its on but not when its on. But, needless to say, clan tek shouldn't be on the open market in the IS at the dates in question regardless of settings.