Files
Bubberstation/code/modules/unit_tests/metabolizing.dm
SmArtKar eb2796831b [MDB Ignore] Refactors pills, patches, and generalizes stomach contents, nothing to see here. (#89549)
## About The Pull Request

Currently patches are a subtype of pills, and while they have the
``dissolveable`` var set to FALSE, barely anything checks it (because
people don't expect patches to be pills in disguise) so we end up
patches being dissolveable and implantable, which is far from ideal.
Both have been moved into an ``/obj/item/reagent_containers/applicator``
class, which handles their common logic and helps handling cases where
either one fits. As for gameplay changes:
* Pills no longer dissolve instantly, instead adding their contents to
your stomach after 3 seconds (by default). You can increase the timer by
dropping sugar onto them to thicken their coating, 1s per 1u applied, up
to a full minute. Coating can also be dissolved with water, similarly
-1s per 1u applied. Pills with no coating will work like before.
* Patches now only take half as long to apply (1.5s), but also slowly
trickle in their reagents instead of instantly applying all of them.
This is done via embedding so you could theoretically (if you get lucky)
stick a ranged patch at someone, although they are rather quick to rip
off. The implementation and idea itself are separate, but the idea for
having a visual display has been taken from
https://github.com/Monkestation/Monkestation2.0/pull/2558.

![dreamseeker_Ywd4jQcy3t](https://github.com/user-attachments/assets/7ce0e549-9ecd-4a8a-98ea-12e00754bdd9)
* In order to support the new pill mechanics, stomachs have received
contents. Pills and items that you accidentally swallow now go into your
stomach instead of your chest cavity, and may damage it if they're
sharp, requiring having them surgically cut out (cut the stomach open
with a scalpel, then cauterize it to mend the incision). Or maybe you
can get a bacchus's blessing, or a geneticist hulk to gut punch you,
that may also work. Alien devour ability also uses this system now. If
you get a critical slashing wound on your chest contents of your cut
apart stomach (if a surgeon forgot to mend it, or if you ate too much
glass shard for breakfast) may fall out. However, spacemen with the
strong stomach trait can eat as much glass cereal as they want.

Pill duration can also be chosen in ChemMaster when you have a pill
selected, 0 to 30 seconds.

![image](https://github.com/user-attachments/assets/1f40210e-74dd-49c2-8093-432a747ac8dd)

## Why It's Good For The Game

Patches and pills are extremely similar in their implemenation, former
being a worse version of sprays and pills, with only change being that
pills cannot be applied through helmets while patches and sprays ignore
both. This change makes them useful for separate cases, and allows
reenactment of some classic... movie, scenes, with the pill change. As
for stomach contents, this was probably the sanest way of implementing
pill handling, and everything else (item swallowing and cutting stomachs
open to remove a cyanide pill someone ate before it dissolves) kind of
snowballed from there. I pray to whatever gods that are out there that
this won't have some extremely absurd and cursed interactions (it
probably will).

## Changelog
🆑
add: Instead of dissolving instantly, pills now activate after 4
seconds. This timer can be increased by using a dropper filled with
sugar on them, 1s added per 1u dropped.
add: Patches now stick to you and slowly bleed their reagents, instead
of being strictly inferior to both pills and sprays.
add: Items that you accidentally swallow now go into your stomach
contents.
refactor: Patches are no longer considered pills by the game
refactor: All stomachs now have contents, instead of it being exclusive
to aliens. You can cut open a stomach to empty it with a scalpel, and
mend an existing incision with a cautery.
/🆑
2025-03-13 17:31:37 +01:00

125 lines
4.9 KiB
Plaintext

/datum/unit_test/metabolization/Run()
// Pause natural mob life so it can be handled entirely by the test
SSmobs.pause()
var/mob/living/carbon/human/human = allocate(/mob/living/carbon/human/consistent)
var/list/blacklisted_reagents = list(
/datum/reagent/eigenstate, //Creates clones after a delay which get into other tests
)
var/list/reagents_to_check = subtypesof(/datum/reagent) - blacklisted_reagents - GLOB.fake_reagent_blacklist
for (var/reagent_type in reagents_to_check)
test_reagent(human, reagent_type)
/datum/unit_test/metabolization/proc/test_reagent(mob/living/carbon/C, reagent_type)
C.reagents.add_reagent(reagent_type, 10)
C.reagents.metabolize(C, SSMOBS_DT, 0, can_overdose = TRUE)
C.reagents.clear_reagents()
/datum/unit_test/metabolization/Destroy()
SSmobs.ignite()
return ..()
/datum/unit_test/on_mob_end_metabolize/Run()
SSmobs.pause()
var/mob/living/carbon/human/user = allocate(/mob/living/carbon/human/consistent)
var/obj/item/reagent_containers/applicator/pill/pill = allocate(/obj/item/reagent_containers/applicator/pill)
var/datum/reagent/drug/methamphetamine/meth = /datum/reagent/drug/methamphetamine
// Give them enough meth to be consumed in 2 metabolizations
pill.reagents.add_reagent(meth, 1.9 * initial(meth.metabolization_rate) * SSMOBS_DT)
pill.layers_remaining = 0
pill.interact_with_atom(user, user)
user.Life(SSMOBS_DT)
TEST_ASSERT(user.reagents.has_reagent(meth), "User does not have meth in their system after consuming it")
TEST_ASSERT(user.has_movespeed_modifier(/datum/movespeed_modifier/reagent/methamphetamine), "User consumed meth, but did not gain movespeed modifier")
user.Life(SSMOBS_DT)
TEST_ASSERT(!user.reagents.has_reagent(meth), "User still has meth in their system when it should've finished metabolizing")
TEST_ASSERT(!user.has_movespeed_modifier(/datum/movespeed_modifier/reagent/methamphetamine), "User still has movespeed modifier despite not containing any more meth")
/datum/unit_test/on_mob_end_metabolize/Destroy()
SSmobs.ignite()
return ..()
/datum/unit_test/addictions/Run()
SSmobs.pause()
var/mob/living/carbon/human/pill_user = allocate(/mob/living/carbon/human/consistent)
var/mob/living/carbon/human/syringe_user = allocate(/mob/living/carbon/human/consistent)
var/mob/living/carbon/human/pill_syringe_user = allocate(/mob/living/carbon/human/consistent)
var/datum/mind/pill_mind = new /datum/mind(null)
pill_mind.active = TRUE
pill_mind.transfer_to(pill_user)
var/datum/mind/syringe_mind = new /datum/mind(null)
syringe_mind.active = TRUE
syringe_mind.transfer_to(syringe_user)
var/datum/mind/pill_syringe_mind = new /datum/mind(null)
pill_syringe_mind.active = TRUE
pill_syringe_mind.transfer_to(pill_syringe_user)
var/obj/item/reagent_containers/applicator/pill/pill = allocate(/obj/item/reagent_containers/applicator/pill)
var/obj/item/reagent_containers/applicator/pill/pill_two = allocate(/obj/item/reagent_containers/applicator/pill)
var/obj/item/reagent_containers/syringe/syringe = allocate(/obj/item/reagent_containers/syringe)
var/datum/reagent/drug/methamphetamine/meth = allocate(/datum/reagent/drug/methamphetamine)
var/addiction_type_to_check
for(var/key in meth.addiction_types)
addiction_type_to_check = key //idk how to do this otherwise
// Let's start with stomach metabolism
pill.reagents.add_reagent(meth.type, 5)
pill.layers_remaining = 0
pill.interact_with_atom(pill_user, pill_user)
// Set the metabolism efficiency to 1.0 so it transfers all reagents to the body in one go.
var/obj/item/organ/stomach/pill_belly = pill_user.get_organ_slot(ORGAN_SLOT_STOMACH)
pill_belly.metabolism_efficiency = 1
pill_user.Life()
TEST_ASSERT(pill_user.mind.addiction_points[addiction_type_to_check], "User did not gain addiction points after metabolizing meth")
// Then injected metabolism
syringe.volume = 5
syringe.amount_per_transfer_from_this = 5
syringe.reagents.add_reagent(meth.type, 5)
syringe.melee_attack_chain(syringe_user, syringe_user)
syringe_user.Life()
TEST_ASSERT(syringe_user.mind.addiction_points[addiction_type_to_check], "User did not gain addiction points after metabolizing meth")
// One half syringe
syringe.reagents.remove_all()
syringe.volume = 5
syringe.amount_per_transfer_from_this = 5
syringe.reagents.add_reagent(meth.type, (5 * 0.5) + 1)
// One half pill
pill_two.reagents.add_reagent(meth.type, (5 * 0.5) + 1)
pill_two.layers_remaining = 0
pill_two.interact_with_atom(pill_syringe_user, pill_syringe_user)
syringe.melee_attack_chain(pill_syringe_user, pill_syringe_user)
// Set the metabolism efficiency to 1.0 so it transfers all reagents to the body in one go.
pill_belly = pill_syringe_user.get_organ_slot(ORGAN_SLOT_STOMACH)
pill_belly.metabolism_efficiency = 1
pill_syringe_user.Life()
TEST_ASSERT(pill_syringe_user.mind.addiction_points[addiction_type_to_check], "User did not gain addiction points after metabolizing meth")
/datum/unit_test/addictions/Destroy()
SSmobs.ignite()
return ..()