The Genes - KonradHeinser/EBSGFramework GitHub Wiki
The most important portion of the DRG system is the Resource Gene itself. This is the gene referenced by all other parts of the system, and handles the bars, the hediffs, and even the primary resource packs pawns look for. A lot of this system is handled by the normal GeneDef stuff, meaning all main DRGs should have this stuff within the GeneDef itself:
<geneClass>EBSGFramework.ResourceGene</geneClass>
<resourceLossPerDay>1</resourceLossPerDay> <!--Negative means regeneration. A -1 would mean regenerating 100 per day-->
<resourceGizmoThresholds>
<li>0.25</li>
<li>0.5</li>
<li>0.75</li>
</resourceGizmoThresholds>
<resourceGizmoType>EBSGFramework.GeneGizmo_ResourceGene</resourceGizmoType> <!--If you have a GeneGizmo_Resource error, it's because you forgot this-->
<showGizmoOnWorldView>false</showGizmoOnWorldView>
<showGizmoWhenDrafted>true</showGizmoWhenDrafted>
<resourceDescription>Insert resource description here.</resourceDescription>
<resourceLabel>insert resource label here</resourceLabel>
All of that stuff will tell the game that the resource gene is, well a resource. Below all of these would be the extension itself, which gives details about what the code needs to do with the resource. Lets start with customizing the bar, and telling the code that this is the main gene.
<modExtensions>
<li Class="EBSGFramework.DRGExtension">
<!--Basics-->
<isMainGene>True</isMainGene> <!--Tells the code that this is the gene handling the resource manipulation-->
<!--Does as their name implies. If you want to see them in action, make the RGBs two very different colors-->
<barColor>(255, 255, 0)</barColor>
<barHighlightColor>(205, 205, 50)</barHighlightColor>
<iconThing>Uranium</iconThing> <!--For Hemogen, this is that little pack at the top of the gizmo. For radiation, it's the first Uranium icon-->
</li>
</modExtensions>
Next up will be demonstrating the tags that alter the maximum values the stat can have, and what happens when the maximum or minimum are reached. It's important to note that maximum and maxStat are mutually exclusive.
<modExtensions>
<li Class="EBSGFramework.DRGExtension">
<!--Basics-->
<isMainGene>True</isMainGene> <!--Tells the code that this is the gene handling the resource manipulation-->
<!--Does as their name implies. If you want to see them in action, make the RGBs two very different colors-->
<barColor>(255, 255, 0)</barColor>
<barHighlightColor>(205, 205, 50)</barHighlightColor>
<iconThing>Uranium</iconThing>
<!--Limit stuff-->
<maximum>10</maximum> <!--The maximum shown in game is 100 times this, so a value of 10 is a maximum of 1,000-->
<maxStat>maxStatDefName</maxStat> <!--Multiplies the stat value here by 100 to set the maximum-->
<maxFactorStat>maxFactorStatDefName</maxFactorStat> <!--Multiplies whatever maximum is set above by the value of this stat-->
<cravingHediff>cravingHediffDefName</cravingHediff> <!--Optional. When the resource is out, this hediff starts climbing-->
<overchargeHediff>overchargeHediffDefName</overchargeHediff><!--Optional. When the resource is at the max, this hediff starts climbing-->
<gainStat>gainStatDefName</gainStat> <!--Optional. Multiplies any resource gains from non-gene, non-ability sources-->
<passiveFactorStat>passiveStatDefName</passiveFactorStat> <!--Optional. Multiplies the effects of resource genes and resource drain genes-->
</li>
</modExtensions>
It is important to remember that every ability that uses the resource has the 100x multiplier, so if you see an ability explained here that has 0.1 in its example, that translates to 10 resource in-game.
And the final, but probably most important, thing to deal with is telling the gene what things will give the resource. This is split into two categories, resource packs and generic raw foods. The raw foods part may seem weird to some, but those who use Hemogenic a lot may have noticed that raw human flesh gives a bit of Hemogen when consumed. The amount given is based on the nutrition of each item, and the number of items consumed.
<modExtensions>
<li Class="EBSGFramework.DRGExtension">
<!--Basics-->
<isMainGene>True</isMainGene> <!--Tells the code that this is the gene handling the resource manipulation-->
<!--Does as their name implies. If you want to see them in action, make the RGBs two very different colors-->
<barColor>(255, 255, 0)</barColor>
<barHighlightColor>(205, 205, 50)</barHighlightColor>
<iconThing>Uranium</iconThing>
<!--Limit stuff-->
<maximum>10</maximum>
<maxStat>maxStatDefName</maxStat>
<maxFactorStat>maxFactorStatDefName</maxFactorStat>
<cravingHediff>cravingHediffDefName</cravingHediff>
<overchargeHediff>overchargeHediffDefName</overchargeHediff>
<!--Resource Packs-->
<resourcePacksAllowed>True</resourcePacksAllowed> <!--True is the default value for this, and you should only set it to false if you don't have resource packs-->
<resourcePacks> <!--Optional-->
<li>ResourcePackDefName</li>
</resourcePacks>
<gainStat>gainStatDefName</gainStat> <!--Optional. Increases resources gained from packs-->
<!--Ingestion Effects-->
<checkIngestion>True</checkIngestion> <!--If this is not manually set to true, then the code just assumes there aren't special effects-->
<eggIngestionEffect>0.04</eggIngestionEffect> <!--Optional. As far as I know, it only counts what Rimworld knows is a raw egg-->
<drugIngestionEffect>0.04</drugIngestionEffect> <!--Optional. Probably won't do much since most drugs don't have nutrition, and aren't consumed in massive quantities-->
<corpseIngestionEffect>0.04</corpseIngestionEffect> <!--Optional. Still not 100% sure if this works, but it should activate if someone picks up a corpse to eat it-->
<humanlikeIngestionEffect>0.04</humanlikeIngestionEffect> <!--Optional. Hemogen uses 0.0375 for this. Only covers raw meat from a humanlike source-->
<genericMeatIngestionEffect>0.04</genericMeatIngestionEffect> <!--Optional. Non-human raw meat. If you want all meat to be covered, set both to the same value-->
</li>
</modExtensions>
The final thing to cover is drain/regen genes, similar to HemogenDrain. These require almost nothing. Slap this code into a GeneDef, and you have yourself a draining gene. Make the loss negative, and you have a regeneration gene.
<resourceLabel>insert resource label here</resourceLabel>
<geneClass>EBSGFramework.ResourceDrainGene</geneClass>
<prerequisite>InsertMainGeneDefNameHere</prerequisite> <!--All that really matters is that the main resource gene is always there-->
<resourceLossPerDay>0.1</resourceLossPerDay> <!--Losing 10 per day-->
<modExtensions>
<li Class="EBSGFramework.DRGExtension">
<mainResourceGene>InsertMainGeneDefNameHere</mainResourceGene> <!--This must be whatever the main resource gene is-->
</li>
</modExtensions>
Up until this point, all of the drain and regen genes we've been making are constantly active, but what if we only want them to be active in certain situations, like when in light/darkness, or only when the pawn has certain hediffs active? The DRG extension has some tags that allow you to only take effect when specific conditions are met.
-
requiredHediffs : List of hediffs that the pawn needs to have all of to make the gene offset the resource
-
requireOneOfHediffs : List of hediffs that the pawn needs to have any one of to make the gene offset the resource
-
forbiddenHediffs : List of hediffs that the pawn needs to have none of to make the gene offset the resource
-
lightLevel : Default (0~1) : The light level of the area the pawn is standing must be in this range
-
progressThroughDay : Default (0~1) : % of progress through the day when this will be active. For example, if this is set to be 0~0.5, then the ability is usable from midnight until noon, 0.5~1 would be noon until midnight, and 0.25~0.75 6:00 to 18:00
- If you aren't sure what to put for the percentage, take the hour you want it to start/end at, and divide it by 24. For example, if you want the available times to be 5:00-15:00 (5-3 for those who stick to 12 hour clocks), you would do 5/24 and 15/24 to get 0.208~0.625
-
needLevels : Special list of items that cause the resource to only be offset if all needs are in their specified ranges (min 0 to max 1)
<needLevels>
<li>
<need>InsertNeedDefNameHere</need>
<minNeedLevel>0</minNeedLevel>
<maxNeedLevel>1</maxNeedLevel>
</li>
</needLevels>
If you want to have the initial or drain genes apply a specific hediff when added similar to what Hediff Adder does, you can do that by adding the same extension as what Hediff Adder uses. You do not need a special gene class to do this as the functionality is built directly into the DRG Gene classes.
- If a drain gene is added at a different time from when the main gene is added, the gizmo does not report it on the list. After some experimentation, this appears to be a solely visual caused by limitations in when the drain gene list is made, which can only occur on add or post-reload. The drain/regen itself should still apply without issue though.
Adapted Superhero Genes resource for Radiomancers, a type of superhero that uses a specialized form of radiation.
<GeneDef>
<defName>SHG_Archetypes_Radiomancer</defName>
<label>radiomancer</label>
<description>There was a lengthy description here, but I killed it for this example.</description>
<displayCategory>Miscellaneous</displayCategory>
<iconPath>Archetypes/Gene_Radiomancer</iconPath>
<geneClass>EBSGFramework.ResourceGene</geneClass>
<resourceGizmoThresholds>
<li>0.25</li>
<li>0.5</li>
<li>0.75</li>
</resourceGizmoThresholds>
<resourceGizmoType>EBSGFramework.GeneGizmo_ResourceGene</resourceGizmoType>
<showGizmoOnWorldView>false</showGizmoOnWorldView>
<showGizmoWhenDrafted>true</showGizmoWhenDrafted>
<resourceDescription>I have murdered another description!</resourceDescription>
<resourceLabel>radiation</resourceLabel>
<biostatArc>1</biostatArc>
<resourceLossPerDay>-0.1</resourceLossPerDay>
<displayOrderInCategory>-0.8</displayOrderInCategory>
<modExtensions>
<li Class="EBSGFramework.DRGExtension">
<isMainGene>True</isMainGene>
<maximum>1</maximum> <!--Not really needed since this is the default-->
<barColor>(255, 255, 0)</barColor>
<barHighlightColor>(205, 205, 50)</barHighlightColor>
<iconThing>Uranium</iconThing>
<cravingHediff>SHG_RadiomancerDrained</cravingHediff>
<overchargeHediff>SHG_RadiomancerOvercharge</overchargeHediff>
<resourcePacks>
<li>SHG_RadiationPack</li>
</resourcePacks>
</li>
</modExtensions>
</GeneDef>
<GeneDef>
<defName>SHG_RadiomancerDrain</defName>
<label>radiomancer drain</label>
<labelShortAdj>draining</labelShortAdj>
<description>Carriers lose 10 radiation per day from entropy.</description>
<resourceLabel>radiation</resourceLabel>
<geneClass>EBSGFramework.ResourceDrainGene</geneClass>
<iconPath>UI/Icons/Genes/Gene_HemogenDrain</iconPath>
<prerequisite>SHG_Archetypes_Radiomancer</prerequisite>
<resourceLossPerDay>0.1</resourceLossPerDay>
<displayCategory>SHG_Radiomancer_Entropy</displayCategory>
<displayOrderInCategory>1</displayOrderInCategory>
<minAgeActive>3</minAgeActive>
<biostatCpx>1</biostatCpx>
<biostatMet>6</biostatMet>
<modExtensions>
<li Class="EBSGFramework.DRGExtension">
<mainResourceGene>SHG_Archetypes_Radiomancer</mainResourceGene>
</li>
</modExtensions>
</GeneDef>
- Resource Packs : Add a special ingestion outcome doer that alters the resource
- Craving and Overcharge Hediffs : Hediffs that appear when the resource runs out or sits at the maximum for extended periods of time
- Resource Using Abilities : Make abilities that use(or give) the resource
- Converting Resources : Make abilities that convert one DRG resource into another
- Special DRG Abilities : Make abilities similar to non-DRG ones that scale based on a variable amount of the consumed resource
- Special DRG Hediffs : Make hediffs that do various things and usually allow for more interaction between DRGs than normal