Replacing Textures for Prosthetics

Started by jabbamonkey, April 15, 2021, 01:26:57 PM

Previous topic - Next topic

jabbamonkey

I've been using the "Expanded Prosthetics and Organ Engineering" mod...
https://steamcommunity.com/sharedfiles/filedetails/?id=725956940

The mod shows a single graphic for all the prosthetics (a box image). I wanted to update the graphics with my own mod, so each prosthetics has their own graphic. I've been able to do this successfully for most of the images... but am having trouble with a few items...

See example here: http://www.amazingdg.com/_client/rimworld/med.jpg

I've replaced the images for many of the items (i.e. adv bionic leg, bionic ear, mutant leg, mutant arm, mutant eye, artificial clavicle). But, for some reason, I can't change the textures/images for any of the Archotech items (the microchip in the image above)...



Here is the code that I used for all of the other medical items (replacing the defName for each object), but it doesn't work for the archotech items.

<li Class="patchOperationAdd">
<success>Always</success>
<xpath>Defs/ThingDef[defName = "PegLeg"]</xpath>
<value>
<graphicData>
<texPath>Things/Item/BodyPart/PegLeg</texPath>
<graphicClass>Graphic_Single</graphicClass>
<drawSize>0.80</drawSize>
</graphicData>
</value>
</li>


I've also tried this code (and this didn't work either) ...

      <li Class="patchOperationReplace">
<success>Always</success>
<xpath>Defs/ThingDef[defName = "ArchotechEar"]/graphicData/texPath</xpath>
<value>
<texPath>Things/Item/BodyPart/ArchotechEar</texPath>
</value>
</li>


Any help?



I don't know XML too well... but I think (maybe) it might have to do with the "ParentName" ... Below is from the Mod, where they classify the group/parent, and designate the MAIN graphic. Then they designate the individual items...

<ThingDef Name="ArchotechBase" ParentName="BodyPartModBase" Abstract="True">
    <graphicData>
      <texPath>Things/Item/BodyPart/Bionic2</texPath>
      <graphicClass>Graphic_Single</graphicClass>
      <drawSize>0.90</drawSize>
    </graphicData>
    <thingCategories>
      <li>AdvancedProstheses</li>
    </thingCategories>
  </ThingDef>

  <ThingDef ParentName="ArchotechBase">
    <defName>ArchotechEye</defName>
    <label>archotech eye</label>
    <description>An artifical eye...</description>
    <techLevel>Archotech</techLevel>
    <thingSetMakerTags>
      <li>RewardSpecial</li>
    </thingSetMakerTags>
    <statBases>
      <MarketValue>3100</MarketValue>
      <Mass>0.3</Mass>
    </statBases>
  </ThingDef>

Shinzy

Oh hi Jabba! glad yo see you're still alive! :D

Anyhow, you're right about the parent being the problem here
what you can do is a patch sequence like this one (from my own mod)
<Operation Class="PatchOperationSequence">

<success>Always</success>
<operations>
<li Class="PatchOperationTest">
<xpath>/Defs/ResearchProjectDef[defName = "ComplexClothing"]/tab</xpath>
<success>Invert</success>
</li>

<li Class="PatchOperationRemove">
<xpath>/Defs/ResearchProjectDef[defName = "ComplexClothing"]/researchViewY</xpath>
</li>

<li Class="PatchOperationReplace">
<xpath>/Defs/ResearchProjectDef[defName = "ComplexClothing"]/researchViewX</xpath>
<value>
<researchViewX>0</researchViewX>
<researchViewY>0</researchViewY>
<tab>ApparelTab</tab>
</value>
</li>
</operations>
</Operation>


just to explain the first part of the sequence,
PatchOperationTest bit checks if the thing you're looking for can even be found (as it could be removed by another mod, which is unlikely) so you could skip that bit

So with the Remove operation you'd have to remove just the tex path from 'Archotec base'

and with Replace operation add the texpath in the bodypart def
BUT you'll also need to add the graphic data tags with it, cause it doesn't have one yet. something like this
<li Class="patchOperationReplace">
<xpath>Defs/ThingDef[defName = "ArchotechEar"]</xpath>
<value>
    <graphicData>
                                          <texPath>Things/Item/BodyPart/Bionic2</texPath>
                                    </graphicData>
</value>
</li>


you should also chain all the other archotec bodyparts in the same sequence (cause you've removed the base) I'm pretty sure you can do this by just adding more replace operations after the first one within the sequence operation

jabbamonkey

Yeah, the game versions kept changing, so I found it hard to keep up with updating the mods... and took a break for awhile.

But, back to the problem.....
As I mentioned, my XML knowledge is VERY limited. I got the following error (with the code I tried below):

Quote
XML error: <value><graphicData><texPath>Things/Item/BodyPart/Bionic2</texPath></graphicData></value> doesn't correspond to any field in type PatchOperationRemove. Context: <li Class="PatchOperationRemove"><xpath>Defs/ThingDef[defName = "ArchotechBase"]</xpath><value><graphicData><texPath>Things/Item/BodyPart/Bionic2</texPath></graphicData></value></li>


[MyMod]Patch operation Verse.PatchOperationSequence(count=109, lastFailedOperation=Verse.PatchOperationTest(Defs/ThingDef[defName = "ArchotechBase"])) failed
file: D:\Games\Steam\steamapps\common\RimWorld\Mods\MyMod\Patches\MedPatches.xml

And here is the modified code (I'm sure there's some mistakes in there). I commented out what I THINK is going on, and what some possible issues could be...

<li Class="PatchOperationTest">
<xpath>Defs/ThingDef[defName = "ArchotechBase"]</xpath>
</li>
<!-- So, the above should check if it exists (if the xpath is correct). This appears to be where the error is .... See my notes below the code. -->
<li Class="PatchOperationRemove">
<xpath>Defs/ThingDef[defName = "ArchotechBase"]</xpath>
<value>
<graphicData>
<texPath>Things/Item/BodyPart/Bionic2</texPath>
</graphicData>
</value>
</li>
<!-- and this should remove the texture from the parent. Right?  I don't want to remove any of the other information from ArchotechBase because it might be important. -->
<li Class="patchOperationReplace">
<xpath>Defs/ThingDef[defName = "ArchotechEar"]</xpath>
<value>
  <graphicData>
                             <texPath>Things/Item/BodyPart/ArchotechEar</texPath>
                           </graphicData>
</value>
</li>
<!-- I think, since the base texture is removed now, this code should replace the texture for the individual item? correct? -->


So, I guess the first question... is the xpath correct?  The <ThingDef Name="ArchotechBase" ParentName="BodyPartModBase" Abstract="True"> tags are located in a file called Items_BodyParts_ArchoVanilla.xml.  So, does that mean the "xpath" is correct or not (not sure how to determine this ... I just know all of the other ThingDefs are in here)

Shinzy

I might've also not explained the whole thing with enough clarity to begin with!
here *should* be a working patch operation (I'm not 100% as I haven't touched patching in years)

I feel like you might understand it better if you have a working I hope example to look at :D

You'll just need to fill in the remaining body parts there or it'll likely complain about missing textures on startup
If there's any further problems let me know as It's possible I've overlooked something

<Operation Class="PatchOperationSequence">
<!--This one is the main operation that handles all the other ones nested within it's 'operations' in a single go-->
<success>Always</success>
<operations>

<li Class="PatchOperationTest">
<xpath>/Defs/ThingDef[defName = "ArchotechBase"]/graphicData/texPath</xpath>
<success>Invert</success>
</li>
<!--This one checks if tex path exists within ArchotechBase-->

<li Class="PatchOperationRemove">
<xpath>/Defs/ThingDef[defName = "ArchotechBase"]/graphicData/texPath</xpath>
</li>
<!-- This one removes it-->

<li Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[defName = "ArchotechEar"]</xpath>
<value>
<graphicData>
<texPath>Things/Item/BodyPart/ArchotechEar</texPath>
                    </graphicData>
</value>
</li>
<!--This one needed to be Add operation instead of replace like I instructed initially! my bad!-->

<li Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[defName = "OTHER ARCHOTECH BODY PART"]</xpath>
<value>
<graphicData>
<texPath>Things/Item/BodyPart/OTHER ARCHOTECH BODYPART TEXTURE</texPath>
                    </graphicData>
</value>
</li>
<!--Add all the bodyparts after eachother like this, make sure they're all within the 'operations' tags!-->
</operations>
</Operation>

jabbamonkey

I placed in all the code (and the extra lines for each item...). But, getting an error and the inidividual graphics still aren't showing up (just the default Bionics2 image). Looks like an error with REMOVING the ArchotechBase texPath....

Quote[Jabbamonkey's HIRES Graphic Overhaul] Patch operation Verse.PatchOperationSequence(count=108, lastFailedOperation=Verse.PatchOperationRemove(/Defs/ThingDef[defName = "ArchotechBase"]/graphicData/texPath)) failed


Canute


jabbamonkey

QuoteMy suggestion, try to look at
Body Parts Textures
https://steamcommunity.com/sharedfiles/filedetails/?id=2439038368
how he did the patches.

I tried that... getting an error using their code too....

Fakeaccount123

I´m not sure if we are talking about the same mod but the "ParentName" of archotech implants in Expanded Prosthetics and Organ Engineering is not ArchotechBase, is "Glitterworld". Which are specifically the implants/body parts you can´t patch?

jabbamonkey

Quote from: Fakeaccount123 on April 18, 2021, 08:16:50 PM
I´m not sure if we are talking about the same mod but the "ParentName" of archotech implants in Expanded Prosthetics and Organ Engineering is not ArchotechBase, is "Glitterworld". Which are specifically the implants/body parts you can´t patch?

Code in the mod states:
<ThingDef Name="ArchotechBase" ParentName="BodyPartModBase" Abstract="True">

Shinzy

I just had a look at the archotech bodypart defs and the defname for the base is 'BodyPartArchotechBase'
Also I couldn't spot an ArchotechEar at all, there only seems to be: ArchotechLeg, ArchotechArm and ArchotechEye

with any luck there isn't anything else wrong with the patch ;D

jabbamonkey

Crap ... was I looking at the wrong mod?  Grrrrrr....

So, ArchotechEar definitely exists in my game (when I create a stockpile, I have a whole list of Archotech items, including an ArchotechEar). 

Let's me try this again... So, I searched my RimWorld Workshop folder for xml patches containing "ArchotechEar" ... and the only mention of ArchotechEar that came up was from the mod "Save Our Ship 2" in the "1909914131/1.2/Defs/Misc/ArchotechGifts.xml" file. Here is that mention ...

<ArchotechGiftDef>
    <defName>ArchotechEar</defName>
<research>SoSArchotechOrgans</research>
<thing>SoSArchotechEar</thing>
  </ArchotechGiftDef>


That seems odd... because there is no other DEF information on ArchotechEar (no info on how the bionic part improves a pawn, surgery information, etc.). But, there are a TON of cs files. There are a few that mention "Archo" ... one called "QuestNode_GenerateThingSetArchotech.cs" which details individual Archotech items:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;

namespace RimWorld.QuestGen
{
    class QuestNode_GenerateThingSetArchotech : QuestNode
    {
public SlateRef<FloatRange?> totalMarketValueRange;

public SlateRef<QualityGenerator?> qualityGenerator;

protected override void RunInt()
        {
Slate slate = QuestGen.slate;
ThingSetMakerParams parms = default(ThingSetMakerParams);
parms.totalMarketValueRange = totalMarketValueRange.GetValue(slate);
parms.qualityGenerator = qualityGenerator.GetValue(slate);
parms.techLevel = TechLevel.Archotech;
ThingSetMaker maker = new ThingSetMaker_ArchotechGift();

List<Thing> list = maker.Generate(parms);
QuestPart_Choice choice = new QuestPart_Choice();
choice.choices = new List<QuestPart_Choice.Choice>();
QuestPart_Choice.Choice theChoice = new QuestPart_Choice.Choice();
Reward_Items items = new Reward_Items();
items.items = list;
theChoice.rewards.Add(items);
QuestPart_ArchotechSpawn spawn = new QuestPart_ArchotechSpawn();
spawn.mapParent = QuestGen.slate.Get<Map>("map").Parent;
spawn.Things = list;
spawn.quest = QuestGen.quest;
spawn.inSignal = slate.Get<string>("inSignal");
theChoice.questParts.Add(spawn);
QuestGen.quest.AddPart(spawn);
choice.choices.Add(theChoice);

list = maker.Generate(parms);
theChoice = new QuestPart_Choice.Choice();
items = new Reward_Items();
items.items = list;
theChoice.rewards.Add(items);
spawn = new QuestPart_ArchotechSpawn();
spawn.mapParent = QuestGen.slate.Get<Map>("map").Parent;
spawn.Things = list;
spawn.quest = QuestGen.quest;
spawn.inSignal = slate.Get<string>("inSignal");
theChoice.questParts.Add(spawn);
QuestGen.quest.AddPart(spawn);
choice.choices.Add(theChoice);

list = maker.Generate(parms);
theChoice = new QuestPart_Choice.Choice();
items = new Reward_Items();
items.items = list;
theChoice.rewards.Add(items);
spawn = new QuestPart_ArchotechSpawn();
spawn.mapParent = QuestGen.slate.Get<Map>("map").Parent;
spawn.Things = list;
spawn.quest = QuestGen.quest;
spawn.inSignal= slate.Get<string>("inSignal");
theChoice.questParts.Add(spawn);
QuestGen.quest.AddPart(spawn);
choice.choices.Add(theChoice);

QuestGen.quest.AddPart(choice);
choice.quest = QuestGen.quest;
}

        protected override bool TestRunInt(Slate slate)
        {
            return true;
        }
    }
}



I don't know how to edit CS files at all... I'm hoping I can just change things using XML (which I only know a bit).

Note: There are a bunch of other CS files containing Archotech ... noteable ones were QuestPart_ArchotechSpawn.cs and QuestNode_ArchotechSpawn.cs

Shinzy

Oh! I was so focused on just the patch that I forgot this was all about a mod to begin with ;D Ignore me

based on your findings I do believe the Ear's defname is "SoSArchotechEar", you might be able to find a def file for that

jabbamonkey

THAT'S IT!!!!!

I uploaded an image to the mod page, showing all the body parts and prosthetics (3rd image in the list)
https://steamcommunity.com/sharedfiles/filedetails/?id=2460633890

Thanks alot!!!

Canute

jabba,
you need to go back to the editor! :-(
When i just activate the mod alone i am geting
XML error: Duplicate XML node name shaderType in this XML block: <graphicData><texPath>Things/Building/Production/TableTailorHand</texPath><graphicClass>Graphic_Multi</graphicClass><drawSize>(3.5,1.5)</drawSize><shaderType>CutoutComplex</shaderType><damageData><cornerTL>Damage/Corner</cornerTL><cornerTR>Damage/Corner</cornerTR><cornerBL>Damage/Corner</cornerBL><cornerBR>Damage/Corner</cornerBR></damageData><shaderType>CutoutComplex</shaderType></graphicData>

Root node: <ThingDef ParentName="BenchBase"><defName>HandTailoringBench</defName><label>hand tailor bench</label><description>A workbench for tailoring clothes by hand. Works at 50% of the speed of an electric tailoring bench.</description><thingClass>Building_WorkTable</thingClass><graphicData><texPath>Things/Building/Production/TableTailorHand</texPath><graphicClass>Graphic_Multi</graphicClass><drawSize>(3.5,1.5)</drawSize><shaderType>CutoutComplex</shaderType><damageData><cornerTL>Damage/Corner</cornerTL><cornerTR>Damage/Corner</cornerTR><cornerBL>Damage/Corner</cornerBL><cornerBR>Damage/Corner</cornerBR></damageData><shaderType>CutoutComplex</shaderType></graphicData><castEdgeShadows>true</castEdgeShadows><staticSunShadowHeight>0.20</staticSunShadowHeight><costStuffCount>75</costStuffCount><stuffCategories><li>Metallic</li><li>Woody</li></stuffCategories><altitudeLayer>Building</altitudeLayer><fillPercent>0.5</fillPercent><useHitPoints>True</useHitPoints><statBases><WorkToBuild>2000</WorkToBuild><MaxHitPoints>180</MaxHitPoints><Flammability>1.0</Flammability><WorkTableWorkSpeedFactor>0.5</WorkTableWorkSpeedFactor></statBases><size>(3,1)</size><designationCategory>Production</designationCategory><passability>PassThroughOnly</passability><pathCost>50</pathCost><hasInteractionCell>True</hasInteractionCell><interactionCellOffset>(0,0,-1)</interactionCellOffset><surfaceType>Item</surfaceType><inspectorTabs><li>ITab_Bills</li></inspectorTabs><building><spawnedConceptLearnOpportunity>BillsTab</spawnedConceptLearnOpportunity></building><comps><li Class="CompProperties_AffectedByFacilities"><linkableFacilities><li>ToolCabinet</li></linkableFacilities></li></comps><placeWorkers><li>PlaceWorker_ShowFacilitiesConnections</li><li>PlaceWorker_PreventInteractionSpotOverlap</li></placeWorkers><researchPrerequisites><li>ComplexClothing</li></researchPrerequisites></ThingDef>

(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)

XML error: Duplicate XML node name shaderType in this XML block: <graphicData><texPath>Things/Building/Production/TableTailorElectric</texPath><graphicClass>Graphic_Multi</graphicClass><drawSize>(3.5,1.5)</drawSize><shaderType>CutoutComplex</shaderType><damageData><cornerTL>Damage/Corner</cornerTL><cornerTR>Damage/Corner</cornerTR><cornerBL>Damage/Corner</cornerBL><cornerBR>Damage/Corner</cornerBR></damageData><shaderType>CutoutComplex</shaderType></graphicData>

Root node: <ThingDef ParentName="BenchBase"><defName>ElectricTailoringBench</defName><label>electric tailor bench</label><description>A workbench with a sewing machine for rapid tailoring of clothes. Can work without electricity at 50% of normal speed.</description><thingClass>Building_WorkTable</thingClass><graphicData><texPath>Things/Building/Production/TableTailorElectric</texPath><graphicClass>Graphic_Multi</graphicClass><drawSize>(3.5,1.5)</drawSize><shaderType>CutoutComplex</shaderType><damageData><cornerTL>Damage/Corner</cornerTL><cornerTR>Damage/Corner</cornerTR><cornerBL>Damage/Corner</cornerBL><cornerBR>Damage/Corner</cornerBR></damageData><shaderType>CutoutComplex</shaderType></graphicData><castEdgeShadows>true</castEdgeShadows><staticSunShadowHeight>0.20</staticSunShadowHeight><costStuffCount>75</costStuffCount><costList><Steel>50</Steel><ComponentIndustrial>2</ComponentIndustrial></costList><stuffCategories><li>Metallic</li><li>Woody</li></stuffCategories><altitudeLayer>Building</altitudeLayer><fillPercent>0.5</fillPercent><useHitPoints>True</useHitPoints><statBases><WorkToBuild>2500</WorkToBuild><MaxHitPoints>180</MaxHitPoints><Flammability>1.0</Flammability></statBases><size>(3,1)</size><designationCategory>Production</designationCategory><passability>PassThroughOnly</passability><pathCost>50</pathCost><hasInteractionCell>True</hasInteractionCell><interactionCellOffset>(0,0,-1)</interactionCellOffset><surfaceType>Item</surfaceType><constructionSkillPrerequisite>4</constructionSkillPrerequisite><inspectorTabs><li>ITab_Bills</li></inspectorTabs><building><spawnedConceptLearnOpportunity>BillsTab</spawnedConceptLearnOpportunity><unpoweredWorkTableWorkSpeedFactor>0.5</unpoweredWorkTableWorkSpeedFactor></building><comps><li Class="CompProperties_Power"><compClass>CompPowerTrader</compClass><shortCircuitInRain>true</shortCircuitInRain><basePowerConsumption>120</basePowerConsumption></li><li Class="CompProperties_Flickable" /><li Class="CompProperties_AffectedByFacilities"><linkableFacilities><li>ToolCabinet</li></linkableFacilities></li><li Class="CompProperties_Breakdownable" /></comps><placeWorkers><li>PlaceWorker_ShowFacilitiesConnections</li><li>PlaceWorker_PreventInteractionSpotOverlap</li></placeWorkers><researchPrerequisites><li>ComplexClothing</li><li>Electricity</li></researchPrerequisites></ThingDef>

(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)

XML Verse.GraphicData defines the same field twice: shaderType.

Field contents: CutoutComplex.

Whole XML:

<graphicData><texPath>Things/Building/Production/TableTailorHand</texPath><graphicClass>Graphic_Multi</graphicClass><drawSize>(3.5,1.5)</drawSize><shaderType>CutoutComplex</shaderType><damageData><cornerTL>Damage/Corner</cornerTL><cornerTR>Damage/Corner</cornerTR><cornerBL>Damage/Corner</cornerBL><cornerBR>Damage/Corner</cornerBR></damageData><shaderType>CutoutComplex</shaderType></graphicData>

(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)

XML Verse.GraphicData defines the same field twice: shaderType.

Field contents: CutoutComplex.

Whole XML:

<graphicData><texPath>Things/Building/Production/TableTailorElectric</texPath><graphicClass>Graphic_Multi</graphicClass><drawSize>(3.5,1.5)</drawSize><shaderType>CutoutComplex</shaderType><damageData><cornerTL>Damage/Corner</cornerTL><cornerTR>Damage/Corner</cornerTR><cornerBL>Damage/Corner</cornerBL><cornerBR>Damage/Corner</cornerBR></damageData><shaderType>CutoutComplex</shaderType></graphicData>

Just got Core,Royalty and your mod active.


jabbamonkey

Quote from: Canute on April 20, 2021, 12:43:05 PM
jabba,
you need to go back to the editor! :-(
When i just activate the mod alone i am geting...

Hey Canute,
Someone else mentioned issues with the Tailor workbench and a few other mods... so I just updated my mod, and I removed all instances of the Tailor workbench (hand an electric), so you shouldn't be getting any errors anymore. Check and let me know. Thanks!

Note: My mods are all texture changes, so they wont affect save games.