Hediff Adding Traits - KonradHeinser/EBSGFramework GitHub Wiki

Similar to the Hediff Adder gene class, the EBSGExtension can be attached to a TraitDef to have it try to add hediffs post-add. If the trait in question is intended to be added via genes, it is strongly recommended you stick to the Hediff Adder because it tends to have fewer weird situations where stuff breaks. I've made this as stable as I can, but there are some rare situations where hediffs may not be added/removed properly when the trait is added/removed:

        <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 trait is removed by anything. It is recommended to leave this as True unless you are really sure
  • degree : The trait degree this hediff is attached to. If not specified, it's attached to all degrees in the trait. If multiple, but not all, degrees need the same hediff, then each degree needs its own li

This example does the same thing as the Hediff Adder, just with a trait instead:

    <TraitDef>
        <defName>EBSG_DamagedKidney</defName>
        <commonality>1</commonality>
        <degreeDatas>
            <li>
                <label>damaged kidney</label>
                <description>{PAWN_nameDef} has a damaged kidney because Alite isn't terribly creative with his examples.</description>
            </li>
        </degreeDatas>
        <modExtensions>
            <li Class="EBSGFramework.EBSGExtension">
                <hediffsToApply>
                    <li>
                        <hediff>EBSG_DamagedKidney</hediff>
                        <bodyParts>
                            <li>Kidney</li>
                        </bodyParts>
                    </li>
                </hediffsToApply>
            </li>
	    </modExtensions>
    </TraitDef>

    <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** ⚠️