Botany Rework Part 1: Mutations (#31163)

Instead of each mutation being a flag that gets checked at some unique point in BotanySystem somewhere, they're now EntityEffects that get applied when the mutation occurs and when produce is harvested. One new list was added to SeedData so that multiple other fields could be removed.

All the non-stat-change mutations that have been rolled are added to the Mutations list, and get applied to the plant when the mutation occurs or when a seed with the mutation is planted. Produce get mutations applied at harvest if they apply to the produce, and carry all of the plant's mutations over as a seed. This gets rid of the one-off checks for things like Slippery, Bioluminescent, Sentient, etc.

The base odds of a mutation applying should be equal to the odds of the original mutation check. It pretended to have 1 bit flip (on averge) per mutation power, and odds of each mutation was the odds of one of its bit being flipped (1 /275 * bits). The 'thermometer code' applied for numbers will be replaced with simple random rolls, as both average out to the middle value. The new checks are much easier to understand and don't obfuscate the actual changes of something happening behind 3 layers of math. The biggest player-facing change is that Potency will be able to get over 65 significantly more often than it did in the previous system, but it will be just as common to get low values as high ones.

Mutation definitions have been moved to a .yml file. These include the odds per tick per mutagen strength of that mutation applying that tick, the effect applied, if it applies to the plant and/or its produce. This makes mutations simpler to add and edit.

This PR is limited specifically to the mutation logic. Improving other aspects of the system will be done in other PRs per the design document. Mutations was chosen first because its got the largest amount of one-off checks scattered all over that could be consolidated. Once this is merged, mutations could be contributed to the codebase with minimal extra work for later botany refactor PRs.
This commit is contained in:
drakewill-CRL
2024-09-14 23:12:17 -04:00
committed by GitHub
parent 62eaae6504
commit 1dec19cc05
19 changed files with 812 additions and 441 deletions

View File

@@ -0,0 +1,178 @@
- type: RandomPlantMutationList
id: RandomPlantMutations
mutations:
- name: Bioluminescent
baseOdds: 0.036
effect: !type:Glow
- name: Sentient
baseOdds: 0.0072
appliesToPlant: false # makes the botany tray sentient if true
effect: !type:MakeSentient # existing effect.
- name: Slippery
baseOdds: 0.036
effect: !type:Slipify
- name: ChangeSpecies
baseOdds: 0.036
appliesToProduce: false
effect: !type:PlantSpeciesChange
- name: Unviable
baseOdds: 0.109
persists: false
effect: !type:PlantChangeStat
targetValue: Viable
- name: ChangeWaterConsumption
baseOdds: 0.018
persists: false
effect: !type:PlantChangeStat
targetValue: WaterConsumption
minValue: 0.3
maxValue: 0.9
steps: 5
- name: ChangeNutrientConsumption
baseOdds: 0.018
persists: false
effect: !type:PlantChangeStat
targetValue: NutrientConsumption
minValue: 0.05
maxValue: 1.2
steps: 5
- name: ChangeIdealHeat
baseOdds: 0.018
persists: false
effect: !type:PlantChangeStat
targetValue: IdealHeat
minValue: 263
maxValue: 323
steps: 5
- name: ChangeHeatTolerance
baseOdds: 0.018
persists: false
effect: !type:PlantChangeStat
targetValue: HeatTolerance
minValue: 2
maxValue: 25
steps: 5
- name: ChangeToxinsTolerance
baseOdds: 0.018
persists: false
effect: !type:PlantChangeStat
targetValue: ToxinsTolerance
minValue: 1
maxValue: 10
steps: 5
- name: ChangeLowPressureTolerance
baseOdds: 0.018
persists: false
effect: !type:PlantChangeStat
targetValue: LowPressureTolerance
minValue: 60
maxValue: 100
steps: 5
- name: ChangeHighPressureTolerance
baseOdds: 0.018
persists: false
effect: !type:PlantChangeStat
targetValue: HighPressureTolerance
minValue: 100
maxValue: 140
steps: 5
- name: ChangePestTolerance
baseOdds: 0.018
persists: false
effect: !type:PlantChangeStat
targetValue: PestTolerance
minValue: 0
maxValue: 15
steps: 5
- name: ChangeWeedTolerance
baseOdds: 0.018
persists: false
effect: !type:PlantChangeStat
targetValue: WeedTolerance
minValue: 0
maxValue: 15
steps: 5
- name: ChangeEndurance
baseOdds: 0.036
persists: false
effect: !type:PlantChangeStat
targetValue: Endurance
minValue: 50
maxValue: 150
steps: 5
- name: ChangeYield
baseOdds: 0.036
persists: false
effect: !type:PlantChangeStat
targetValue: Yield
minValue: 3
maxValue: 10
steps: 5
- name: ChangeLifespan
baseOdds: 0.036
persists: false
effect: !type:PlantChangeStat
targetValue: Lifespan
minValue: 10
maxValue: 80
steps: 5
- name: ChangeMaturation
baseOdds: 0.036
persists: false
effect: !type:PlantChangeStat
targetValue: Maturation
minValue: 3
maxValue: 8
steps: 5
- name: ChangeProduction
baseOdds: 0.036
persists: false
effect: !type:PlantChangeStat
targetValue: Production
minValue: 1
maxValue: 10
steps: 5
- name: ChangePotency
baseOdds: 0.036
persists: false
effect: !type:PlantChangeStat
targetValue: Potency
minValue: 30
maxValue: 100
steps: 5
- name: ChangeSeedless
baseOdds: 0.036
persists: false
effect: !type:PlantChangeStat
targetValue: Seedless
- name: ChangeLigneous
baseOdds: 0.036
persists: false
effect: !type:PlantChangeStat
targetValue: Ligneous
- name: ChangeTurnIntoKudzu
baseOdds: 0.036
persists: false
effect: !type:PlantChangeStat
targetValue: TurnIntoKudzu
- name: ChangeScreaming
baseOdds: 0.036
persists: false
effect: !type:PlantChangeStat
targetValue: CanScream
- name: ChangeChemicals
baseOdds: 0.072
persists: false
effect: !type:PlantMutateChemicals
- name: ChangeExudeGasses
baseOdds: 0.0145
persists: false
effect: !type:PlantMutateExudeGasses
- name: ChangeConsumeGasses
baseOdds: 0.0036
persists: false
effect: !type:PlantMutateConsumeGasses
- name: ChangeHarvest
baseOdds: 0.036
persists: false
effect: !type:PlantMutateHarvest