Hediff Adder - KonradHeinser/EBSGFramework GitHub Wiki

To head off any comments, I know Vanilla Expanded Framework has a hediff adding extension, which is objectively better than a class. Except, as I found out the hard way, it isn't objectively better if your hediffs are supposed to go away in certain conditions. I made this because the VFE hediff adder makes the hediffs pop up again if any new genes are added through any other method, like a gene randomizing hediff as a wild example.

These are the basic stuff for the class

        <!--Basic gene class for genes that don't need to use another class-->
        <geneClass>EBSGFramework.HediffAdder</geneClass>

        <!--Use this in place of Gene_HemogenDrain if you need to add hediffs as well-->
        <geneClass>EBSGFramework.Gene_HemoHediffAdder</geneClass>

<!--If you're using any other class within this framework, then you can access all the hediff adding stuff listed on this page.
The only exception is the spawn age limiter because the HediffAdder inherits from that-->

        <modExtensions>
	    <li Class="EBSGFramework.EBSGExtension">
                <hediffsToApply>
                    <li>
                    </li>
                </hediffsToApply>
	    </li>
	</modExtensions>

hediffsToApply is a special list of items that has the following options available to it:

  • hediff : The HediffDef to add. This is required
  • bodyParts : The list of BodyPartDefs to add the hediff to. If left blank, then it will add to the full body
  • onlyIfNew : Default (False) : While True, the hediff won't be added to a pawn/pawn part if the pawn already has it
  • severity : Default (0.5) : The severity to apply/add to the hediff
  • chance : Default (1) : The chances of the hediff actually being added
  • removeOnRemove : Default (True) : If set to false, then this specific hediff will be not be removed when the gene is removed by anything. It is recommended to leave this as True unless your really really sure

In addition to hediffsToApply, there is also an option to make the gene delete itself shortly after it finishes adding the hediff(s). This should go directly after the closing or directly before the opening

  • vanishingGene : Default (False) : When the hediff(s) are done being added, delete the gene

Important note: If you leave onlyIfNew as false, make sure to test that the hediff itself is fine with that

Other Important Note: If you're finding that the hediffs are not being added, double-check your geneClass. If the gene class is not added, or is not one from this framework, then the hediffs won't be added. EBSGFramework.HediffAdder is usually the one you're looking for

Third Important Note: If you are looking for min/max age stuff, the hediff will not be added/removed properly by this class. This can be solved by using Hediffs at Age instead


This example adds a damaged kidney hediff, which causes one of the pawn's kidneys to become damaged shortly after spawning:

    <GeneDef>
        <defName>EBSG_DamagedKidney</defName>
        <label>damaged kidney</label>
        <geneClass>EBSGFramework.HediffAdder</geneClass>
        <description>There was a description here.</description>
        <displayOrderInCategory>0.1</displayOrderInCategory>
        <biostatMet>1</biostatMet>
        <exclusionTags><li>EBSG_Kidney</li></exclusionTags>
        <customEffectDescriptions>
            <li>One kidney loses 50% health on spawn.</li>
        </customEffectDescriptions>
        <modExtensions>
	    <li Class="EBSGFramework.EBSGExtension">
                <hediffsToApply>
                    <li>
                        <hediff>EBSG_DamagedKidney</hediff>
                        <bodyParts>
                            <li>Kidney</li>
                        </bodyParts>
                    </li>
                </hediffsToApply>
            </li>
	</modExtensions>
    </GeneDef>

    <HediffDef>
        <defName>EBSG_DamagedKidney</defName>
        <label>damaging kidney</label>
        <description>There was a description here.</description>
        <defaultLabelColor>(0.7, 0.7, 0.7)</defaultLabelColor>
	<hediffClass>HediffWithComps</hediffClass>
	<scenarioCanAdd>true</scenarioCanAdd>
	<maxSeverity>1.0</maxSeverity>
	<isBad>false</isBad>
        <comps>
            <li Class="EBSGFramework.HediffCompProperties_DamageBodyParts">
                <bodyPartsToDamage>
                    <li>
                        <bodyPart>Kidney</bodyPart>
                        <damagePercentage>0.5</damagePercentage>
                    </li>
                </bodyPartsToDamage>
            </li>
        </comps>
    </HediffDef>
⚠️ **GitHub.com Fallback** ⚠️