Survival Meal is "Fine Meal"

Started by TiberianSun371AlexW, September 24, 2018, 09:55:01 AM

Previous topic - Next topic

TiberianSun371AlexW

I was trying to make a simple mod to make packaged survival meals count as "fine meals" for the mood modifier.

I don't know how to do the "code" thing that is on the forums

Anyways, the relevant set of code is this
<ThoughtDef>
    <defName>AteFineMeal</defName>
    <durationDays>1</durationDays>
    <stages>
      <li>
        <label>ate fine meal</label>
        <description>I ate a really tasty fine meal. Yum!</description>
        <baseMoodEffect>5</baseMoodEffect>
      </li>
    </stages>
  </ThoughtDef>

So first I go into C:\Program Files (x86)\Steam\steamapps\common\RimWorld
In the mods folder I create a new folder. I went with "tasty_survival"
Then I create an about xml starting with the line

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

I don't know what this line is for BTW.

So then I make a new sub folder which needs to be called ThingDefs
Then inside tasty_survival/ThingDefs, I need to create an xml file called Patch_Thoughs_Memory_Eating

Then is the xml patching.

So the xml file would have no prefix like
<?xml version="1.0" encoding="utf-8"?>
Which is apparently only used for the about xml.

The contents of the original file Thoughts_Memory_Eating is
<ThoughtDef>
    <defName>AteFineMeal</defName>
    <durationDays>1</durationDays>
    <stages>
      <li>
        <label>ate fine meal</label>
        <description>I ate a really tasty fine meal. Yum!</description>
        <baseMoodEffect>5</baseMoodEffect>
      </li>
    </stages>
  </ThoughtDef>

So my patch Patch_Thoughs_Memory_Eating.xml should be
<Patch>
   <Operation Class="PatchOperationReplace">
       <xpath>/ThingDefs/ThingDef[defName = "AteFineMeal"]/stages/li/label</xpath>
       <value>
                <label>ate fine meal OR packaged survival meal</label>
       </value>
   </Operation>
</Patch>

Patch Opeartion replace tells Rimworld to override.
In xml path, thingdefs is... I don't know actually. Shouldn't it be "thoguhtdefs"?
defname= "AteFineMeal" because that is the def name of the original file.
Stages is a subnode of AteFineMeal
li is a subnode of Stages
label is the target node

<value> is defining what patch operation replace does.

"ate fine meal OR packaged survival meal" allows packaged survival meals to count as "fine"

</value> tells Rimwrold this is the end of the replacement.
</Operation> tells Rimworld this is the end of the operation
</Patch> tells Rimworld this is the end of the patch.

I feel like I'm missing something important.