Beaker resistance check moved.

This commit is contained in:
Thalpy
2019-05-29 18:29:56 +01:00
parent 1ce25acb0c
commit 45149ffc11
3 changed files with 70 additions and 57 deletions
+28 -57
View File
@@ -342,30 +342,6 @@
R.on_update (A)
update_total()
//beaker check proc,
/datum/reagents/proc/beaker_check(atom/A)
if(istype(A, /obj/item/reagent_containers/glass/beaker/meta) || istype(A, /obj/item/reagent_containers/glass/bottle)) //prevent bottles from being dispenced and melting.
return
if(istype(A, /obj/item/reagent_containers/glass/beaker/plastic))//reaclly weird how this runtimes but the previous doesn't
if(chem_temp > 444)//assuming polypropylene
var/list/seen = viewers(5, get_turf(A))
var/iconhtml = icon2html(A, seen)
for(var/mob/M in seen)
to_chat(M, "<span class='notice'>[iconhtml] \The [my_atom]'s melts from the temperature!</span>")
playsound(get_turf(A), 'sound/FermiChem/heatmelt.ogg', 80, 1)
qdel(A)
return
else if(istype(A, /obj/item/reagent_containers/glass) && ((pH < 0.5) || (pH > 13.5)))//maybe make it higher?
var/list/seen = viewers(5, get_turf(A))
var/iconhtml = icon2html(A, seen)
for(var/mob/M in seen)
to_chat(M, "<span class='notice'>[iconhtml] \The [my_atom]'s melts from the extreme pH!</span>")
playsound(get_turf(A), 'sound/FermiChem/acidmelt.ogg', 80, 1)
qdel(A)
return
/datum/reagents/proc/handle_reactions()//HERE EDIT HERE THE MAIN REACTION
if(fermiIsReacting == TRUE)
@@ -377,10 +353,6 @@
if(reagents_holder_flags & REAGENT_NOREACT)
return
//QPlasticCheck - this is done to reduce calculations
if (istype(my_atom, /obj/item/reagent_containers/glass/beaker/plastic))
beaker_check()
var/reaction_occurred = 0 // checks if reaction, binary variable
var/continue_reacting = FALSE //Helps keep track what kind of reaction is occuring; standard or fermi.
@@ -604,7 +576,7 @@
return
/datum/reagents/proc/FermiReact(selected_reaction, cached_temp, pH, reactedVol, targetVol, cached_required_reagents, cached_results, multiplier)
/datum/reagents/proc/FermiReact(selected_reaction, cached_temp, cached_pH, reactedVol, targetVol, cached_required_reagents, cached_results, multiplier)
var/datum/chemical_reaction/fermi/C = selected_reaction
var/deltaT = 0
var/deltapH = 0
@@ -614,40 +586,24 @@
var/purity = 1
//Begin checks
//Check extremes first
if (cached_temp > C.ExplodeTemp)
//go to explode proc
fermiIsReacting = FALSE
C.FermiExplode(src, my_atom, (reactedVol+targetVol), cached_temp, pH)
STOP_PROCESSING(SSprocessing, src)
return
//Make sure things are limited.
if (pH > 14)
pH = 14
else if (pH < 0)
pH = 0
//some beakers melt at extremes.
//For now, purity is handled elsewhere (on add)
//Calculate DeltapH (Deviation of pH from optimal)
//Lower range
if (pH < C.OptimalpHMin)
if (pH < (C.OptimalpHMin - C.ReactpHLim))
if (cached_pH < C.OptimalpHMin)
if (cached_pH < (C.OptimalpHMin - C.ReactpHLim))
deltapH = 0
return//If outside pH range, no reaction
else
deltapH = (((pH - (C.OptimalpHMin - C.ReactpHLim))**C.CurveSharppH)/((C.ReactpHLim**C.CurveSharppH)))
deltapH = (((cached_pH - (C.OptimalpHMin - C.ReactpHLim))**C.CurveSharppH)/((C.ReactpHLim**C.CurveSharppH)))
//Upper range
else if (pH > C.OptimalpHMax)
if (pH > (C.OptimalpHMax + C.ReactpHLim))
else if (cached_pH > C.OptimalpHMax)
if (cached_pH > (C.OptimalpHMax + C.ReactpHLim))
deltapH = 0
return //If outside pH range, no reaction
else
deltapH = (((- pH + (C.OptimalpHMax + C.ReactpHLim))**C.CurveSharppH)/(C.ReactpHLim**C.CurveSharppH))//Reverse - to + to prevent math operation failures.
deltapH = (((- cached_pH + (C.OptimalpHMax + C.ReactpHLim))**C.CurveSharppH)/(C.ReactpHLim**C.CurveSharppH))//Reverse - to + to prevent math operation failures.
//Within mid range
else if (pH >= C.OptimalpHMin && pH <= C.OptimalpHMax)
else if (cached_pH >= C.OptimalpHMin && cached_pH <= C.OptimalpHMax)
deltapH = 1
//This should never proc:
else
@@ -711,6 +667,22 @@
pH += (C.HIonRelease * addChemAmmount)
//keep track of the current reacted amount
reactedVol = reactedVol + addChemAmmount
//Check extremes
if (chem_temp > C.ExplodeTemp)
//go to explode proc
fermiIsReacting = FALSE
C.FermiExplode(src, my_atom, (reactedVol+targetVol), cached_temp, pH)
STOP_PROCESSING(SSprocessing, src)
return
//Make sure things are limited.
if (pH > 14)
pH = 14
else if (pH < 0)
pH = 0
//some beakers melt at extremes. This proc is called in add_reagent
//return said amount to compare for next step.
return (reactedVol)
@@ -815,7 +787,6 @@
chem_temp = CLAMP(chem_temp + (J / (S * total_volume)), min_temp, max_temp)
/datum/reagents/proc/add_reagent(reagent, amount, list/data=null, reagtemp = 300, other_purity = 1, other_pH, no_react = 0)//EDIT HERE TOO ~FERMICHEM~
//beaker_check(my_atom)
if(!isnum(amount) || !amount)
return FALSE
@@ -841,8 +812,6 @@
s.start()
return FALSE
beaker_check(my_atom) //Beaker resilience test
if(!pH)
other_pH = D.pH
@@ -869,10 +838,11 @@
chem_temp = thermal_energy / (specific_heat * new_total)
////
//pH = round(-log(10, ((cached_total * (10^(-cached_pH))) + (amount * (10^(-other_pH)))) / new_total), REAGENT_PH_ACCURACY) I think this is wrong? I'm getting negative numbers?
//cacluate reagent based pH shift.
pH = ((cached_pH * cached_total)+(D.pH * amount))/(cached_total + amount)//should be right
//add the reagent to the existing if it exists
holder.pH_check()//checks beaker resilience
//add the reagent to the existing if it exists
for(var/A in cached_reagents)
var/datum/reagent/R = A
if (R.id == reagent)
@@ -954,6 +924,7 @@
pH = 7
else
pH = ((pH * total_volume)-(R.pH * amount))/(total_volume - amount)
holder.pH_check()
amount = CLAMP(amount, 0, R.volume)
R.volume -= amount
update_total()
@@ -11,6 +11,8 @@
var/spawned_disease = null
var/disease_amount = 20
var/spillable = FALSE
var/pH_immunne = TRUE//true for now, just so things that shouldn't melt don't.
var/temp_immune = TRUE
/obj/item/reagent_containers/Initialize(mapload, vol)
. = ..()
@@ -122,9 +124,40 @@
reagents.clear_reagents()
//melts plastic beakers
/obj/item/reagent_containers/microwave_act(obj/machinery/microwave/M)
reagents.expose_temperature(1000)
if(temp_immune == TRUE)
return
var/list/seen = viewers(5, get_turf(src))
var/iconhtml = icon2html(src, seen)
for(var/mob/M in seen)
to_chat(M, "<span class='notice'>[iconhtml] \The [src]'s melts from the temperature!</span>")
playsound(get_turf(src), 'sound/FermiChem/heatmelt.ogg', 80, 1)
qdel(A)
..()
//melts plastic beakers
/obj/item/reagent_containers/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
reagents.expose_temperature(exposed_temperature)
if(temp_immune == TRUE)
return
if(reagents.chem_temp > 444)//assuming polypropylene
var/list/seen = viewers(5, get_turf(src))
var/iconhtml = icon2html(src, seen)
for(var/mob/M in seen)
to_chat(M, "<span class='notice'>[iconhtml] \The [src]'s melts from the temperature!</span>")
playsound(get_turf(src), 'sound/FermiChem/heatmelt.ogg', 80, 1)
qdel(A)
//melts glass beakers
/obj/item/reagent_containers/proc/pH_check()
if(pH_immunne == TRUE)
return
else if((pH < 0.5) || (pH > 13.5))
var/list/seen = viewers(5, get_turf(src))
var/iconhtml = icon2html(A, seen)
for(var/mob/M in seen)
to_chat(M, "<span class='notice'>[iconhtml] \The [my_atom]'s melts from the extreme pH!</span>")
playsound(get_turf(src), 'sound/FermiChem/acidmelt.ogg', 80, 1)
qdel(A)
@@ -113,6 +113,7 @@
icon_state = "beaker"
item_state = "beaker"
materials = list(MAT_GLASS=500)
pH_immunne = FALSE
/obj/item/reagent_containers/glass/beaker/Initialize()
. = ..()
@@ -164,6 +165,7 @@
volume = 100
amount_per_transfer_from_this = 10
possible_transfer_amounts = list(5,10,15,20,25,30,50,100)
pH_immunne = FALSE
/obj/item/reagent_containers/glass/beaker/plastic
name = "x-large beaker"
@@ -173,6 +175,7 @@
volume = 150
amount_per_transfer_from_this = 10
possible_transfer_amounts = list(5,10,15,20,25,30,50,100,150)
temp_immune = FALSE
/obj/item/reagent_containers/glass/beaker/plastic/update_icon()
icon_state = "beakerlarge" // hack to lets us reuse the large beaker reagent fill states
@@ -211,6 +214,7 @@
volume = 300
amount_per_transfer_from_this = 10
possible_transfer_amounts = list(5,10,15,20,25,30,50,100,300)
pH_immunne = FALSE
/obj/item/reagent_containers/glass/beaker/cryoxadone
list_reagents = list("cryoxadone" = 30)
@@ -267,6 +271,7 @@
SLOT_L_STORE, SLOT_R_STORE,\
SLOT_GENERC_DEXTROUS_STORAGE
)
pH_immunne = FALSE
/obj/item/reagent_containers/glass/bucket/attackby(obj/O, mob/user, params)
if(istype(O, /obj/item/mop))
@@ -316,6 +321,8 @@
materials = list(MAT_GLASS=0)
volume = 50
amount_per_transfer_from_this = 10
pH_immunne = FALSE
temp_immune = FALSE
/obj/item/reagent_containers/glass/beaker/waterbottle/empty
list_reagents = list()
@@ -327,6 +334,8 @@
list_reagents = list("water" = 100)
volume = 100
amount_per_transfer_from_this = 20
pH_immunne = FALSE
temp_immune = FALSE
/obj/item/reagent_containers/glass/beaker/waterbottle/large/empty
list_reagents = list()