CompProperties_Drug custom chemical type

Started by UNIT5, August 14, 2017, 09:40:38 AM

Previous topic - Next topic

UNIT5

I want to change a custom drug's addiction chemical from "Psychite" to something else. The closest I've gotten with my admittedly limited knowledge of C# is public class ChemicalDef : Def, but I'm not sure how to script the game to recognize a new <chemical> from there.

Is this just out of my league, or is there a simple way of doing this that I'm missing? (ChemicalIwanttoadd is what the new chemical would be called)

I realize maybe I need to create a new Verse.Def but I'm not sure how to actually compile something like that

<li Class="CompProperties_Drug">
        <chemical>ChemicalIwanttoadd</chemical>
        <addictiveness>0.08</addictiveness>
        <minToleranceToAddict>0.04</minToleranceToAddict>
        <existingAddictionSeverityOffset>0.20</existingAddictionSeverityOffset>
        <needLevelOffset>1</needLevelOffset>
        <isCombatEnhancingDrug>true</isCombatEnhancingDrug>
        <listOrder>100</listOrder>
        <overdoseSeverityOffset>
          <min>0.18</min>
          <max>0.35</max>
        </overdoseSeverityOffset>
<largeOverdoseChance>0.01</largeOverdoseChance>
</li>

Distman

First off; Welcome to the forums and the wonderful (but sometimes confusing) world of Rimworld modding!  :D

I think you are overcomplicating things... If i am not misunderstanding your problem.
Chemicals are defined in xml using the <ChemicalDef> class.
Search for it and i think you find all you need.

/Distman

kaptain_kavern

#2
I was thinking the same but not replied because "it seems too simple"
:-s

But indeed I made modded drugs, needs and addiction without C# voodoo, just by copy-pasting vanilla ones.

<comps>
      <li Class="CompProperties_Drug">
        <chemical>Smokeleaf</chemical>
        <addictiveness>0.020</addictiveness>
        <minToleranceToAddict>0.15</minToleranceToAddict>
        <existingAddictionSeverityOffset>0.06</existingAddictionSeverityOffset>
        <needLevelOffset>1</needLevelOffset>
        <listOrder>20</listOrder>
      </li>
    </comps>


This one is from smokeleaf code (Core/Defs/Drugs/Smokeleaf.xml)

UNIT5

Oh wow I'm stupid, I kept searching for the wrong thing so I never found the ChemicalDef type. I assumed the Psychite addiction coding would be included in Flake (the only code I searched through, because I'm an idiot), but it's only included in Yayo's code.

  <ChemicalDef>
    <defName>I'manidiot</defName>
    <label>psychite</label>
    <addictionHediff>PsychiteAddiction</addictionHediff>
    <toleranceHediff>PsychiteTolerance</toleranceHediff>
    <onGeneratedAddictedToleranceChance>0.8</onGeneratedAddictedToleranceChance>
    <onGeneratedAddictedEvents>
      <li>
        <hediff>ChemicalDamageSevere</hediff>
        <chance>0.15</chance>
        <partsToAffect>
          <li>LeftKidney</li>
          <li>RightKidney</li>
        </partsToAffect>
      </li>
    </onGeneratedAddictedEvents>
  </ChemicalDef>


No matter how much experience I get modding all sorts of games I always seem to get stuck on the simplest possible bit of coding just because I can't read. Thanks a lot for the help, and hopefully I'll be able to carry myself the rest of the way  ;D

kaptain_kavern

Oh right, I haven't thought about it sooner but yes they are the perfect example that you can have several drugs sharing the same chemical and so same addiction...

QuoteNo matter how much experience I get modding all sorts of games I always seem to get stuck on the simplest possible bit of coding just because I can't read. Thanks a lot for the help, and hopefully I'll be able to carry myself the rest of the way  ;D

I feel you. But don't worry. I found perfectly normal that after several hours of reading walls of text (especially code or foreign language) you may sometimes just need a fresh pair of eyes ;-) - And I'm speaking of experiences :-p

Hope you'll manage, else don't hesitate to use this section of the forum again ^^