Conditional Stat Affecters - KonradHeinser/EBSGFramework GitHub Wiki
Conditional Stat Affecters are things that can be added to genes that cause stats inside it to only be changed when conditions are met. Unlike most conditional stat affecters, the ones in this framework are more flexible than normal. They don't check for specific values, but instead let you set the list of things it checks for, or the range of values that are valid:
- Capacity : Active based on the pawn's capacities, like sight
- Hediff : Active based on the hediffs the pawn currently has
- Gene : Active based on other genes the pawn has
- Light : Active based on the light level of the area around the pawn
- Map Condition : Active based on the current map condition (i.e. psychic drone, eclipse, heat wave, cold snap, etc)
- Need : Active based on need levels of the pawn
- Terrains : Active based on the terrain the pawn is standing on, including generic checks for if it is a type of water or not
- Rain/Snow Rate : Active when the map has the right rain and/or snow rate
- Skills : Active based on the pawn's sklll levels
- Temperature : Active based on the temperature of the area around the pawn
- Time : Active based on the time of day
- Weather : Active based on the current weather of the map
Multi Conditionals combine various conditionals into one, but should only be used if no other conditional would work. Because they have more things to check for, they can often be more taxing on performance if overused:
- Map Multi : This only covers conditions that only relate to the area around the pawn (i.e. light levels, temperature, time, etc)
- Pawn Multi : This only covers conditions that only relate to the pawn themselves (i.e. hediffs, skills, genes, etc)
- Generic Multi : Checks all the conditionals in this framework
Some examples of how the code is set up. While the specific tags may change, the overall structure and concepts will remain the same:
<GeneDef>
<defName>EBSG_MostlyAquatic</defName>
<label>mostly aquatic</label>
<iconPath>UI/Icons/Genes/Gene_HairColor</iconPath>
<displayCategory>Miscellaneous</displayCategory>
<conditionalStatAffecters>
<li Class="EBSGFramework.ConditionalStatAffecter_Terrain">
<anyWater>True</anyWater>
<label>in non-swampy water</label>
<hateTerrains>True</hateTerrains>
<terrains>
<li>Marsh</li>
</terrains>
<statFactors>
<MoveSpeed>2</MoveSpeed>
</statFactors>
</li>
<li Class="EBSGFramework.ConditionalStatAffecter_Terrain">
<anyNonWater>True</anyNonWater>
<label>on land or in swampy water</label>
<terrains>
<li>Marsh</li>
</terrains>
<statFactors>
<MoveSpeed>0.5</MoveSpeed>
</statFactors>
</li>
</conditionalStatAffecters>
</GeneDef>
<GeneDef>
<defName>BloodySpeed</defName>
<label>bloody speed</label>
<description>Ability to control blood makes this pawn go fast.</description>
<iconPath>UI/Icons/Genes/Gene_Hemogenic</iconPath>
<displayCategory>Hemogen</displayCategory>
<conditionalStatAffecters>
<li Class="EBSGFramework.ConditionalStatAffector_OtherGenes">
<anyOfGenes>
<li>Hemogenic</li>
</anyOfGenes>
<label>hemogenic</label>
<statOffsets>
<MoveSpeed>2</MoveSpeed>
</statOffsets>
</li>
</conditionalStatAffecters>
</GeneDef>
<GeneDef>
<defName>InconvenientReproductiveOrgans</defName>
<label>big balls/ovaries</label>
<description>If the parts aren't sterilized medically there may be issues.</description>
<iconPath>UI/Icons/Genes/Gene_Hemogenic</iconPath>
<displayCategory>Reproduction</displayCategory>
<conditionalStatAffecters>
<li Class="EBSGFramework.ConditionalStatAffector_Hediffs">
<anyOfHediffs>
<li>Sterilized</li>
<li>Vasectomy</li>
<li>ImplantedIUD</li>
<li>TubalLigation</li>
</anyOfHediffs>
<label>medically sterilized</label>
<statFactors>
<MoveSpeed>1.3</MoveSpeed>
</statFactors>
</li>
<li Class="EBSGFramework.ConditionalStatAffector_Hediffs">
<noneOfHediffs>
<li>Sterilized</li>
<li>Vasectomy</li>
<li>ImplantedIUD</li>
<li>TubalLigation</li>
</noneOfHediffs>
<label>not medically sterilized</label>
<statFactors>
<MoveSpeed>0.7</MoveSpeed>
<Fertility>2</Fertility>
</statFactors>
</li>
</conditionalStatAffecters>
<exclusionTags>
<li>Fertility</li>
</exclusionTags>
</GeneDef>