Ludeon Forums

RimWorld => Mods => Help => Topic started by: CombinedAutism on March 10, 2019, 08:21:24 AM

Title: Can't modify abstract class? (XML)
Post by: CombinedAutism on March 10, 2019, 08:21:24 AM
Hello, I have two questions:

1. I tried to modify the abstract TerrainDef FloorBase with the following xml patch to add pathCost to it.

<?xml version="1.0" encoding="utf-8"?>
<Patch>
   <Operation Class="PatchOperationAdd">
      <xpath>*/Defs/TerrrainDef[@Name="FloorBase"]</xpath>
      <value>
         <pathCost>3</pathCost>                     
      </value>
   </Operation>   
</Patch>

Though when I load the mod it says "Verse.PatchOperationAdd failed file [name of my xml file]. Editing the Floorbase manually and adding the pathCost this way does not return such an error and correctly reduces movement speed for all floors.


2. Is there any way you can INCREASE Movement Speed on certain terrain to over 100%? Setting pathCost to a decimal<1 does not work. That was the original point of the tweak
Title: Re: Can't modify abstract class? (XML)
Post by: Kirby23590 on March 10, 2019, 08:39:56 AM
I don't know if this one will work since i never used that.

Try PatchOperationAttributeSet (https://rimworldwiki.com/wiki/Modding_Tutorials/PatchOperations#PatchOperationAttributeSet) but it's more in the much more advanced side, since i didn't try it.

Title: Re: Can't modify abstract class? (XML)
Post by: CombinedAutism on March 10, 2019, 09:42:17 AM
I dont think what I want to modify is an attribute. I think you would call it adding a node which is different.
Title: Re: Can't modify abstract class? (XML)
Post by: Kirby23590 on March 10, 2019, 11:12:31 AM
Well it's hard to modify the abstract class. And there is no better way than replacing the entire base.

Even by looking at it, i don't have enough skill to do it, so you're better off modifying or replacing the entire FloorBase...

Unless there is a better modder out there that can really help you, since i lack the knowledge of replacing the abstract class via patching...
Title: Re: Can't modify abstract class? (XML)
Post by: CombinedAutism on March 10, 2019, 12:20:36 PM
Im just very surprised because in the patching tutorials it says to just an @ in front of the name and that is it.
Title: Re: Can't modify abstract class? (XML)
Post by: Mehni on March 10, 2019, 12:25:40 PM
Quote from: CombinedAutism on March 10, 2019, 08:21:24 AM
1. I tried to modify the abstract TerrainDef FloorBase with the following xml patch to add pathCost to it.

<xpath>Defs/TerrrainDef[@Name="FloorBase"]</xpath>

You had */Defs.

Quote from: CombinedAutism on March 10, 2019, 08:21:24 AM
2. Is there any way you can INCREASE Movement Speed on certain terrain to over 100%? Setting pathCost to a decimal<1 does not work. That was the original point of the tweak

At a quick glance, not with just XML.
Title: Re: Can't modify abstract class? (XML)
Post by: CombinedAutism on March 10, 2019, 01:05:44 PM
I tried with and without *. Both give the same error: "Failed file"
Title: Re: Can't modify abstract class? (XML)
Post by: LWM on March 11, 2019, 07:32:24 PM
Can you try as Mehni suggested and post your entire xml file?

(Off topic slightly) By the way, Mehni, /Defs/... is **slightly** faster than Defs/...  The difference is tiny, tho.

--LWM
Title: Re: Can't modify abstract class? (XML)
Post by: CombinedAutism on March 11, 2019, 10:17:39 PM
What do you mean by entire xml file? That was all of the xml, I just tried to modify the Floor Base for starters. Tried with /Defs, Defs, */Defs, all fail to Patch this abstract class.
Title: Re: Can't modify abstract class? (XML)
Post by: LWM on March 11, 2019, 10:34:18 PM
Well, as written, it won't work.  It's easier to double check something if we can see exactly what you put in.
Title: Re: Can't modify abstract class? (XML)
Post by: Kirby23590 on March 12, 2019, 12:31:28 PM
When he mean't entire xml file.

He meant entire the code of your patch... Otherwise we don't know what's the problem...
Title: Re: Can't modify abstract class? (XML)
Post by: CombinedAutism on March 12, 2019, 12:53:42 PM
That is the entire code so far. That's why I'm surprised that such a supposedly simple opration returns an error
Title: Re: Can't modify abstract class? (XML)
Post by: Kirby23590 on March 12, 2019, 01:12:09 PM

Maybe try this code...


<?xml version="1.0" encoding="utf-8"?>
<Patch>
   <Operation Class="PatchOperationSequence">
<success>Always</success>
<operations>

<li Class="PatchOperationSequence">
    <success>Always</success>
    <operations>
        <li Class="PatchOperationAdd">
        <xpath>Defs/TerrrainDef[@Name="FloorBase"]</xpath>
                        <value>
                                      <pathCost>3</pathCost>                     
                                </value>
        </li>
    </operations>
</li>

</operations>
</Operation>
</Patch>


Most my Patch Mods follow this, from following some Xpath Tutorials out there...

Will it still throw an error?
Title: Re: Can't modify abstract class? (XML)
Post by: CombinedAutism on March 12, 2019, 04:35:05 PM
F... me. While I was checking what might have been different in your code I noticed you misspelled TerrainDef with 3 r's. Then I noticed that I misspelled Terrain in the original post. Barely noticable lol...
I guess the mystery is solved, thanks for helping everybody  :-X
Title: Re: Can't modify abstract class? (XML)
Post by: Kirby23590 on March 12, 2019, 05:37:04 PM
Oh..... Ywoch...

Wow... I didn't notice that since i kinda copy and pasted your post, to show of the other way if would work...

How didn't we not notice that typo... :P
Title: Re: Can't modify abstract class? (XML)
Post by: CombinedAutism on March 12, 2019, 06:00:19 PM
rrr is just very hard to separate by the eye I guess /shrug.