Adds the framework for stacked metabolization effects (#95123)

## About The Pull Request
- You can now add effects when multiple reagents are metabolized per
tick by creating a new subtype of
`/datum/stacked_metabolization_effect`. So lets say you have 3 reagents
A & B & C and you want to implement some unique effect when all 3
reagents are present at the same time. Instead of implementing those
effect inside each of those reagents like such

```dm
/datum/reagentA/on_mob_life()
    if(holder.hasReagent(/datum/reagentB) && holder.hasReagent(/datum/reagentC))
        //do stuff

/datum/reagentB/on_mob_life()
    if(holder.hasReagent(/datum/reagentC) && holder.hasReagent(/datum/reagentA))
        //do stuff

/datum/reagentC/on_mob_life()
    if(holder.hasReagent(/datum/reagentA) && holder.hasReagent(/datum/reagentB))
        //do stuff
``` 

You can now implement that effect by creating a subtype of stack reagent
effect as such

```dm
/datum/stacked_metabolization_effect/unique_effect
	requirements = list(/datum/reagent/A = 1, /datum/reagent/B = 1, /datum/reagent/C = 1)

/datum/stacked_metabolization_effect/unique_effect/apply(list/reagents_metabolized, mob/living/carbon/owner, seconds_per_tick)
	var/metabolization_ratio = average(reagents_metabolized)
       //do stuff with the ratio
``` 

The effect is applied per tick and you can check for subtypes as well
like such

```dm
/datum/stacked_metabolization_effect/unique_effect
	requirements = list(/datum/reagent/A = 3)
``` 

## Why it's good for the game
The framework of stacked reagent effects allows contributors to
implement unique effects for metabolizing multiple reagents at once. The
benefits are obvious.
Right now it's a framework that is unused but should hopefully see some
use in the future

## Changelog
🆑
code: adds a framework for implementing effects when multiple reagents
are metabolized per tick
/🆑

---------

Co-authored-by: Jordan Dominion <jordanhcbrown+github@gmail.com>
This commit is contained in:
SyncIt21
2026-02-19 15:22:57 +01:00
committed by GitHub
co-authored by Jordan Dominion
parent 7e3bc5695e
commit 2eb4b5e0cb
6 changed files with 108 additions and 5 deletions
+1
View File
@@ -313,6 +313,7 @@
#include "spraycan.dm"
#include "spritesheets.dm"
#include "stack_singular_name.dm"
#include "stacked_metab.dm"
#include "station_trait_tests.dm"
#include "status_effect_validity.dm"
#include "stomach.dm"
+22
View File
@@ -0,0 +1,22 @@
/datum/unit_test/stacked_metabolization_effect_verify
/datum/unit_test/stacked_metabolization_effect_verify/Run()
for(var/datum/stacked_metabolization_effect/effect as anything in valid_subtypesof(/datum/stacked_metabolization_effect))
effect = new effect()
if(!length(effect.requirements))
TEST_FAIL("Effect [effect] does not have any requirments!")
qdel(effect)
continue
for(var/datum/reagent/key as anything in effect.requirements)
if(!ispath(key, /datum/reagent))
TEST_FAIL("Effect [effect] has an non reagent key [key] as requirment")
break
var/count = effect.requirements[key]
if(count < 1)
TEST_FAIL("Effect [effect] has an invalid requirement count [count] for key [key] ")
break
qdel(effect)