Alter Xenotype on Use by Severity - KonradHeinser/EBSGFramework GitHub Wiki

This thing comp allows you to make usable things alter a pawn's xenotype similar to the Alter Xenotype on Use, but instead of working in isolation, it relies on a hediff to know if/how to change the pawn:

        <comps>
            <li Class="EBSGFramework.CompProperties_UseEffectAlterXenotypeByHediffSeverity">
            </li>
        </comps>

These are the options available in the comp:

  • hediff : The HediffDef this comp is linked to. It is generally recommended that the hediff be little more than a storage that is dedicated solely to remembering how many are consumed unless you intend to have this alter xenotype based on situation instead of cumulative uses

  • severityChange : Default (1) : The amount of severity to give/add to the hediff. It is generally recommended that this be the only way the hediff's severity is altered unless you are very sure about what you're doing

  • xenotypes : A special list of items that determines what happens after the hediff's severity is changed

    • severity : The hediff severity required for this to be the chosen set. This can be a singular value (usually if the linked hediff is just a cumulative use counter) or a range of values
    • xenotype : The XenotypeDef to turn the pawn into. Technically optional if you only want to add/remove specific genes
    • setXenotype : Default (True) : While true, most old genes are removed, with the only exceptions being hair and skin color endogenes. When False, only genes that are incompatible with genes from the new xenotype are removed, creating a type of hybrid that still uses the new xenotype's name
      • Keep in mind that because old genes are not removed, the second or third xenotype on a list can become a merged version of the merged version of the previous xeno if this setting is set to False. This can be countered by using exclusionTags on the genes, or by designing the xenotypes to build off of each other
    • removeGenes : A list of GeneDefs to remove after the xenotype is applied, assuming it isn't left blank. This is optional
    • addGenes : A list of GeneDefs to add after the xenotype is applied and genes are removed, assuming either of those need to occur. This is optional
    • filth : A ThingDef to create around the pawn when the comp triggers
    • filthCount : Default (4-7) : How many of the filth to create, if filth is used
  • prerequisites : A special item that limits who can use the item

    • hasAnyOfHediffs : List of HediffDefs that the pawn must have any one of
    • hasAllOfHediffs : List of HediffDefs that the pawn must have all of
    • hasNoneOfHediffs : List of HediffDefs that the pawn must have none of
    • hasAnyOfGenes : List of GeneDefs that the pawn must have any one of
    • hasAllOfGenes : List of GeneDefs that the pawn must have all of
    • hasNoneOfGenes : List of GeneDefs that the pawn must have none of
    • isAnyOfXenotype : List of XenotypeDefs that the pawn must be one of
    • isNoneOfXenotype : List of XenotypeDefs that the pawn must not be one of
  • sendMessage : Default (False) : Sends a generic message about the xenotype being applied


This example turns the user into a sanguophage. On the first use, the pawn becomes a bloodfeeder without ageless and deathless, but the next two uses give those genes to the pawn:

    <ThingDef ParentName="ResourceBase">
        <defName>SanguophageEvolution</defName>
        <label>sanguophage evolution</label>
        <description>A serum that turns the pawn into a sanguophage, with some genes missing until more are used.</description>
        <stackLimit>10</stackLimit>
        <graphicData>
            <texPath>Things/Item/Resource/DeathrestCapacitySerum</texPath>
            <graphicClass>Graphic_Single</graphicClass>
        </graphicData>
        <statBases>
            <MaxHitPoints>60</MaxHitPoints>
            <MarketValue>1000</MarketValue>
            <DeteriorationRate>5</DeteriorationRate>
            <Mass>0.50</Mass>
            <Flammability>0.7</Flammability>
        </statBases>
        <thingCategories>
            <li>Drugs</li>
        </thingCategories>
        <comps>
            <li Class="CompProperties_Usable">
                <useJob>UseArtifact</useJob>
                <useLabel>Use {0_label}</useLabel>
                <showUseGizmo>true</showUseGizmo>
            </li>
            <li Class="EBSGFramework.CompProperties_UseEffectAlterXenotypeByHediffSeverity">
                <hediff>SanguophageEvolution</hediff>
                <sendMessage>False</sendMessage>
                <prerequisites>
                    <hasNoneOfGenes> 
                        <!--All deathless pawns, sanguophage and non-sanguophage alike, can't use this item-->
                        <li>Deathless</li>
                    </hasNoneOfGenes>
                </prerequisites>
                <xenotypes>
                    <li>
                        <severity>1</severity>
                        <xenotype>Sanguophage</xenotype>
                        <removeGenes>
                            <li>Ageless</li>
                            <li>Deathless</li>
                        </removeGenes>
                        <!--Overrides the pawn's genes to be those of a sanguophage, then -->
                    </li>
                    <li>
                        <severity>2</severity>
                        <addGenes>
                            <li>Ageless</li>
                        </addGenes>
                        <!--Because this only adds a gene, gene changes from other sources will persist-->
                    </li>
                    <li>
                        <severity>3</severity>
                        <xenotype>Sanguophage</xenotype>
                        <!--Ensures the pawn is a true sanguophage
                        If other sources altered the pawn's genes between the 1st and 3rd use, those changes are overriden-->
                    </li>
                </xenotypes>
            </li>
            <li Class="CompProperties_UseEffectDestroySelf" />
        </comps>
        <thingSetMakerTags>
            <li>RewardStandardHighFreq</li>
        </thingSetMakerTags>
    </ThingDef>

    <HediffDef>
        <defName>SanguophageEvolution</defName>
        <label>sanguophage evolution</label>
        <description>This pawn is becoming closer to what a true sanguophage should be.</description>
        <everCurableByItem>false</everCurableByItem>
        <initialSeverity>1</initialSeverity>
        <hediffClass>HediffWithComps</hediffClass>
        <scenarioCanAdd>false</scenarioCanAdd>
        <stages>
            <li>
                <label>Bloodfeeder</label>
                <becomeVisible>false</becomeVisible>
            </li>
            <li>
                <minSeverity>2</minSeverity>
                <label>Bloodfeeder</label>
                <becomeVisible>false</becomeVisible>
            </li>
        </stages>
        <comps>
            <li Class="EBSGFramework.HediffCompProperties_RemoveAtSeverities">
                <severity>3</severity>
            </li>
        </comps>
    </HediffDef>
⚠️ **GitHub.com Fallback** ⚠️