SOLVED - How do you restrict meat types sold by vendors?

Started by o-o-o, January 17, 2018, 12:30:57 PM

Previous topic - Next topic

o-o-o

Preface - I am currently only working with XML files; actual programming remains out of reach

I am attempting to restrict the types of meat that my custom faction traders will sell to only domesticated animals - beef, pork and chicken only , and no boomrat, cobraflesh or yorkshire terrier meat for sale.  I used the <tradetags> function a bunch to successfully restrict what guns and clothes the traders would sell, but I can't get it to work for meat.  The <tradetags> for animals appears to be only for the sale of whole animals (so I could potentially make a vendor only sell chickens, cows or pigs) and not their meat products. 

The option I want to pursue is to make a custom ThingCategoryDef that is a child of the MeatRaw ThingCategoryDef.  That way I can just use the StockGenerator_Category function to pull from that group.  But I can't seem to find where you actually populate a ThingCategoryDef.  Is this hardwired in code, or did I miss it somewhere?

Alternatively, is there another way of doing this?

jamaicancastle

Normally, you would use the <thingCategories> tag inside of a thingDef to assign it to one or more categories. However, as you've probably discovered, the different types of meat don't have their own discrete thingDefs in XML; they're generated from the animals when the game launches.

In this case I think your best bet, since you're trying to target a relatively small number of different kinds of meat, is to use a StockGenerator_MultiDef instead of Category. The MultiDef expects a list of specific thingDefs instead of a category; it should otherwise work the same way. I believe the meat types are normally named [animal]_Meat, as in our perennial favorite Human_Meat.

o-o-o

Using StockGenerator_MultiDef worked, I was able to add just chicken, pig and cow meat to the caravan trade items.  I had seen that function a bunch when looking at the vanilla TraderKindDefs, but did not have a sense of how and where to use it. 

As an added bonus, I also now know how to have traders sell human meat, useful for when I finally make my cannibal faction!