diff --git a/code/datums/supplypacks/medical.dm b/code/datums/supplypacks/medical.dm index 554a826f20f..1b164a2cdf3 100644 --- a/code/datums/supplypacks/medical.dm +++ b/code/datums/supplypacks/medical.dm @@ -339,14 +339,14 @@ /datum/supply_pack/med/distillery name = "Chemical distiller crate" contains = list(/obj/machinery/portable_atmospherics/powered/reagent_distillery = 1) - cost = 175 + cost = 50 containertype = /obj/structure/largecrate containername = "Chemical distiller crate" /datum/supply_pack/med/advdistillery name = "Industrial Chemical distiller crate" contains = list(/obj/machinery/portable_atmospherics/powered/reagent_distillery/industrial = 1) - cost = 250 + cost = 150 containertype = /obj/structure/largecrate containername = "Industrial Chemical distiller crate" diff --git a/code/modules/reagents/distilling/distilling.dm b/code/modules/reagents/distilling/distilling.dm index 50c2b598c04..78780a35433 100644 --- a/code/modules/reagents/distilling/distilling.dm +++ b/code/modules/reagents/distilling/distilling.dm @@ -108,6 +108,57 @@ ..() +/obj/machinery/portable_atmospherics/powered/reagent_distillery/examine(mob/user) + ..() + if(get_dist(user, src) < 3) + to_chat(user, "\The [src] is powered [on ? "on" : "off"].") + + to_chat(user, "\The [src]'s gauges read:") + if(!use_atmos) + to_chat(user, "- Target Temperature: [target_temp]") + to_chat(user, "- Temperature: [current_temp]") + + if(InputBeaker) + if(InputBeaker.reagents.reagent_list.len) + to_chat(user, "\The [src]'s input beaker holds [InputBeaker.reagents.total_volume] units of liquid.") + else + to_chat(user, "\The [src]'s input beaker is empty!") + + if(Reservoir.reagents.reagent_list.len) + to_chat(user, "\The [src]'s internal buffer holds [Reservoir.reagents.total_volume] units of liquid.") + else + to_chat(user, "\The [src]'s internal buffer is empty!") + + if(OutputBeaker) + if(OutputBeaker.reagents.reagent_list.len) + to_chat(user, "\The [src]'s output beaker holds [OutputBeaker.reagents.total_volume] units of liquid.") + else + to_chat(user, "\The [src]'s output beaker is empty!") + +/obj/machinery/portable_atmospherics/powered/reagent_distillery/verb/toggle_power(mob/user = usr) + set name = "Toggle Distillery Heating" + set category = "Object" + set src in view(1) + + if(powered()) + on = !on + to_chat(user, "You turn \the [src] [on ? "on" : "off"].") + else + to_chat(user, " Nothing happens.") + +/obj/machinery/portable_atmospherics/powered/reagent_distillery/verb/toggle_mixing(mob/user = usr) + set name = "Start Distillery Mixing" + set category = "Object" + set src in view(1) + + to_chat(user, "You press \the [src]'s chamber agitator button.") + if(on) + visible_message("\The [src] rattles to life.") + Reservoir.reagents.handle_reactions() + else + spawn(1 SECOND) + to_chat(user, "Nothing happens..") + /obj/machinery/portable_atmospherics/powered/reagent_distillery/attack_hand(mob/user) var/list/options = list() options["examine"] = radial_examine @@ -138,9 +189,7 @@ examine(user) if("use") - if(powered()) - on = !on - to_chat(user, "You turn \the [src] [on ? "on" : "off"].") + toggle_power(user) if("inspect gauges") to_chat(user, "\The [src]'s gauges read:") @@ -149,13 +198,7 @@ to_chat(user, "- Temperature: [current_temp]") if("pulse agitator") - to_chat(user, "You press \the [src]'s chamber agitator button.") - if(on) - visible_message("\The [src] rattles to life.") - Reservoir.reagents.handle_reactions() - else - spawn(1 SECOND) - to_chat(user, "Nothing happens..") + toggle_mixing(user) if("eject input") if(InputBeaker) @@ -252,19 +295,36 @@ if(!powered()) on = FALSE - if(!on || (use_atmos && (!connected_port || avg_pressure < 1000))) + if(!on || (use_atmos && (!connected_port || (avg_pressure / avg_temp) < (1000 / T20C)))) // This mostly respects gas laws by ignoring volume but it should make it usable at low temps current_temp = round((current_temp + T20C) / 2) else if(on) if(!use_atmos) if(current_temp != round(target_temp)) - var/shift_mod = 0 - if(current_temp < target_temp) - shift_mod = 1 - else if(current_temp > target_temp) - shift_mod = -1 - current_temp = CLAMP(round((current_temp + 1 * shift_mod) + (rand(-5, 5) / 10)), min_temp, max_temp) + // Some horrible bastardized attempt at approximating the values of a logistic function, bounded by (max_temp, target_temp, min_temp) + // So we can attempt to estimate the change in temperature for this process() step + + // Apply inverse of the logistic function to fetch our x value + var/x = -1 * log((current_temp < target_temp ? (target_temp - min_temp) / (current_temp - min_temp) : (max_temp - target_temp) / (max_temp - current_temp)) - 1) + if(!x) + x = 0 // Keep null from propagating into the temp + + // Apply the derivative of the logistic function to get the slope + var/dy = (NUM_E ** (-1 * x)) / ((1 + (NUM_E ** (-1 * x))) ** 2) + + // Compute temperature diff, being farther from the target should result in larger steps + // IMPORTANT: If you want to tweak how quickly this changes, tweak this *10! + // As of initial testing, a *10 gives ~5-6 minutes to go from room temp to 500C (+/-0.5C) + var/temp_diff = (current_temp < target_temp ? dy * 10 * target_temp / current_temp : dy * -10 * current_temp / target_temp) + + current_temp = CLAMP(round((current_temp + temp_diff), 0.01), min_temp, max_temp) use_power(power_rating * CELLRATE) + + if(target_temp == round(current_temp, 1.0)) + current_temp = target_temp // Hard set it so we don't need to worry about exact decimals any more, after we've been keeping track of it all this time + playsound(src, 'sound/machines/ping.ogg', 50, 0) + src.visible_message("\The [src] pings as it reaches the target temperature.") + else if(connected_port && avg_pressure > 1000) current_temp = round((current_temp + avg_temp) / 2) else if(!run_pump) diff --git a/html/changelogs/atermonera_distillery.yml b/html/changelogs/atermonera_distillery.yml new file mode 100644 index 00000000000..8388ec540e8 --- /dev/null +++ b/html/changelogs/atermonera_distillery.yml @@ -0,0 +1,6 @@ +author: Atermonera +delete-after: True +changes: + - rscadd: "Basic distillery (not the industrial-) will ping when it reaches its target temperature." + - tweak: "Basic distillery uses logistic curve to determine temperature change, and should be much faster." + - tweak: "Industrial distillery respects gas laws, particularly as pertains to low temperatures." \ No newline at end of file