Patch not working ( Beginner modder )

Started by Dubois.F, June 26, 2023, 01:34:57 PM

Previous topic - Next topic

Dubois.F

So I could use some help with my patch , I just started modding and patching and I am having a real hard time understanding why my patch isn't working at all.
I have tried the modding Wikipedia and looking for an answer on the forum but I am still new to it.

The aim of this patch is to remove the cryosleep sickness that pawns have after exiting a cryosleep casket ( I know that I can edit it in the core folder of rimworld but I want to make a fully fledge patch mod in order to learn how to upload them to the steam workshop )

Here is the patch itself :
<?xml version="1.0" encoding="utf-8" ?>

<Patch>

   <Operation Class="PatchOperationRemove">
      <xpath>/Defs/HediffDefs/Hediffs_Global_Misc[defName="CryptosleepSickness"]/stages</xpath>
   </Operation>
</Patch>

And here is the error log :
[CryosleepModified] Patch operation Verse.PatchOperationRemove(/Defs/HediffDefs/Hediffs_Global_Misc[defName="CryptosleepSickness"]/stages) failed
file: D:\Steam\steamapps\common\RimWorld\Mods\Nocryosleepsickness\1.4\Patches\SicknessPatch.xml
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Error (string)
Verse.PatchOperation:Complete (string)
Verse.LoadedModManager:ClearCachedPatches ()
Verse.LoadedModManager:LoadAllActiveMods ()
Verse.PlayDataLoader:DoPlayLoad ()
Verse.PlayDataLoader:LoadAllPlayData (bool)
Verse.Root/<>c:<Start>b__6_1 ()
Verse.LongEventHandler:RunEventFromAnotherThread (System.Action)
Verse.LongEventHandler/<>c:<UpdateCurrentAsynchronousEvent>b__27_0 ()
System.Threading.ThreadHelper:ThreadStart_Context (object)
System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)
System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)
System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object)
System.Threading.ThreadHelper:ThreadStart ()

It is probably a simple rookie mistake but I cant figure it out for now so I would gladly accept any help thanks !

Kopp

Your line
<xpath>/Defs/HediffDefs/Hediffs_Global_Misc[defName="CryptosleepSickness"]/stages</xpath>
should be smth like
<xpath>/Defs/HediffDef[defName="CryptosleepSickness"]/stages</xpath>

Besides that:
1: Not sure if the game will complain that the hediff misses the whole "stages" part
2: Your pawns will probably still get the hediff, it just does not do anything
3: So this approach may cause unwanted behaviour if using mods that rely on the hediff working the vanilla way

So a clean solution would probably be using C# and change the code in the CryptosleepCasket thingClass to just not give a hediff at all.

Dubois.F

I see what you mean , I will try with your current pathway and I will actually try to replace the values this hediff create into another value rather than completely erase it since it might affect other vanilla parts of the game thanks !

Dubois.F

Just a quick update , I was able to actually change the value into another rather than removing it completely , thanks !