Alter Genes on Use - KonradHeinser/EBSGFramework GitHub Wiki

This thing comp allows you to make usable things alter a pawn's genes similar to the Alter Genes Ability when used. If you are familiar with that comp, all the same options apply. You will still need the other normal usable comps to make it possible for players to activate it:

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

These are the options available in the comp:

  • removeGenesFromOtherLists : Default (True) : While true, when a random set is selected it will remove the genes from all the other sets that are on the pawn. Individual sets can choose to ignore this
  • inheritable : Default (True) : Dictates if the genes created are inherited. Individual sets can override this
  • alwaysAddedGenes : Regardless of chosen set, genes on this list are always added. This is the first step of the gene changing process
  • alwaysRemovedGenes : List of genes to always remove. Removing these genes is the last step
  • showMessage : Default (True) : If the pawn is in the player's faction, this makes causes a message to be sent on successful alteration
  • geneSets : Special list of items that determines the random options available
    • weightOfGeneSet : Default (1) : Alters how likely it is that this item will be chosen using a weighted average
    • reverseInheritence : Default (False) : This set does the reverse of what the inheritable tag says
    • alwaysRemoveGenes : Default (False) : If true, the geneSet will be removed even if removeGenesFromOtherLists is false
    • geneSet : The list of GeneDefs to apply
  • 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

This example makes the pawn hemogenic, and gives a gene that will help them avoid dying more easily. If the pawn has one of the genes already, then that gene set creates a chance for a partially, and sometimes completely, wasted use (i.e. a pawn with super fast wound healing will have a 70% chance of having nothing happen, assuming they already have the hemogenic gene):

    <ThingDef ParentName="ResourceBase">
        <defName>DeathResistantGenesSerum</defName>
        <label>death resistant genes serum</label>
        <description>A serum that permanently alters the genes of the user to make them more resistant to death.</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_UseEffectAlterGenes">
                <alwaysAddedGenes>
                    <li>Hemogenic</li>
                </alwaysAddedGenes>
                <removeGenesFromOtherLists>False</removeGenesFromOtherLists>
                <geneSets>
                    <li>
                        <weightOfGeneSet>0.1</weightOfGeneSet>
                        <geneSet>
                            <li>Deathless</li>
                        </geneSet>
                    </li>
                    <li>
                        <weightOfGeneSet>0.2</weightOfGeneSet>
                        <geneSet>
                            <li>Superclotting</li>
                        </geneSet>
                    </li>
                    <li>
                        <weightOfGeneSet>0.7</weightOfGeneSet>
                        <geneSet>
                            <li>WoundHealing_SuperFast</li>
                        </geneSet>
                    </li>
                </geneSets>
            </li>
            <li Class="CompProperties_UseEffectPlaySound">
                <soundOnUsed>DeathrestCapacitySerum_Consume</soundOnUsed>
            </li>
            <li Class="CompProperties_UseEffectDestroySelf" />
        </comps>
        <thingSetMakerTags>
            <li>RewardStandardHighFreq</li>
        </thingSetMakerTags>
    </ThingDef>
⚠️ **GitHub.com Fallback** ⚠️