Ludeon Forums

RimWorld => Mods => Topic started by: Bud8013 on November 17, 2021, 10:24:51 PM

Title: Patching a New Smithy
Post by: Bud8013 on November 17, 2021, 10:24:51 PM
Hello, first post on the forums.

Trying to create a new Smithy that runs on a different material however doesn't show the any recipes to smith. I tried both adding recipes through the Smithy <Recipes> like the Stoves <Recipes> and also patching items from their <RecipeMaker> <RecipeUser> section.

The only item that works is the Simple Helmet. All the rest of the armors and weapons use a ParentName such as <ArmorSmithableBase> and bring up the Patching Failed error.

Does anyone know how to patch Armors and Weapons that use base <RecipeMaker> like <ArmorSmithableBase> to add to the workbench.

Here is the patch I have for it:

<Operation Class="PatchOperationAdd">
   <order>Append</order>
   <xpath>Defs/ThingDef[defName = "ArmorSmithableBase"]/recipeMaker/recipeUsers</xpath>           
   <value>
      <li>MW_PoweredSmithy</li>
   </value>
</Operation>


I don't know why only the Simple Helmet works using this process. I can only guess it's due to it having a dedicated <RecipeMaker> section. Any help would be great.
Title: Re: Patching a New Smithy
Post by: cory3573 on November 18, 2021, 11:12:13 AM
Did some quick poking around not everything consistently uses either method. I made some of my own defs and patches and any time I added a new recipe that wasn't linked to a parent object, it got it's own
<recipeUsers>
  <li>FabricationBench</li>
</recipeUsers>

Otherwise one or more of the parent objects will all need a recipeUsers entry, make sure you hop all the way up the parent chain and confirm you don't need to patch your bench in. I also noticed, a few items are no inherit and applied directly to a bench, for example <ThingDef Name="ApparelArmorReconBase" ParentName="ArmorMachineableBase" Abstract="True"> within the Apparel_Various has it's own override
      <recipeUsers Inherit="False">
        <li>FabricationBench</li>
      </recipeUsers>

You could painstakingly try and add an override to all the armor, weapon, and bases pointing to your new workbench
Title: Re: Patching a New Smithy
Post by: Bud8013 on November 18, 2021, 04:40:12 PM
Thank you for the reply,

If you try to override the existing code through the Core.xml files directly ( Like a existing defThing like Apparel_PlateArmor ) rather then patch them, if any other mods using that same Defs file and item, it would bring up many errors due to conflicting files.

I am trying to figure out how to patch items that are smithable to work with my new workbench. Like I said, I used the same exact patching as stated above for getting the Simple Helmet to appear and it works, however, other items using a parentName don't due to the way that it is arranged.

I'm fine with patching each individual item to work with it for my mod but I don't know the "how" of it, like getting the Plate Armor or Knifes and Clubs to appear.
Title: Re: Patching a New Smithy
Post by: cory3573 on November 18, 2021, 09:00:21 PM
Agreed touching existing files is a no go. The third code stack I presented works great I used this one to fix my missing surgeries

<recipeUsers>
  <li>Human</li>
</recipeUsers>

I took a look at the plate armor, knives and clubs and came up with a patch snippet for you. Let me know if it works

<Operation Class="PatchOperationSequence">
<operations>
<li Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[@Name="BaseMeleeWeapon"]/recipeMaker/recipeUser</xpath>
<value><li>YourNewSmithy</li></value>
</li>
<li Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[@Name="ArmorSmithableBase"]/recipeMaker/recipeUser</xpath>
<value><li>YourNewSmithy</li></value>
</li>
</operations>
</Operation>
Title: Re: Patching a New Smithy
Post by: Bud8013 on November 18, 2021, 11:32:48 PM
Thank you for the help however I tried to insert it the best I could, however it brings up this error

Patch operation Verse.PatchOperationSequence
(count=2,lastFailedOperation=Verse.PatchOperationAdd
(/Defs/ThingDef[@Name="BaseMeleeWeapon"]/recipeMaker/recipeUser)) failed


It seems it just get stuck trying to figure out what it wants to do. I even modified the old patch I used a little to try to work it but even still it displays a error.
Title: Re: Patching a New Smithy
Post by: cory3573 on November 19, 2021, 09:51:23 AM
My bad actually, change all the recipeUser to recipeUsers it's been little mistakes like this every time
Title: Re: Patching a New Smithy
Post by: Bud8013 on November 19, 2021, 11:52:55 AM
I never realized it was <RecipeUser> not <RecipeUsers>, even when I was altering and changing the original patch. Sometimes XML can be a pain when you don't get it exact.

Thank you, it works exactly how I hoped.
Title: Re: Patching a New Smithy
Post by: Canute on November 19, 2021, 11:56:37 AM
Maybe try following websearch
"xml validator notepad++"
Title: Re: Patching a New Smithy
Post by: cory3573 on November 19, 2021, 12:41:59 PM
Agree with Canute, I was using this tool to locate my XML paths https://xmltoolbox.appspot.com/xpath_generator.html (https://xmltoolbox.appspot.com/xpath_generator.html)
If anything doesnt have a defName use @Name from the main def or point at another node. Make sure to replace any numbers with identifiable nodes. Glad you got it figured out
Title: Re: Patching a New Smithy
Post by: cory3573 on November 20, 2021, 02:22:33 AM
Quick update for you or anyone else who finds this thread!
If you make a new workbench you have to patch the work giver defs to include your new bench.
The location is */Core/Defs/WorkGiverDefs/WorkGivers.xml
Locate your associated worktype (DoBillsMakeWeapons,DoBillsMachiningTable,DoBillsCook,etc...) and insert your bench into the fixedBillGiverDefs list.
This is my snippet I used for my automated stove.

<li Class="PatchOperationAdd">
<xpath>/Defs/WorkGiverDef[defName="DoBillsCook"]/fixedBillGiverDefs</xpath>
<value><li>AutomatedElectricStove</li></value>
</li>
<li Class="PatchOperationAdd">
<xpath>/Defs/WorkGiverDef[defName="DoBillsBrew"]/fixedBillGiverDefs</xpath>
<value><li>AutomatedElectricStove</li></value>
</li>