Xpath not working

Started by Deathawaits4, March 10, 2018, 02:41:14 PM

Previous topic - Next topic

Deathawaits4

I read every guide, i tried a 1000 things and nothing worked. I am trying to replace some stuff from the orassans mod but it wont work no matter what i try. It works with the vanilla items but not with mod things.

this is my test xpath:

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

<Patch>
<Operation Class="PatchOperationReplace">
     <xpath>/Defs/HediffDef[defName = "PlasteelClaws"]/comps/li/verbs/li/meleeDamageBaseAmount</xpath>
     <value>
      <meleeDamageBaseAmount>500</meleeDamageBaseAmount>
     </value>
</Operation>
</Patch>

If i test the xpath online it shows the right value, but if i go ingame its like i did nothing what so ever. Damage didnt change nothing. And i just cant figure out what in the world is wrong.

I tried changing the line to: <xpath>/Defs/Hediffs/HediffDef[defName = "PlasteelClaws"]/comps/li/verbs/li/meleeDamageBaseAmount</xpath>

But it didnt work either. Someone notice the error? also my console doesnt throw any errors.

ilikegoodfood

I don't know anything about the Orassans mod, so I can't say if it's something specific to that, but every Harmony patch that I've seen, and I've seen a fair few by now, places the Patch Operations inside a PatchOperationSequence.

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

<Patch>
<Operation Class="PatchOperationSequence">
<success>Always</success>
<operations>
<li Class="PatchOperationReplace">
<xpath>/Defs/HediffDef[defName = "PlasteelClaws"]/comps/li/verbs/li/meleeDamageBaseAmount</xpath>
<value>
<meleeDamageBaseAmount>500</meleeDamageBaseAmount>
</value>
</li>
</operations>
</Operation>
</Patch>


It may not have anything to do with that, but everything else looks correct to me.
Other than obvious things that you'll have already done, like triple checking the defName, making sure that it uses a defName instead of a Name="" and such, there aren't many things that could be causing the problem...

Does your Patch target more than one file?
If it does, then they'll need to be separated into distinct sub-sequences. Also, if you are using a ModCheck.FindFile, it limits the following operations to only search the contents of that file, thus if it's targeting a different file, it won't work at all.

I've also read that targeting List items, <li>, can cause issues if there are multiple ones, but since that is an added body part hediff it should only have the one anyway.

I wish I could be more helpful, but I'm also very new to this.
It may help to look at the Patch files of a mod that uses a lot of them, such as CombatExtended, but be sure to use a few different sources because not everyone updates their patches or mod methods when new features are implemented.

Deathawaits4

I figured it out, after hours.. im so stupid. instead of calling my folder "Patches", i called it "Patch". It took me so long to realize that. Im not using the sequenc, since it is only a replacement.. it shouldn't be needed.

jamaicancastle

Quote from: ilikegoodfood on March 10, 2018, 04:57:46 PM
every Harmony patch that I've seen, and I've seen a fair few by now, places the Patch Operations inside a PatchOperationSequence.
Two things: first, xpath patches and Harmony patches are totally different things. Harmony patches are in C# code. Just putting that out there before anyone gets confused.
Second, don't put your patches in a sequence like that, at least not initially. What the "success" does is artificially suppress any error messages that might arise. That can make it look nicer to the end user, but it also prevents you from being able to troubleshoot problems in your xpath as easily.