Rico-GeneticArtifact icon


Adds an artifact that emulates a genetic algorithm on monster stats.

Last updated 2 weeks ago
Total downloads 265623
Total rating 26 
Categories Mods Artifacts
Dependency string Rico-GeneticArtifact-4.5.3
Dependants 100 other packages depend on this package

This mod requires the following mods to function

RiskofThunder-HookGenPatcher-1.2.3 icon

MMHOOK generation at runtime.

Preferred version: 1.2.3
RiskofThunder-R2API_Language-1.0.1 icon

API for modifying the language localisation of the game

Preferred version: 1.0.1
RiskofThunder-R2API_ArtifactCode-1.0.1 icon

API for making Artifact Codes

Preferred version: 1.0.1
RiskofThunder-R2API_Items-1.0.3 icon

API for adding custom items

Preferred version: 1.0.3
bbepis-BepInExPack-5.4.2113 icon

Unified BepInEx all-in-one modding pack - plugin framework, detour library

Preferred version: 5.4.2113
RiskofThunder-R2API_RecalculateStats-1.3.0 icon

API for manipulating Character Stats

Preferred version: 1.3.0
RiskofThunder-R2API_ContentManagement-1.0.4 icon

API for adding content to the game

Preferred version: 1.0.4
RiskofThunder-R2API_Core-5.0.12 icon

Core R2API module

Preferred version: 5.0.12


Basic Description

  • This mod adds a genetics system to the monsters, with every stat being able to mutate in specific ways
  • The core stats that are affected are: Health, MoveSpeed, Damage, and AttackSpeed
  • The goal of the system detailed below is to allow the game to adapt to the player, and in turn force the player to adapt to it

How it Works

  • Every monster has four genes (Health, MoveSpeed, Damage, and AttackSpeed)
  • Every minute (or after 40 monster deaths), the algorithm learns from the fallen monsters and adjusts it's "strategy"
  • This learning is primarily done through a weighted average system that attempts to judge the "combat effectiveness" of a mutation

Video Explanations

Known Issues/Planned Updates

  • A feedback system (visual or other) to let the player know how the mutations are trending
  • I need to make some actual documentation/architecture to explain how it works from a dev point-of-view
  • Is GeneticsVariantsPatch coming back? Yep! Check it out here: https://thunderstore.io/package/Rico/GeneticVariantsPatch/
  • Is there anything else to add? Maybe. I'm considering making a patch for Artifacts of Doom and Risk of Chaos (*wink*)
  • Are you a dev who has questions? Make an issue on GitHub and flag it as a question, I'm always happy to help


- Added compatibility for RiskOfOptions
  - Gone are the days of restarting the game to update a config value
  - (Technically already could do this with DebugToolkit and saving over the config file)

- Publicized the monster copy adaption method, for dev usage
  - Should`ve done this a long time ago, but now devs can force specific mutations ad-hoc
  - Monster copy methods do not trigger RecalculateStats on their own, to avoid duplicated effort
- Added explicit RecalculateStats call on monster copy first generation
  - Monster spawn already does this iirc, but this guarantees genes take effect in fringe cases

- No new functionality, just refactored to use the Nuget packages instead of local libraries
  - Should make remote development much easier if I ever need to do that
- Gene-specific cap and floor overrides are back, and without config bloat this time
  - Two new config options, one to opt into using the overrides and the other to actually define them
  - Override syntax is "Gene1,FloorForGene1,CapForGene1|Gene2,FloorForGene2,CapForGene2"
    - Current valid Gene names are MaxHealth, MoveSpeed, AttackSpeed, and AttackDamage
	- Floors/caps need to be parseable into floats, and should follow the same rules as shared floor/cap

- Bugfix for the token calculation and application methods
  - Stat modifications should more accurately and consistently represent the monster`s genes
  - Previously was bugged to represent the difference from the master copy instead sometimes
- Also added public events to most major steps in the genetic engine, for dev usage
  - These include: master copy creation and mutation, monster copy mutation and scoring, and global engine learning

- Added mode that allows stat modifications to apply even if the artifact is disabled
  - This means no sudden drops in difficulty if you disable it mid-run
  - There`s a config option for this, and it`s disabled by default (ie the old behaviour)

- Re-Added a configuration file for this
  - Tweak-able values include: when and how the algorithm decides to learn, mutation rates and limits
  - Safety limits might be a bit strict for now, but I want testing a feedback before lifting them

- Fix for Patch 1.2.3 since there are items in here
  - Converted to the new ArtifactCodeAPI methods since they work now
  - Also converted items to ContentAddition methods, expect harmless warnings

- Updated for SOTV and new R2API build
  - Also fixed a fringe case nullref bug that could happen in the Bulwark

- Added a GeneBlocker item for use in GeneticVariantsPatch that prevents stat mutations from effecting the holder
  - This item also prevents the holder from scoring points and participating in the fitness evaluation

- Added portal code, compound, and challenge for the artifact (thanks to ArtifactCodeAPI)
  - The Genetics challenge will not be required to unlock it for new runs, but...
  - The challenge will instead provide a dramatic mutation rate while in the Bulwark (20%-500% instead of base 90%-110%)
  - Portal code - in left-right top-bottom order - is TDTCGCTDT

- Fixed the random assignment math that`s been broken since 4.0.0 (oops)
  - Monsters now have the chance to get stronger instead of just atrophying away
  - Random range is now 90%-110% instead of 90%-90%

- Adjusted/fixed the math in the RecalculateStatsAPI stat hook
  - Stat modifications should work like all non-4.0.5 versions now

- Rebuilt the hidden item stats using RecalculateStatsAPI from R2API v3.0.43
  - This should help prevent future conflicts with other stat-adjusting mods

- Adjusted TakeDamage hook to avoid certain nullrefs
  - This should prevent Glacial Wisps from infinitely exploding when they die
- Adjusted learning algorithm to round to 2 digits before spawning new bodies
  - Should prevent fringe cases where items are given when they shouldn`t be

- Algorithm will no longer attempt to give genes to bodies that lack inventories (Barrels, Pots, Vagrant Bombs, Urchins, etc.)
  - This would cause nullrefs for these bodies when it tried to allocate their genes
  - Mods that give inventories to these special bodies shouldn`t re-break them

- Fixed a potential divide-by-zero error that could happen during the learning cycle
  - This would only happen if a given BodyIndex had no scoring children

- Removed caching that was causing some major conflicts with certain lobby mods
  - This should fix not being able to start a run in most cases

- Reduced number of genes to 4 (Health, MoveSpeed, AttackSpeed, and AttackDamage)
  - Regen and Armor either didn`t apply to most monsters, or were used by the algorithm to "cheat-out" extra points in other stats
  - Size never really worked they way I wanted, and balancing it doesn`t make much sense
  - The remaining stats should keep the algorithm learning and guessing, instead of just sticking with one stat
- Max and Min gene values have been greatly expanded (0.01 to 10.00, starting at 1.00)
  - Max Product has also been adjusted (from 10 down to 1.5)
  - This should prevent the algorithm from maxing multiple stats, instead pushing for a more balanced build
- Scoring algorithm has been adjusted to focus on time spent in combat instead of just dps
  - Should prevent mega-tanks and glass-cannons, instead pushing for solid combatants
- Learning algorithm has been revamped to use new scores and more data
  - Instead of every 10 seconds, the learn only runs every 60 seconds or once enough data (40 monsters) is available
  - This may seem significantly slower than before, but the extra data means that it can be "smarter" with it
- Networking is now managed through hidden items
  - Host is now the source of truth for the algorithm, no more work for clients
- Rapid Mutation and Infection have been removed
  - Infection was unstable at best and buggy more often than it was worth
  - Rapid Mutation might come back if demand is high enough, but the new algorithm benefits from having more data


Place the .dll in Risk of Rain 2\BepInEx\plugins or use a mod manager.


If you have issues/suggestions leave them on the github as an issue/suggestion or reach out to Rico#6416 on the modding Discord.