Atmospheric analyzer mole additions.

Made a general proc to avoid COPYPASTE CODE WHY.
Renamed the analyzer to make the name less ambiguous.
Analyzers now show the moles of gas in a container as well as the pressure.
This commit is contained in:
ComicIronic
2015-01-12 20:21:39 +00:00
parent 56f907154c
commit 4221578fbd
5 changed files with 50 additions and 137 deletions

View File

@@ -579,31 +579,9 @@
if(istype(W, /obj/item/weapon/pipe_dispenser) || istype(W, /obj/item/device/pipe_painter)) if(istype(W, /obj/item/weapon/pipe_dispenser) || istype(W, /obj/item/device/pipe_painter))
return // Coloring pipes. return // Coloring pipes.
if (istype(W, /obj/item/device/analyzer) && get_dist(user, src) <= 1) if (istype(W, /obj/item/device/analyzer) && get_dist(user, src) <= 1)
for (var/mob/O in viewers(user, null)) user.visible_message("<span class='attack'>[user] has used [W] on \icon[icon] [src]</span>", "<span class='attack'>You use \the [W] on \icon[icon] [src]</span>")
O << "<span class='attack'>[user] has used the analyzer on \icon[icon]</span>" var/obj/item/device/analyzer/analyzer = W
user.show_message(analyzer.output_gas_scan(air_temporary, src, 0), 1)
var/pressure = parent.air.return_pressure()
var/total_moles = parent.air.total_moles()
user << "<span class='notice'>Results of analysis of \icon[icon]</span>"
if (total_moles>0)
var/o2_concentration = parent.air.oxygen/total_moles
var/n2_concentration = parent.air.nitrogen/total_moles
var/co2_concentration = parent.air.carbon_dioxide/total_moles
var/plasma_concentration = parent.air.toxins/total_moles
var/unknown_concentration = 1-(o2_concentration+n2_concentration+co2_concentration+plasma_concentration)
user << "<span class='info'>Pressure: [round(pressure,0.1)] kPa</span>"
user << "<span class='info'>Nitrogen: [round(n2_concentration*100)]%</span>"
user << "<span class='info'>Oxygen: [round(o2_concentration*100)]%</span>"
user << "<span class='info'>CO2: [round(co2_concentration*100)]%</span>"
user << "<span class='info'>Plasma: [round(plasma_concentration*100)]%</span>"
if(unknown_concentration>0.01)
user << "<span class='warning'>Unknown: [round(unknown_concentration*100)]%</span>"
user << "<span class='info'>Temperature: [round(parent.air.temperature-T0C)]&deg;C</span>"
else
user << "<span class='notice'>Tank is empty!</span>"
/obj/machinery/atmospherics/pipe/manifold /obj/machinery/atmospherics/pipe/manifold
icon = 'icons/obj/atmospherics/pipe_manifold.dmi' icon = 'icons/obj/atmospherics/pipe_manifold.dmi'

View File

@@ -118,32 +118,9 @@
return return
else if ((istype(W, /obj/item/device/analyzer)) && get_dist(user, src) <= 1) else if ((istype(W, /obj/item/device/analyzer)) && get_dist(user, src) <= 1)
visible_message("\red [user] has used [W] on \icon[icon]") user.visible_message("<span class='attack'>[user] has used [W] on \icon[icon] [src]</span>", "<span class='attack'>You use \the [W] on \icon[icon] [src]</span>")
if(air_contents) var/obj/item/device/analyzer/analyzer = W
var/pressure = air_contents.return_pressure() user.show_message(analyzer.output_gas_scan(src.air_contents, src, 0), 1)
var/total_moles = air_contents.total_moles() src.add_fingerprint(user)
user << "\blue Results of analysis of \icon[icon]"
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
var/unknown_concentration = 1-(o2_concentration+n2_concentration+co2_concentration+plasma_concentration)
user << "\blue Pressure: [round(pressure,0.1)] kPa"
user << "\blue Nitrogen: [round(n2_concentration*100)]%"
user << "\blue Oxygen: [round(o2_concentration*100)]%"
user << "\blue CO2: [round(co2_concentration*100)]%"
user << "\blue Plasma: [round(plasma_concentration*100)]%"
if(unknown_concentration>0.01)
user << "\red Unknown: [round(unknown_concentration*100)]%"
user << "\blue Temperature: [round(air_contents.temperature-T0C)]&deg;C"
else
user << "\blue Tank is empty!"
else
user << "\blue Tank is empty!"
return return
return return

View File

@@ -230,7 +230,7 @@ REAGENT SCANNER
/obj/item/device/analyzer /obj/item/device/analyzer
desc = "A hand-held environmental scanner which reports current gas levels." desc = "A hand-held environmental scanner which reports current gas levels."
name = "analyzer" name = "atmospheric analyzer"
icon_state = "atmos" icon_state = "atmos"
item_state = "analyzer" item_state = "analyzer"
w_class = 2.0 w_class = 2.0
@@ -259,48 +259,48 @@ REAGENT SCANNER
return return
var/datum/gas_mixture/environment = location.return_air() var/datum/gas_mixture/environment = location.return_air()
user.show_message(output_gas_scan(environment, get_turf(src), 1), 1)
var/pressure = environment.return_pressure()
var/total_moles = environment.total_moles()
user.show_message("\blue <B>Results:</B>", 1)
if(abs(pressure - ONE_ATMOSPHERE) < 10)
user.show_message("\blue Pressure: [round(pressure,0.1)] kPa", 1)
else
user.show_message("\red Pressure: [round(pressure,0.1)] kPa", 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/unknown_concentration = 1-(o2_concentration+n2_concentration+co2_concentration+plasma_concentration)
if(abs(n2_concentration - N2STANDARD) < 20)
user.show_message("\blue Nitrogen: [round(n2_concentration*100)]%", 1)
else
user.show_message("\red Nitrogen: [round(n2_concentration*100)]%", 1)
if(abs(o2_concentration - O2STANDARD) < 2)
user.show_message("\blue Oxygen: [round(o2_concentration*100)]%", 1)
else
user.show_message("\red Oxygen: [round(o2_concentration*100)]%", 1)
if(co2_concentration > 0.01)
user.show_message("\red CO2: [round(co2_concentration*100)]%", 1)
else
user.show_message("\blue CO2: [round(co2_concentration*100)]%", 1)
if(plasma_concentration > 0.01)
user.show_message("\red Plasma: [round(plasma_concentration*100)]%", 1)
if(unknown_concentration > 0.01)
user.show_message("\red Unknown: [round(unknown_concentration*100)]%", 1)
user.show_message("\blue Temperature: [round(environment.temperature-T0C)]&deg;C", 1)
src.add_fingerprint(user) src.add_fingerprint(user)
return return
//if human_standard is enabled, the message will be formatted to show which values are dangerous
/obj/item/device/analyzer/proc/output_gas_scan(var/datum/gas_mixture/scanned, var/atom/container, human_standard = 0)
if(!scanned)
return "\red No gas mixture found."
scanned.update_values()
var/pressure = scanned.return_pressure()
var/total_moles = scanned.total_moles()
var/message = ""
if(!container || istype(container, /turf))
message += "\blue <B>Results:</B><br>"
else
message += "\blue <B>\icon [container] Results of [container] scan:</B><br>"
if(total_moles)
message += "[human_standard && abs(pressure - ONE_ATMOSPHERE) > 10 ? "\red" : "\blue"] Pressure: [round(pressure,0.1)] kPa<br>"
var/o2_concentration = scanned.oxygen/total_moles
var/n2_concentration = scanned.nitrogen/total_moles
var/co2_concentration = scanned.carbon_dioxide/total_moles
var/plasma_concentration = scanned.toxins/total_moles
var/unknown_concentration = 1-(o2_concentration+n2_concentration+co2_concentration+plasma_concentration)
if(n2_concentration > 0.01)
message += "[human_standard && abs(n2_concentration - N2STANDARD) > 20 ? "\red" : "\blue"] Nitrogen: [round(scanned.nitrogen, 0.1)] mol, [round(n2_concentration*100)]%<br>"
if(o2_concentration > 0.01)
message += "[human_standard && abs(o2_concentration - O2STANDARD) > 2 ? "\red" : "\blue"] Oxygen: [round(scanned.oxygen, 0.1)] mol, [round(o2_concentration*100)]%<br>"
if(co2_concentration > 0.01)
message += "[human_standard ? "\red" : "\blue"] CO2: [round(scanned.carbon_dioxide, 0.1)] mol, [round(co2_concentration*100)]%<br>"
if(plasma_concentration > 0.01)
message += "[human_standard ? "\red" : "\blue"] Plasma: [round(scanned.toxins, 0.1)] mol, [round(plasma_concentration*100)]%<br>"
if(unknown_concentration > 0.01)
message += "\blue Unknown: [round(unknown_concentration*100)]%<br>"
message += "[human_standard && !(scanned.temperature-T0C in range(0, 40)) ? "\red" : "\blue"] Temperature: [round(scanned.temperature-T0C)]&deg;C"
else
message += "\red No gasses detected[container && !istype(container, /turf) ? " in \the [container]." : ""]!"
return message
/obj/item/device/mass_spectrometer /obj/item/device/mass_spectrometer
desc = "A hand-held mass spectrometer which identifies trace chemicals in a blood sample." desc = "A hand-held mass spectrometer which identifies trace chemicals in a blood sample."
name = "mass-spectrometer" name = "mass-spectrometer"

View File

@@ -116,30 +116,9 @@
return return
if(istype(W, /obj/item/device/analyzer) && ptank) if(istype(W, /obj/item/device/analyzer) && ptank)
var/obj/item/weapon/icon = src var/obj/item/device/analyzer/analyzer = W
user.visible_message("<span class='notice'>[user] has used the analyzer on \icon[icon]</span>") user.visible_message("<span class='notice'>[user] has used the analyzer on \icon[icon]</span>")
var/pressure = ptank.air_contents.return_pressure() user.show_message(analyzer.output_gas_scan(ptank.air_contents, src, 0), 1)
var/total_moles = ptank.air_contents.total_moles()
user << "\blue Results of analysis of \icon[icon]"
if(total_moles>0)
var/o2_concentration = ptank.air_contents.oxygen/total_moles
var/n2_concentration = ptank.air_contents.nitrogen/total_moles
var/co2_concentration = ptank.air_contents.carbon_dioxide/total_moles
var/plasma_concentration = ptank.air_contents.toxins/total_moles
var/unknown_concentration = 1-(o2_concentration+n2_concentration+co2_concentration+plasma_concentration)
user << "\blue Pressure: [round(pressure,0.1)] kPa"
user << "\blue Nitrogen: [round(n2_concentration*100)]%"
user << "\blue Oxygen: [round(o2_concentration*100)]%"
user << "\blue CO2: [round(co2_concentration*100)]%"
user << "\blue Plasma: [round(plasma_concentration*100)]%"
if(unknown_concentration>0.01)
user << "\red Unknown: [round(unknown_concentration*100)]%"
user << "\blue Temperature: [round(ptank.air_contents.temperature-T0C)]&deg;C"
else
user << "\blue Tank is empty!"
return return
..() ..()
return return

View File

@@ -90,29 +90,8 @@
if ((istype(W, /obj/item/device/analyzer)) && get_dist(user, src) <= 1) if ((istype(W, /obj/item/device/analyzer)) && get_dist(user, src) <= 1)
user.visible_message("<span class='attack'>[user] has used [W] on \icon[icon] [src]</span>", "<span class='attack'>You use \the [W] on \icon[icon] [src]</span>") user.visible_message("<span class='attack'>[user] has used [W] on \icon[icon] [src]</span>", "<span class='attack'>You use \the [W] on \icon[icon] [src]</span>")
var/pressure = air_contents.return_pressure() var/obj/item/device/analyzer/analyzer = W
manipulated_by = user.real_name //This person is aware of the contents of the tank. user.show_message(analyzer.output_gas_scan(src.air_contents, src, 0), 1)
var/total_moles = air_contents.total_moles()
user << "<span class='notice'>Results of analysis of \icon[icon]</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
var/unknown_concentration = 1-(o2_concentration+n2_concentration+co2_concentration+plasma_concentration)
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='warning'>Unknown: [round(unknown_concentration*100)]%</span>"
user << "<span class='notice'>Temperature: [round(air_contents.temperature-T0C)]&deg;C</span>"
else
user << "<span class='notice'>Tank is empty!</span>"
src.add_fingerprint(user) src.add_fingerprint(user)
else if (istype(W,/obj/item/latexballon)) else if (istype(W,/obj/item/latexballon))
var/obj/item/latexballon/LB = W var/obj/item/latexballon/LB = W