Patching a modded trader for another mod

Started by Ink., October 12, 2020, 05:56:23 PM

Previous topic - Next topic

Ink.

Okay, so I'm having an issue trying to get a patch working for another mod integration with mine. What my mod does is adds a market value to the ships of the SRTS Expanded mod and then introduces a new trader that sells those ships. That works flawlessly.

But now others would like a patch that supports other add-ons that add more ships to SRTS, and to work with mine as well. And that's where I'm having issue. I'm trying to figure out how I can do the same to that mod as I do to mine. I've had success in patching the market value of the add-on ships mod, but I cannot figure out how I then patch my own mod to include those ships in the trader IF the add-on mod is installed.

The following xml is the best I've come up with but fails with the error:

Quote[SRTS Expanded: Trader Ships] Patch operation Verse.PatchOperationFindMod([RWY]SRTS Expanded: The Crimson Fleet) failed
file: C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\SRTS Trader Ships\Patches\Patch_CrimsonFleet.xml

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

<!-- Potentially patching the value of all ships * 2 -->
<Patch>

<Operation Class="PatchOperationFindMod">
<mods>
<li>[RWY]SRTS Expanded: The Crimson Fleet</li>
</mods>
<match Class="PatchOperationSequence">
<success>Normal</success>
<operations>
<li Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[defName="TCFSurveyor"]/statBases</xpath>
<value>
<MarketValue>11274</MarketValue>
</value>
</li>

<li Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[defName="TCFComet"]/statBases</xpath>
<value>
<MarketValue>17130</MarketValue>
</value>
</li>

<li Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[defName="TCFCourier"]/statBases</xpath>
<value>
<MarketValue>18908</MarketValue>
</value>
</li>

<li Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[defName="TCFBasilisk"]/statBases</xpath>
<value>
<MarketValue>32620</MarketValue>
</value>
</li>

<li Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[defName="TCFTitan"]/statBases</xpath>
<value>
<MarketValue>48560</MarketValue>
</value>
</li>

<li Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[defName="TCFAurora"]/statBases</xpath>
<value>
<MarketValue>178200</MarketValue>
</value>
</li>

<li Class="PatchOperationFindMod">
<mods>
<li>SRTS Expanded: Trader Ships</li>
</mods>

<match Class="PatchOperationSequence">
<success>Normal</success>
<operations>
<li Class="PatchOperationAdd">
<xpath>/Defs/TraderKindDef[defName="SRTSSHIPTrader"]/stockGenerators</xpath>
<value>
<li><li Class="StockGenerator_SingleDef">
<thingDef>TCFSurveyor</thingDef>
<countRange>1~3</countRange>
</li></li>
</value>
</li>

<li Class="PatchOperationAdd">
<xpath>/Defs/TraderKindDef[defName="SRTSSHIPTrader"]/stockGenerators</xpath>
<value>
<li><li Class="StockGenerator_SingleDef">
<thingDef>TCFComet</thingDef>
<countRange>1~3</countRange>
</li></li>
</value>
</li>

<li Class="PatchOperationAdd">
<xpath>/Defs/TraderKindDef[defName="SRTSSHIPTrader"]/stockGenerators</xpath>
<value>
<li><li Class="StockGenerator_SingleDef">
<thingDef>TCFCourier</thingDef>
<countRange>1~3</countRange>
</li></li>
</value>
</li>

<li Class="PatchOperationAdd">
<xpath>/Defs/TraderKindDef[defName="SRTSSHIPTrader"]/stockGenerators</xpath>
<value>
<li><li Class="StockGenerator_SingleDef">
<thingDef>TCFBasilisk</thingDef>
<countRange>1~3</countRange>
</li></li>
</value>
</li>

<li Class="PatchOperationAdd">
<xpath>/Defs/TraderKindDef[defName="SRTSSHIPTrader"]/stockGenerators</xpath>
<value>
<li><li Class="StockGenerator_SingleDef">
<thingDef>TCFTitan</thingDef>
<countRange>1~3</countRange>
</li></li>
</value>
</li>

<li Class="PatchOperationAdd">
<xpath>/Defs/TraderKindDef[defName="SRTSSHIPTrader"]/stockGenerators</xpath>
<value>
<li><li Class="StockGenerator_SingleDef">
<thingDef>TCFAurora</thingDef>
<countRange>1~3</countRange>
</li></li>
</value>
</li>

</operations>
</match>

</li>
</operations>
</match>
</Operation>

</Patch>


I don't have immense experience with patching so I'm a bit confused about what's happening. Any info you can provide would be greatly appreciated and help my understanding of the patching process. Thank you.

RawCode

what about trying to patch ONE thing at time?

it's always fun and "effective" to pack everything into single patch and ask on forum, but...

Ink.

Quote from: RawCode on October 12, 2020, 05:58:45 PM
what about trying to patch ONE thing at time?

it's always fun and "effective" to pack everything into single patch and ask on forum, but...

Right, that makes sense. From there, my question simply narrows down to how I can get the patch for adding the add-on ships to my trader to only add them if that mod is active. So far, I've tried to nest a findmod operation within to do this, based on an example on rimworld wiki, but I get the same error as above.

So I'm struggling to find out where I'm misunderstanding my process.

LWM

Look at the PatchOperations page in the wiki (http://rimworldwiki.com/) - you want the PatchOperationFindMod (I think)