Need help adding a surgery

Started by TranslucenceY, December 17, 2018, 11:02:58 PM

Previous topic - Next topic

TranslucenceY

I am working on a mod that will allow you to extract a brain from a pawn, and in turn uses that brain to construct a device to boost research speed.

I have been digging through, but I haven't been able to figure out how to add in the surgery for brain removal.

I think I have everything else set up, but any help I can get would be much appreciated!

Mehni

I'll assume you already have a recipe to extract the brain, and that your issue is that your recipe isn't showing up on the pawn.

Add your RecipeDef to the <recipes> list of the Human def using xpath, or add the Human to the recipeUsers of your RecipeDef.

TranslucenceY

#2
I have that added near the top, but it still doesn't seem to want to show as an option under the surgery bills. Here is what I have put together so far under the RecipeDef:

<?xml version="1.0" encoding="utf-8" ?>
<Defs>

<RecipeDef Name="SurgeryNatural" ParentName="SurgeryFlesh" Abstract="True">
<surgerySuccessChanceFactor>0.8</surgerySuccessChanceFactor>
<deathOnFailedSurgeryChance>0.3</deathOnFailedSurgeryChance>
<recipeUsers>
<li>Human</li>
</recipeUsers>
</RecipeDef>

  <RecipeDef ParentName="SurgeryFlesh">
    <defName>HarvestBrain</defName>
    <label>Harvest brain</label>
    <description>Remove the brain.</description>
    <workerClass>Recipe_InstallNaturalBodyPart</workerClass>
    <jobString>Harvesting brain.</jobString>
    <workAmount>4000</workAmount>
    <deathOnFailedSurgeryChance>1</deathOnFailedSurgeryChance>
    <skillRequirements>
      <Medicine>8</Medicine>
    </skillRequirements>
    <ingredients>
      <li>
        <filter>
          <categories>
            <li>Medicine</li>
          </categories>
        </filter>
        <count>1</count>
      </li>
    </ingredients>
    <fixedIngredientFilter>
      <categories>
        <li>Medicine</li>
      </categories>
      <thingDefs>
        <li>Brain</li>
      </thingDefs>
    </fixedIngredientFilter>
    <appliedOnFixedBodyParts>
      <li>Brain</li>
    </appliedOnFixedBodyParts>
  </RecipeDef>

</Defs>

Mehni


<RecipeDef Name="SurgeryNatural" ParentName="SurgeryFlesh" Abstract="True">
  <RecipeDef ParentName="SurgeryFlesh">


I see you define a new parent.

Try actually using it as well.

TranslucenceY

That is a result of me cutting and pasting from another mod that does something similar while trying to understand how pieces fit together.
since I don't end up using the new parent, and to avoid complicating things I'll have it removed.

I have the recipeUsers moved over to be under the recipe for harvest brain, but still seems to be absent in game. Could there be something else I am missing?

Mehni

any errors in game?

The alternative I have for you is in my first post here: Add your RecipeDef to the <recipes> list of the Human thingdef using xpath.

TranslucenceY

No errors, even when I set up a patch for xpath:

<?xml version="1.0" encoding="utf-8" ?>
<Patch>
<Operation Class="PatchOperationSequence">
<success>Always</success>
<operations>
<li Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[defName = "Human"]/recipes</xpath>
<value>
<li>HarvestBrain</li>
</value>
</li>
<li Class="PatchOperationAdd">
<xpath>*/ThingDef[defName = "HiTechResearchBench"]/comps/li[@Class="CompProperties_AffectedByFacilities"]/linkableFacilities</xpath>
<value>
<li>BrainInAJar</li>
</value>
</li>
</operations>
</Operation>
</Patch>


There might be something else I am missing, but I am at a loss.

TranslucenceY

I found the issue! Works like a charm.
All I needed to do was xpath into the brain and add a spawnthingonremoved for it to work, since that part does not have it in the first place:

<li Class="PatchOperationAdd">
<xpath>/Defs/BodyPartDef[defName = "Brain"]</xpath>
<value>
<spawnThingOnRemoved>Brain</spawnThingOnRemoved>
</value>
</li>