@@ -15,26 +15,14 @@
//Create gas mixture to hold data for passing
var/datum/gas_mixture/GM = new

GM.oxygen = oxygen
GM.carbon_dioxide = carbon_dioxide
GM.nitrogen = nitrogen
GM.toxins = toxins

GM.temperature = temperature
GM.copy_from(src)

return GM

/turf/remove_air(amount as num)
var/datum/gas_mixture/GM = new

var/sum = oxygen + carbon_dioxide + nitrogen + toxins
if(sum>0)
GM.oxygen = (oxygen/sum)*amount
GM.carbon_dioxide = (carbon_dioxide/sum)*amount
GM.nitrogen = (nitrogen/sum)*amount
GM.toxins = (toxins/sum)*amount
/turf/remove_air(amount)
var/datum/gas_mixture/GM = return_air()

GM.temperature = temperature
GM.remove(amount)

return GM

@@ -61,11 +49,7 @@
visibilityChanged()
if(!blocks_air)
air = new
air.oxygen = oxygen
air.carbon_dioxide = carbon_dioxide
air.nitrogen = nitrogen
air.toxins = toxins
air.temperature = temperature
air.copy_from_turf(src)

/turf/simulated/Destroy()
visibilityChanged()
@@ -254,11 +238,10 @@
return null

/turf/simulated/proc/tile_graphic()
if(air.toxins > MOLES_PLASMA_VISIBLE)
if(air.gases[GAS_PL][MOLES] > MOLES_PLASMA_VISIBLE)
return "plasma"

var/datum/gas/sleeping_agent = locate(/datum/gas/sleeping_agent) in air.trace_gases
if(sleeping_agent && (sleeping_agent.moles > 1))
if(air.gases[GAS_N2O][MOLES] > 1)
return "sleeping_agent"
return null

@@ -331,36 +314,15 @@

/datum/excited_group/proc/self_breakdown()
var/datum/gas_mixture/A = new
var/datum/gas/sleeping_agent/S = new
A.trace_gases += S
for(var/turf/simulated/T in turf_list)
A.oxygen += T.air.oxygen
A.carbon_dioxide+= T.air.carbon_dioxide
A.nitrogen += T.air.nitrogen
A.toxins += T.air.toxins

if(T.air.trace_gases.len)
for(var/datum/gas/N in T.air.trace_gases)
S.moles += N.moles
A.merge(T.air)

for(var/turf/simulated/T in turf_list)
T.air.oxygen = A.oxygen/turf_list.len
T.air.carbon_dioxide= A.carbon_dioxide/turf_list.len
T.air.nitrogen = A.nitrogen/turf_list.len
T.air.toxins = A.toxins/turf_list.len

if(S.moles > 0)
if(T.air.trace_gases.len)
for(var/datum/gas/G in T.air.trace_gases)
G.moles = S.moles/turf_list.len
else
var/datum/gas/sleeping_agent/G = new
G.moles = S.moles/turf_list.len
T.air.trace_gases += G
for(var/gas in T.air.gases)
gas[MOLES] = A.gases[gas[GAS_INDEX]][MOLES]/turf_list.len

T.update_visuals()


/datum/excited_group/proc/dismantle()
for(var/turf/simulated/T in turf_list)
T.excited = 0
@@ -20,8 +20,9 @@
//indices of values in gas lists. used by listmos.
#define MOLES 1
#define ARCHIVE 2
#define SPECIFIC_HEAT 3
#define GAS_INDEX 4
#define GAS_INDEX 3
#define SPECIFIC_HEAT 4
#define GAS_NAME 5

//stuff you should probably leave well alone!
//ATMOS
@@ -1046,20 +1046,13 @@ var/list/WALLITEMS_INVERSE = list(

user << "<span class='notice'>Results of analysis of \icon[icon] [target].</span>"
if(total_moles>0)
var/o2_concentration = air_contents.oxygen/total_moles
var/n2_concentration = air_contents.nitrogen/total_moles
var/co2_concentration = air_contents.carbon_dioxide/total_moles
var/plasma_concentration = air_contents.toxins/total_moles
user << "<span class='notice'>Pressure: [round(pressure,0.1)] kPa</span>"

var/unknown_concentration = 1-(o2_concentration+n2_concentration+co2_concentration+plasma_concentration)
for(var/gas in air_contents.gases)
var/gas_concentration = gas[MOLES]/total_moles
if(gas[GAS_INDEX] <= 4 || gas_concentration > 0.01) //ensures the four primary gases are always shown.
user << "<span class='notice'>[gas[GAS_NAME]]: [round(gas_concentration*100)] %</span>"

user << "<span class='notice'>Pressure: [round(pressure,0.1)] kPa</span>"
user << "<span class='notice'>Nitrogen: [round(n2_concentration*100)] %</span>"
user << "<span class='notice'>Oxygen: [round(o2_concentration*100)] %</span>"
user << "<span class='notice'>CO2: [round(co2_concentration*100)] %</span>"
user << "<span class='notice'>Plasma: [round(plasma_concentration*100)] %</span>"
if(unknown_concentration>0.01)
user << "<span class='danger'>Unknown: [round(unknown_concentration*100)] %</span>"
user << "<span class='notice'>Temperature: [round(air_contents.temperature-T0C)] &deg;C</span>"
else
user << "<span class='notice'>[target] is empty!</span>"
@@ -1217,7 +1210,7 @@ B --><-- A
transform = shift

SpinAnimation(rotation_speed, -1, clockwise, rotation_segments)

//we stack the orbits up client side, so we can assign this back to normal server side without it breaking the orbit
transform = initial_transform
while(orbiting && orbiting == A && A.loc)
@@ -1227,7 +1220,7 @@ B --><-- A
loc = targetloc
lastloc = loc
sleep(0.6)

if (orbiting == A) //make sure we haven't started orbiting something else.
orbiting = null
SpinAnimation(0,0)
@@ -29,29 +29,29 @@ What are the archived variables for?
/datum/gas/volatile_fuel
specific_heat = 30

var/list/gas_heats = list( //this is actually the list that decides what gases exist and in what order
20, //GAS_O2
20, //GAS_N2
30, //GAS_C02
200,//GAS_PLASMA
40, //GAS_N20
300,//GAS_AGENT_B
30, //GAS_V_FUEL
var/list/meta_gas_info = list( //this is actually the list that decides what gases exist and in what order
list(20, "Oxygen"), //GAS_O2
list(20, "Nitrogen"), //GAS_N2
list(30, "Carbon Dioxide"), //GAS_C02
list(200, "Plasma"), //GAS_PLASMA
list(40, "Nitrous Oxide"), //GAS_N20
list(300, "Oxygen Agent B"), //GAS_AGENT_B
list(30, "Volatile Fuel") //GAS_V_FUEL
)

var/list/cached_gases_list

/proc/gaseslist()
. = new /list
for(var/i in 1 to gas_heats.len)
.[i] = gaslist(gas_heats[i], i)
for(var/i in 1 to meta_gas_info.len)
.[i] = gaslist(meta_gas_info[i], i)

/proc/gaslist(specific_heat, index)
/proc/gaslist(gas_info, index)
. = new /list
. += 0 //MOLES
. += 0 //ARCHIVE
. += specific_heat //SPECIFIC_HEAT
. += index //GAS_INDEX
. += gas_info //all the rest

/datum/gas_mixture
/*
@@ -257,6 +257,8 @@ var/list/cached_gases_list

/datum/gas_mixture/proc/temperature_share(datum/gas_mixture/sharer, conduction_coefficient)

/datum/gas_mixture/proc/temperature_mimic(turf/model, conduction_coefficient)

/datum/gas_mixture/proc/temperature_turf_share(turf/simulated/sharer, conduction_coefficient)

/datum/gas_mixture/proc/compare(datum/gas_mixture/sample)
@@ -410,6 +412,17 @@ var/list/cached_gases_list
temperature -= heat/self_heat_capacity
sharer.temperature += heat/sharer_heat_capacity

/datum/gas_mixture/temperature_mimic(turf/model, conduction_coefficient)
var/delta_temperature = (temperature - model.temperature)
if(abs(delta_temperature) > MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER)
var/self_heat_capacity = heat_capacity()

if((model.heat_capacity > MINIMUM_HEAT_CAPACITY) && (self_heat_capacity > MINIMUM_HEAT_CAPACITY))
var/heat = conduction_coefficient*delta_temperature* \
(self_heat_capacity*model.heat_capacity/(self_heat_capacity+model.heat_capacity))

temperature -= heat/self_heat_capacity

/datum/gas_mixture/temperature_turf_share(turf/simulated/sharer, conduction_coefficient)
var/delta_temperature = (temperature_archived - sharer.temperature)
if(abs(delta_temperature) > MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER)
@@ -290,7 +290,12 @@
var/turf/simulated/floor/F = random_location
if(F.air)
var/datum/gas_mixture/A = F.air
if(A.oxygen >= 16 && !A.toxins && A.carbon_dioxide < 10 && !A.trace_gases.len)//Can most things breathe in this location?
var/trace_gases
for(var/i in 5 to A.gases.len)
if(A.gases[i][MOLES])
trace_gases = TRUE
break
if(A.gases[GAS_O2][MOLES] >= 16 && !A.gases[GAS_PL][MOLES] && A.gases[GAS_CO2][MOLES] < 10 && !trace_gases)//Can most things breathe in this location?
if((A.temperature > 270) && (A.temperature < 360))//Not too hot, not too cold
var/pressure = A.return_pressure()
if((pressure > 20) && (pressure < 550))//Account for crushing pressure or vaccuums
@@ -94,7 +94,7 @@
/datum/objective_item/steal/plasma/check_special_completion(obj/item/weapon/tank/T)
var/target_amount = text2num(name)
var/found_amount = 0
found_amount += T.air_contents.toxins
found_amount += T.air_contents.gases[GAS_PL][MOLES]
return found_amount>=target_amount


@@ -257,7 +257,7 @@
if(!location)
return
var/datum/gas_mixture/environment = location.return_air()
var/total = environment.oxygen + environment.nitrogen + environment.carbon_dioxide + environment.toxins
var/total = environment.total_moles()

var/list/environment_data = list()
data["atmos_alarm"] = alarm_area.atmosalm
@@ -273,25 +273,25 @@
environment_data += list(list("name" = "Pressure", "value" = pressure, "unit" = "kPa", "danger_level" = pressure_danger))

cur_tlv = TLV["oxygen"]
var/oxygen_danger = cur_tlv.get_danger_level(environment.oxygen*partial_pressure)
environment_data += list(list("name" = "Oxygen", "value" = environment.oxygen / total * 100, "unit" = "%", "danger_level" = oxygen_danger))
var/oxygen_danger = cur_tlv.get_danger_level(environment.gases[GAS_O2][MOLES]*partial_pressure)
environment_data += list(list("name" = "Oxygen", "value" = environment.gases[GAS_O2][MOLES] / total * 100, "unit" = "%", "danger_level" = oxygen_danger))

cur_tlv = TLV["nitrogen"]
var/nitrogen_danger = cur_tlv.get_danger_level(environment.nitrogen*partial_pressure)
environment_data += list(list("name" = "Nitrogen", "value" = environment.nitrogen / total * 100, "unit" = "%", "danger_level" = nitrogen_danger))
var/nitrogen_danger = cur_tlv.get_danger_level(environment.gases[GAS_N2][MOLES]*partial_pressure)
environment_data += list(list("name" = "Nitrogen", "value" = environment.gases[GAS_N2][MOLES] / total * 100, "unit" = "%", "danger_level" = nitrogen_danger))

cur_tlv = TLV["carbon dioxide"]
var/carbon_dioxide_danger = cur_tlv.get_danger_level(environment.carbon_dioxide*partial_pressure)
environment_data += list(list("name" = "Carbon Dioxide", "value" = environment.carbon_dioxide / total * 100, "unit" = "%", "danger_level" = carbon_dioxide_danger))
var/carbon_dioxide_danger = cur_tlv.get_danger_level(environment.gases[GAS_CO2][MOLES]*partial_pressure)
environment_data += list(list("name" = "Carbon Dioxide", "value" = environment.gases[GAS_CO2][MOLES] / total * 100, "unit" = "%", "danger_level" = carbon_dioxide_danger))

cur_tlv = TLV["plasma"]
var/plasma_danger = cur_tlv.get_danger_level(environment.toxins*partial_pressure)
environment_data += list(list("name" = "Toxins", "value" = environment.toxins / total * 100, "unit" = "%", "danger_level" = plasma_danger))
var/plasma_danger = cur_tlv.get_danger_level(environment.gases[GAS_PL][MOLES]*partial_pressure)
environment_data += list(list("name" = "Toxins", "value" = environment.gases[GAS_PL][MOLES] / total * 100, "unit" = "%", "danger_level" = plasma_danger))

cur_tlv = TLV["other"]
var/other_moles = 0
for(var/datum/gas/G in environment.trace_gases)
other_moles+=G.moles
for(var/i in 5 to environment.gases.len)
other_moles+=environment.gases[i][MOLES]
var/other_danger = cur_tlv.get_danger_level(other_moles*partial_pressure)
environment_data += list(list("name" = "Other", "value" = other_moles / total * 100, "unit" = "%", "danger_level" = other_danger))

@@ -612,18 +612,18 @@
var/pressure_dangerlevel = cur_tlv.get_danger_level(environment_pressure)

cur_tlv = TLV["oxygen"]
var/oxygen_dangerlevel = cur_tlv.get_danger_level(environment.oxygen*GET_PP)
var/oxygen_dangerlevel = cur_tlv.get_danger_level(environment.gases[GAS_O2][MOLES]*GET_PP)

cur_tlv = TLV["carbon dioxide"]
var/co2_dangerlevel = cur_tlv.get_danger_level(environment.carbon_dioxide*GET_PP)
var/co2_dangerlevel = cur_tlv.get_danger_level(environment.gases[GAS_CO2][MOLES]*GET_PP)

cur_tlv = TLV["plasma"]
var/plasma_dangerlevel = cur_tlv.get_danger_level(environment.toxins*GET_PP)
var/plasma_dangerlevel = cur_tlv.get_danger_level(environment.gases[GAS_PL][MOLES]*GET_PP)

cur_tlv = TLV["other"]
var/other_moles = 0
for(var/datum/gas/G in environment.trace_gases)
other_moles+=G.moles
for(var/i in 5 to environment.gases.len)
other_moles+=environment.gases[i][MOLES]
var/other_dangerlevel = cur_tlv.get_danger_level(other_moles*GET_PP)

cur_tlv = TLV["temperature"]
@@ -47,13 +47,13 @@
var/total_moles = air_sample.total_moles()
if(total_moles > 0)
if(output&4)
signal.data["oxygen"] = round(100*air_sample.oxygen/total_moles,0.1)
signal.data["oxygen"] = round(100*air_sample.gases[GAS_O2][MOLES]/total_moles,0.1)
if(output&8)
signal.data["toxins"] = round(100*air_sample.toxins/total_moles,0.1)
signal.data["toxins"] = round(100*air_sample.gases[GAS_PL][MOLES]/total_moles,0.1)
if(output&16)
signal.data["nitrogen"] = round(100*air_sample.nitrogen/total_moles,0.1)
signal.data["nitrogen"] = round(100*air_sample.gases[GAS_N2][MOLES]/total_moles,0.1)
if(output&32)
signal.data["carbon_dioxide"] = round(100*air_sample.carbon_dioxide/total_moles,0.1)
signal.data["carbon_dioxide"] = round(100*air_sample.gases[GAS_CO2][MOLES]/total_moles,0.1)
else
signal.data["oxygen"] = 0
signal.data["toxins"] = 0
@@ -344,11 +344,10 @@ update_flag
logmsg = "Valve was <b>opened</b> by [key_name(usr)], starting the transfer into the [holding]<br>"
else
logmsg = "Valve was <b>opened</b> by [key_name(usr)], starting the transfer into the <span class='boldannounce'>air</span><br>"
if(air_contents.toxins > 0)
if(air_contents.gases[GAS_PL][MOLES] > 0)
message_admins("[key_name_admin(usr)] (<A HREF='?_src_=holder;adminmoreinfo=\ref[usr]'>?</A>) (<A HREF='?_src_=holder;adminplayerobservefollow=\ref[usr]'>FLW</A>) opened a canister that contains plasma! (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)")
log_admin("[key_name(usr)] opened a canister that contains plasma at [x], [y], [z]")
var/datum/gas/sleeping_agent = locate(/datum/gas/sleeping_agent) in air_contents.trace_gases
if(sleeping_agent && (sleeping_agent.moles > 1))
if(air_contents.gases[GAS_N2O][MOLES] > 1)
message_admins("[key_name_admin(usr)] (<A HREF='?_src_=holder;adminmoreinfo=\ref[usr]'>?</A>) (<A HREF='?_src_=holder;adminplayerobservefollow=\ref[usr]'>FLW</A>) opened a canister that contains N2O! (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)")
log_admin("[key_name(usr)] opened a canister that contains N2O at [x], [y], [z]")
investigate_log(logmsg, "atmos")
@@ -367,30 +366,29 @@ update_flag
/obj/machinery/portable_atmospherics/canister/toxins/New()
..()

src.air_contents.toxins = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)
air_contents.gases[GAS_PL][MOLES] = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)

src.update_icon()
update_icon()
return 1

/obj/machinery/portable_atmospherics/canister/oxygen/New()
..()

src.air_contents.oxygen = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)
air_contents.gases[GAS_O2][MOLES] = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)

src.update_icon()
update_icon()
return 1

/obj/machinery/portable_atmospherics/canister/sleeping_agent/New()
..()

var/datum/gas/sleeping_agent/trace_gas = new
air_contents.trace_gases += trace_gas
trace_gas.moles = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)
air_contents.gases[GAS_N2O][MOLES] = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)

src.update_icon()
update_icon()
return 1

//Dirty way to fill room with gas. However it is a bit easier to do than creating some floor/engine/n2o -rastaf0
/*
/obj/machinery/portable_atmospherics/canister/sleeping_agent/roomfiller/New()
..()
@@ -404,30 +402,31 @@ update_flag
location.assume_air(air_contents)
air_contents = new
return 1
*/

/obj/machinery/portable_atmospherics/canister/nitrogen/New()

..()

src.air_contents.nitrogen = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)
air_contents.gases[GAS_N2][MOLES] = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)

src.update_icon()
update_icon()
return 1

/obj/machinery/portable_atmospherics/canister/carbon_dioxide/New()

..()
src.air_contents.carbon_dioxide = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)
air_contents.gases[GAS_CO2][MOLES] = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)

src.update_icon()
update_icon()
return 1


/obj/machinery/portable_atmospherics/canister/air/New()

..()
src.air_contents.oxygen = (O2STANDARD*src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)
src.air_contents.nitrogen = (N2STANDARD*src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)
air_contents.gases[GAS_O2][MOLES] = (O2STANDARD*src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)
air_contents.gases[GAS_N2][MOLES] = (N2STANDARD*src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)

src.update_icon()
update_icon()
return 1
@@ -76,23 +76,17 @@
filtered_out.temperature = removed.temperature


filtered_out.toxins = removed.toxins
removed.toxins = 0

filtered_out.carbon_dioxide = removed.carbon_dioxide
removed.carbon_dioxide = 0

if(removed.trace_gases.len>0)
for(var/datum/gas/trace_gas in removed.trace_gases)
if(istype(trace_gas, /datum/gas/sleeping_agent))
removed.trace_gases -= trace_gas
filtered_out.trace_gases += trace_gas

if(removed.trace_gases.len>0)
for(var/datum/gas/trace_gas in removed.trace_gases)
if(istype(trace_gas, /datum/gas/oxygen_agent_b))
removed.trace_gases -= trace_gas
filtered_out.trace_gases += trace_gas
filtered_out.gases[GAS_PL][MOLES] = removed.gases[GAS_PL][MOLES]
removed.gases[GAS_PL][MOLES] = 0

filtered_out.gases[GAS_CO2][MOLES] = removed.gases[GAS_CO2][MOLES]
removed.gases[GAS_CO2][MOLES] = 0

filtered_out.gases[GAS_AGENT_B][MOLES] = removed.gases[GAS_AGENT_B][MOLES]
removed.gases[GAS_AGENT_B][MOLES] = 0

filtered_out.gases[GAS_N2O][MOLES] = removed.gases[GAS_N2O][MOLES]
removed.gases[GAS_AGENT_B][MOLES] = 0

//Remix the resulting gases
air_contents.merge(filtered_out)
@@ -437,12 +437,12 @@
return
var/datum/gas_mixture/GM = new
if(prob(10))
GM.toxins += 100
GM.gases[GAS_PL][MOLES] += 100
GM.temperature = 1500+T0C //should be enough to start a fire
T.visible_message("The [src] suddenly disgorges a cloud of heated plasma.")
qdel(src)
else
GM.toxins += 5
GM.gases[GAS_PL][MOLES] += 5
GM.temperature = istype(T) ? T.air.return_temperature() : T20C
T.visible_message("The [src] suddenly disgorges a cloud of plasma.")
T.assume_air(GM)
@@ -177,8 +177,8 @@
cabin_air = new
cabin_air.temperature = T20C
cabin_air.volume = 200
cabin_air.oxygen = O2STANDARD*cabin_air.volume/(R_IDEAL_GAS_EQUATION*cabin_air.temperature)
cabin_air.nitrogen = N2STANDARD*cabin_air.volume/(R_IDEAL_GAS_EQUATION*cabin_air.temperature)
cabin_air.gases[GAS_O2][MOLES] = O2STANDARD*cabin_air.volume/(R_IDEAL_GAS_EQUATION*cabin_air.temperature)
cabin_air.gases[GAS_N2][MOLES] = N2STANDARD*cabin_air.volume/(R_IDEAL_GAS_EQUATION*cabin_air.temperature)
return cabin_air

/obj/mecha/proc/add_radio()
@@ -163,9 +163,9 @@
T.air_update_turf()
for(var/obj/effect/hotspot/H in T)
qdel(H)
if(G.toxins)
G.nitrogen += (G.toxins)
G.toxins = 0
if(G.gases[GAS_PL][MOLES])
G.gases[GAS_N2][MOLES] += (G.gases[GAS_PL][MOLES])
G.gases[GAS_PL][MOLES] = 0
for(var/obj/machinery/atmospherics/components/unary/U in T)
if(!isnull(U.welded) && !U.welded) //must be an unwelded vent pump or vent scrubber.
U.welded = 1
@@ -421,17 +421,11 @@ var/global/list/obj/item/device/pda/PDAs = list()
dat += "Air Pressure: [round(pressure,0.1)] kPa<br>"

if (total_moles)
var/o2_level = environment.oxygen/total_moles
var/n2_level = environment.nitrogen/total_moles
var/co2_level = environment.carbon_dioxide/total_moles
var/plasma_level = environment.toxins/total_moles
var/unknown_level = 1-(o2_level+n2_level+co2_level+plasma_level)
dat += "Nitrogen: [round(n2_level*100)]%<br>"
dat += "Oxygen: [round(o2_level*100)]%<br>"
dat += "Carbon Dioxide: [round(co2_level*100)]%<br>"
dat += "Plasma: [round(plasma_level*100)]%<br>"
if(unknown_level > 0.01)
dat += "OTHER: [round(unknown_level)]%<br>"
for(var/gas in environment.gases)
var/gas_level = gas[MOLES]/total_moles
if(gas[GAS_INDEX] <= 4 || gas_level > 0.01)
dat += "[gas[GAS_NAME]]: [round(gas_level*100)]%<br>"

dat += "Temperature: [round(environment.temperature-T0C)]&deg;C<br>"
dat += "<br>"

@@ -719,7 +713,7 @@ var/global/list/obj/item/device/pda/PDAs = list()

if(!message || !targets.len)
return

if(last_text && world.time < last_text + 5)
return

@@ -746,7 +740,7 @@ var/global/list/obj/item/device/pda/PDAs = list()
user << "<span class='notice'>ERROR: Server isn't responding.</span>"
return
photo = null

if(multiple)
show_to_sender(last_sucessful_msg,1)
show_to_ghosts(last_sucessful_msg,1)
@@ -808,7 +802,7 @@ var/global/list/obj/item/device/pda/PDAs = list()
if(useTC == 2)
return useMS
else
return null
return null


/obj/item/device/pda/proc/send_to_all(mob/living/U = usr)
@@ -268,12 +268,11 @@ MASS SPECTROMETER
else
user.show_message("<span class='alert'>Pressure: [round(pressure,0.1)] kPa</span>", 1)
if(total_moles)
var/o2_concentration = environment.oxygen/total_moles
var/n2_concentration = environment.nitrogen/total_moles
var/co2_concentration = environment.carbon_dioxide/total_moles
var/plasma_concentration = environment.toxins/total_moles
var/o2_concentration = environment.gases[GAS_O2][MOLES]/total_moles
var/n2_concentration = environment.gases[GAS_N2][MOLES]/total_moles
var/co2_concentration = environment.gases[GAS_CO2][MOLES]/total_moles
var/plasma_concentration = environment.gases[GAS_PL][MOLES]/total_moles

var/unknown_concentration = 1-(o2_concentration+n2_concentration+co2_concentration+plasma_concentration)
if(abs(n2_concentration - N2STANDARD) < 20)
user.show_message("<span class='info'>Nitrogen: [round(n2_concentration*100)] %</span>", 1)
else
@@ -292,8 +291,9 @@ MASS SPECTROMETER
if(plasma_concentration > 0.01)
user.show_message("<span class='info'>Plasma: [round(plasma_concentration*100)] %</span>", 1)

if(unknown_concentration > 0.01)
user.show_message("<span class='alert'>Unknown: [round(unknown_concentration*100)] %</span>", 1)
for(var/i in 5 to environment.gases.len)
var/gas_concentration = environment.gases[i][MOLES]/total_moles
user.show_message("<span class='alert'>[environment.gases[i][GAS_NAME]]: [round(gas_concentration*100)] %</span>", 1)

user.show_message("<span class='info'>Temperature: [round(environment.temperature-T0C)] &deg;C</span>", 1)

@@ -239,8 +239,8 @@

/obj/effect/chrono_field/return_air() //we always have nominal air and temperature
var/datum/gas_mixture/GM = new
GM.oxygen = MOLES_O2STANDARD
GM.nitrogen = MOLES_N2STANDARD
GM.gases[GAS_O2][MOLES] = MOLES_O2STANDARD
GM.gases[GAS_N2][MOLES] = MOLES_N2STANDARD
GM.temperature = T20C
return GM

@@ -194,7 +194,7 @@
//TODO: DEFERRED Consider checking to make sure tank pressure is high enough before doing this...
//Transfer 5% of current tank air contents to turf
var/datum/gas_mixture/air_transfer = ptank.air_contents.remove_ratio(release_amount)
air_transfer.toxins = air_transfer.toxins * 5
air_transfer.gases[GAS_PL][MOLES] = air_transfer.gases[GAS_PL][MOLES] * 5
target.assume_air(air_transfer)
//Burn it based on transfered gas
target.hotspot_expose((ptank.air_contents.temperature*2) + 380,500)
@@ -54,7 +54,7 @@

var/datum/gas_mixture/G = src.air_contents.remove(num)

var/allgases = G.carbon_dioxide + G.nitrogen + G.oxygen + G.toxins //fuck trace gases -Pete
var/allgases = G.total_moles()
if(allgases >= 0.005)
return 1

@@ -73,7 +73,7 @@

/obj/item/weapon/tank/jetpack/void/New()
..()
air_contents.oxygen = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.gases[GAS_O2][MOLES] = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)


/obj/item/weapon/tank/jetpack/oxygen
@@ -84,7 +84,7 @@

/obj/item/weapon/tank/jetpack/oxygen/New()
..()
air_contents.oxygen = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.gases[GAS_O2][MOLES] = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)

/obj/item/weapon/tank/jetpack/oxygen/harness
name = "jet harness (oxygen)"
@@ -114,7 +114,7 @@
..()
ion_trail = new /datum/effect_system/trail_follow/ion()
ion_trail.set_up(src)
air_contents.carbon_dioxide = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.gases[GAS_CO2][MOLES] = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)


/obj/item/weapon/tank/jetpack/suit
@@ -20,7 +20,7 @@

/obj/item/weapon/tank/internals/oxygen/New()
..()
src.air_contents.oxygen = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.gases[GAS_O2][MOLES] = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
return


@@ -45,13 +45,8 @@

/obj/item/weapon/tank/internals/anesthetic/New()
..()

src.air_contents.oxygen = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * O2STANDARD

var/datum/gas/sleeping_agent/trace_gas = new()
trace_gas.moles = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * N2STANDARD

src.air_contents.trace_gases += trace_gas
air_contents.gases[GAS_O2][MOLES] = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * O2STANDARD
air_contents.gases[GAS_N2O][MOLES] = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * N2STANDARD
return

/*
@@ -67,8 +62,8 @@
/obj/item/weapon/tank/internals/air/New()
..()

src.air_contents.oxygen = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * O2STANDARD
src.air_contents.nitrogen = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * N2STANDARD
air_contents.gases[GAS_O2][MOLES] = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * O2STANDARD
air_contents.gases[GAS_N2][MOLES] = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * N2STANDARD
return


@@ -87,7 +82,7 @@
/obj/item/weapon/tank/internals/plasma/New()
..()

src.air_contents.toxins = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.gases[GAS_PL][MOLES] = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
return

/obj/item/weapon/tank/internals/plasma/attackby(obj/item/weapon/W, mob/user, params)
@@ -105,7 +100,7 @@

/obj/item/weapon/tank/internals/plasma/full/New()
..()
src.air_contents.toxins = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.gases[GAS_PL][MOLES] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
return


@@ -121,13 +116,13 @@
/obj/item/weapon/tank/internals/plasmaman/New()
..()

src.air_contents.toxins = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.gases[GAS_PL][MOLES] = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
return

/obj/item/weapon/tank/internals/plasmaman/full/New()
..()

src.air_contents.toxins = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.gases[GAS_PL][MOLES] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
return


@@ -140,7 +135,7 @@
/obj/item/weapon/tank/internals/plasmaman/belt/full/New()
..()

src.air_contents.toxins = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.gases[GAS_PL][MOLES] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
return


@@ -162,7 +157,7 @@

/obj/item/weapon/tank/internals/emergency_oxygen/New()
..()
src.air_contents.oxygen = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
air_contents.gases[GAS_O2][MOLES] = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
return

/obj/item/weapon/tank/internals/emergency_oxygen/engi
@@ -66,15 +66,14 @@

/obj/structure/closet/crate/freezer/return_air()
var/datum/gas_mixture/gas = (..())
if(!gas) return null
if(!gas)
return null

var/datum/gas_mixture/newgas = new/datum/gas_mixture()
newgas.oxygen = gas.oxygen
newgas.carbon_dioxide = gas.carbon_dioxide
newgas.nitrogen = gas.nitrogen
newgas.toxins = gas.toxins
newgas.volume = gas.volume
newgas.temperature = gas.temperature
if(newgas.temperature <= target_temp) return
newgas.copy_from(gas)

if(newgas.temperature <= target_temp)
return

if((newgas.temperature - cooling_power) > target_temp)
newgas.temperature -= cooling_power
@@ -11,8 +11,8 @@
/obj/structure/transit_tube_pod/New(loc)
..(loc)

air_contents.oxygen = MOLES_O2STANDARD * 2
air_contents.nitrogen = MOLES_N2STANDARD
air_contents.gases[GAS_O2][MOLES] = MOLES_O2STANDARD * 2
air_contents.gases[GAS_N2][MOLES] = MOLES_N2STANDARD
air_contents.temperature = T20C

// Give auto tubes time to align before trying to start moving
@@ -123,11 +123,7 @@
// datum, there might be problems if I don't...
/obj/structure/transit_tube_pod/return_air()
var/datum/gas_mixture/GM = new()
GM.oxygen = air_contents.oxygen
GM.carbon_dioxide = air_contents.carbon_dioxide
GM.nitrogen = air_contents.nitrogen
GM.toxins = air_contents.toxins
GM.temperature = air_contents.temperature
GM.copy_from(air_contents)
return GM

// For now, copying what I found in an unused FEA file (and almost identical in a
@@ -134,10 +134,8 @@
/turf/simulated/floor/engine/n20/New()
..()
var/datum/gas_mixture/adding = new
var/datum/gas/sleeping_agent/trace_gas = new

trace_gas.moles = 6000
adding.trace_gases += trace_gas
adding.gases[GAS_N2O][MOLES] = 6000
adding.temperature = T20C

assume_air(adding)
@@ -141,11 +141,7 @@
//////Assimilate Air//////
/turf/simulated/proc/Assimilate_Air()
if(air)
var/aoxy = 0//Holders to assimilate air from nearby turfs
var/anitro = 0
var/aco = 0
var/atox = 0
var/atemp = 0
var/datum/gas_mixture/a_gas_mixture = new//Holders to assimilate air from nearby turfs
var/turf_count = 0

for(var/direction in cardinal)//Only use cardinals to cut down on lag
@@ -156,17 +152,13 @@
else if(istype(T,/turf/simulated/floor))
var/turf/simulated/S = T
if(S.air)//Add the air's contents to the holders
aoxy += S.air.oxygen
anitro += S.air.nitrogen
aco += S.air.carbon_dioxide
atox += S.air.toxins
atemp += S.air.temperature
for(var/gas in a_gas_mixture.gases)
gas[MOLES] += S.air.gases[gas[GAS_INDEX]][MOLES]
a_gas_mixture.temperature += S.air.temperature
turf_count ++
air.oxygen = (aoxy/max(turf_count,1))//Averages contents of the turfs, ignoring walls and the like
air.nitrogen = (anitro/max(turf_count,1))
air.carbon_dioxide = (aco/max(turf_count,1))
air.toxins = (atox/max(turf_count,1))
air.temperature = (atemp/max(turf_count,1))//Trace gases can get bant
for(var/gas in air.gases)
gas[MOLES] = (a_gas_mixture.gases[gas[GAS_INDEX]][MOLES]/max(turf_count,1))//Averages contents of the turfs, ignoring walls and the like
air.temperature = (a_gas_mixture.temperature/max(turf_count,1))//Trace gases can get bant
SSair.add_to_active(src)

/turf/proc/ReplaceWithLattice()
@@ -189,10 +189,9 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
var/datum/gas_mixture/env = T.return_air()

var/t = ""
t+= "Nitrogen : [env.nitrogen]\n"
t+= "Oxygen : [env.oxygen]\n"
t+= "Plasma : [env.toxins]\n"
t+= "CO2: [env.carbon_dioxide]\n"
for(var/gas in env.gases)
if(gas[GAS_INDEX] <= 4 || gas[MOLES])
t+= "[gas[GAS_NAME]] : [gas[MOLES]]\n"

usr.show_message(t, 1)
feedback_add_details("admin_verb","ASL") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
@@ -631,7 +630,7 @@ var/global/list/g_fancy_list_of_types = null
if(Rad.anchored)
if(!Rad.P)
var/obj/item/weapon/tank/internals/plasma/Plasma = new/obj/item/weapon/tank/internals/plasma(Rad)
Plasma.air_contents.toxins = 70
Plasma.air_contents.gases[GAS_PL][MOLES] = 70
Rad.drainratio = 0
Rad.P = Plasma
Plasma.loc = Rad
@@ -12,9 +12,10 @@
if(T.active_hotspot)
burning = 1

usr << "<span class='adminnotice'>@[target.x],[target.y]: O:[GM.oxygen] T:[GM.toxins] N:[GM.nitrogen] C:[GM.carbon_dioxide] w [GM.temperature] Kelvin, [GM.return_pressure()] kPa [(burning)?("\red BURNING"):(null)]</span>"
for(var/datum/gas/trace_gas in GM.trace_gases)
usr << "[trace_gas.type]: [trace_gas.moles]"
usr << "<span class='adminnotice'>@[target.x],[target.y]: [GM.temperature] Kelvin, [GM.return_pressure()] kPa [(burning)?("\red BURNING"):(null)]</span>"
for(var/gas in GM.gases)
if(gas[GAS_INDEX] <= 4 || gas[MOLES])
usr << "[gas[GAS_NAME]]: [gas[MOLES]]"
feedback_add_details("admin_verb","DAST") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!

/client/proc/fix_next_move()
@@ -108,7 +108,7 @@
return

/obj/item/weapon/tank/proc/ignite() //This happens when a bomb is told to explode
var/fuel_moles = air_contents.toxins + air_contents.oxygen/6
var/fuel_moles = air_contents.gases[GAS_PL][MOLES] + air_contents.gases[GAS_O2][MOLES]/6
var/strength = 1

var/turf/ground_zero = get_turf(loc)
@@ -228,7 +228,7 @@
var/turf/simulated/floor/T = holder.loc
if(istype(T))
var/datum/gas_mixture/GM = T.air
GM.oxygen = max(0, GM.oxygen - severity * holder.energy)
GM.gases[GAS_O2][MOLES] = max(0, GM.gases[GAS_O2][MOLES] - severity * holder.energy)

/datum/spacevine_mutation/nitro_eater
name = "nitrogen consuming"
@@ -240,7 +240,7 @@
var/turf/simulated/floor/T = holder.loc
if(istype(T))
var/datum/gas_mixture/GM = T.air
GM.nitrogen = max(0, GM.nitrogen - severity * holder.energy)
GM.gases[GAS_N2][MOLES] = max(0, GM.gases[GAS_N2][MOLES] - severity * holder.energy)

/datum/spacevine_mutation/carbondioxide_eater
name = "CO2 consuming"
@@ -252,7 +252,7 @@
var/turf/simulated/floor/T = holder.loc
if(istype(T))
var/datum/gas_mixture/GM = T.air
GM.carbon_dioxide = max(0, GM.carbon_dioxide - severity * holder.energy)
GM.gases[GAS_CO2][MOLES] = max(0, GM.gases[GAS_CO2][MOLES] - severity * holder.energy)

/datum/spacevine_mutation/plasma_eater
name = "toxins consuming"
@@ -264,7 +264,7 @@
var/turf/simulated/floor/T = holder.loc
if(istype(T))
var/datum/gas_mixture/GM = T.air
GM.toxins = max(0, GM.toxins - severity * holder.energy)
GM.gases[GAS_PL][MOLES] = max(0, GM.gases[GAS_PL][MOLES] - severity * holder.energy)

/datum/spacevine_mutation/thorns
name = "thorny"
@@ -254,11 +254,7 @@
A.nitrogen = 82
A.carbon_dioxide = 0
A.toxins = 0
A.air.oxygen = 21
A.air.carbon_dioxide = 0
A.air.nitrogen = 82
A.air.toxins = 0
A.air.temperature = 293.15
A.air.copy_from_turf(A)
SSair.add_to_active(A)
A.overlays.Cut()

@@ -11,20 +11,20 @@
var/breath_pressure = (breath.total_moles()*R_IDEAL_GAS_EQUATION*breath.temperature)/BREATH_VOLUME

//Partial pressure of the toxins in our breath
var/Toxins_pp = (breath.toxins/breath.total_moles())*breath_pressure
var/Toxins_pp = (breath.gases[GAS_PL][MOLES]/breath.total_moles())*breath_pressure

if(Toxins_pp) // Detect toxins in air
adjustPlasma(breath.toxins*250)
adjustPlasma(breath.gases[GAS_PL][MOLES]*250)
throw_alert("alien_tox", /obj/screen/alert/alien_tox)

toxins_used = breath.toxins
toxins_used = breath.gases[GAS_PL][MOLES]

else
clear_alert("alien_tox")

//Breathe in toxins and out oxygen
breath.toxins -= toxins_used
breath.oxygen += toxins_used
breath.gases[GAS_PL][MOLES] -= toxins_used
breath.gases[GAS_O2][MOLES] += toxins_used

//BREATH TEMPERATURE
handle_breath_temperature(breath)
@@ -1168,17 +1168,17 @@
var/gas_breathed = 0

//Partial pressures in our breath
var/O2_pp = breath.get_breath_partial_pressure(breath.oxygen)
var/Toxins_pp = breath.get_breath_partial_pressure(breath.toxins)
var/CO2_pp = breath.get_breath_partial_pressure(breath.carbon_dioxide)
var/O2_pp = breath.get_breath_partial_pressure(breath.gases[GAS_O2][MOLES])
var/Toxins_pp = breath.get_breath_partial_pressure(breath.gases[GAS_PL][MOLES])
var/CO2_pp = breath.get_breath_partial_pressure(breath.gases[GAS_CO2][MOLES])


//-- OXY --//

//Too much oxygen! //Yes, some species may not like it.
if(safe_oxygen_max)
if(O2_pp > safe_oxygen_max && !(NOBREATH in specflags))
var/ratio = (breath.oxygen/safe_oxygen_max) * 10
var/ratio = (breath.gases[GAS_O2][MOLES]/safe_oxygen_max) * 10
H.adjustOxyLoss(Clamp(ratio,oxy_breath_dam_min,oxy_breath_dam_max))
H.throw_alert("too_much_oxy", /obj/screen/alert/too_much_oxy)
else
@@ -1187,17 +1187,17 @@
//Too little oxygen!
if(safe_oxygen_min)
if(O2_pp < safe_oxygen_min)
gas_breathed = handle_too_little_breath(H,O2_pp,safe_oxygen_min,breath.oxygen)
gas_breathed = handle_too_little_breath(H,O2_pp,safe_oxygen_min,breath.gases[GAS_O2][MOLES])
H.throw_alert("oxy", /obj/screen/alert/oxy)
else
H.failed_last_breath = 0
H.adjustOxyLoss(-5)
gas_breathed = breath.oxygen/6
gas_breathed = breath.gases[GAS_O2][MOLES]/6
H.clear_alert("oxy")

//Exhale
breath.oxygen -= gas_breathed
breath.carbon_dioxide += gas_breathed
breath.gases[GAS_O2][MOLES] -= gas_breathed
breath.gases[GAS_CO2][MOLES] += gas_breathed
gas_breathed = 0


@@ -1224,17 +1224,17 @@
//Too little CO2!
if(safe_co2_min)
if(CO2_pp < safe_co2_min)
gas_breathed = handle_too_little_breath(H,CO2_pp, safe_co2_min,breath.carbon_dioxide)
gas_breathed = handle_too_little_breath(H,CO2_pp, safe_co2_min,breath.gases[GAS_CO2][MOLES])
H.throw_alert("not_enough_co2", /obj/screen/alert/not_enough_co2)
else
H.failed_last_breath = 0
H.adjustOxyLoss(-5)
gas_breathed = breath.carbon_dioxide/6
gas_breathed = breath.gases[GAS_CO2][MOLES]/6
H.clear_alert("not_enough_co2")

//Exhale
breath.carbon_dioxide -= gas_breathed
breath.oxygen += gas_breathed
breath.gases[GAS_CO2][MOLES] -= gas_breathed
breath.gases[GAS_O2][MOLES] += gas_breathed
gas_breathed = 0


@@ -1243,7 +1243,7 @@
//Too much toxins!
if(safe_toxins_max)
if(Toxins_pp > safe_toxins_max && !(NOBREATH in specflags))
var/ratio = (breath.toxins/safe_toxins_max) * 10
var/ratio = (breath.gases[GAS_PL][MOLES]/safe_toxins_max) * 10
if(H.reagents)
H.reagents.add_reagent("plasma", Clamp(ratio, tox_breath_dam_min, tox_breath_dam_max))
H.throw_alert("tox_in_air", /obj/screen/alert/tox_in_air)
@@ -1254,32 +1254,32 @@
//Too little toxins!
if(safe_toxins_min)
if(Toxins_pp < safe_toxins_min && !(NOBREATH in specflags))
gas_breathed = handle_too_little_breath(H,Toxins_pp, safe_toxins_min, breath.toxins)
gas_breathed = handle_too_little_breath(H,Toxins_pp, safe_toxins_min, breath.gases[GAS_PL][MOLES])
H.throw_alert("not_enough_tox", /obj/screen/alert/not_enough_tox)
else
H.failed_last_breath = 0
H.adjustOxyLoss(-5)
gas_breathed = breath.toxins/6
gas_breathed = breath.gases[GAS_PL][MOLES]/6
H.clear_alert("not_enough_tox")

//Exhale
breath.toxins -= gas_breathed
breath.carbon_dioxide += gas_breathed
breath.gases[GAS_PL][MOLES] -= gas_breathed
breath.gases[GAS_CO2][MOLES] += gas_breathed
gas_breathed = 0


//-- TRACES --//

if(breath.trace_gases.len && !(NOBREATH in specflags)) // If there's some other shit in the air lets deal with it here.
for(var/datum/gas/sleeping_agent/SA in breath.trace_gases)
var/SA_pp = breath.get_breath_partial_pressure(SA.moles)
if(SA_pp > SA_para_min) // Enough to make us paralysed for a bit
H.Paralyse(3) // 3 gives them one second to wake up and run away a bit!
if(SA_pp > SA_sleep_min) // Enough to make us sleep as well
H.sleeping = max(H.sleeping+2, 10)
else if(SA_pp > 0.01) // There is sleeping gas in their lungs, but only a little, so give them a bit of a warning
if(prob(20))
spawn(0) H.emote(pick("giggle", "laugh"))
if(breath && !(NOBREATH in specflags)) // If there's some other shit in the air lets deal with it here.
var/SA_pp = breath.get_breath_partial_pressure(breath.gases[GAS_N2O][MOLES])
if(SA_pp > SA_para_min) // Enough to make us paralysed for a bit
H.Paralyse(3) // 3 gives them one second to wake up and run away a bit!
if(SA_pp > SA_sleep_min) // Enough to make us sleep as well
H.sleeping = max(H.sleeping+2, 10)
else if(SA_pp > 0.01) // There is sleeping gas in their lungs, but only a little, so give them a bit of a warning
if(prob(20))
spawn(0)
H.emote(pick("giggle", "laugh"))

handle_breath_temperature(breath, H)

@@ -505,7 +505,7 @@ var/global/image/plasmaman_on_fire = image("icon"='icons/mob/OnFire.dmi', "icon_
if(environment)
var/total_moles = environment.total_moles()
if(total_moles)
if((environment.oxygen /total_moles) >= 0.01)
if((environment.gases[GAS_O2][MOLES] /total_moles) >= 0.01)
H.adjust_fire_stacks(0.5)
if(!H.on_fire && H.fire_stacks > 0)
H.visible_message("<span class='danger'>[H]'s body reacts with the atmosphere and bursts into flames!</span>","<span class='userdanger'>Your body reacts with the atmosphere and bursts into flame!</span>")
@@ -105,9 +105,9 @@
var/oxygen_used = 0
var/breath_pressure = (breath.total_moles()*R_IDEAL_GAS_EQUATION*breath.temperature)/BREATH_VOLUME

var/O2_partialpressure = (breath.oxygen/breath.total_moles())*breath_pressure
var/Toxins_partialpressure = (breath.toxins/breath.total_moles())*breath_pressure
var/CO2_partialpressure = (breath.carbon_dioxide/breath.total_moles())*breath_pressure
var/O2_partialpressure = (breath.gases[GAS_O2][MOLES]/breath.total_moles())*breath_pressure
var/Toxins_partialpressure = (breath.gases[GAS_PL][MOLES]/breath.total_moles())*breath_pressure
var/CO2_partialpressure = (breath.gases[GAS_CO2][MOLES]/breath.total_moles())*breath_pressure


//OXYGEN
@@ -119,7 +119,7 @@
var/ratio = safe_oxy_min/O2_partialpressure
adjustOxyLoss(min(5*ratio, 3))
failed_last_breath = 1
oxygen_used = breath.oxygen*ratio/6
oxygen_used = breath.gases[GAS_O2][MOLES]*ratio/6
else
adjustOxyLoss(3)
failed_last_breath = 1
@@ -128,11 +128,11 @@
else //Enough oxygen
failed_last_breath = 0
adjustOxyLoss(-5)
oxygen_used = breath.oxygen/6
oxygen_used = breath.gases[GAS_O2][MOLES]/6
clear_alert("oxy")

breath.oxygen -= oxygen_used
breath.carbon_dioxide += oxygen_used
breath.gases[GAS_O2][MOLES] -= oxygen_used
breath.gases[GAS_CO2][MOLES] += oxygen_used

//CARBON DIOXIDE
if(CO2_partialpressure > safe_co2_max)
@@ -151,24 +151,23 @@

//TOXINS/PLASMA
if(Toxins_partialpressure > safe_tox_max)
var/ratio = (breath.toxins/safe_tox_max) * 10
var/ratio = (breath.gases[GAS_PL][MOLES]/safe_tox_max) * 10
if(reagents)
reagents.add_reagent("plasma", Clamp(ratio, MIN_PLASMA_DAMAGE, MAX_PLASMA_DAMAGE))
throw_alert("tox_in_air", /obj/screen/alert/tox_in_air)
else
clear_alert("tox_in_air")

//TRACE GASES
if(breath.trace_gases.len)
for(var/datum/gas/sleeping_agent/SA in breath.trace_gases)
var/SA_partialpressure = (SA.moles/breath.total_moles())*breath_pressure
if(SA_partialpressure > SA_para_min)
Paralyse(3)
if(SA_partialpressure > SA_sleep_min)
sleeping = max(sleeping+2, 10)
else if(SA_partialpressure > 0.01)
if(prob(20))
spawn(0) emote(pick("giggle","laugh"))
//NITROUS OXIDE
if(breath.gases[GAS_N2O][MOLES])
var/SA_partialpressure = (breath.gases[GAS_N2O][MOLES]/breath.total_moles())*breath_pressure
if(SA_partialpressure > SA_para_min)
Paralyse(3)
if(SA_partialpressure > SA_sleep_min)
sleeping = max(sleeping+2, 10)
else if(SA_partialpressure > 0.01)
if(prob(20))
spawn(0) emote(pick("giggle","laugh"))

//BREATH TEMPERATURE
handle_breath_temperature(breath)
@@ -142,7 +142,7 @@
ExtinguishMob()
return
var/datum/gas_mixture/G = loc.return_air() // Check if we're standing in an oxygenless environment
if(G.oxygen < 1)
if(G.gases[GAS_O2][MOLES] < 1)
ExtinguishMob() //If there's no oxygen in the tile we're on, put out the fire
return
var/turf/location = get_turf(src)
@@ -534,17 +534,10 @@
dat += "Air Pressure: [round(pressure,0.1)] kPa<br>"

if (total_moles)
var/o2_level = environment.oxygen/total_moles
var/n2_level = environment.nitrogen/total_moles
var/co2_level = environment.carbon_dioxide/total_moles
var/plasma_level = environment.toxins/total_moles
var/unknown_level = 1-(o2_level+n2_level+co2_level+plasma_level)
dat += "Nitrogen: [round(n2_level*100)]%<br>"
dat += "Oxygen: [round(o2_level*100)]%<br>"
dat += "Carbon Dioxide: [round(co2_level*100)]%<br>"
dat += "Plasma: [round(plasma_level*100)]%<br>"
if(unknown_level > 0.01)
dat += "OTHER: [round(unknown_level)]%<br>"
for(var/gas in environment.gases)
var/gas_level = gas[MOLES]/total_moles
if(gas[GAS_INDEX] <= 4 || gas_level > 0.01)
dat += "[gas[GAS_NAME]]: [round(gas_level*100)]%<br>"
dat += "Temperature: [round(environment.temperature-T0C)]&deg;C<br>"
dat += "<a href='byond://?src=\ref[src];software=atmosensor;sub=0'>Refresh Reading</a> <br>"
dat += "<br>"
@@ -386,7 +386,12 @@
if(src.beacon) //Check that the beacon still exists and is in a safe place. No instant kills.
if(beacon.air)
var/datum/gas_mixture/Z = beacon.air
if(Z.oxygen >= 16 && !Z.toxins && Z.carbon_dioxide < 10 && !Z.trace_gases.len)
var/trace_gases
for(var/i in 5 to Z.gases.len)
if(Z.gases[i][MOLES])
trace_gases = TRUE
break
if(Z.gases[GAS_O2][MOLES] >= 16 && !Z.gases[GAS_PL][MOLES] && Z.gases[GAS_CO2][MOLES] < 10 && !trace_gases)
if((Z.temperature > 270) && (Z.temperature < 360))
var/pressure = Z.return_pressure()
if((pressure > 20) && (pressure < 550))
@@ -42,11 +42,11 @@
if(istype(src.loc, /turf/simulated))
var/turf/simulated/T = src.loc
if(T.air)
var/co2 = T.air.carbon_dioxide
var/co2 = T.air.gases[GAS_CO2][MOLES]
if(co2 > 0)
if(prob(25))
var/amt = min(co2, 9)
T.air.carbon_dioxide -= amt
T.air.gases[GAS_CO2][MOLES] -= amt
T.atmos_spawn_air(SPAWN_OXYGEN, amt)

/mob/living/simple_animal/hostile/tree/AttackingTarget()
@@ -196,10 +196,10 @@
if(istype(T,/turf/simulated))
var/turf/simulated/ST = T
if(ST.air)
var/tox = ST.air.toxins
var/oxy = ST.air.oxygen
var/n2 = ST.air.nitrogen
var/co2 = ST.air.carbon_dioxide
var/tox = ST.air.gases[GAS_PL][MOLES]
var/oxy = ST.air.gases[GAS_O2][MOLES]
var/n2 = ST.air.gases[GAS_N2][MOLES]
var/co2 = ST.air.gases[GAS_CO2][MOLES]

if(atmos_requirements["min_oxy"] && oxy < atmos_requirements["min_oxy"])
atmos_suitable = 0
@@ -33,14 +33,11 @@ var/next_mob_id = 0

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

var/t = "<span class='notice'>Coordinates: [x],[y] \n</span>"
t+= "<span class='danger'>Temperature: [environment.temperature] \n</span>"
t+= "<span class='notice'>Nitrogen: [environment.nitrogen] \n</span>"
t+= "<span class='notice'>Oxygen: [environment.oxygen] \n</span>"
t+= "<span class='notice'>Plasma : [environment.toxins] \n</span>"
t+= "<span class='notice'>Carbon Dioxide: [environment.carbon_dioxide] \n</span>"
for(var/datum/gas/trace_gas in environment.trace_gases)
t+= "<span class='notice'>[trace_gas.type]: [trace_gas.moles] \n</span>"
var/t = "<span class='notice'>Coordinates: [x],[y] \n</span>"
t += "<span class='danger'>Temperature: [environment.temperature] \n</span>"
for(var/gas in environment.gases)
if(gas[MOLES])
t+="<span class='notice'>[gas[GAS_NAME]]: [gas[MOLES]] \n</span>"

usr.show_message(t, 1)

@@ -26,12 +26,12 @@ var/global/list/rad_collectors = list()

/obj/machinery/power/rad_collector/process()
if(P)
if(P.air_contents.toxins <= 0)
if(P.air_contents.gases[GAS_PL][MOLES] <= 0)
investigate_log("<font color='red'>out of fuel</font>.","singulo")
P.air_contents.toxins = 0
P.air_contents.gases[GAS_PL][MOLES] = 0
eject()
else
P.air_contents.toxins -= 0.001*drainratio
P.air_contents.gases[GAS_PL][MOLES] -= 0.001*drainratio
return


@@ -43,7 +43,7 @@ var/global/list/rad_collectors = list()
toggle_power()
user.visible_message("[user.name] turns the [src.name] [active? "on":"off"].", \
"<span class='notice'>You turn the [src.name] [active? "on":"off"].</span>")
investigate_log("turned [active?"<font color='green'>on</font>":"<font color='red'>off</font>"] by [user.key]. [P?"Fuel: [round(P.air_contents.toxins/0.29)]%":"<font color='red'>It is empty</font>"].","singulo")
investigate_log("turned [active?"<font color='green'>on</font>":"<font color='red'>off</font>"] by [user.key]. [P?"Fuel: [round(P.air_contents.gases[GAS_PL][MOLES]/0.29)]%":"<font color='red'>It is empty</font>"].","singulo")
return
else
user << "<span class='warning'>The controls are locked!</span>"
@@ -130,7 +130,7 @@ var/global/list/rad_collectors = list()
/obj/machinery/power/rad_collector/proc/receive_pulse(pulse_strength)
if(P && active)
var/power_produced = 0
power_produced = P.air_contents.toxins*pulse_strength*20
power_produced = P.air_contents.gases[GAS_PL][MOLES]*pulse_strength*20
add_avail(power_produced)
last_power = power_produced
return
@@ -138,7 +138,7 @@
damage = max( damage + ( (removed.temperature - 800) / 150 ) , 0 )
//Ok, 100% oxygen atmosphere = best reaction
//Maxes out at 100% oxygen pressure
oxygen = max(min((removed.oxygen - (removed.nitrogen * NITROGEN_RETARDATION_FACTOR)) / MOLES_CELLSTANDARD, 1), 0)
oxygen = max(min((removed.gases[GAS_O2][MOLES] - (removed.gases[GAS_N2][MOLES] * NITROGEN_RETARDATION_FACTOR)) / MOLES_CELLSTANDARD, 1), 0)

var/temp_factor = 50

@@ -169,9 +169,9 @@
removed.temperature = max(0, min(removed.temperature, 2500))

//Calculate how much gas to release
removed.toxins += max(device_energy / PLASMA_RELEASE_MODIFIER, 0)
removed.gases[GAS_PL][MOLES] += max(device_energy / PLASMA_RELEASE_MODIFIER, 0)

removed.oxygen += max((device_energy + removed.temperature - T0C) / OXYGEN_RELEASE_MODIFIER, 0)
removed.gases[GAS_O2][MOLES] += max((device_energy + removed.temperature - T0C) / OXYGEN_RELEASE_MODIFIER, 0)

env.merge(removed)

@@ -14,11 +14,7 @@
SSair.remove_from_active(T)
for(var/turf/simulated/T in map)
if(T.air)
T.air.oxygen = T.oxygen
T.air.nitrogen = T.nitrogen
T.air.carbon_dioxide = T.carbon_dioxide
T.air.toxins = T.toxins
T.air.temperature = T.temperature
T.air.copy_from_turf(T)
SSair.add_to_active(T)

//Only places atoms/turfs on area borders