[Help] Adding chemical damage that mounts up over time to a drug

Started by Apfelkuchenbemme, March 09, 2017, 06:40:27 AM

Previous topic - Next topic

Apfelkuchenbemme

Hello there!

First of all forgive me if this question has already been asked, but after looking through the forum for a bit, I didn't quite see an existing thread that seemed to be about this topic.

Speaking of topic, I'm screwing around with a bunch of things in my free time, one of which is a drug (in Rimworld, of course!). It's supposed to be a highly potent stimulant which boosts all aspects of the mortal body for prolonged periods of time. The downsides for this are supposed to be a rather long and resource expensive production process and irreparable chemical damage to the body.

Said damage is supposed to start out small and pretty much negligible, but once you've managed to get addicted to the drug or even go into withdrawal, you're really in for it!

I have thought about implementing this damage similarily to how the vanilla drugs of Rimworld can cause chemical damage to the brains or kidneys. Yayo for example goes about the punishment for kidneys this way:

<HediffDef ParentName="DrugToleranceBase">
  <defName>PsychiteTolerance</defName>
...
    <hediffGivers>
<li Class="HediffGiver_RandomDrugEffect">
<hediff>ChemicalDamageKidney</hediff>
<minSeverity>0.50</minSeverity>
<baseMtbDays>120</baseMtbDays>
<partsToAffect>
<li>LeftKidney</li>
<li>RightKidney</li>
</partsToAffect>
</li>
    </hediffGivers>
</HediffDef>


So basically, once a person's tolerance to psychite reaches 50%, their kidneys are going to catch chemical damage in a time span of up to two years.

Additionally, a pistol's bullet is dealing the <damageDef>Bullet, with a <damageAmountBase> of 9. The <damageDef>Bullet on the other hand, is designated to the <hediff>Gunshot. Thus, the bullet of a pistol deals 9 points of "bullet damage", of which the effects in terms of tending, bleeding, pain etc. are written down in the <hediff>Gunshot.

Since I would like to implement the chemical damage of my drug by giving the drug a chance to deal 1 point of permanent damage to any living part, with the chance rising in account to how high the tolerance is and whether or not the user is addicted / in withdrawal, my best guess is:

1.) I have to add an <HedfiffDef>, which contains the info that the damage instantly scars + labels and values for damaged parts

2.) I have to add a <DamageDef>, which contains the info that the damage is supposed to ignore armor, isn't a battle wound, has no impact sound and contains the message that pops up when someone succumbs to the damage

Now the problem is that the vanilla drugs cause their chemical damage to organs via <hediffGivers>. However, in order to properly limit the chemical damage to a single point at a time, I obviously wanted to implement it with a <damageAmountBase> of 1. But since hell would freeze over long before I could add a <damageDef> + a <DamageAmountBase> under <hediffGivers>, I'm kind of lost here.

So far, I have resorted to adding an <Hediff> with stages in steps of 0.05 severity, where every next stage lowers the efficiency of the body part and causes more severe pain. Moreover, I gave the drug's tolerance an <HediffGiver_RandomDrugEffect> to cause said <Hediff>, with <canAffectAnyLivePart> enabled.
It kinda works and properly affects every body part but obviously, it would be stuck on the first stage because without a function in place that raises the severity. I've added this via <comps> with <HediffCompProperties_Immunizable> + a certain value for <severityPerDayNotImmune> in combination with <severityPerDayNotImmuneRandomFactor>, so it truly works in terms of a progressing illness.



  <!----HediffGiver that causes the illness in the definition of the drug's tolerance---->

<hediffGivers>
<li Class="HediffGiver_RandomDrugEffect">
<hediff>ChemDamDiffCPEDII</hediff>
<minSeverity>0.001</minSeverity>
<baseMtbDays>0.01</baseMtbDays>
<canAffectAnyLivePart>true</canAffectAnyLivePart>
</li>
</hediffGivers>


  <!----Hediff that acts as the illness---->

  <HediffDef Name="CPEDIIDiseaseBase" Abstract="True">
    <hediffClass>HediffWithComps</hediffClass>
    <defaultLabelColor>(190,180,20)</defaultLabelColor>
    <initialSeverity>0.001</initialSeverity>
  </HediffDef>
 
  <HediffDef ParentName="CPEDIIDiseaseBase">
<defName>ChemDamDiffCPEDII</defName>
<hediffClass>HediffWithComps</hediffClass>
<label>Chemical damage</label>
<tendable>false</tendable>
<stages>
<li>
<label>negligible</label>
</li>
<li>
<minSeverity>0.05</minSeverity>
<label>negligible</label>
<partEfficiencyFactor>0.98</partEfficiencyFactor>
<painOffset>0.01</painOffset>
</li>
<li>
<minSeverity>0.1</minSeverity>
<label>negligible</label>
<partEfficiencyFactor>0.96</partEfficiencyFactor>
<painOffset>0.0133</painOffset>
</li>
<li>
<minSeverity>0.15</minSeverity>
<label>minor</label>
<partEfficiencyFactor>0.94</partEfficiencyFactor>
<painOffset>0.0166</painOffset>
</li>
<li>
<minSeverity>0.2</minSeverity>
<label>minor</label>
<partEfficiencyFactor>0.91</partEfficiencyFactor>
<painOffset>0.02</painOffset>
</li>
<li>
<minSeverity>0.25</minSeverity>
<label>minor</label>
<partEfficiencyFactor>0.88</partEfficiencyFactor>
<painOffset>0.025</painOffset>
</li>
<li>
<minSeverity>0.3</minSeverity>
<label>medium</label>
<partEfficiencyFactor>0.85</partEfficiencyFactor>
<painOffset>0.03</painOffset>
</li>
<li>
<minSeverity>0.35</minSeverity>
<label>medium</label>
<partEfficiencyFactor>0.81</partEfficiencyFactor>
<painOffset>0.0366</painOffset>
</li>
<li>
<minSeverity>0.4</minSeverity>
<label>medium</label>
<partEfficiencyFactor>0.77</partEfficiencyFactor>
<painOffset>0.0433</painOffset>
</li>
<li>
<minSeverity>0.45</minSeverity>
<label>medium</label>
<partEfficiencyFactor>0.73</partEfficiencyFactor>
<painOffset>0.05</painOffset>
</li>
<li>
<minSeverity>0.5</minSeverity>
<label>medium</label>
<partEfficiencyFactor>0.666</partEfficiencyFactor>
<painOffset>0.0575</painOffset>
</li>
<li>
<minSeverity>0.55</minSeverity>
<label>major</label>
<partEfficiencyFactor>0.6</partEfficiencyFactor>
<painOffset>0.065</painOffset>
</li>
<li>
<minSeverity>0.6</minSeverity>
<label>major</label>
<partEfficiencyFactor>0.533</partEfficiencyFactor>
<painOffset>0.075</painOffset>
</li>
<li>
<minSeverity>0.65</minSeverity>
<label>major</label>
<partEfficiencyFactor>0.466</partEfficiencyFactor>
<painOffset>0.0875</painOffset>
</li>
<li>
<minSeverity>0.7</minSeverity>
<label>major</label>
<partEfficiencyFactor>0.4</partEfficiencyFactor>
<painOffset>0.10</painOffset>
</li>
<li>
<minSeverity>0.75</minSeverity>
<label>extreme</label>
<partEfficiencyFactor>0.325</partEfficiencyFactor>
<painOffset>0.1125</painOffset>
</li>
<li>
<minSeverity>0.8</minSeverity>
<label>extreme</label>
<partEfficiencyFactor>0.25</partEfficiencyFactor>
<painOffset>0.125</painOffset>
</li>
<li>
<minSeverity>0.85</minSeverity>
<label>extreme</label>
<partEfficiencyFactor>0.17</partEfficiencyFactor>
<painOffset>0.14</painOffset>
</li>
<li>
<minSeverity>0.9</minSeverity>
<label>threatening</label>
<partEfficiencyFactor>0.1</partEfficiencyFactor>
<painOffset>0.155</painOffset>
</li>
<li>
<minSeverity>0.95</minSeverity>
<label>threatening</label>
<partEfficiencyFactor>0.02</partEfficiencyFactor>
<painOffset>0.175</painOffset>
</li>
<li>
<minSeverity>1</minSeverity>
<label>threatening</label>
<partEfficiencyFactor>0</partEfficiencyFactor>
<painOffset>0.2</painOffset>
<destroyPart>true</destroyPart>
</li>
    </stages>
<comps>
<li Class="HediffCompProperties_Immunizable">
<severityPerDayNotImmune>20</severityPerDayNotImmune>
<severityPerDayNotImmuneRandomFactor>
<min>0.5</min>
<max>3</max>
        </severityPerDayNotImmuneRandomFactor>
</li>
</comps>

  </HediffDef>




However, I would prefer the way of implementing the chemical damage via a <DamageDef>, so the chemical damage stops mounting up once you've managed to get rid of addiction and tolerance to the drug. But as I've said before, I have no clue how that's supposed to work, so help would be appreciated!