Adding Overdose Immunity to Chemical Dependency Genes

Started by PamboS, July 13, 2023, 09:09:22 AM

Previous topic - Next topic

PamboS

Hi there, first time RimWorld modder here.

I'm trying to modify the default Chemical Dependency genes (such as Wake-up dependency) to also provide a 0% overdose chance factor, similar to what Wake-up Impervious provides.

I've looked at how the GeneChemicalBase class is defined in RimWorld/Data/Biotech/Defs/GeneDefs/GeneTemplateDefs.xml but unlike addictionChanceFactor, which affects the probability of getting addicted to the drug, I can't figure out a way to also modify overdoseChanceFactor -- this parameter doesn't seem to be accepted by the class so I presume that overdose immunity is defined/processed somewhere else.

Any suggestions would be highly appreciated!

Below I copied the relevant code I'm looking at from GeneTemplateDefs.xml:

  <GeneTemplateDef ParentName="GeneChemicalBase">
    <defName>ChemicalDependency</defName>
    <label>{0} dependency</label>
    <description>Carriers of this gene need to ingest {0} on a regular basis to survive. After {DEFICIENCYDURATION} without {0}, carriers will suffer from {0} deficiency. After {COMADURATION}, they will fall into a coma. After {DEATHDURATION}, they will die.</description>
    <geneClass>Gene_ChemicalDependency</geneClass>
    <labelShortAdj>{0}-dependent</labelShortAdj>
    <iconPath>UI/Icons/Genes/Chemicals/{0}/ChemicalDependency</iconPath>
    <addictionChanceFactor>0</addictionChanceFactor>
    <displayOrderOffset>0</displayOrderOffset>
    <minAgeActive>13</minAgeActive>
    <chemicalBiostatOverrides>
      <li>
        <chemical>Alcohol</chemical>
        <biostatMet>3</biostatMet>
      </li>
      <li>
        <chemical>Smokeleaf</chemical>
        <biostatMet>3</biostatMet>
      </li>
    </chemicalBiostatOverrides>
    <biostatCpx>1</biostatCpx>
    <biostatMet>4</biostatMet>
  </GeneTemplateDef>

  <GeneTemplateDef ParentName="GeneChemicalBase">
    <defName>AddictionImmune</defName>
    <label>{0} impervious</label><!-- text_todo -->
    <description>Carriers of this gene never get addicted to {0}.</description>
    <labelShortAdj>{0}-impervious</labelShortAdj><!-- text_todo -->
    <iconPath>UI/Icons/Genes/Chemicals/{0}/AddictionImmune</iconPath>
    <addictionChanceFactor>0</addictionChanceFactor>
    <displayOrderOffset>20</displayOrderOffset>
    <chemicalBiostatOverrides>
      <li>
        <chemical>Alcohol</chemical>
        <biostatMet>-3</biostatMet>
      </li>
      <li>
        <chemical>Smokeleaf</chemical>
        <biostatMet>-3</biostatMet>
      </li>
    </chemicalBiostatOverrides>
    <biostatCpx>2</biostatCpx>
    <biostatMet>-5</biostatMet>
  </GeneTemplateDef>

Kopp

In the C# class RimWorld.GeneTemplateDef exists no field called "overdoseChanceFactor".
Thats why the game complains when you try to add the xml tag to the GeneTemplateDef.

But it exists in the class Verse.GeneDef, thats why you can add it to GeneDefs.

As I dont know much about Biotech and dont know how the gene system works, I unfortunately cant help you any further.

PamboS

Quote from: Kopp on July 13, 2023, 11:50:17 AMIn the C# class RimWorld.GeneTemplateDef exists no field called "overdoseChanceFactor".
Thats why the game complains when you try to add the xml tag to the GeneTemplateDef.

But it exists in the class Verse.GeneDef, thats why you can add it to GeneDefs.

As I dont know much about Biotech and dont know how the gene system works, I unfortunately cant help you any further.

Got it, thanks for the reply!