anchor.diff:  	if(!connected || (connected.stat & (NOPOWER|BROKEN)))
   		user << "\red This console is not connected to a functioning body scanner."
   		return
  -	
  +
   	if(!ishuman(connected.occupant))
   		user << "\red This device can only scan compatible lifeforms."
   		return
  
positive.code: 	icon_state = "body_scanner_0"
  	density = 1
  	anchored = 1
  	
  	use_power = 1
  	idle_power_usage = 60
  	active_power_usage = 10000	//10 kW. It's a big all-body scanner.
  
negative.code: 		dat = text("[]<BR><BR><A href='?src=\ref[];clear=1'>Main Menu</A>", src.temphtml, src)
  	else
  		if (src.connected) //Is something connected?
  			dat = format_occupant_data(src.connected.get_occupant_data())
  			dat += "<HR><A href='?src=\ref[src];print=1'>Print</A><BR>"
  		else
  			dat = "<font color='red'> Error: No Body Scanner connected.</font>"
  
  	dat += text("<BR><A href='?src=\ref[];mach_close=scanconsole'>Close</A>", user)
  	user << browse(dat, "window=scanconsole;size=430x600")
  	return
  
  
  /obj/machinery/body_scanconsole/Topic(href, href_list)
  	if (..())
  		return
  
  	if (href_list["print"])
  		if (!src.connected)
  			usr << "\icon[src]<span class='warning'>Error: No body scanner connected.</span>"
  			return
  		var/mob/living/carbon/human/occupant = src.connected.occupant
  		if (!src.connected.occupant)
  			usr << "\icon[src]<span class='warning'>The body scanner is empty.</span>"
  			return
  		if (!istype(occupant,/mob/living/carbon/human))
  			usr << "\icon[src]<span class='warning'>The body scanner cannot scan that lifeform.</span>"
  			return
  		var/obj/item/weapon/paper/R = new(src.loc)
  		R.name = "Body scan report"
  		R.info = format_occupant_data(src.connected.get_occupant_data())
  
  
  /obj/machinery/bodyscanner/proc/get_occupant_data()
  	if (!occupant || !istype(occupant, /mob/living/carbon/human))
  		return
  	var/mob/living/carbon/human/H = occupant
  	var/list/occupant_data = list(
  		"stationtime" = worldtime2text(),
  		"stat" = H.stat,
  		"health" = H.health,
  		"virus_present" = H.virus2.len,
  		"bruteloss" = H.getBruteLoss(),
  		"fireloss" = H.getFireLoss(),
  		"oxyloss" = H.getOxyLoss(),
  		"toxloss" = H.getToxLoss(),
  		"rads" = H.radiation,
  		"cloneloss" = H.getCloneLoss(),
  		"brainloss" = H.getBrainLoss(),
  		"paralysis" = H.paralysis,
  		"bodytemp" = H.bodytemperature,
  		"borer_present" = H.has_brain_worms(),
  		"inaprovaline_amount" = H.reagents.get_reagent_amount("inaprovaline"),
  		"dexalin_amount" = H.reagents.get_reagent_amount("dexalin"),
  		"stoxin_amount" = H.reagents.get_reagent_amount("stoxin"),
  		"bicaridine_amount" = H.reagents.get_reagent_amount("bicaridine"),
  		"dermaline_amount" = H.reagents.get_reagent_amount("dermaline"),
  		"blood_amount" = H.vessel.get_reagent_amount("blood"),
  		"disabilities" = H.sdisabilities,
  //		"tg_diseases_list" = H.viruses.Copy(),
  		"lung_ruptured" = H.is_lung_ruptured(),
  		"external_organs" = H.organs.Copy(),
  		"internal_organs" = H.internal_organs.Copy(),
  		"species_organs" = H.species.has_organ //Just pass a reference for this, it shouldn't ever be modified outside of the datum.
  		)
  	return occupant_data
  
  
  /obj/machinery/body_scanconsole/proc/format_occupant_data(var/list/occ)
  	var/dat = "<font color='blue'><b>Scan performed at [occ["stationtime"]]</b></font><br>"
  	dat += "<font color='blue'><b>Occupant Statistics:</b></font><br>"
  	var/aux
  	switch (occ["stat"])
  		if(0)
  			aux = "Conscious"
  		if(1)
  			aux = "Unconscious"
  		else
  			aux = "Dead"
  	dat += text("[]\tHealth %: [] ([])</font><br>", (occ["health"] > 50 ? "<font color='blue'>" : "<font color='red'>"), occ["health"], aux)
  	if (occ["virus_present"])
  		dat += "<font color='red'>Viral pathogen detected in blood stream.</font><br>"
  	dat += text("[]\t-Brute Damage %: []</font><br>", (occ["bruteloss"] < 60 ? "<font color='blue'>" : "<font color='red'>"), occ["bruteloss"])
  	dat += text("[]\t-Respiratory Damage %: []</font><br>", (occ["oxyloss"] < 60 ? "<font color='blue'>" : "<font color='red'>"), occ["oxyloss"])
  	dat += text("[]\t-Toxin Content %: []</font><br>", (occ["toxloss"] < 60 ? "<font color='blue'>" : "<font color='red'>"), occ["toxloss"])
  	dat += text("[]\t-Burn Severity %: []</font><br><br>", (occ["fireloss"] < 60 ? "<font color='blue'>" : "<font color='red'>"), occ["fireloss"])
  
  	dat += text("[]\tRadiation Level %: []</font><br>", (occ["rads"] < 10 ?"<font color='blue'>" : "<font color='red'>"), occ["rads"])
  	dat += text("[]\tGenetic Tissue Damage %: []</font><br>", (occ["cloneloss"] < 1 ?"<font color='blue'>" : "<font color='red'>"), occ["cloneloss"])
  	dat += text("[]\tApprox. Brain Damage %: []</font><br>", (occ["brainloss"] < 1 ?"<font color='blue'>" : "<font color='red'>"), occ["brainloss"])
  	dat += text("Paralysis Summary %: [] ([] seconds left!)<br>", occ["paralysis"], round(occ["paralysis"] / 4))
  	dat += text("Body Temperature: [occ["bodytemp"]-T0C]&deg;C ([occ["bodytemp"]*1.8-459.67]&deg;F)<br><HR>")
  
  	if(occ["borer_present"])
  		dat += "Large growth detected in frontal lobe, possibly cancerous. Surgical removal is recommended.<br>"
  
  	dat += text("[]\tBlood Level %: [] ([] units)</FONT><BR>", (occ["blood_amount"] > 448 ?"<font color='blue'>" : "<font color='red'>"), occ["blood_amount"]*100 / 560, occ["blood_amount"])
  
  	dat += text("Inaprovaline: [] units<BR>", occ["inaprovaline_amount"])
  	dat += text("Soporific: [] units<BR>", occ["stoxin_amount"])
  	dat += text("[]\tDermaline: [] units</FONT><BR>", (occ["dermaline"] < 30 ? "<font color='black'>" : "<font color='red'>"), occ["dermaline"])
  	dat += text("[]\tBicaridine: [] units<BR>", (occ["bicaridine"] < 30 ? "<font color='black'>" : "<font color='red'>"), occ["bicaridine"])
  	dat += text("[]\tDexalin: [] units<BR>", (occ["dexalin"] < 30 ? "<font color='black'>" : "<font color='red'>"), occ["dexalin"])
  
  	for(var/datum/disease/D in occ["tg_diseases_list"])
  		if(!D.hidden[SCANNER])
  			dat += text("<font color='red'><B>Warning: [D.form] Detected</B>\nName: [D.name].\nType: [D.spread].\nStage: [D.stage]/[D.max_stages].\nPossible Cure: [D.cure]</FONT><BR>")
  
  	dat += "<HR><table border='1'>"
  	dat += "<tr>"
  	dat += "<th>Organ</th>"
  	dat += "<th>Burn Damage</th>"
  	dat += "<th>Brute Damage</th>"
  	dat += "<th>Other Wounds</th>"
  	dat += "</tr>"
  
  	for(var/datum/organ/external/e in occ["external_organs"])
  		var/AN = ""
  		var/open = ""
  		var/infected = ""
  		var/imp = ""
  		var/bled = ""
  		var/robot = ""
  		var/splint = ""
  		var/internal_bleeding = ""
  		var/lung_ruptured = ""
  
  		dat += "<tr>"
  
  		for(var/datum/wound/W in e.wounds) if(W.internal)
  			internal_bleeding = "<br>Internal bleeding"
  			break
  		if(istype(e, /datum/organ/external/chest) && occ["lung_ruptured"])
  			lung_ruptured = "Lung ruptured:"
  		if(e.status & ORGAN_SPLINTED)
  			splint = "Splinted:"
  		if(e.status & ORGAN_BLEEDING)
  			bled = "Bleeding:"
  		if(e.status & ORGAN_BROKEN)
  			AN = "[e.broken_description]:"
  		if(e.status & ORGAN_ROBOT)
  			robot = "Prosthetic:"
  		if(e.open)
  			open = "Open:"
  
  		switch (e.germ_level)
  			if (INFECTION_LEVEL_ONE to INFECTION_LEVEL_ONE + 200)
  				infected = "Mild Infection:"
  			if (INFECTION_LEVEL_ONE + 200 to INFECTION_LEVEL_ONE + 300)
  				infected = "Mild Infection+:"
  			if (INFECTION_LEVEL_ONE + 300 to INFECTION_LEVEL_ONE + 400)
  				infected = "Mild Infection++:"
  			if (INFECTION_LEVEL_TWO to INFECTION_LEVEL_TWO + 200)
  				infected = "Acute Infection:"
  			if (INFECTION_LEVEL_TWO + 200 to INFECTION_LEVEL_TWO + 300)
  				infected = "Acute Infection+:"
  			if (INFECTION_LEVEL_TWO + 300 to INFECTION_LEVEL_TWO + 400)
  				infected = "Acute Infection++:"
  			if (INFECTION_LEVEL_THREE to INFINITY)
  				infected = "Septic:"
  
  		if (e.implants.len)
  			var/unknown_body = 0
  			for(var/I in e.implants)
  				if(is_type_in_list(I,known_implants))
  					imp += "[I] implanted:"
  				else
  					unknown_body++
  			if(unknown_body || e.hidden)
  				imp += "Unknown body present:"
  
  		if(!AN && !open && !infected & !imp)
  			AN = "None:"
  		if(!(e.status & ORGAN_DESTROYED))
  			dat += "<td>[e.display_name]</td><td>[e.burn_dam]</td><td>[e.brute_dam]</td><td>[robot][bled][AN][splint][open][infected][imp][internal_bleeding][lung_ruptured]</td>"
  		else
  			dat += "<td>[e.display_name]</td><td>-</td><td>-</td><td>Not Found</td>"
  		dat += "</tr>"
  
  	for(var/datum/organ/internal/i in occ["internal_organs"])
  
  		var/mech = ""
  		if(i.robotic == 1)
  			mech = "Assisted:"
  		if(i.robotic == 2)
  			mech = "Mechanical:"
  
  		var/infection = "None"
  		switch (i.germ_level)
  			if (1 to INFECTION_LEVEL_ONE + 200)
  				infection = "Mild Infection:"
  			if (INFECTION_LEVEL_ONE + 200 to INFECTION_LEVEL_ONE + 300)
  				infection = "Mild Infection+:"
  			if (INFECTION_LEVEL_ONE + 300 to INFECTION_LEVEL_ONE + 400)
  				infection = "Mild Infection++:"
  			if (INFECTION_LEVEL_TWO to INFECTION_LEVEL_TWO + 200)
  				infection = "Acute Infection:"
  			if (INFECTION_LEVEL_TWO + 200 to INFECTION_LEVEL_TWO + 300)
  				infection = "Acute Infection+:"
  			if (INFECTION_LEVEL_TWO + 300 to INFINITY)
  				infection = "Acute Infection++:"
  
  		dat += "<tr>"
  		dat += "<td>[i.name]</td><td>N/A</td><td>[i.damage]</td><td>[infection]:[mech]</td><td></td>"
  		dat += "</tr>"
  	dat += "</table>"
  
  	var/list/species_organs = occ["species_organs"]
  	for(var/organ_name in species_organs)
  		if(!locate(species_organs[organ_name]) in occ["internal_organs"])
  			dat += text("<font color='red'>No [organ_name] detected.</font><BR>")
  
  	if(occ["sdisabilities"] & BLIND)
  		dat += text("<font color='red'>Cataracts detected.</font><BR>")
  	if(occ["sdisabilities"] & NEARSIGHTED)
  		dat += text("<font color='red'>Retinal misalignment detected.</font><BR>")
  	return dat