Patching a leather to no longer be "leathery"

Started by Lime_time, October 10, 2020, 09:11:54 PM

Previous topic - Next topic

Lime_time

So I'm trying to remove dog leather from the game entirely. While just flat out removing it via xml xpath works for me and my mods, it doesn't work for other mods.

So far, I've think I've got it where it doesn't appear in traders:

    <tradeability>Sellable</tradeability>


But now I want it to not appear in raider's clothings. I saw some people talking about injections, but my C# isn't quite up to par so I'm hoping XML can do it.

  <ThingDef ParentName="LeatherBase">
    <defName>Leather_Dog</defName>
    <label>generic leather</label>
    <description>This shouldn't be popping up, but if it does...</description>
    <graphicData>
      <color>(209,168,39)</color>
    </graphicData>
    <thingCategories>
      <li>Leathers</li>
    </thingCategories>
    <statBases>
      <MarketValue>2.0</MarketValue>
      <StuffPower_Insulation_Cold>14</StuffPower_Insulation_Cold>
    </statBases>
      <stuffProps>
      <categories>
        <li>Leathery</li>
      </categories>
      <commonality>0.025</commonality>
      <statFactors>
        <MaxHitPoints>1.3</MaxHitPoints>
      </statFactors>
    </stuffProps>
    <tradeability>Sellable</tradeability>
  </ThingDef>


The important bits, as far as I can see, are the stuffProps/categories and thingCategories. I tried just flat out removing both of those via patch, but that threw error messages. I then tried to overwrite Leather_Dog with those two categories blank, and that didn't work.

Any help would be much appreciated! I looked through the forums and didn't quite see how to fix this.

RawCode

kay, what will happen when player try to butcher dog?

Lime_time

It drops another type of leather, which was done via patch.

Canute

Lime,
while browsing through the Mods for a new list i notice
Optimized Leather
https://steamcommunity.com/sharedfiles/filedetails/?id=2252798130
Maybe you can analyse that mod and get some idea's for yours.

Lime_time

That's my mod.  :'(

Just trying to patch some things up for it so it won't throw error messages when people are running random mods I haven't patched for.

Canute

If you got knowledge of C#, can't you made a recursive code to scan all active leather def's and patch/change them at your way ?
So you don't need to made patches for each new leather type a mod may add.
So far i remember is that what the author of "Too many leathers" did.

Lime_time

Unfortunately my C# is very basic, so I'm looking for either an XML workaround or a good C# tutorial. 😂 I've been slowly learning C#, but rimworld is like jumping into the deep end when I've just learned to swim.

RawCode

not leather def, you must walk "race" def first, if you just remove random leather def your game will crash

Lime_time

I'm afraid I don't understand what you mean by "walk 'race' def first".

The game does not crash if you remove leather defs. I've removed several leathers on several occasions with zero issues (depending on your other mods, of course). You can successfully remove leather defs without the game throwing error messages, so long as you patch the animals to drop something else.

That being said, it WILL throw error messages with other mods (for example, Vanilla Expanded Factions - Vikings adds in a dog and a cow) if you've removed a core leather that the mod then uses. This is what I'm trying to avoid by removing the "leathery" quality from a leather so that it won't spawn in clothing, so I don't have to flat out remove it from the game. :)

Canute

I think your need to add at the about.xml that your mod is loaded after that mod.
Then you need to patch the mod animal to drop your leather.

Lime_time

I already do that (the mod in question is Optimized Leather by Trublucaribou on Steam). I am trying to create a work around in XML so that I don't have to remove dog leather from the game.

I want to hide it.

I have figured out how to get sellers to not sell it as plain dog leather, but it spawns in clothing. I want to see how to remove it from being leathery as the title says, so that it won't appear in clothing on raiders. I tried removing the node from it a few different ways, but it didn't work. That's what I'm stuck on.

RawCode

you should open apparel generator and check how exactly it pick stuff components and
A) work around by setting fields that actually have effect without "guessing"
B) change apparel generator code to suit your needs
optional) change butcher code, animal card and other classes in way that will allow only "white listed" leather to appear, replacing other leather types with something "related"

you can make something similar with XML only, but this is hard way and comparable to driving nails with iPhone, possible but slow and painful (and you will feel regret)

Cozarkian

See the ParentName="LeatherBase"? Let's look at that def:


  <ThingDef Abstract="True" Name="LeatherBase" ParentName="ResourceBase">
    <description>Tanned, dried, scraped skin. A good traditional material for making clothes and bags.</description>
    <graphicData>
      <texPath>Things/Item/Resource/Leather</texPath>
      <graphicClass>Graphic_StackCount</graphicClass>
    </graphicData>
    <statBases>
      <MaxHitPoints>60</MaxHitPoints>
      <DeteriorationRate>2</DeteriorationRate>
      <Mass>0.03</Mass>
      <Flammability>1</Flammability>
      <MarketValue>2.1</MarketValue>
      <StuffPower_Armor_Sharp>0.81</StuffPower_Armor_Sharp>
      <StuffPower_Armor_Blunt>0.24</StuffPower_Armor_Blunt>
      <StuffPower_Armor_Heat>1.5</StuffPower_Armor_Heat>
      <StuffPower_Insulation_Cold>16</StuffPower_Insulation_Cold>
      <StuffPower_Insulation_Heat>16</StuffPower_Insulation_Heat>
    </statBases>
    <thingCategories>
      <li>Leathers</li>
    </thingCategories>
    <burnableByRecipe>true</burnableByRecipe>
    <healthAffectsPrice>false</healthAffectsPrice>
    <minRewardCount>30</minRewardCount>
    <stuffProps>
      <categories>
        <li>Leathery</li>
      </categories>
      <commonality>0.025</commonality>
      <statFactors>
        <MaxHitPoints>1.3</MaxHitPoints>
      </statFactors>
    </stuffProps>
  </ThingDef>


Notice that the vanilla Leather Base has a thingCategories list. The fact it is a list is key. Non-list nodes are overwritten by a child, but list nodes ar additive, so when you give dog leather an empty thingCategories list, it still has the inherited thingCategories of its parent. You can stop the inheritance by giving dog leather the following:

<thingCategories Inherit="False"></thingCategories>


Alternatively, remove the ParentName so there is nothing to inherit from.