From b8190552f142566096e7e07ae5e52d29d01f40a9 Mon Sep 17 00:00:00 2001 From: Fermi <> Date: Thu, 19 Sep 2019 21:24:50 +0100 Subject: [PATCH] Update defines, and vars, and created new procs --- code/__DEFINES/reagents.dm | 7 ++- code/modules/mob/living/carbon/life.dm | 6 +- code/modules/reagents/chemistry/reagents.dm | 59 ++++++++++--------- .../chemistry/reagents/alcohol_reagents.dm | 2 +- code/modules/reagents/chemistry/recipes.dm | 1 + .../reagents/chemistry/reagents/MKUltra.dm | 3 +- .../reagents/chemistry/reagents/SDGF.dm | 1 + .../chemistry/reagents/fermi_reagents.dm | 7 ++- .../reagents/chemistry/reagents/healing.dm | 2 +- .../reagents/chemistry/recipes/fermi.dm | 18 +++++- 10 files changed, 66 insertions(+), 40 deletions(-) diff --git a/code/__DEFINES/reagents.dm b/code/__DEFINES/reagents.dm index 9b91fb72d0..36ea64de2c 100644 --- a/code/__DEFINES/reagents.dm +++ b/code/__DEFINES/reagents.dm @@ -42,4 +42,9 @@ #define REAGENT_ONMOBMERGE (1<<3) //Call on_mob_life proc when reagents are merging. #define REAGENT_INVISIBLE (1<<4) //Doesn't appear on handheld health analyzers. #define REAGENT_FORCEONNEW (1<<5) //Forces a on_new() call without a data overhead -#define REAGENT_SNEAKYNAME (1<<6) //When metabolised it takes the name of the splitting chem +#define REAGENT_SNEAKYNAME (1<<6) //When inverted, the inverted chem uses the name of the original chem +#define REAGENT_SPLITRETAINVOL (1<<7) //Retains initial volume of chem when splitting + +//Chemical reaction flags, for determining reaction specialties +#define REACTION_CLEAR_IMPURE (1<<0) //Convert into impure/pure on reaction completion +#define REACTION_CLEAR_INVERSE (1<<1) //Convert into inverse on reaction completion when purity is low enough diff --git a/code/modules/mob/living/carbon/life.dm b/code/modules/mob/living/carbon/life.dm index 675f17d37e..2d55797a48 100644 --- a/code/modules/mob/living/carbon/life.dm +++ b/code/modules/mob/living/carbon/life.dm @@ -43,9 +43,9 @@ return 1 //Procs called while dead -/mob/living/carbon/handle_death() - for(var/datum/reagents/R in reagents.reagent_list) - if(R.reagentFlag & REAGENT_DEAD_PROCESS) +/mob/living/carbon/proc/handle_death() + for(var/datum/reagent/R in reagents.reagent_list) + if(R.reagentFlags & REAGENT_DEAD_PROCESS) R.on_mob_dead(src) /////////////// diff --git a/code/modules/reagents/chemistry/reagents.dm b/code/modules/reagents/chemistry/reagents.dm index 26b8b7dc6e..3d6740aba3 100644 --- a/code/modules/reagents/chemistry/reagents.dm +++ b/code/modules/reagents/chemistry/reagents.dm @@ -34,13 +34,14 @@ var/overdosed = 0 // You fucked up and this is now triggering its overdose effects, purge that shit quick. var/self_consuming = FALSE //I think this uhhh, makes weird stuff happen when metabolising, but... doesn't seem to do what I think, so I'm gonna leave it. //Fermichem vars: - var/purity = 1 //How pure a chemical is from 0 - 1. + var/purity = 1 //How pure a chemical is from 0 - 1. + var/cached_purity = 1 var/turf/loc = null //Should be the creation location! var/pH = 7 //pH of the specific reagent, used for calculating the sum pH of a holder. - var/SplitChem = FALSE //If the chem splits on metabolism - var/ImpureChem = "fermiTox"// What chemical is metabolised with an inpure reaction - var/InverseChemVal = 0.25 // If the impurity is below 0.5, replace ALL of the chem with InverseChem upon metabolising - var/InverseChem = "fermiTox"// What chem is metabolised when purity is below InverseChemVal, this shouldn't be made, but if it does, well, I guess I'll know about it. + //var/SplitChem = FALSE //If the chem splits on metabolism + var/ImpureChem // What chemical is metabolised with an inpure reaction + var/InverseChemVal = 0 // If the impurity is below 0.5, replace ALL of the chem with InverseChem upon metabolising + var/InverseChem // What chem is metabolised when purity is below InverseChemVal, this shouldn't be made, but if it does, well, I guess I'll know about it. var/metabolizing = FALSE var/reagentFlags //REAGENT_DEAD_PROCESS, REAGENT_DONOTSPLIT, REAGENT_ONLYINVERSE, REAGENT_ONMOBMERGE, REAGENT_INVISIBLE, REAGENT_FORCEONNEW, REAGENT_SNEAKYNAME //REAGENT_DEAD_PROCESS Calls on_mob_dead() if present in a dead body @@ -80,7 +81,7 @@ return //called when a mob processes chems when dead. -/datum/reagent/proc/on_mob_death(mob/living/carbon/M) +/datum/reagent/proc/on_mob_dead(mob/living/carbon/M) if(!(reagentFlags & REAGENT_DEAD_PROCESS)) //justincase return current_cycle++ @@ -90,29 +91,29 @@ // Called when this reagent is first added to a mob /datum/reagent/proc/on_mob_add(mob/living/L, amount) - if(SplitChem) + if(!(reagentFlags & REAGENT_DONOTSPLIT)) var/mob/living/carbon/M = L if(!M) return + if (purity == 1) + log_game("FERMICHEM: [M] ckey: [M.key] has ingested [volume]u of [id]") + return if(cached_purity == 1) cached_purity = purity if(cached_purity < 0) CRASH("Purity below 0 for chem: [id], Please let Fermis Know!") - if (purity == 1 || DoNotSplit == TRUE) - log_game("FERMICHEM: [M] ckey: [M.key] has ingested [volume]u of [id]") - return - else if (InverseChemVal > purity)//Turns all of a added reagent into the inverse chem - if(!(reagentFlags & REAGENT_SPLITRETAINVOL)) - M.reagents.remove_reagent(id, amount, FALSE) + else if ((InverseChemVal > purity) && (InverseChem))//Turns all of a added reagent into the inverse chem + M.reagents.remove_reagent(id, amount, FALSE) M.reagents.add_reagent(InverseChem, amount, FALSE, other_purity = 1-cached_purity) log_game("FERMICHEM: [M] ckey: [M.key] has ingested [volume]u of [InverseChem]") return - else + else if (ImpureChem) var/impureVol = amount * (1 - purity) //turns impure ratio into impure chem - M.reagents.remove_reagent(id, (impureVol), FALSE) + if(!(reagentFlags & REAGENT_SPLITRETAINVOL)) + M.reagents.remove_reagent(id, (impureVol), FALSE) M.reagents.add_reagent(ImpureChem, impureVol, FALSE, other_purity = 1-cached_purity) if(reagentFlags & REAGENT_SNEAKYNAME) - var/datum/reagent/R = has_reagent("[InverseChem]") + var/datum/reagent/R = M.reagents.has_reagent("[InverseChem]") R.name = name//Negative effects are hidden log_game("FERMICHEM: [M] ckey: [M.key] has ingested [volume - impureVol]u of [id]") @@ -140,31 +141,31 @@ // Called when two reagents of the same are mixing. /datum/reagent/proc/on_merge(data, amount, mob/living/carbon/M, purity) - if(SplitChem) - if(!ishuman(M)) + if(!(reagentFlags & REAGENT_DONOTSPLIT)) + if(!iscarbon(M)) + return + if (purity == 1) + log_game("FERMICHEM: [M] ckey: [M.key] has ingested [volume]u of [id]") return if(cached_purity == 1) cached_purity = purity if (purity < 0) CRASH("Purity below 0 for chem: [id], Please let Fermis Know!") - if (purity == 1 || DoNotSplit == TRUE) - log_game("FERMICHEM: [M] ckey: [M.key] has merged [volume]u of [id] in themselves") - return - else if (InverseChemVal > purity) - if(!(reagentFlags & REAGENT_SPLITRETAINVOL)) - M.reagents.remove_reagent(id, amount, FALSE) - M.reagents.add_reagent(InverseChem, amount, FALSE, other_purity = 1) + else if ((InverseChemVal > purity) && (InverseChem)) + M.reagents.remove_reagent(id, amount, FALSE) + M.reagents.add_reagent(InverseChem, amount, FALSE, other_purity = 1-cached_purity) for(var/datum/reagent/fermi/R in M.reagents.reagent_list) if(R.name == "") R.name = name//Negative effects are hidden log_game("FERMICHEM: [M] ckey: [M.key] has merged [volume]u of [InverseChem]") return - else + else if (ImpureChem) var/impureVol = amount * (1 - purity) - M.reagents.remove_reagent(id, impureVol, FALSE) - M.reagents.add_reagent(ImpureChem, impureVol, FALSE, other_purity = 1) + if(!(reagentFlags & REAGENT_SPLITRETAINVOL)) + M.reagents.remove_reagent(id, impureVol, FALSE) + M.reagents.add_reagent(ImpureChem, impureVol, FALSE, other_purity = 1-cached_purity) if(reagentFlags & REAGENT_SNEAKYNAME) - var/datum/reagent/R = has_reagent("[InverseChem]") + var/datum/reagent/R = M.reagents.has_reagent("[InverseChem]") R.name = name//Negative effects are hidden log_game("FERMICHEM: [M] ckey: [M.key] has merged [volume - impureVol]u of [id]") diff --git a/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm b/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm index 88073ca5f3..9a3d9b4b88 100644 --- a/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm @@ -1383,7 +1383,7 @@ All effects don't start immediately, but rather get worse over time; the rate is glass_icon_state = "neurotoxinglass" glass_name = "Neurotoxin" glass_desc = "A drink that is guaranteed to knock you silly." - SplitChem = TRUE + //SplitChem = TRUE ImpureChem = "neuroweak" InverseChemVal = 0 //Clear conversion InverseChem = "neuroweak" diff --git a/code/modules/reagents/chemistry/recipes.dm b/code/modules/reagents/chemistry/recipes.dm index 32155c9b89..a55262c41e 100644 --- a/code/modules/reagents/chemistry/recipes.dm +++ b/code/modules/reagents/chemistry/recipes.dm @@ -32,6 +32,7 @@ var/RateUpLim = 10 // Optimal/max rate possible if all conditions are perfect var/FermiChem = FALSE // If the chemical uses the Fermichem reaction mechanics//If the chemical uses the Fermichem reaction mechanics var/FermiExplode = FALSE // If the chemical explodes in a special way + var/ClearConversion //bitflags for clear conversions; REACTION_CLEAR_IMPURE or REACTION_CLEAR_INVERSE var/PurityMin = 0.15 //If purity is below 0.15, it explodes too. Set to 0 to disable this. diff --git a/modular_citadel/code/modules/reagents/chemistry/reagents/MKUltra.dm b/modular_citadel/code/modules/reagents/chemistry/reagents/MKUltra.dm index 9d90e4fcc2..7ff43d63d2 100644 --- a/modular_citadel/code/modules/reagents/chemistry/reagents/MKUltra.dm +++ b/modular_citadel/code/modules/reagents/chemistry/reagents/MKUltra.dm @@ -136,7 +136,6 @@ Creating a chem with a low purity will make you permanently fall in love with so color = "#660015" // rgb: , 0, 255 taste_description = "synthetic chocolate, a base tone of alcohol, and high notes of roses" overdose_threshold = 100 //If this is too easy to get 100u of this, then double it please. - reagentFlags = REAGENT_DONOTSPLIT metabolization_rate = 0.1//It has to be slow, so there's time for the effect. data = list("creatorID" = null, "creatorGender" = null, "creatorName" = null) var/creatorID //ckey @@ -144,7 +143,7 @@ Creating a chem with a low purity will make you permanently fall in love with so var/creatorName var/mob/living/creator pH = 10 - reagentFlags = REAGENT_ONMOBMERGE //Procs on_mob_add when merging into a human + reagentFlags = REAGENT_ONMOBMERGE | REAGENT_DONOTSPLIT //Procs on_mob_add when merging into a human can_synth = FALSE diff --git a/modular_citadel/code/modules/reagents/chemistry/reagents/SDGF.dm b/modular_citadel/code/modules/reagents/chemistry/reagents/SDGF.dm index c350326c0f..f9536f663c 100644 --- a/modular_citadel/code/modules/reagents/chemistry/reagents/SDGF.dm +++ b/modular_citadel/code/modules/reagents/chemistry/reagents/SDGF.dm @@ -316,6 +316,7 @@ IMPORTANT FACTORS TO CONSIDER WHILE BALANCING metabolization_rate = 0.5 * REAGENTS_METABOLISM var/startHunger can_synth = TRUE + reagentFlags = REAGENT_SNEAKYNAME /datum/reagent/fermi/SDZF/on_mob_life(mob/living/carbon/M) //If you're bad at fermichem, turns your clone into a zombie instead. switch(current_cycle)//Pretends to be normal diff --git a/modular_citadel/code/modules/reagents/chemistry/reagents/fermi_reagents.dm b/modular_citadel/code/modules/reagents/chemistry/reagents/fermi_reagents.dm index 9acf3d3dfc..18458f509d 100644 --- a/modular_citadel/code/modules/reagents/chemistry/reagents/fermi_reagents.dm +++ b/modular_citadel/code/modules/reagents/chemistry/reagents/fermi_reagents.dm @@ -6,7 +6,10 @@ id = "fermi" taste_description = "affection and love!" can_synth = FALSE - SplitChem = TRUE + //SplitChem = TRUE + ImpureChem = "fermiTox"// What chemical is metabolised with an inpure reaction + InverseChemVal = 0.25 // If the impurity is below 0.5, replace ALL of the chem with InverseChem upon metabolising + InverseChem = "fermiTox" //This should process fermichems to find out how pure they are and what effect to do. /datum/reagent/fermi/on_mob_add(mob/living/carbon/M, amount) @@ -16,7 +19,7 @@ //When merging two fermichems, see above /datum/reagent/fermi/on_merge(data, amount, mob/living/carbon/M, purity)//basically on_mob_add but for merging . = ..() - + //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/modular_citadel/code/modules/reagents/chemistry/reagents/healing.dm b/modular_citadel/code/modules/reagents/chemistry/reagents/healing.dm index 32c09131a2..33ca422785 100644 --- a/modular_citadel/code/modules/reagents/chemistry/reagents/healing.dm +++ b/modular_citadel/code/modules/reagents/chemistry/reagents/healing.dm @@ -80,7 +80,7 @@ taste_description = "a weird, syrupy flavour, yamero" color = "#68e83a" pH = 8.6 - reagentFlags = REAGENT_INVISIBLE + reagentFlags = REAGENT_INVISIBLE /datum/reagent/fermi/yamerol_tox/on_mob_life(mob/living/carbon/C) var/obj/item/organ/tongue/T = C.getorganslot(ORGAN_SLOT_TONGUE) diff --git a/modular_citadel/code/modules/reagents/chemistry/recipes/fermi.dm b/modular_citadel/code/modules/reagents/chemistry/recipes/fermi.dm index d993322fcb..d017868120 100644 --- a/modular_citadel/code/modules/reagents/chemistry/recipes/fermi.dm +++ b/modular_citadel/code/modules/reagents/chemistry/recipes/fermi.dm @@ -6,7 +6,23 @@ return //Called when reaction STOP_PROCESSING -/datum/chemical_reaction/proc/FermiFinish(datum/reagents/holder) +/datum/chemical_reaction/proc/FermiFinish(datum/reagents/holder, var/atom/my_atom) + if(ClearConversion == REACTION_CLEAR_IMPURE | REACTION_CLEAR_INVERSE) + for(var/id in results) + var/datum/reagent/R = my_atom.reagents.has_reagent("[id]") + if(R.purity == 1) + continue + + var/cached_volume = R.volume + if(ClearConversion == REACTION_CLEAR_INVERSE && R.InverseChem) + if(R.InverseChemVal > R.purity) + my_atom.reagents.remove_reagent(R.id, cached_volume, FALSE) + my_atom.reagents.add_reagent(R.InverseChem, cached_volume, FALSE, other_purity = 1) + + else if (ClearConversion == REACTION_CLEAR_IMPURE && R.ImpureChem) + var/impureVol = cached_volume * (1 - R.purity) + my_atom.reagents.remove_reagent(R.id, (impureVol), FALSE) + my_atom.reagents.add_reagent(R.ImpureChem, impureVol, FALSE, other_purity = 1) return //Called when temperature is above a certain threshold, or if purity is too low.