Atmos control auto-update fixes

Air alarms now auto-refresh and have a mechanism to heat or cool rooms.
Space heaters can both heat and cool rooms
This commit is contained in:
SkyMarshal
2013-04-19 01:43:58 -07:00
parent 66cdc1a493
commit 6a38e51c73
3 changed files with 83 additions and 11 deletions

View File

@@ -13,9 +13,19 @@
var/overridden = 0 //not set yet, can't think of a good way to do it
req_access = list(access_ce)
/obj/machinery/computer/atmoscontrol/attack_ai(var/mob/user as mob)
return interact(user)
/obj/machinery/computer/atmoscontrol/attack_paw(var/mob/user as mob)
return interact(user)
/obj/machinery/computer/atmoscontrol/attack_hand(mob/user)
if(..())
return
return interact(user)
/obj/machinery/computer/atmoscontrol/interact(mob/user)
user.set_machine(src)
if(allowed(user))
overridden = 1
@@ -62,7 +72,6 @@
return
if(href_list["reset"])
current = null
src.updateUsrDialog()
if(href_list["alarm"])
current = locate(href_list["alarm"])
if(href_list["command"])
@@ -129,6 +138,11 @@
selected[2] = selected[4]
if(selected[3] > selected[4])
selected[3] = selected[4]
//Sets the temperature the built-in heater/cooler tries to maintain.
if(env == "temperature")
current.target_temperature = (selected[2] + selected[3])/2
spawn(1)
updateUsrDialog()
return
@@ -167,7 +181,7 @@
spawn(5)
src.updateUsrDialog()
return
src.updateUsrDialog()
updateUsrDialog()
//copypasta from alarm code, changed to work with this without derping hard
//---START COPYPASTA----
@@ -185,7 +199,7 @@
output += {"
<a href='?src=\ref[src];alarm=\ref[current];screen=[AALARM_SCREEN_SCRUB]'>Scrubbers Control</a><br>
<a href='?src=\ref[src];alarm=\ref[current];screen=[AALARM_SCREEN_VENT]'>Vents Control</a><br>
<a href='?src=\ref[src];alarm=\ref[current];screen=[AALARM_SCREEN_MODE]'>Set envirenomentals mode</a><br>
<a href='?src=\ref[src];alarm=\ref[current];screen=[AALARM_SCREEN_MODE]'>Set environmental mode</a><br>
<a href='?src=\ref[src];alarm=\ref[current];screen=[AALARM_SCREEN_SENSORS]'>Sensor Control</a><br>
<HR>
"}

View File

@@ -31,7 +31,7 @@
#define AALARM_MODE_SCRUBBING 1
#define AALARM_MODE_REPLACEMENT 2 //like scrubbing, but faster.
#define AALARM_MODE_PANIC 3 //constantly sucks all air
#define AALARM_MODE_CYCLE 4 //sucks off all air, then refill and swithes to scrubbing
#define AALARM_MODE_CYCLE 4 //sucks off all air, then refill and switches to scrubbing
#define AALARM_MODE_FILL 5 //emergency fill
#define AALARM_SCREEN_MAIN 1
@@ -46,6 +46,9 @@
#define RCON_AUTO 2
#define RCON_YES 3
//1000 joules equates to about 1 degree every 2 seconds for a single tile of air.
#define MAX_ENERGY_CHANGE 2000
//all air alarms in area are connected via magic
/area
var/obj/machinery/alarm/master_air_alarm
@@ -82,6 +85,9 @@
var/area/alarm_area
var/danger_level = 0
var/target_temperature = T0C+20
var/regulating_temperature = 0
var/datum/radio_frequency/radio_connection
var/list/TLV = list()
@@ -95,6 +101,7 @@
TLV["other"] = list(-1.0, -1.0, 0.5, 1.0) // Partial pressure, kpa
TLV["pressure"] = list(0,ONE_ATMOSPHERE*0.10,ONE_ATMOSPHERE*1.40,ONE_ATMOSPHERE*1.60) /* kpa */
TLV["temperature"] = list(20, 40, 140, 160) // K
target_temperature = 90
New()
..()
@@ -111,7 +118,7 @@
TLV["plasma"] = list(-1.0, -1.0, 0.2, 0.5) // Partial pressure, kpa
TLV["other"] = list(-1.0, -1.0, 0.5, 1.0) // Partial pressure, kpa
TLV["pressure"] = list(ONE_ATMOSPHERE*0.80,ONE_ATMOSPHERE*0.90,ONE_ATMOSPHERE*1.10,ONE_ATMOSPHERE*1.20) /* kpa */
TLV["temperature"] = list(T0C, T0C+10, T0C+40, T0C+66) // K
TLV["temperature"] = list(T0C-26, T0C, T0C+40, T0C+66) // K
initialize()
set_frequency(frequency)
@@ -151,6 +158,41 @@
current_settings = TLV["temperature"]
var/temperature_dangerlevel = get_danger_level(environment.temperature, current_settings)
//Handle temperature adjustment here.
if(temperature_dangerlevel || regulating_temperature)
//If it goes too far, we should adjust ourselves back before stopping.
if(!regulating_temperature)
regulating_temperature = 1
visible_message("\The [src] clicks as it starts [environment.temperature > target_temperature ? "cooling" : "heating"] the room.",\
"You hear a click and a faint electronic hum.")
if(target_temperature > T0C + 90)
target_temperature = T0C + 90
if(target_temperature < T0C - 40)
target_temperature = T0C - 40
var/datum/gas_mixture/gas = location.remove_air(0.25*environment.total_moles)
var/heat_capacity = gas.heat_capacity()
var/energy_used = max( abs( heat_capacity*(gas.temperature - target_temperature) ), MAX_ENERGY_CHANGE)
//Use power. Assuming that each power unit represents 1000 watts....
use_power(energy_used/1000, ENVIRON)
//We need to cool ourselves.
if(environment.temperature > target_temperature)
gas.temperature -= energy_used/heat_capacity
else
gas.temperature -= energy_used/heat_capacity
environment.merge(gas)
if(abs(environment.temperature - target_temperature) <= 0.5)
regulating_temperature = 0
visible_message("\The [src] clicks quietly as it stops [environment.temperature > target_temperature ? "cooling" : "heating"] the room.",\
"You hear a click as a faint electronic humming stops.")
var/old_danger_level = danger_level
danger_level = max(pressure_dangerlevel,
oxygen_dangerlevel,
@@ -513,11 +555,16 @@
//END HACKING//
///////////////
attack_ai(mob/user)
return interact(user)
attack_hand(mob/user)
. = ..()
if (.)
return
return interact(user)
interact(mob/user)
user.set_machine(src)
if ( (get_dist(src, user) > 1 ))
@@ -900,6 +947,11 @@ table tr:first-child th:first-child { border: none;}
selected[2] = selected[4]
if(selected[3] > selected[4])
selected[3] = selected[4]
//Sets the temperature the built-in heater/cooler tries to maintain.
if(env == "temperature")
target_temperature = (selected[2] + selected[3])/2
apply_mode()
if(href_list["screen"])

View File

@@ -83,6 +83,10 @@
attack_hand(mob/user as mob)
src.add_fingerprint(user)
interact(user)
interact(mob/user as mob)
if(open)
var/dat
@@ -127,7 +131,7 @@
var/value = text2num(href_list["val"])
// limit to 20-90 degC
set_temperature = dd_range(20, 90, set_temperature + value)
set_temperature = dd_range(0, 90, set_temperature + value)
if("cellremove")
if(open && cell && !usr.get_active_hand())
@@ -164,7 +168,7 @@
var/turf/simulated/L = loc
if(istype(L))
var/datum/gas_mixture/env = L.return_air()
if(env.temperature < (set_temperature+T0C))
if(env.temperature != set_temperature + T0C)
var/transfer_moles = 0.25 * env.total_moles()
@@ -176,10 +180,12 @@
var/heat_capacity = removed.heat_capacity()
//world << "heating ([heat_capacity])"
if(heat_capacity == 0 || heat_capacity == null) // Added check to avoid divide by zero (oshi-) runtime errors -- TLE
heat_capacity = 1
removed.temperature = min((removed.temperature*heat_capacity + heating_power)/heat_capacity, 1000) // Added min() check to try and avoid wacky superheating issues in low gas scenarios -- TLE
cell.use(heating_power/20000)
if(heat_capacity) // Added check to avoid divide by zero (oshi-) runtime errors -- TLE
if(removed.temperature < set_temperature + T0C)
removed.temperature = min(removed.temperature + heating_power/heat_capacity, 1000) // Added min() check to try and avoid wacky superheating issues in low gas scenarios -- TLE
else
removed.temperature = max(removed.temperature - heating_power/heat_capacity, TCMB)
cell.use(heating_power/20000)
//world << "now at [removed.temperature]"