Question Extracting recipe sources from the game files (how do shops work?)

numsku1l

Cowpoke
Specifically this question is about Queen Of The Sauce recipes and recipes you get from shops. I'm still a beginner at this so there's a lot I'm getting used to, but here is some context:

I'm writing a script that goes through the game's Content files and extracts information about recipes. I know that the cooking and crafting recipes are found in Content/Data/CookingRecipes.xnb and Content/Data/CraftingRecipes.xnb respectively, and that the Content/Data/ObjectInformation.xnb file provides the translation from the numerical item codes to item information strings. So far my script correctly produces a hash table indexed by recipe names and whose values are lists of their ingredient names/quantities.

Now I'm trying to extract the sources for recipes. The ...Recipes.xnb files provide *at most one* source for each recipe, which covers recipe sources obtained by default, skill levels, and friendship levels, but it doesn't provide sources from Queen Of The Sauce or shops (or upgrading the farmhouse/completing special quests, but that's an edge case that I'm planning to handle manually).

So, first I will ask about Queen of the Sauce. There is a file called Content/Data/TV/CookingChannel.xbn and it contains all of the recipe names and the strings that are used for the TV broadcast, but it doesn't directly indicate what date you're supposed to learn the recipe. The recipes are indexed by the numerical values 1-32, and they seem to be in the order they are learned, so my suspicion is that on the Sunday of week x the TV show simply teaches the recipe at index x, and restarts the cycle once year 3 starts. Is this true?

For the shops I am much more lost, because I haven't been able to find any information about them in the Content folder at all. A bit of googling suggests that the shops aren't handled by xnb files at all and are hard-coded in the game. Is there a straightforward way of accessing (not necessarily modifying) this information? If I just decompiled the exe with ILSpy for example, where should I look in the resulting code?
 

numsku1l

Cowpoke
Update: I have decompiled the code using ILSpy and located some shop information, but I'm still missing a lot. For example under StardewValley.Locations I found a SeedShop class that extends ShopLocation, and has a public shopStock() method. In particular I found where the Grass Starter recipe is added to the stock: 1612044822327.png

This seems like a promising start, but when I look in the FishShop class for example, which also extends ShopLocation, it *doesn't* have a shopStock() method and I can't find anything in the class about stock at all. Moreover I've been unable to locate the carpenter shop or the Dwarf shop. It is looking like it will be way easier to just handle these cases manually rather than write a script to go through these C# files, but I'm still interested in knowing if there's a more methodical approach to getting the complete stock lists for each of the shops.
 

numsku1l

Cowpoke
Thanks so much for the tip!! That did indeed help me well along the way to tracking down what I *think* is all of the shop inventories (depending on what you mean by "shop" I guess). I think I should post what I found in case other people search and find this thread.


It seems like most of the original shop inventories are contained in the StardewValley.Utility class. Here are the methods I found and the inventories they construct (shop inventories with a * contain at least one recipe):

StardewValley.Utility::generateLocalTravelingMerchantStock(int seed)
- Travelling Merchant

StardewValley.Utility::getDwarfShopStock()
- Dwarf Shop in Mines *

StardewValley.Utility::getHospitalStock()
- Hospital

StardewValley.Utility::getQiShopStock()
- Qi Shop (???)

StardewValley.Utility::getJojaStock()
- Joja Mart

StardewValley.Utility::getHatStock()
- Hat Shop

StardewValley.Utility::getFishShopStock(Farmer who)
- Fish Shop

StardewValley.Utility::getCarpenterStock()
- Carpenter Shop *

StardewValley.Utility::GetQiChallengeRewardStock(Farmer who) [sic]
- Qi Challenge Rewards *

StardewValley.Utility::getAdventureRecoveryStock()
- Adventure Recovery

StardewValley.Utility::getAdventureShopStock()
- Adventure Shop

StardewValley.Utility::getSaloonStock()
- Saloon *

StardewValley.Utility::getBlacksmithStock()
- Blacksmith Items

StardewValley.Utility::getBlacksmithUpgradeStock(Farmer who)
- Blacksmith Upgrades

StardewValley.Utility::getAnimalShopStock()
- Animal Shop Items

StardewValley.Utility::getPurchaseAnimalStock()
- Animal Shop Animals

StardewValley.Utility::getShopStock(bool Pierres)
- "Shop" (???)


Then there are a couple of inventories in the StardewValley.GameLocation class:

StardewValley.GameLocation::sandyShopStock()
- Sandy

StardewValley.GameLocation::carpenters(Location tileLocation)
- Carpenter's improvements


Shops that are "outside" (except for the travelling merchant) appear to have their inventories stored in StardewValley.Locations, in the location classes where they're spawned. Here's what I found:

StardewValley.Locations.VolcanoDungeon::checkAction()
- Dwarf Shop (Volcano) *

StardewValley.Locations.BeachNightMarket::
getBlueBoatStock()
- Blue Boat
geMagicShopStock() [sic]
- Magic Shop

StardewValley.Locations.SeedShop::shopStock()
- Pierre's General Store *

StardewValley.Locations.Sewer::getShadowShopStock()
- Krobus *

StardewValley.Locations.Desert::getDesertMerchantTradeStock()
- Desert merchant in the tent *

StardewValley.Locations.IslandNorth::getIslandMerchantTradeStock()
- Island trader *

StardewValley.Locations.IslandSouth::checkAction()
- Gus' Resort shop *




There are a couple of things I still don't fully understand. In particular the "Shop" in the Utility class seems like Pierre's but is missing some times, as if the SeedShop definition overrides it, and I'm not sure what exactly the Qi Shop from the Utility class is defining.
 
Last edited:

BlaDe

Farmer
Nice work!

You will also find that festival shops are defined in the festival data (Content\Data\Festivals).
 

numsku1l

Cowpoke
Perfect, thank you! I had just remembered about Festival shops, so thanks for reminding me.

I'm wondering if you also know how to decode the information string for festival shops, since the community wiki's "Modding:Festival data" page doesn't have information about it. For example the "fall27" file contains the entry

"shop": "BO 113 5000 1 O 746 750 5 BL 746 2000 1 BO 47 350 -1 F 2870 4000 -1"

I haven't encountered these B, O, L or F flags yet. The "O 476 750" and "BL 476 2000" segments seem to represent buying a Jack-O-Lantern as an item *and* a recipe, but the key "113" points to "Chicken Statue" rather than "Rarecrow" in ObjectInformation and all of the keys there are less than "2870", so I'm definitely not sure how to read all of the information in this line.
 

numsku1l

Cowpoke
Yes that's exactly what I needed, thank you! I will post what I found out, again for the sake of completeness.

The

Utility.getItemFromStandardTextDescription(string description, Farmer who, char delimiter = ' ')

function is a switch statement whose cases are these character codes, and the constructors used in each case give the hint as to which xnb file you should use to translate the numerical code. There is still a bit of figuring out to do though because the StardewValley.Object constructor is overloaded and the different versions can produce normal objects or big craftables, depending on whether or not they have an initialStack as an argument (you can't stack big craftables). In the end I came up with this:

KeyTranslationConstructorData File
"F""Furniture"Furniture.GetFurnitureInstance(index, Vector2.Zero) Furniture.xnb
"O""Object"StardewValley.Object(index, 1)ObjectInformation.xnb
"BO""Big Object"StardewValley.Object(Vector2.Zero, index)BigCraftablesInformation.xnb
"R""Ring"Ring(index)ObjectInformation.xnb
"B""BootBoots(index)Boots.xnb
"W""Weapon"MeleeWeapon(index)weapons.xnb
"BL""Blueprint"StardewValley.Object(index, 1, isRecipe: true)ObjectInformation.xnb
"H""Hat"Hat(index)hats.xnb
"BBL""Big Blueprint"StardewValley.Object(Vector2.Zero, index, isRecipe: true)BigCraftablesInformation.xnb
"C""Clothing"Clothing(index)ClothingInformation.xnb
 
Top