Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions code/game/machinery/alarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ var/global/list/air_alarms = list()
var/buildstage = 2 //2 is built, 1 is building, 0 is frame.
var/cycle_after_preset = 1 // Whether we automatically cycle when presets are changed

var/target_temperature = T0C+20
var/target_temperature //Manual override for target temperature changing, usable for maps/admin vv edits
var/regulating_temperature = 0

var/datum/radio_frequency/radio_connection
Expand Down Expand Up @@ -439,32 +439,45 @@ var/global/list/air_alarms = list()
if(!istype(location))
return//returns if loc is not simulated

if(!isnull(target_temperature))
set_temperature(target_temperature, FALSE)
target_temperature = null

var/datum/gas_mixture/environment = location.return_air()

// Handle temperature adjustment here.
if(environment.temperature < config.target_temperature - 2 || environment.temperature > config.target_temperature + 2 || regulating_temperature)
//If it goes too far, we should adjust ourselves back before stopping.
var/actual_target_temperature = target_temperature
var/actual_target_temperature = config.target_temperature
if(config.temperature_threshold.assess_danger(actual_target_temperature))
//use the max or min safe temperature
actual_target_temperature = clamp(actual_target_temperature, config.temperature_threshold.min_1(), config.temperature_threshold.max_1())

var/thermo_changed = FALSE
if(!regulating_temperature)
regulating_temperature = 1
visible_message("\The [src] clicks as it starts [environment.temperature > config.target_temperature ? "cooling" : "heating"] the room.",\
if(environment.temperature > config.target_temperature)
regulating_temperature = "cooling"
else
regulating_temperature = "heating"
thermo_changed = TRUE
else if(regulating_temperature == "heating" && environment.temperature > config.target_temperature)
regulating_temperature = "cooling"
thermo_changed = TRUE
else if(regulating_temperature == "cooling" && environment.temperature < config.target_temperature)
regulating_temperature = "heating"
thermo_changed = TRUE
if(thermo_changed)
visible_message("\The [src] clicks as it starts [regulating_temperature] the room.",\
"You hear a click and a faint electronic hum.")

var/datum/gas_mixture/gas = environment.remove_volume(0.25 * CELL_VOLUME)
if(gas)
var/heat_capacity = gas.heat_capacity()
var/energy_used = min(abs(heat_capacity * (gas.temperature - actual_target_temperature)), MAX_ENERGY_CHANGE)
var/cooled = 0 //1 means we cooled this tick, 0 means we warmed. Used for the message below.

// We need to cool ourselves, but only if the gas isn't already colder than what we can do.
if (environment.temperature > actual_target_temperature && gas.temperature >= MIN_TEMPERATURE)
gas.temperature -= energy_used / heat_capacity
use_power(energy_used/3) //these are heat pumps, so they can have a >100% efficiency, typically about 300%
cooled = 1
// We need to warm ourselves, but only if the gas isn't already hotter than what we can do.
else if (environment.temperature < actual_target_temperature && gas.temperature <= MAX_TEMPERATURE)
gas.temperature += energy_used / heat_capacity
Expand All @@ -473,9 +486,9 @@ var/global/list/air_alarms = list()
environment.merge(gas)

if (abs(environment.temperature - actual_target_temperature) <= 0.5)
regulating_temperature = 0
visible_message("\The [src] clicks quietly as it stops [cooled ? "cooling" : "heating"] the room.",\
visible_message("\The [src] clicks quietly as it stops [regulating_temperature] the room.",\
"You hear a click as a faint electronic humming stops.")
regulating_temperature = 0

var/old_level = local_danger_level
var/new_danger = calculate_local_danger_level(environment)
Expand Down Expand Up @@ -976,14 +989,11 @@ var/global/list/air_alarms = list()
else
max_temperature = temperature_threshold.max_1() - T0C
min_temperature = temperature_threshold.min_1() - T0C
var/input_temperature = input("What temperature (in C) would you like the system to target? (Capped between [min_temperature]C and [max_temperature]C).\n\nNote that the cooling unit in this air alarm can not go below [MIN_TEMPERATURE]C or above [MAX_TEMPERATURE]C by itself. ", "Thermostat Controls") as num|null
var/input_temperature = input("What temperature (in C) would you like the system to target? (Capped between [min_temperature]C and [max_temperature]C).\n\nNote that the cooling unit in this air alarm can not go below [MIN_TEMPERATURE - T0C]C or above [MAX_TEMPERATURE - T0C]C by itself. ", "Thermostat Controls") as num|null
if(input_temperature==null)
return 1
if(!input_temperature || input_temperature >= max_temperature || input_temperature <= min_temperature)
to_chat(usr, "<span class='warning'>Temperature must be between [min_temperature]C and [max_temperature]C.</span>")
else
input_temperature = input_temperature + T0C
set_temperature(input_temperature)
input_temperature = round(clamp(input_temperature, min_temperature, max_temperature) + T0C, 0.01)
set_temperature(input_temperature)
return 1

if(!buttonCheck(usr))
Expand Down
16 changes: 5 additions & 11 deletions code/game/machinery/computer/atmos_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,10 @@ var/global/list/atmos_controllers = list()
if(href_list["set_preset_setting"] == "target_temperature")
var/max_temperature = MAX_TARGET_TEMPERATURE - T0C //these defines should come from code\game\machinery\alarm.dm
var/min_temperature = MIN_TARGET_TEMPERATURE - T0C
var/input_temperature = input("What temperature (in C) would you like the system to target? (Capped between [min_temperature]C and [max_temperature]C).\n\nNote that the cooling unit in this air alarm can not go below [MIN_TEMPERATURE]C or above [MAX_TEMPERATURE]C by itself. ", "Thermostat Controls") as num|null
var/input_temperature = input("What temperature (in C) would you like the system to target? (Capped between [min_temperature]C and [max_temperature]C).\n\nNote that the cooling unit in this air alarm can not go below [MIN_TEMPERATURE - T0C]C or above [MAX_TEMPERATURE - T0C]C by itself. ", "Thermostat Controls") as num|null
if(input_temperature==null)
return 1
if(!input_temperature || input_temperature >= max_temperature || input_temperature <= min_temperature)
to_chat(usr, "<span class='warning'>Temperature must be between [min_temperature]C and [max_temperature]C.</span>")
else
input_temperature = input_temperature + T0C
input_temperature = round(clamp(input_temperature, min_temperature, max_temperature) + T0C, 0.01)
selected_preset.target_temperature = input_temperature
return 1
else if(href_list["set_preset_setting"] == "scrubbed_gases")
Expand Down Expand Up @@ -613,14 +610,11 @@ var/global/list/atmos_controllers = list()
else
max_temperature = temperature_threshold.max_1() - T0C
min_temperature = temperature_threshold.min_1() - T0C
var/input_temperature = input("What temperature (in C) would you like the system to target? (Capped between [min_temperature]C and [max_temperature]C).\n\nNote that the cooling unit in this air alarm can not go below [MIN_TEMPERATURE]C or above [MAX_TEMPERATURE]C by itself. ", "Thermostat Controls") as num|null
var/input_temperature = input("What temperature (in C) would you like the system to target? (Capped between [min_temperature]C and [max_temperature]C).\n\nNote that the cooling unit in this air alarm can not go below [MIN_TEMPERATURE - T0C]C or above [MAX_TEMPERATURE - T0C]C by itself. ", "Thermostat Controls") as num|null
if(input_temperature==null)
return 1
if(!input_temperature || input_temperature >= max_temperature || input_temperature <= min_temperature)
to_chat(usr, "<span class='warning'>Temperature must be between [min_temperature]C and [max_temperature]C.</span>")
else
input_temperature = input_temperature + T0C
current.set_temperature(input_temperature)
input_temperature = round(clamp(input_temperature, min_temperature, max_temperature) + T0C, 0.01)
current.set_temperature(input_temperature)
return 1

#undef ACA_SCREEN_DETAILSVIEW
Expand Down
Loading