Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Shifted

#1
I love mods like Vegetable Garden, but I've often found myself just going for the most efficient meal and crop every time. I wanted to try make cooking a bit more interesting by giving you a reason to grow, hunt, produce, and buy different ingredients every new game you play. The cooking recipes this mod creates are procedurally generated at the start of every new game, and offer different stats and effects that may make them better or worse for each situation you're in. Recipes tend to be specialized; one recipe might offer great stats for doctors, another recipe might be great for shooting, yet another recipe might have a high nutrition value to help with low food biomes. You must choose the ones you think best adapt to your situation. Here is how it works:


  • Several procedurally generated cooking recipes get created at the start of the game. Their stats and effects are balanced around different power levels. The higher a recipe's level, the more powerful the effects, but they also require higher cooking skill to make and higher ingredient diversity. All recipes come with upsides and a downside, so choose wisely.
  • To unlock cooking recipes, you can use the new draft system on the "Materia" tab. Throughout the game, you'll be given several opportunities to choose amongst different recipes. The one you select will become available on the electric and fueled stoves after some time. This gives you the opportunity to start growing the ingredients you'll need while the recipe gets unlocked.
  • (Optional) Normal cooking recipes that make end products (meals that aren't used as ingredients in any other recipe) are removed from the game. Things like Fine Meal and Sweet Rolls are removed, while things like Polenta, Cornmeal, and Bread are kept. The only exceptions are Simple Meal and Pemmican. Doing this makes sure you are incentivized to grow different things instead of going for overpowered recipes like Lavish Meal and Stew every time. It also increases the stakes on the decisions you make using the drafting system, knowing they are your only meal options moving forward. However, you can disable this on the mod's settings if you like.
  • (WIP) Colonists will tend to diversify their diet so that the effects from different meals can overlap. Moreover, colonists get a small mood penalty or bonus based on the meal diversity available to them.
  • (WIP) There is a chance you'll get the option to unlock a rare recipe. Rare recipes offer better stats and have unique effects that only rare recipes can get (like turning colonists into cannibals). However, they require very specific ingredients, usually in the form of a specific animal's meat (i.e. Ibex Meat), or a specific animal's product (i.e. Cobra Eggs) together with other ingredients. This should make them not be the obvious choice when they show up, but if you're lucky they might just be what you need.

I highly recommend you use Vegetable Garden with this mod. In fact, that's mostly how I've tested it. Even though you might not use the meals of it, the added crop diversity and intermediary ingredients like Bread make the procedural recipes more interesting.

I'm still trying to balance things out and playtest the system to see how it feels. Any feedback or ideas you might have are greatly appreciated. The mod also needs more flavor text, which is easy to add through XML definitions. If you're interested in adding some, let me know. Textures might be nice too, in case anyone is interested in making them. You'll get full credit in anything you do of course. I'm more interested in making this a community project than anything else. Otherwise it might end up being too specific to the way I play the game, and not be that useful for other people.

You can find the mod here and start using it: https://github.com/shifteds/materia

#2
Thanks for the responses. I guess I wanted to make sure there wasn't a less hacky way of doing it than using reflection. After looking at other mods, it seems some people are even straight up editing memory to detour methods from the assembly so I guess "hacky" is the name of the game in here.

I'm making a mod that allows you to combine any ingredient and creates procedural recipes and items from each combination, randomizing the effects for each new game. It's my first venture into Rimworld modding (though not to programming) and I'm still trying to figure out the entire architecture of it and how things happen.

So far, I've managed to make a proof of concept prototype; though there's still a few details I'm trying to figure out. I ended up using a combination of hoppers and a normal work table that lets a pawn combine the materials and produce a "Recipe" item that saves ingredient information. This creates a new "recipe template" for that particular combination on a global static registry that verifies it's not a duplicate, and gives the template a new name (eventually random stat buffs once I figure that out hopefully). A pawn can then activate the recipe item through right-click (similar to artifacts) and that causes the "learning" to happen. When learning happens, it generates a new RecipeDef and ThingDef using the previously generated recipe template on the registry.

In regards to my question, I ended up just needing to add the new RecipeDef to the ThingDef.AllRecipes list of the appropriate users to make it work. The ingredient getter property seems to default to the volumen type, which is fine for what the new recipes are doing, don't really need to use nutrition; so thankfully I managed to avoid having to use reflection, which I've never liked using. Though there's still some things I'm not sure about, like how does this get affected by save/load of games. The idea would be to make sure these recipes and items persist through reloads, but not for future new games. I'm looking at HugsLibs right now, which seems to have a convenient way to save data on the save file that I might be able to use, though strangely enough from the tests I've made it seems once the new RecipeDef is added to the DefDatabase<> saving and reloading the game maintains the new recipe.

Here's a quick video showcasing the prototype, I'll clean it up a bit and make a github repository soon in case anyone else is interested in contributing.
https://youtu.be/A83hKDmVsl0
#3
If I wanted to make a RecipeDef at runtime programatically, is there a way to set its "ingredientValueGetterClass" private property somehow? Or perhaps there's something I'm missing here, maybe a better way of creating RecipeDefs at runtime other than instantiating the object and adding it to DefDatabase<RecipeDef>. I'm also wondering how you'd go about clearing the AllRecipes cache on building defs like the cooking stove.

Thanks!
#4
Thanks! Yup, I'm fine with using C#. Got a follow up question if you don't mind. After poking around the game's dll, it seems a Building_WorkTable instance gets the available recipes from its own ThingDef.AllRecipes property, which in turn gets its recipes from the DefDatabase<RecipeDef>.AllDefsListForReading list before caching them. I was wondering if I could make a new RecipeDef programatically at runtime (to give it random properties instead of specifying them on an XML template) and add it to the database through DefDatabase<RecipeDef>.Add(myNewRecipe), then perhaps clearing the cached AllRecipes list of the Building_MySpecialWorkTable def so it gets populated again but now with my new recipe. If this is fine to do and doesn't make the game explode, then how can I make my programatically generated RecipeDefs persist through save game reloads? Will the game save anything it has on DefDatabase<RecipeDef>.AllDefsListForReading itself or must I save the RecipeDef somewhere on the save file?

Thanks for the help!
#5
I was thinking of making a mod that adds a new workbench, and to add some replay value I wanted to try have it randomize it's recipes at the start of each game. The idea would be to have it pick X recipes randomly from a larger pool.
Any ideas on how I might achieve this?
#6
First of all, thank you for all the effort you've put into this. The cave biome looks spectacular and I really want to play it. However, for some reason it seems the cave biome reduces my FPS to 25-30 when playing on speed 4 and 50-55 on speed 3 while every other biome is a constant 60 FPS on any speed (GTX1080, i7, 4K). I've gotten the same results testing it without any other mods except these two, and also tried using the commented out devil's tongue, which seems to make no difference for me. If you want me to do any tests let me know. 
#7
Thanks!
#8
Is there a way to prevent raiders from spawning with a weapon you create on a mod?