From fa5531285a2f8ac41cf9e2ed5558edc640069b03 Mon Sep 17 00:00:00 2001 From: Fermi Date: Fri, 17 May 2019 16:23:34 +0100 Subject: [PATCH] Push for Neko, probably doesn't compile atm. --- code/modules/reagents/chemistry/holder.dm | 38 ++++++++++----- code/modules/reagents/chemistry/reagents.dm | 3 +- .../chemistry/reagents/other_reagents.dm | 10 ++-- code/modules/surgery/organs/lungs.dm | 47 +++++++++++++++++-- code/modules/surgery/organs/tongue.dm | 3 ++ .../chemistry/reagents/fermi_reagents.dm | 9 ++-- .../reagents/chemistry/recipes/FermiCalc.Py | 7 +++ .../reagents/chemistry/recipes/fermi.dm | 12 ++++- 8 files changed, 103 insertions(+), 26 deletions(-) create mode 100644 modular_citadel/code/modules/reagents/chemistry/recipes/FermiCalc.Py diff --git a/code/modules/reagents/chemistry/holder.dm b/code/modules/reagents/chemistry/holder.dm index 27b8b440f4..85f1f0ad69 100644 --- a/code/modules/reagents/chemistry/holder.dm +++ b/code/modules/reagents/chemistry/holder.dm @@ -1,4 +1,4 @@ - +im /proc/build_chemical_reagent_list() //Chemical Reagents - Initialises all /datum/reagent into a list indexed by reagent id @@ -484,6 +484,7 @@ return 0 else //reactedVol = FermiReact(selected_reaction, chem_temp, pH, multiplier, reactedVol, targetVol, cached_required_reagents, cached_results) + selected_reaction.on_reaction(src, multiplier) START_PROCESSING(SSprocessing, src) message_admins("FermiChem processing started") fermiIsReacting = TRUE @@ -558,8 +559,8 @@ targetVol = 0 handle_reactions() update_total() - - C.on_reaction(src, multiplier, special_react_result) + C.fermiFinish(src, multiplier) + //C.on_reaction(src, multiplier, special_react_result) return for(var/P in cached_results) targetVol = cached_results[P]*multiplier @@ -581,7 +582,8 @@ targetVol = 0 handle_reactions() update_total() - C.on_reaction(src, multiplier, special_react_result) + C.fermiFinish(src, multiplier) + //C.on_reaction(src, multiplier, special_react_result) return else STOP_PROCESSING(SSprocessing, src) @@ -591,7 +593,8 @@ targetVol = 0 handle_reactions() update_total() - C.on_reaction(src, multiplier, special_react_result) + C.fermiFinish(src, multiplier) + //C.on_reaction(src, multiplier, special_react_result) return //handle_reactions() @@ -613,13 +616,16 @@ if (chem_temp > C.ExplodeTemp) //go to explode proc message_admins("temperature is over limit: [C.ExplodeTemp] Current temperature: [chem_temp]") - FermiExplode() + C.FermiExplode(src, (reactedVol+targetVol), chem_temp, pH) - if (pH > 14 || pH < 0) + if (pH > 14) + pH = 14 + else (pH < 0 || ) + pH = 0 //Create chemical sludge eventually(for now just destroy the beaker I guess?) //TODO Strong acids eat glass, make it so you NEED plastic beakers for superacids(for some reactions) message_admins("pH is lover limit, cur pH: [pH]") - FermiExplode() + //For now, purity is handled elsewhere @@ -630,14 +636,14 @@ deltapH = 0 return//If outside pH range, no reaction else - deltapH = (((pH - (C.OptimalpHMin - C.ReactpHLim))**C.CurveSharppH)/(C.ReactpHLim**C.CurveSharppH)) + deltapH = (((pH - (C.OptimalpHMin - C.ReactpHLim))**C.CurveSharppH)/((C.ReactpHLim**C.CurveSharppH)) //Upper range else if (pH > C.OptimalpHMin) if (pH > (C.OptimalpHMin + C.ReactpHLim)) deltapH = 0 return //If outside pH range, no reaction else - deltapH = ((C.ReactpHLim -(pH - (C.OptimalpHMax + C.ReactpHLim))+C.ReactpHLim)/(C.ReactpHLim**C.CurveSharppH)) + deltapH = (((pH - (C.OptimalpHMax + C.ReactpHLim))**C.CurveSharppH)/(C.ReactpHLim**C.CurveSharppH)) //Within mid range else if (pH >= C.OptimalpHMin && pH <= C.OptimalpHMax) deltapH = 1 @@ -650,7 +656,7 @@ //Calculate DeltaT (Deviation of T from optimal) if (chem_temp < C.OptimalTempMax && chem_temp >= C.OptimalTempMin) - deltaT = (((C.OptimalTempMin - chem_temp)**C.CurveSharpT)/((C.OptimalTempMax - C.OptimalTempMin)**C.CurveSharpT)) + deltaT = (((chem_temp - C.OptimalTempMin)**C.CurveSharpT)/((C.OptimalTempMax - C.OptimalTempMin)**C.CurveSharpT)) else if (chem_temp >= C.OptimalTempMax) deltaT = 1 else @@ -692,6 +698,7 @@ SSblackbox.record_feedback("tally", "chemical_reaction", cached_results[P]*stepChemAmmount, P)//log add_reagent(P, cached_results[P]*stepChemAmmount, null, chem_temp, purity)//add reagent function!! I THINK I can do this: + C.FermiCreate(src) message_admins("purity: [purity], purity of beaker") message_admins("Temp before change: [chem_temp], pH after change: [pH]") //Apply pH changes and thermal output of reaction to beaker @@ -809,6 +816,14 @@ WARNING("[my_atom] attempted to add a reagent called '[reagent]' which doesn't exist. ([usr])") return FALSE + if (D.id == "water") //Do like an otter, add acid to water. + (if pH <= 2) + var/datum/effect_system/smoke_spread/chem/smoke_machine/s = new + s.set_up(reagents, totalVol, pH*10, src) + s.start() + remove_any(amount/10) + + if(!pH) other_pH = D.pH @@ -872,6 +887,7 @@ if(istype(D, /datum/reagent/fermi))//Is this a fermichem? var/datum/reagent/fermi/FermiTime = D //It's Fermi time! FermiTime.fermiCreate(R.holder) //Seriously what is "data" ???? + //This is how I keep myself sane. diff --git a/code/modules/reagents/chemistry/reagents.dm b/code/modules/reagents/chemistry/reagents.dm index 87d823cf52..289896ddac 100644 --- a/code/modules/reagents/chemistry/reagents.dm +++ b/code/modules/reagents/chemistry/reagents.dm @@ -131,7 +131,8 @@ rs += "[R.name], [R.volume]" return rs.Join(" | ") - +/* MOVED TO CHEMICAL REACTION //Handler for explosion reaction /datum/reagents/proc/FermiExplode(turf/T, obj/O, mob/living/M, volume) return +*/ diff --git a/code/modules/reagents/chemistry/reagents/other_reagents.dm b/code/modules/reagents/chemistry/reagents/other_reagents.dm index 558f2ebdf4..1c8fefcfae 100644 --- a/code/modules/reagents/chemistry/reagents/other_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/other_reagents.dm @@ -1108,6 +1108,7 @@ color = "#C8A5DC" // rgb: 200, 165, 220 metabolization_rate = 1.5 * REAGENTS_METABOLISM taste_description = "sourness" + pH = 11.9 /datum/reagent/cryptobiolin/on_mob_life(mob/living/carbon/M) M.Dizzy(1) @@ -1514,8 +1515,8 @@ description = "An aromatic ring of carbon with a hydroxyl group. A useful precursor to some medicines, but has no healing properties on its own." reagent_state = LIQUID color = "#C8A5DC" - taste_description = "acid" - pH = 5 + taste_description = "sweet and tarry" //Again, not a strong acid. + pH = 5.5 /datum/reagent/ash name = "Ash" @@ -1532,7 +1533,7 @@ description = "A slick, slightly carcinogenic liquid. Has a multitude of mundane uses in everyday life." reagent_state = LIQUID color = "#C8A5DC" - taste_description = "acid" + taste_description = "solvent"//It's neutral though..? /datum/reagent/colorful_reagent name = "Colorful Reagent" @@ -1630,7 +1631,8 @@ description = "Also known as sodium hydroxide. As a profession making this is somewhat underwhelming." reagent_state = LIQUID color = "#FFFFD6" // very very light yellow - taste_description = "acid" + taste_description = "alkali" //who put ACID for NaOH ???? + pH = 13 /datum/reagent/drying_agent name = "Drying agent" diff --git a/code/modules/surgery/organs/lungs.dm b/code/modules/surgery/organs/lungs.dm index 412b97d503..b952c19d66 100644 --- a/code/modules/surgery/organs/lungs.dm +++ b/code/modules/surgery/organs/lungs.dm @@ -54,6 +54,36 @@ var/crit_stabilizing_reagent = "epinephrine" + //health + var/health = 500 + var/damage = 0 + +//TODO: lung health affects lung function +/obj/item/organ/tongue/proc/adjustLungLoss(mob/living/carbon/M, damage_mod) + if (maxHealth == "plasma") + return + if(damage+damage_mod < 0) + damage = 0 + return + + damage += damage_mod + if ((damage / maxHealth) > 1) + to_chat(M, "You feel your lungs collapse within your chest as you gasp for air, unable to inflate them anymore!") + M.emote("cough") + qdel(src) + else if ((damage / maxHealth) > 0.75) + to_chat(M, "It's getting really hard to breathe!!") + M.emote("gasp") + H.Dizzy(3) + else if ((damage / maxHealth) > 0.5) + H.Dizzy(2) + to_chat(M, "Your chest is really starting to hurt.") + M.emote("cough") + H.Dizzy(1) + else if ((damage / maxHealth) > 0.2) + to_chat(M, "You feel an ache within your chest.") + M.emote("cough") + /obj/item/organ/lungs/proc/check_breath(datum/gas_mixture/breath, mob/living/carbon/human/H) if((H.status_flags & GODMODE)) @@ -126,7 +156,7 @@ else H.failed_last_breath = FALSE if(H.health >= H.crit_threshold) - H.adjustOxyLoss(-5) + H.adjustOxyLoss(-5*((damage/health)/2)) //More damaged lungs = slower oxy rate up to a factor of half gas_breathed = breath_gases[/datum/gas/oxygen][MOLES] H.clear_alert("not_enough_oxy") @@ -155,7 +185,7 @@ else H.failed_last_breath = FALSE if(H.health >= H.crit_threshold) - H.adjustOxyLoss(-5) + H.adjustOxyLoss(-5*((damage/health)/2)) gas_breathed = breath_gases[/datum/gas/nitrogen][MOLES] H.clear_alert("nitro") @@ -192,7 +222,7 @@ else H.failed_last_breath = FALSE if(H.health >= H.crit_threshold) - H.adjustOxyLoss(-5) + H.adjustOxyLoss(-5*((damage/health)/2)) gas_breathed = breath_gases[/datum/gas/carbon_dioxide][MOLES] H.clear_alert("not_enough_co2") @@ -222,7 +252,7 @@ else H.failed_last_breath = FALSE if(H.health >= H.crit_threshold) - H.adjustOxyLoss(-5) + H.adjustOxyLoss(-5*((damage/health)/2)) gas_breathed = breath_gases[/datum/gas/plasma][MOLES] H.clear_alert("not_enough_tox") @@ -372,9 +402,12 @@ var/cold_modifier = H.dna.species.coldmod if(breath_temperature < cold_level_3_threshold) H.apply_damage_type(cold_level_3_damage*cold_modifier, cold_damage_type) + adjustLungLoss(cold_level_3_damage*cold_modifier) if(breath_temperature > cold_level_3_threshold && breath_temperature < cold_level_2_threshold) H.apply_damage_type(cold_level_2_damage*cold_modifier, cold_damage_type) + adjustLungLoss(cold_level_2_damage*cold_modifier) if(breath_temperature > cold_level_2_threshold && breath_temperature < cold_level_1_threshold) + adjustLungLoss(cold_level_1_damage*cold_modifier) H.apply_damage_type(cold_level_1_damage*cold_modifier, cold_damage_type) if(breath_temperature < cold_level_1_threshold) if(prob(20)) @@ -384,10 +417,13 @@ var/heat_modifier = H.dna.species.heatmod if(breath_temperature > heat_level_1_threshold && breath_temperature < heat_level_2_threshold) H.apply_damage_type(heat_level_1_damage*heat_modifier, heat_damage_type) + adjustLungLoss(cold_level_1_damage*heat_modifier) if(breath_temperature > heat_level_2_threshold && breath_temperature < heat_level_3_threshold) H.apply_damage_type(heat_level_2_damage*heat_modifier, heat_damage_type) + adjustLungLoss(cold_level_1_damage*heat_modifier) if(breath_temperature > heat_level_3_threshold) H.apply_damage_type(heat_level_3_damage*heat_modifier, heat_damage_type) + adjustLungLoss(cold_level_1_damage*heat_modifier) if(breath_temperature > heat_level_1_threshold) if(prob(20)) to_chat(H, "You feel [hot_message] in your [name]!") @@ -406,12 +442,14 @@ safe_oxygen_max = 0 // Like, at all. safe_toxins_min = 16 //We breath THIS! safe_toxins_max = 0 + health = "plasma"//I don't understand how plamamen work, so I'm not going to try t give them special lungs atm /obj/item/organ/lungs/cybernetic name = "cybernetic lungs" desc = "A cybernetic version of the lungs found in traditional humanoid entities. It functions the same as an organic lung and is merely meant as a replacement." icon_state = "lungs-c" synthetic = TRUE + health = 600 /obj/item/organ/lungs/cybernetic/emp_act() . = ..() @@ -431,6 +469,7 @@ cold_level_1_threshold = 200 cold_level_2_threshold = 140 cold_level_3_threshold = 100 + health = 750 /obj/item/organ/lungs/ashwalker name = "ash lungs" diff --git a/code/modules/surgery/organs/tongue.dm b/code/modules/surgery/organs/tongue.dm index 86916217be..5dadd2a729 100644 --- a/code/modules/surgery/organs/tongue.dm +++ b/code/modules/surgery/organs/tongue.dm @@ -41,6 +41,9 @@ M.apply_damage(damage_mod, BURN, target) to_chat(M, "The drink burns your skull! Oof, your bones!") return + if(damage+damage_mod < 0) + damage = 0 + return damage += damage_mod if ((damage / maxHealth) > 1) 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 fcfda529d8..52b086b9c3 100644 --- a/modular_citadel/code/modules/reagents/chemistry/reagents/fermi_reagents.dm +++ b/modular_citadel/code/modules/reagents/chemistry/reagents/fermi_reagents.dm @@ -22,7 +22,8 @@ //holder.remove_reagent(src.id, metabolization_rate / M.metabolism_efficiency, FALSE) //fermi reagents stay longer if you have a better metabolism //return ..() -/datum/reagent/fermi/proc/fermiCreate(holder) //You can get holder by reagents.holder WHY DID I LEARN THIS NOW??? +//Called when reaction stops. +/datum/reagent/fermi/proc/fermiFinish(holder) //You can get holder by reagents.holder WHY DID I LEARN THIS NOW??? return //This should process fermichems to find out how pure they are and what effect to do. @@ -584,7 +585,7 @@ IMPORTANT FACTORS TO CONSIDER WHILE BALANCING InverseChem = "BEsmaller" //At really impure vols, it just becomes 100% inverse /datum/reagent/fermi/BElarger/on_mob_add(mob/living/carbon/M) - ..() + . = ..() var/mob/living/carbon/human/H = M var/obj/item/organ/genital/breasts/B = H.getorganslot("breasts") if(!B) @@ -1042,7 +1043,7 @@ And as stated earlier, this chem is hard to make, and is punishing on failure. Y message_admins("name: [creatorName], ID: [creatorID], gender: [creatorGender], creator:[creator]") /datum/reagent/fermi/enthrall/on_mob_add(mob/living/carbon/M) - ..() + . = ..() if(!creatorID) CRASH("Something went wrong in enthral creation") else if(M.key == creatorID && creatorName == M.real_name) //same name AND same player - same instance of the player. (should work for clones?) @@ -1114,7 +1115,7 @@ And as stated earlier, this chem is hard to make, and is punishing on failure. Y /datum/reagent/fermi/hatmium/on_mob_add(mob/living/carbon/human/M) - //var/mob/living/carbon/human/o = M + . = ..() var/items = M.get_contents() for(var/obj/item/W in items) if(W == M.head) diff --git a/modular_citadel/code/modules/reagents/chemistry/recipes/FermiCalc.Py b/modular_citadel/code/modules/reagents/chemistry/recipes/FermiCalc.Py new file mode 100644 index 0000000000..d78b49ff30 --- /dev/null +++ b/modular_citadel/code/modules/reagents/chemistry/recipes/FermiCalc.Py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +""" +Created on Fri May 17 05:12:17 2019 + +@author: Fermi +""" + diff --git a/modular_citadel/code/modules/reagents/chemistry/recipes/fermi.dm b/modular_citadel/code/modules/reagents/chemistry/recipes/fermi.dm index 425d54becf..bd17353382 100644 --- a/modular_citadel/code/modules/reagents/chemistry/recipes/fermi.dm +++ b/modular_citadel/code/modules/reagents/chemistry/recipes/fermi.dm @@ -1,6 +1,14 @@ //TO TWEAK: -/datum/chemical_reaction/eigenstate +//Called for every reaction step +/datum/chemical_reaction/fermi/proc/FermiCreate(holder) //You can get holder by reagents.holder WHY DID I LEARN THIS NOW??? + return + +//Called for every reaction step +/datum/chemical_reaction/fermi/proc/FermiExplode(holder) //You can get holder by reagents.holder WHY DID I LEARN THIS NOW??? + return + +/datum/chemical_reaction/fermi/eigenstate name = "Eigenstasium" id = "eigenstate" results = list("eigenstate" = 1) @@ -22,7 +30,7 @@ FermiChem = TRUE//If the chemical uses the Fermichem reaction mechanics FermiExplode = FALSE //If the chemical explodes in a special way -/datum/chemical_reaction/eigenstate/on_reaction(datum/reagents/holder) +/datum/chemical_reaction/eigenstate/FermiCreate(datum/reagents/holder) var/location = get_turf(holder.my_atom) var/datum/reagent/fermi/eigenstate/E = locate(/datum/reagent/fermi/eigenstate) in holder.reagent_list E.location_created = location