Evolving Genes - KonradHeinser/EBSGFramework GitHub Wiki
This gene class allows you to make genes that get replaced/removed when certain conditions are met, with a check occurring once per hour. It requires a specific class and the EBSGExtension, though any gene stuff in this framework which references the HediffAdder class in its description or examples are also available:
<geneClass>EBSGFramework.Gene_EvolvingGene</geneClass>
<modExtensions>
<li Class="EBSGFramework.EBSGExtension">
</li>
</modExtensions>
These are the options available in the extension tied specifically to this class:
- checkEvolutionsPostAdd : Default (False) : Determines if the gene should check its conditions immediately after being added. This can often act strange when initially creating pawns due to the order that things are added to pawns during initial generation. There are a few instances where this can be set to True, namely if you aren't worried about misfires, the gene is generally added to a pawn mid-game, or the only conditions used are validAges and chancePerCheck
- Hediffs will almost always be treated as missing, skills will always be treated as though they were level 0, and gene checks can frequently fail to check things properly depending on the order the game decides to add them in
- geneticEvolutions : The list of items that contains the conditions and results. Each li may contain the following:
- result : The GeneDef to replace this gene with. If left empty, then this gene is removed if all other conditions are met
- skipIfCarrierHasResult : Default (False) : If the carrier already has the result, this option will be skipped. Doesn't work so well if the result is empty
- inheritable : Default (Same) : Determines if the result should be a Xeno or Endo gene. The options are Same, Xeno, and Endo, with Same copying the inheritability of the evolving gene
- chancePerCheck : Default (1) : The chance of the evolution actually having a chance to occur each hour. If this chance fails, then this evolution is skipped, and the gene checks the next one on the list
- ignoreChanceDuringPostAdd : Default (False) : If checkEvolutionsPostAdd is set to True, then this determines if that initial check will use the chancePerCheck
- message : The message to send on evolution if the pawn is a colonist, colony slave, or colony prisoner as long as said pawn is on a map or in a caravan. {0} is the pawn's name, {1} is a capitalized version of the result's label, and {2} is the result's label
- messageType : Default (NeutralEvent) : The MessageTypeDef to use for message
- hasAnyOfHediff : Special list of hediffs that uses the HediffDef's defName for the tag, and a range of severities for the value. The pawn must have at least one of the listed hediffs with severities in the range
- hasAllOfHediff : Special list of hediffs that uses the HediffDef's defName for the tag, and a range of severities for the value. The pawn must have all of the listed hediffs with severities in the range
- hasNoneOfHediff : Special list of hediffs that uses the HediffDef's defName for the tag, and a range of severities for the value. The pawn must have none of the listed hediffs with severities in the range
- hasAnyOfGene : List of GeneDefs that the pawn must have at least one of
- hasAllOfGene : List of GeneDefs that the pawn must have all of
- hasNoneOfGene : List of GeneDefs that the pawn must have none of
- validAges : Range of ages that the evolution apply for. If your goal is solely to remove the gene at a certain age, it is recommended to use Remove at Age instead
- skillRequirements : Special list of skills that use the SkillDef's defName for the tag, and a range of skill levels for the value. If no value is entered (i.e. ), then the condition is met as long as the skill is not disabled. Aptitude is not included in the level, so other genes won't affect this
This example can evolve in 4 different ways. If the pawn's shooting or melee passes 10, then combat evolution is replaced with the related shooting/melee gene. If the pawn has at least 80% bloodloss when the check occurs, then this gene replaces itself with the wound healing gene. If the pawn suffers from any level of malnutrition, then there is a 5% chance per hour that the gene will be removed.
The first 3 are set up to check languages files for the message, though if you just copy this gene over your message will just be the text in the message tags because your language files probably don't have those:
<GeneDef>
<defName>CombatEvolution</defName>
<label>combat evolution</label>
<description>Carriers of this gene can become specialized in melee or shooting with enough practice. In certain cases, this may evolve in unexpected ways.</description>
<geneClass>EBSGFramework.Gene_EvolvingGene</geneClass>
<biostatMet>-3</biostatMet>
<modExtensions>
<li Class="EBSGFramework.EBSGExtension">
<geneticEvolutions>
<li>
<result>AptitudeRemarkable_Shooting</result>
<message>EvolutionCombat</message>
<skillRequirements>
<Shooting>10~20</Shooting>
</skillRequirements>
</li>
<li>
<result>AptitudeRemarkable_Melee</result>
<message>EvolutionCombat</message>
<skillRequirements>
<Melee>10~20</Melee>
</skillRequirements>
</li>
<li>
<result>WoundHealing_SuperFast</result>
<message>EvolutionHealing</message>
<hasAnyOfHediff>
<BloodLoss>0.8~1</BloodLoss>
</hasAnyOfHediff>
</li>
<li>
<chancePerCheck>0.05</chancePerCheck>
<message>Gene lost to counter malnutrition</message>
<messageType>NegativeHealthEvent</messageType>
<hasAnyOfHediff>
<Malnutrition />
</hasAnyOfHediff>
</li>
</geneticEvolutions>
</li>
</modExtensions>
</GeneDef>