Skip to content

Commit

Permalink
Fermichem 2.5 - Organ(kinda) related medicines adjustments! (tgstatio…
Browse files Browse the repository at this point in the history
…n#57806)

* Initial dump

* Getting there

* Update impure_medicine_reagents.dm

* Update impure_medicine_reagents.dm

* Adds the reaction mechanics

* Compiling fixes

* Update medicine_reagents.dm

* Updates the debug machine to allow for live recipe edits and tweaks the rest of the stuff

* Few fixes and things I missed

* linters

* Feedback changes

* Apply suggestions from code review. Thanks ATH1909!

Co-authored-by: ATH1909 <[email protected]>

* More changes

* Few more tweaks before component and eyes

* Update chem_recipe_debug.dm

* Fixes loop I think

* I guess I'll just have to hope qdel does it's job

* It really doesn't like nullspace

* Fixes bug in oculine and misspelling

* No obsessed traumas to avoid forced antaging

Co-authored-by: ATH1909 <[email protected]>
Co-authored-by: Aleksej Komarov <[email protected]>
  • Loading branch information
3 people authored Apr 10, 2021
1 parent cc6f1b3 commit 5605978
Show file tree
Hide file tree
Showing 13 changed files with 722 additions and 85 deletions.
5 changes: 3 additions & 2 deletions code/modules/mob/living/brain/brain_item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@
//Direct trauma gaining proc. Necessary to assign a trauma to its brain. Avoid using directly.
/obj/item/organ/brain/proc/brain_gain_trauma(datum/brain_trauma/trauma, resilience, list/arguments)
if(!can_gain_trauma(trauma, resilience))
return
return FALSE

var/datum/brain_trauma/actual_trauma
if(ispath(trauma))
Expand All @@ -378,7 +378,7 @@

if(actual_trauma.brain) //we don't accept used traumas here
WARNING("gain_trauma was given an already active trauma.")
return
return FALSE

traumas += actual_trauma
actual_trauma.brain = src
Expand All @@ -389,6 +389,7 @@
actual_trauma.resilience = resilience
. = actual_trauma
SSblackbox.record_feedback("tally", "traumas", 1, actual_trauma.type)
return TRUE

//Add a random trauma of a certain subtype
/obj/item/organ/brain/proc/gain_trauma_type(brain_trauma_type = /datum/brain_trauma, resilience, natural_gain = FALSE)
Expand Down
55 changes: 55 additions & 0 deletions code/modules/reagents/chemistry/machinery/chem_recipe_debug.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
var/beaker_spawn = FALSE
///If we force min temp on reaction setup
var/min_temp = FALSE
///The recipe we're editing
var/datum/chemical_reaction/edit_recipe

///Create reagents datum
/obj/machinery/chem_recipe_debug/Initialize()
Expand Down Expand Up @@ -207,6 +209,7 @@
data["endIndex"] = cached_reactions.len
data["beakerSpawn"] = beaker_spawn
data["minTemp"] = min_temp
data["editRecipe"] = null

var/list/beaker_contents = list()
for(var/datum/reagent/reagent as anything in reagents.reagent_list)
Expand Down Expand Up @@ -261,6 +264,24 @@
data["activeReactions"] = active_reactions
data["isFlashing"] = flashing

if(edit_recipe)
data["editRecipeName"] = edit_recipe.type
data["editRecipeCold"] = edit_recipe.is_cold_recipe
data["editRecipe"] = list(
list("name" = "required_temp" , "var" = edit_recipe.required_temp),
list("name" = "optimal_temp" , "var" = edit_recipe.optimal_temp),
list("name" = "overheat_temp" , "var" = edit_recipe.overheat_temp),
list("name" = "optimal_ph_min" , "var" = edit_recipe.optimal_ph_min),
list("name" = "optimal_ph_max" , "var" = edit_recipe.optimal_ph_max),
list("name" = "determin_ph_range" , "var" = edit_recipe.determin_ph_range),
list("name" = "temp_exponent_factor" , "var" = edit_recipe.temp_exponent_factor),
list("name" = "ph_exponent_factor" , "var" = edit_recipe.ph_exponent_factor),
list("name" = "thermic_constant" , "var" = edit_recipe.thermic_constant),
list("name" = "H_ion_release" , "var" = edit_recipe.H_ion_release),
list("name" = "rate_up_lim" , "var" = edit_recipe.rate_up_lim),
list("name" = "purity_min" , "var" = edit_recipe.purity_min),
)

return data

/obj/machinery/chem_recipe_debug/ui_act(action, params)
Expand Down Expand Up @@ -335,6 +356,40 @@
relay_all_reactions()
if("minTemp")
min_temp = !min_temp
if("setEdit")
var/name = (input("Enter the name of any reagent", "Input") as text|null)
reaction_names = list()
if(!text)
say("Could not find reaction")
var/datum/reagent/reagent = find_reagent_object_from_type(get_chem_id(name))
if(!reagent)
say("Could not find [name]")
return
var/datum/chemical_reaction/reaction = GLOB.chemical_reactions_list_product_index[reagent.type]
if(!reaction)
say("Could not find [name] reaction!")
return
edit_recipe = reaction[1]
if("updateVar")
var/target = params["target"]
edit_recipe.vars[params["type"]] = target
if("export")
var/export = {"[edit_recipe.type]
[edit_recipe.is_cold_recipe ? "is_cold_recipe = TRUE" : ""]
required_temp = [edit_recipe.required_temp]
optimal_temp = [edit_recipe.optimal_temp]
overheat_temp = [edit_recipe.overheat_temp]
optimal_ph_min = [edit_recipe.optimal_ph_min]
optimal_ph_max = [edit_recipe.optimal_ph_max]
determin_ph_range = [edit_recipe.determin_ph_range]
temp_exponent_factor = [edit_recipe.temp_exponent_factor]
ph_exponent_factor = [edit_recipe.ph_exponent_factor]
thermic_constant = [edit_recipe.thermic_constant]
H_ion_release = [edit_recipe.H_ion_release]
rate_up_lim = [edit_recipe.rate_up_lim]
purity_min = [edit_recipe.purity_min]"}
say(export)
text2file(export, "[GLOB.log_directory]/chem_parse.txt")


/obj/machinery/chem_recipe_debug/ui_interact(mob/user, datum/tgui/ui)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/reagents/chemistry/reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ Primarily used in reagents/reaction_agents
return

/// Called when a reagent is inside of a mob when they are dead
/datum/reagent/proc/on_mob_dead(mob/living/carbon/C)
/datum/reagent/proc/on_mob_dead(mob/living/carbon/C, delta_time)
if(!(chemical_flags & REAGENT_DEAD_PROCESS))
return
current_cycle++
if(length(reagent_removal_skip_list))
return
holder.remove_reagent(type, metabolization_rate * C.metabolism_efficiency)
holder.remove_reagent(type, metabolization_rate * C.metabolism_efficiency * delta_time)

/// Called by [/datum/reagents/proc/conditional_update_move]
/datum/reagent/proc/on_move(mob/M)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
purity = REAGENT_STANDARD_PURITY
inverse_chem_val = 0
inverse_chem = null
failed_chem = /datum/reagent/impurity/healing/medicine_failure
chemical_flags = REAGENT_SPLITRETAINVOL

/******BRUTE******/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,14 @@ Basically, we fill the time between now and 2s from now with hands based off the
this_liver.alcohol_tolerance *= 2

/datum/reagent/impurity/libitoil/proc/on_gained_organ(mob/prev_owner, obj/item/organ/organ)
SIGNAL_HANDLER
if(!istype(organ, /obj/item/organ/liver))
return
var/obj/item/organ/liver/this_liver = organ
this_liver.alcohol_tolerance *= 2

/datum/reagent/impurity/libitoil/proc/on_removed_organ(mob/prev_owner, obj/item/organ/organ)
SIGNAL_HANDLER
if(!istype(organ, /obj/item/organ/liver))
return
var/obj/item/organ/liver/this_liver = organ
Expand Down Expand Up @@ -366,6 +368,7 @@ Basically, we fill the time between now and 2s from now with hands based off the
apply_lung_levels(lungs)

/datum/reagent/inverse/healing/convermol/proc/on_gained_organ(mob/prev_owner, obj/item/organ/organ)
SIGNAL_HANDLER
if(!istype(organ, /obj/item/organ/lungs))
return
var/obj/item/organ/lungs/lungs = organ
Expand All @@ -388,6 +391,7 @@ Basically, we fill the time between now and 2s from now with hands based off the
lungs.cold_level_3_threshold *= creation_purity * 0.5

/datum/reagent/inverse/healing/convermol/proc/on_removed_organ(mob/prev_owner, obj/item/organ/organ)
SIGNAL_HANDLER
if(!istype(organ, /obj/item/organ/lungs))
return
var/obj/item/organ/lungs/lungs = organ
Expand Down Expand Up @@ -497,7 +501,7 @@ Basically, we fill the time between now and 2s from now with hands based off the
///If we brought someone back from the dead
var/back_from_the_dead = FALSE

/datum/reagent/inverse/penthrite/on_mob_dead(mob/living/carbon/owner)
/datum/reagent/inverse/penthrite/on_mob_dead(mob/living/carbon/owner, delta_time)
var/obj/item/organ/heart/heart = owner.getorganslot(ORGAN_SLOT_HEART)
if(!heart || heart.organ_flags & ORGAN_FAILING)
return ..()
Expand Down Expand Up @@ -567,3 +571,222 @@ Basically, we fill the time between now and 2s from now with hands based off the
owner.remove_movespeed_modifier(/datum/movespeed_modifier/reagent/nooartrium)
owner.remove_actionspeed_modifier(/datum/actionspeed_modifier/nooartrium)

/* Non c2 medicines */

/datum/reagent/impurity/mannitol
name = "Mannitoil"
description = "Gives the patient a temporary speech impediment."
color = "#CDCDFF"
addiction_types = list(/datum/addiction/medicine = 5)
ph = 12.4
liver_damage = 0
///The speech we're forcing on the owner
var/speech_option

/datum/reagent/impurity/mannitol/on_mob_add(mob/living/owner, amount)
. = ..()
if(!iscarbon(owner))
return
var/mob/living/carbon/carbon = owner
if(!carbon.dna)
return
var/list/speech_options = list(SWEDISH, UNINTELLIGIBLE, STONER, MEDIEVAL, WACKY, NERVOUS, MUT_MUTE)
while(speech_options || !speech_option)
var/potential_option = pick(speech_options)
if(carbon.dna.get_mutation(potential_option))
speech_options -= potential_option
continue
if(carbon.dna.activate_mutation(potential_option))
speech_option = potential_option
return
else
speech_options -= potential_option


/datum/reagent/impurity/mannitol/on_mob_delete(mob/living/owner)
. = ..()
if(!iscarbon(owner))
return
var/mob/living/carbon/carbon = owner
carbon.dna?.remove_mutation(speech_option)

/datum/reagent/inverse/neurine
name = "Neruwhine"
description = "Induces a temporary brain trauma in the patient by redirecting neuron activity."
color = "#DCDCAA"
ph = 13.4
addiction_types = list(/datum/addiction/medicine = 8)
metabolization_rate = 0.025 * REM
tox_damage = 0
//The temporary trauma passed to the owner
var/datum/brain_trauma/temp_trauma

/datum/reagent/inverse/neurine/on_mob_life(mob/living/carbon/owner, delta_time, times_fired)
.=..()
if(temp_trauma)
return
if(!(DT_PROB(creation_purity*10, delta_time)))
return
var/traumalist = subtypesof(/datum/brain_trauma)
traumalist -= /datum/brain_trauma/severe/split_personality //Uses a ghost, I don't want to use a ghost for a temp thing.
traumalist -= /datum/brain_trauma/special/obsessed //Sets the owner as an antag - I presume this will lead to problems, so we'll remove it
var/obj/item/organ/brain/brain = owner.getorganslot(ORGAN_SLOT_BRAIN)
while(traumalist || !temp_trauma)
var/datum/brain_trauma/trauma = pick(traumalist)
if(brain.brain_gain_trauma(trauma, TRAUMA_RESILIENCE_MAGIC))
temp_trauma = trauma
return
else
traumalist -= trauma

/datum/reagent/inverse/neurine/on_mob_delete(mob/living/carbon/owner)
.=..()
if(!temp_trauma)
return
if(istype(temp_trauma, /datum/brain_trauma/special/imaginary_friend))//Good friends stay by you, no matter what
return
owner.cure_trauma_type(temp_trauma, resilience = TRAUMA_RESILIENCE_MAGIC)

/datum/reagent/inverse/corazargh
name = "Corazargh" //It's what you yell! Though, if you've a better name feel free. Also an omage to an older chem
description = "Interferes with the body's natural pacemaker, forcing the patient to manually beat their heart."
color = "#5F5F5F"
self_consuming = TRUE
ph = 13.5
addiction_types = list(/datum/addiction/medicine = 2.5)
metabolization_rate = 0.01 * REM
chemical_flags = REAGENT_DEAD_PROCESS
tox_damage = 0
///The old heart we're swapping for
var/obj/item/organ/heart/original_heart
///The new heart that's temp added
var/obj/item/organ/heart/cursed/manual_heart

///Creates a new cursed heart and puts the old inside of it, then replaces the position of the old
/datum/reagent/inverse/corazargh/on_mob_metabolize(mob/living/owner)
if(!iscarbon(owner))
return
var/mob/living/carbon/carbon_mob = owner
original_heart = owner.getorganslot(ORGAN_SLOT_HEART)
if(!original_heart)
return
manual_heart = new(null, src)
original_heart.Remove(carbon_mob, special = TRUE) //So we don't suddenly die
original_heart.forceMove(manual_heart)
original_heart.organ_flags |= ORGAN_FROZEN //Not actually frozen, but we want to pause decay
manual_heart.Insert(carbon_mob, special = TRUE)
//these last so instert doesn't call them
RegisterSignal(carbon_mob, COMSIG_CARBON_GAIN_ORGAN, .proc/on_gained_organ)
RegisterSignal(carbon_mob, COMSIG_CARBON_LOSE_ORGAN, .proc/on_removed_organ)
to_chat(owner, "<span class='userdanger'>You feel your heart suddenly stop beating on it's own - you'll have to manually beat it!</spans>")
..()

///Intercepts the new heart and creates a new cursed heart - putting the old inside of it
/datum/reagent/inverse/corazargh/proc/on_gained_organ(mob/owner, obj/item/organ/organ)
SIGNAL_HANDLER
if(!istype(organ, /obj/item/organ/heart))
return
var/mob/living/carbon/carbon_mob = owner
original_heart = organ
original_heart.Remove(carbon_mob, special = TRUE)
original_heart.forceMove(manual_heart)
original_heart.organ_flags |= ORGAN_FROZEN //Not actually frozen, but we want to pause decay
if(!manual_heart)
manual_heart = new(null, src)
manual_heart.Insert(carbon_mob, special = TRUE)

///If we're ejecting out the organ - replace it with the original
/datum/reagent/inverse/corazargh/proc/on_removed_organ(mob/prev_owner, obj/item/organ/organ)
SIGNAL_HANDLER
if(!organ == manual_heart)
return
original_heart.forceMove(organ.loc)
original_heart.organ_flags &= ~ORGAN_FROZEN //enable decay again
qdel(organ)

///We're done - remove the curse and restore the old one
/datum/reagent/inverse/corazargh/on_mob_end_metabolize(mob/living/owner)
//Do these first so Insert doesn't call them
UnregisterSignal(owner, COMSIG_CARBON_LOSE_ORGAN)
UnregisterSignal(owner, COMSIG_CARBON_GAIN_ORGAN)
if(!iscarbon(owner))
return
var/mob/living/carbon/carbon_mob = owner
if(original_heart) //Mostly a just in case
original_heart.organ_flags &= ~ORGAN_FROZEN //enable decay again
original_heart.Insert(carbon_mob, special = TRUE)
qdel(manual_heart)
to_chat(owner, "<span class='userdanger'>You feel your heart start beating normally again!</spans>")
..()

/datum/reagent/inverse/antihol
name = "Prohol"
description = "Promotes alcoholic substances within the patients body, making their effects more potent."
taste_description = "alcohol" //mostly for sneaky slips
chemical_flags = REAGENT_INVISIBLE
metabolization_rate = 0.05 * REM//This is fast
addiction_types = list(/datum/addiction/medicine = 4.5)
color = "#4C8000"
tox_damage = 0

/datum/reagent/inverse/antihol/on_mob_life(mob/living/carbon/C, delta_time, times_fired)
for(var/datum/reagent/consumable/ethanol/alcohol in C.reagents.reagent_list)
alcohol.boozepwr += delta_time
..()

/datum/reagent/inverse/oculine
name = "Oculater"
description = "Temporarily blinds the patient."
reagent_state = LIQUID
color = "#DDDDDD"
metabolization_rate = 0.1 * REM
addiction_types = list(/datum/addiction/medicine = 3)
taste_description = "funky toxin"
ph = 13
tox_damage = 0
metabolization_rate = 0.2 * REM
///Did we get a headache?
var/headache = FALSE

/datum/reagent/inverse/oculine/on_mob_life(mob/living/carbon/owner, delta_time, times_fired)
if(headache)
return ..()
if(DT_PROB(100*(1-creation_purity), delta_time))
owner.become_blind("oculine_impure")
to_chat(owner, "<span class='warning'>You suddenly develop a pounding headache as your vision fluxuates.</spans>")
headache = TRUE
..()

/datum/reagent/inverse/oculine/on_mob_end_metabolize(mob/living/owner)
owner.cure_blind("oculine_impure")
if(headache)
to_chat(owner, "<span class='notice'>Your headache clears up!</spans>")
..()

/datum/reagent/impurity/inacusiate
name = "Tinacusiate"
description = "Makes the patient's hearing temporarily funky."
reagent_state = LIQUID
addiction_types = list(/datum/addiction/medicine = 5.6)
color = "#DDDDFF"
taste_description = "the heat evaporating from your mouth."
ph = 1
liver_damage = 0.1
metabolization_rate = 0.04 * REM
///The random span we start hearing in
var/randomSpan

/datum/reagent/impurity/inacusiate/on_mob_metabolize(mob/living/owner, delta_time, times_fired)
randomSpan = pick(list("clown", "small", "big", "hypnophrase", "alien", "cult", "alert", "danger", "emote", "yell", "brass", "sans", "papyrus", "robot", "his_grace", "phobia"))
RegisterSignal(owner, COMSIG_MOVABLE_HEAR, .proc/owner_hear)
to_chat(owner, "<span class='notice'>Your hearing seems to be a bit off...!</spans>")
..()

/datum/reagent/impurity/inacusiate/on_mob_end_metabolize(mob/living/owner)
UnregisterSignal(owner, COMSIG_MOVABLE_HEAR)
to_chat(owner, "<span class='notice'>You start hearing things normally again.</spans>")
..()

/datum/reagent/impurity/inacusiate/proc/owner_hear(datum/source, list/hearing_args)
SIGNAL_HANDLER
hearing_args[HEARING_RAW_MESSAGE] = "<span class='[randomSpan]'>[hearing_args[HEARING_RAW_MESSAGE]]</span>"
Loading

0 comments on commit 5605978

Please sign in to comment.