code:
/obj/machinery/recharger
	name = "recharger"
	icon = 'icons/obj/stationobjs.dmi'
	icon_state = "recharger0"
	anchored = 1
	use_power = 1
	idle_power_usage = 4
	active_power_usage = 250
	var/obj/item/weapon/charging = null

/obj/machinery/recharger/attackby(obj/item/weapon/G, mob/user, params)
	if(istype(user,/mob/living/silicon) && !ismommi(user))
		return
	if(istype(G, /obj/item/weapon/gun/energy) || istype(G, /obj/item/weapon/melee/baton))
		if(charging)
			return

		//Checks to make sure he's not in space doing it, and that the area got proper power.
		var/area/a = get_area(src)
		if(!isarea(a) || a.power_equip == 0)
			user << "[src] blinks red as you try to insert [G]."
			return

		if (istype(G, /obj/item/weapon/gun/energy/gun/nuclear))
			user << "Your gun's recharge port was removed to make room for a miniaturized reactor."
			return
		user.drop_item()
		G.loc = src
		charging = G
		use_power = 2
		update_icon()
	else if(istype(G, /obj/item/weapon/wrench))
		if(charging)
			user << "Remove the charging item first!"
			return
		anchored = !anchored
		user << "You [anchored ? "attached" : "detached"] [src]."
		playsound(loc, 'sound/items/Ratchet.ogg', 75, 1)

/obj/machinery/recharger/attack_hand(mob/user)
	if(issilicon(user) && !ismommi(user))
		return

	add_fingerprint(user)
	if(charging)
		charging.update_icon()
		charging.loc = loc
		user.put_in_hands(charging)
		charging = null
		use_power = 1
		update_icon()

/obj/machinery/recharger/attack_paw(mob/user)
	return attack_hand(user)

/obj/machinery/recharger/attack_tk(mob/user)
	if(charging)
		charging.update_icon()
		charging.loc = loc
		charging = null
		use_power = 1
		update_icon()

/obj/machinery/recharger/process()
	if(stat & (NOPOWER|BROKEN) || !anchored)
		return

	if(charging)
		if(istype(charging, /obj/item/weapon/gun/energy))
			var/obj/item/weapon/gun/energy/E = charging
			if(E.power_supply.charge < E.power_supply.maxcharge)
				E.power_supply.give(E.power_supply.chargerate)
				icon_state = "recharger1"
				use_power(250)
			else
				icon_state = "recharger2"
			return
		if(istype(charging, /obj/item/weapon/melee/baton))
			var/obj/item/weapon/melee/baton/B = charging
			if(B.bcell)
				if(B.bcell.give(B.bcell.chargerate))
					icon_state = "recharger1"
					use_power(200)
				else
					icon_state = "recharger2"
			else
				icon_state = "recharger3"

/obj/machinery/recharger/emp_act(severity)
	if(stat & (NOPOWER|BROKEN) || !anchored)
		..(severity)
		return

	if(istype(charging,  /obj/item/weapon/gun/energy))
		var/obj/item/weapon/gun/energy/E = charging
		if(E.power_supply)
			E.power_supply.emp_act(severity)

	else if(istype(charging, /obj/item/weapon/melee/baton))
		var/obj/item/weapon/melee/baton/B = charging
		if(B.bcell)
			B.bcell.charge = 0
	..(severity)

/obj/machinery/recharger/update_icon()	//we have an update_icon() in addition to the stuff in process to make it feel a tiny bit snappier.
	if(charging)
		icon_state = "recharger1"
	else
		icon_state = "recharger0"


code:
/obj/machinery/recharge_station
	name = "cyborg recharging station"
	icon = 'icons/obj/objects.dmi'
	icon_state = "borgcharger0"
	density = 0
	anchored = 1
	use_power = 1
	idle_power_usage = 5
	active_power_usage = 1000
	var/circuitboard = "/obj/item/weapon/circuitboard/cyborgrecharger"
	req_access = list(access_robotics)
	var/recharge_speed
	var/repairs
	state_open = 1

/obj/machinery/recharge_station/New()
	..()
	component_parts = list()
	component_parts += new /obj/item/weapon/circuitboard/cyborgrecharger(null)
	component_parts += new /obj/item/weapon/stock_parts/capacitor(null)
	component_parts += new /obj/item/weapon/stock_parts/capacitor(null)
	component_parts += new /obj/item/weapon/stock_parts/manipulator(null)
	component_parts += new /obj/item/weapon/stock_parts/cell/high(null)
	RefreshParts()
	update_icon()

/obj/machinery/recharge_station/RefreshParts()
	recharge_speed = 0
	repairs = 0
	for(var/obj/item/weapon/stock_parts/capacitor/C in component_parts)
		recharge_speed += C.rating * 100
	for(var/obj/item/weapon/stock_parts/manipulator/M in component_parts)
		repairs += M.rating - 1
	for(var/obj/item/weapon/stock_parts/cell/C in component_parts)
		recharge_speed *= C.maxcharge / 10000

/obj/machinery/recharge_station/process()
	if(!is_operational())
		return

	if(occupant)
		process_occupant()
	return 1

/obj/machinery/recharge_station/allow_drop()
	return 0

/obj/machinery/recharge_station/relaymove(mob/user as mob)
	if(user.stat)
		return
	open_machine()

/obj/machinery/recharge_station/emp_act(severity)
	if(stat & (BROKEN|NOPOWER))
		..(severity)
		return
	if(occupant)
		occupant.emp_act(severity)
	open_machine()
	..(severity)

/obj/machinery/recharge_station/ex_act(severity, target)
	if(occupant)
		open_machine()
	..()

/obj/machinery/recharge_station/attack_paw(user as mob)
	return attack_hand(user)

/obj/machinery/recharge_station/attack_ai(user as mob)
	return attack_hand(user)

/obj/machinery/recharge_station/attackby(obj/item/P as obj, mob/user as mob, params)
	if(state_open)
		if(default_deconstruction_screwdriver(user, "borgdecon2", "borgcharger0", P))
			return

	if(exchange_parts(user, P))
		return

	if(default_pry_open(P))
		return

	default_deconstruction_crowbar(P)

/obj/machinery/recharge_station/attack_hand(user as mob)
	if(..(user,1,set_machine = 0))
		return

	toggle_open()
	add_fingerprint(user)

/obj/machinery/recharge_station/proc/toggle_open()
	if(state_open)
		close_machine()
	else
		open_machine()

/obj/machinery/recharge_station/open_machine()
	if(ismommi(occupant))
		var/mob/living/silicon/robot/mommi/R = occupant
		R.updateicon()
	..()
	use_power = 1

/obj/machinery/recharge_station/close_machine()
	if(!panel_open)
		for(var/mob/living/silicon/robot/R in loc)
			R.stop_pulling()
			if(R.client)
				R.client.eye = src
				R.client.perspective = EYE_PERSPECTIVE
			R.loc = src
			occupant = R
			use_power = 2
			add_fingerprint(R)
			break
		state_open = 0
		density = 1
		update_icon()

/obj/machinery/recharge_station/update_icon()
	if(is_operational())
		if(state_open)
			icon_state = "borgcharger0"
		else
			icon_state = (occupant ? "borgcharger1" : "borgcharger2")
	else
		icon_state = (state_open ? "borgcharger-u0" : "borgcharger-u1")

/obj/machinery/recharge_station/power_change()
	..()
	update_icon()

/obj/machinery/recharge_station/proc/process_occupant()
	if(occupant)
		var/mob/living/silicon/robot/R = occupant
		restock_modules()
		if(repairs)
			R.heal_organ_damage(repairs, repairs - 1)
		if(R.cell)
			R.cell.charge = min(R.cell.charge + recharge_speed, R.cell.maxcharge)

/obj/machinery/recharge_station/proc/restock_modules()
	if(occupant)
		var/mob/living/silicon/robot/R = occupant
		if(R.module && R.module.modules)
			var/list/um = R.contents|R.module.modules // Makes single list of active (R.contents) and inactive (R.module.modules) modules
			var/coeff = recharge_speed / 200
			for (var/datum/robot_energy_storage/st in R.module.storages)
				st.energy = min(st.max_energy, st.energy + coeff * st.recharge_rate)
			for(var/obj/O in um)
				//General
				if(istype(O,/obj/item/device/flash))
					var/obj/item/device/flash/F = O
					if(F.broken)
						F.broken = 0
						F.times_used = 0
						F.icon_state = "flash"
				if(istype(O, /obj/item/weapon/extinguisher))
					var/obj/item/weapon/extinguisher/F = O
					if(F.reagents.get_reagent_amount("water") < F.max_water)
						F.reagents.add_reagent("water", 2 * coeff)
						for(var/datum/reagent/water/W in F.reagents.reagent_list)
							W.cooling_temperature = F.cooling_power

				// Engineering
				if(istype(O, /obj/item/weapon/airlock_painter))
					var/obj/item/weapon/airlock_painter/A = O
					if(A.ink && (A.ink.charges < A.ink.max_charges))
						A.ink.charges++

				if(istype(O, /obj/item/weapon/weldingtool))
					var/obj/item/weapon/weldingtool/W = O
					if(W.reagents.get_reagent_amount("fuel") < W.max_fuel)
						W.reagents.add_reagent("fuel", 2 * coeff)

				// Security
				if(istype(O,/obj/item/weapon/gun/energy/gun/advtaser/cyborg))
					var/obj/item/weapon/gun/energy/gun/advtaser/cyborg/T = O
					if(T.power_supply.charge < T.power_supply.maxcharge)
						var/obj/item/ammo_casing/energy/S = T.ammo_type[T.select]
						T.power_supply.give(S.e_cost * coeff)
						T.update_icon()
					else
						T.charge_tick = 0
				if(istype(O,/obj/item/weapon/melee/baton))
					var/obj/item/weapon/melee/baton/B = O
					if(B.bcell)
						B.bcell.charge = B.bcell.maxcharge
				//Service
				if(istype(O,/obj/item/weapon/reagent_containers/food/condiment/enzyme))
					if(O.reagents.get_reagent_amount("enzyme") < 50)
						O.reagents.add_reagent("enzyme", 2 * coeff)
				//Janitor
				if(istype(O, /obj/item/device/lightreplacer))
					var/obj/item/device/lightreplacer/LR = O
					var/rate = coeff
					var/i = 0
					do
						LR.Charge(R)
						i++
					while (i < rate)

			if(R && R.module)
				R.module.respawn_consumable(R)

			//Emagged items for janitor and medical borg
			if(R.module.emag)
				if(istype(R.module.emag, /obj/item/weapon/reagent_containers/spray))
					var/obj/item/weapon/reagent_containers/spray/S = R.module.emag
					if(S.name == "Fluacid spray")
						S.reagents.add_reagent("pacid", 2 * coeff)
					else if(S.name == "lube spray")
						S.reagents.add_reagent("lube", 2 * coeff)

license: mit


code:
var/const/SAFETY_COOLDOWN = 100

/obj/machinery/recycler
	name = "crusher"
	desc = "A large crushing machine which is used to recycle small items ineffeciently; there are lights on the side of it."
	icon = 'icons/obj/recycling.dmi'
	icon_state = "grinder-o0"
	layer = MOB_LAYER+1 // Overhead
	anchored = 1
	density = 1
	var/safety_mode = 0 // Temporality stops the machine if it detects a mob
	var/grinding = 0
	var/icon_name = "grinder-o"
	var/blood = 0
	var/eat_dir = WEST
	var/amount_produced = 1
	var/probability_mod = 1
	var/extra_materials = 0
	var/list/blacklist = list(/obj/item/pipe, /obj/item/pipe_meter, /obj/structure/disposalconstruct, /obj/item/weapon/reagent_containers, /obj/item/weapon/paper, /obj/item/stack/, /obj/item/weapon/pen, /obj/item/weapon/storage/, /obj/item/clothing/mask/cigarette) // Don't allow us to grind things we can poop out at 200 a second for free.

/obj/machinery/recycler/New()
	// On us
	..()
	component_parts = list()
	component_parts += new /obj/item/weapon/circuitboard/recycler(null)
	component_parts += new /obj/item/weapon/stock_parts/matter_bin(null)
	component_parts += new /obj/item/weapon/stock_parts/manipulator(null)
	RefreshParts()
	update_icon()

/obj/machinery/recycler/RefreshParts()
	var/amt_made = 0
	var/prob_mod = 0
	for(var/obj/item/weapon/stock_parts/matter_bin/B in component_parts)
		amt_made = 1 * B.rating
	for(var/obj/item/weapon/stock_parts/manipulator/M in component_parts)
		if(M.rating > 1)
			prob_mod = 2 * M.rating
		else
			prob_mod = 1 * M.rating
		if(M.rating >= 3)
			extra_materials = 1
		else
			extra_materials = 0
	probability_mod = prob_mod
	amount_produced = amt_made

/obj/machinery/recycler/examine(mob/user)
	..()
	user << "The power light is [(stat & NOPOWER) ? "off" : "on"]."
	user << "The safety-mode light is [safety_mode ? "on" : "off"]."
	user << "The safety-sensors status light is [emagged ? "off" : "on"]."

/obj/machinery/recycler/power_change()
	..()
	update_icon()

/obj/machinery/recycler/attackby(var/obj/item/I, var/mob/user, params)
	if(default_deconstruction_screwdriver(user, "grinder-oOpen", "grinder-o0", I))
		return
	if(exchange_parts(user, I))
		return

	if(default_pry_open(I))
		return
	if(default_unfasten_wrench(user, I))
		return

	default_deconstruction_crowbar(I)

	..()

	add_fingerprint(user)
	return

/obj/machinery/recycler/emag_act(user as mob)
	if(!emagged)
		emagged = 1
		if(safety_mode)
			safety_mode = 0
			update_icon()
		playsound(src.loc, "sparks", 75, 1, -1)
		user << "You use the cryptographic sequencer on the [src.name]."

/obj/machinery/recycler/update_icon()
	..()
	var/is_powered = !(stat & (BROKEN|NOPOWER))
	if(safety_mode)
		is_powered = 0
	icon_state = icon_name + "[is_powered]" + "[(blood ? "bld" : "")]" // add the blood tag at the end

// This is purely for admin possession !FUN!.
/obj/machinery/recycler/Bump(var/atom/movable/AM)
	..()
	if(AM)
		Bumped(AM)

/obj/machinery/recycler/Bumped(var/atom/movable/AM)

	if(stat & (BROKEN|NOPOWER))
		return
	if(safety_mode)
		return

	var/move_dir = get_dir(loc, AM.loc)
	if(move_dir == eat_dir)
		if(isliving(AM))
			if(emagged)
				eat(AM)
			else
				stop(AM)
		else if(istype(AM, /obj/item))
			recycle(AM)
		else // Can't recycle
			playsound(src.loc, 'sound/machines/buzz-sigh.ogg', 50, 0)
			AM.loc = src.loc

/obj/machinery/recycler/proc/recycle(var/obj/item/I, var/sound = 1)
	I.loc = src.loc
	if(is_type_in_list(I, blacklist))
		qdel(I)
		if(sound)
			playsound(src.loc, 'sound/items/Welder.ogg', 50, 1)
		return
	qdel(I)
	if(prob(15 + probability_mod))
		var/obj/item/stack/sheet/metal/M = new /obj/item/stack/sheet/metal(loc)
		M.amount = amount_produced
	if(prob(10 + probability_mod))
		var/obj/item/stack/sheet/glass/G = new /obj/item/stack/sheet/glass(loc)
		G.amount = amount_produced
	if(prob(2 + probability_mod))
		var/obj/item/stack/sheet/plasteel/P = new /obj/item/stack/sheet/plasteel(loc)
		P.amount = amount_produced
	if(prob(1 + probability_mod))
		var/obj/item/stack/sheet/rglass/R = new /obj/item/stack/sheet/rglass(loc)
		R.amount = amount_produced
	if(extra_materials)
		if(prob(4 + probability_mod))
			var/obj/item/stack/sheet/mineral/plasma/PS = new /obj/item/stack/sheet/mineral/plasma(loc)
			PS.amount = amount_produced
		if(prob(3 + probability_mod))
			var/obj/item/stack/sheet/mineral/gold/GS = new /obj/item/stack/sheet/mineral/gold(loc)
			GS.amount = amount_produced
		if(prob(2 + probability_mod))
			var/obj/item/stack/sheet/mineral/silver/S = new /obj/item/stack/sheet/mineral/silver(loc)
			S.amount = amount_produced
		if(prob(1 + probability_mod))
			var/obj/item/stack/sheet/mineral/bananium/B = new /obj/item/stack/sheet/mineral/bananium(loc)
			B.amount = amount_produced
		if(prob(1 + probability_mod))
			var/obj/item/stack/sheet/mineral/diamond/D = new /obj/item/stack/sheet/mineral/diamond(loc)
			D.amount = amount_produced
	if(sound)
		playsound(src.loc, 'sound/items/Welder.ogg', 50, 1)

/obj/machinery/recycler/proc/stop(var/mob/living/L)
	playsound(src.loc, 'sound/machines/buzz-sigh.ogg', 50, 0)
	safety_mode = 1
	update_icon()
	L.loc = src.loc

	spawn(SAFETY_COOLDOWN)
		playsound(src.loc, 'sound/machines/ping.ogg', 50, 0)
		safety_mode = 0
		update_icon()

/obj/machinery/recycler/proc/eat(var/mob/living/L)

	L.loc = src.loc

	if(issilicon(L))
		playsound(src.loc, 'sound/items/Welder.ogg', 50, 1)
	else
		playsound(src.loc, 'sound/effects/splat.ogg', 50, 1)

	var/gib = 1
	// By default, the emagged recycler will gib all non-carbons. (human simple animal mobs don't count)
	if(iscarbon(L))
		gib = 0
		if(L.stat == CONSCIOUS)
			L.say("ARRRRRRRRRRRGH!!!")
		add_blood(L)

	if(!blood && !issilicon(L))
		blood = 1
		update_icon()

	// Remove and recycle the equipped items.
	for(var/obj/item/I in L.get_equipped_items())
		if(L.unEquip(I))
			recycle(I, 0)

	// Instantly lie down, also go unconscious from the pain, before you die.
	L.Paralyse(5)

	// For admin fun, var edit emagged to 2.
	if(gib || emagged == 2)
		L.gib()
	else if(emagged == 1)
		L.adjustBruteLoss(1000)

/obj/item/weapon/paper/recycler
	name = "paper - 'garbage duty instructions'"
	info = "
New Assignment
 You have been assigned to collect garbage from trash bins, located around the station. The crewmembers will put their trash into it and you will collect the said trash.

There is a recycling machine near your closet, inside maintenance; use it to recycle the trash for a small chance to get useful minerals. Then deliver these minerals to cargo or engineering. You are our last hope for a clean station, do not screw this up!"


code:
/******************** Requests Console ********************/
/** Originally written by errorage, updated by: Carn, needs more work though. I just added some security fixes */

var/req_console_assistance = list()
var/req_console_supplies = list()
var/req_console_information = list()
var/list/obj/machinery/requests_console/allConsoles = list()

/obj/machinery/requests_console
	name = "requests console"
	desc = "A console intended to send requests to different departments on the station."
	anchored = 1
	icon = 'icons/obj/terminals.dmi'
	icon_state = "req_comp0"
	var/department = "Unknown" //The list of all departments on the station (Determined from this variable on each unit) Set this to the same thing if you want several consoles in one department
	var/list/messages = list() //List of all messages
	var/departmentType = 0
		// 0 = none (not listed, can only replied to)
		// 1 = assistance
		// 2 = supplies
		// 3 = info
		// 4 = ass + sup //Erro goddamn you just HAD to shorten "assistance" down to "ass"
		// 5 = ass + info
		// 6 = sup + info
		// 7 = ass + sup + info
	var/newmessagepriority = 0
		// 0 = no new message
		// 1 = normal priority
		// 2 = high priority
		// 3 = extreme priority - not implemented, will probably require some hacking... everything needs to have a hidden feature in this game.
	var/screen = 0
		// 0 = main menu,
		// 1 = req. assistance,
		// 2 = req. supplies
		// 3 = relay information
		// 4 = write msg - not used
		// 5 = choose priority - not used
		// 6 = sent successfully
		// 7 = sent unsuccessfully
		// 8 = view messages
		// 9 = authentication before sending
		// 10 = send announcement
	var/silent = 0 // set to 1 for it not to beep all the time
	var/hackState = 0
		// 0 = not hacked
		// 1 = hacked
	var/announcementConsole = 0
		// 0 = This console cannot be used to send department announcements
		// 1 = This console can send department announcements
	var/open = 0 // 1 if open
	var/announceAuth = 0 //Will be set to 1 when you authenticate yourself for announcements
	var/msgVerified = "" //Will contain the name of the person who verified it
	var/msgStamped = "" //If a message is stamped, this will contain the stamp name
	var/message = "";
	var/dpt = ""; //the department which will be receiving the message
	var/priority = -1 ; //Priority of the message being sent
	light_range = 0

/obj/machinery/requests_console/power_change()
	..()
	update_icon()

/obj/machinery/requests_console/update_icon()
	if(open)
		if(hackState == 0)
			icon_state="req_comp_open"
		else
			icon_state="req_comp_rewired"
	else if(stat & NOPOWER)
		if(icon_state != "req_comp_off")
			icon_state = "req_comp_off"
	else
		if(newmessagepriority == 1)
			icon_state = "req_comp1"
		else if(newmessagepriority == 2)
			icon_state = "req_comp2"
		else if(newmessagepriority == 3)
			icon_state = "req_comp3"
		else
			icon_state = "req_comp0"

/obj/machinery/requests_console/New()
	name = "\improper [department] requests console"
	allConsoles += src
	//req_console_departments += department
	switch(departmentType)
		if(1)
			if(!("[department]" in req_console_assistance))
				req_console_assistance += department
		if(2)
			if(!("[department]" in req_console_supplies))
				req_console_supplies += department
		if(3)
			if(!("[department]" in req_console_information))
				req_console_information += department
		if(4)
			if(!("[department]" in req_console_assistance))
				req_console_assistance += department
			if(!("[department]" in req_console_supplies))
				req_console_supplies += department
		if(5)
			if(!("[department]" in req_console_assistance))
				req_console_assistance += department
			if(!("[department]" in req_console_information))
				req_console_information += department
		if(6)
			if(!("[department]" in req_console_supplies))
				req_console_supplies += department
			if(!("[department]" in req_console_information))
				req_console_information += department
		if(7)
			if(!("[department]" in req_console_assistance))
				req_console_assistance += department
			if(!("[department]" in req_console_supplies))
				req_console_supplies += department
			if(!("[department]" in req_console_information))
				req_console_information += department

/obj/machinery/requests_console/attack_hand(var/mob/user)
	if(..(user))
		return
	var/dat = ""
	if(!open)
		switch(screen)
			if(1)	//req. assistance
				dat += "Which department do you need assistance from?

"
				dat += "
"
				for(var/dpt in req_console_assistance)
					if (dpt != department)
						dat += "
"
						dat += "[dpt]	"
						dat += "Normal High"
						if (hackState == 1)
							dat += "EXTREME"
						dat += "	"
						dat += "
"
				dat += "
"
				dat += "
<< Back
"

			if(2)	//req. supplies
				dat += "Which department do you need supplies from?

"
				dat += "
"
				for(var/dpt in req_console_supplies)
					if (dpt != department)
						dat += "
"
						dat += "[dpt]	"
						dat += "Normal High"
						if (hackState == 1)
							dat += "EXTREME"
						dat += "	"
						dat += "
"
				dat += "
"
				dat += "
<< Back
"

			if(3)	//relay information
				dat += "Which department would you like to send information to?

"
				dat += "
"
				for(var/dpt in req_console_information)
					if (dpt != department)
						dat += "
"
						dat += "[dpt]	"
						dat += "Normal High"
						if (hackState == 1)
							dat += "EXTREME"
						dat += "	"
						dat += "
"
				dat += "
"
				dat += "
<< Back
"

			if(6)	//sent successfully
				dat += "Message sent.

"
				dat += "Continue
"

			if(7)	//unsuccessful; not sent
				dat += "An error occurred.

"
				dat += "Continue
"

			if(8)	//view messages
				for (var/obj/machinery/requests_console/Console in allConsoles)
					if (Console.department == department)
						Console.newmessagepriority = 0
						Console.update_icon()
						Console.light_range = 1
				newmessagepriority = 0
				update_icon()
				var/messageComposite = ""
				for(var/msg in messages) // This puts more recent messages at the *top*, where they belong.
					messageComposite = "
[msg]
" + messageComposite
				dat += messageComposite
				dat += "
<< Back to Main Menu
"

			if(9)	//authentication before sending
				dat += "Message Authentication

"
				dat += "Message for [dpt]: [message]

"
				dat += "
You may authenticate your message now by scanning your ID or your stamp

"
				dat += "Validated by: [msgVerified ? msgVerified : "Not Validated"]
"
				dat += "Stamped by: [msgStamped ? msgStamped : "Not Stamped"]

"
				dat += "Send Message
"
				dat += "
<< Discard Message
"

			if(10)	//send announcement
				dat += "
Station-wide Announcement
"
				if(announceAuth)
					dat += "
Authentication accepted

"
				else
					dat += "
Swipe your card to authenticate yourself

"
				dat += "Message: [message ? message : "No Message"]
"
				dat += "[message ? "Edit" : "Write"] Message

"
				if (announceAuth && message)
					dat += "Announce Message
"
				else
					dat += "Announce Message
"
				dat += "
<< Back
"

			else	//main menu
				screen = 0
				announceAuth = 0
				if (newmessagepriority == 1)
					dat += "
There are new messages

"
				if (newmessagepriority == 2)
					dat += "
There are new PRIORITY messages

"
				if (newmessagepriority == 3)
					dat += "
There are new EXTREME PRIORITY messages

"
				dat += "View Messages

"

				dat += "Request Assistance
"
				dat += "Request Supplies
"
				dat += "Relay Anonymous Information

"
				if(announcementConsole)
					dat += "Send Station-wide Announcement

"
				if (silent)
					dat += "Speaker OFF"
				else
					dat += "Speaker ON"

		//user << browse("[dat]", "window=request_console")
		//onclose(user, "req_console")
		var/datum/browser/popup = new(user, "req_console", "[department] Requests Console", 450, 440)
		popup.set_content(dat)
		popup.set_title_image(user.browse_rsc_icon(src.icon, src.icon_state))
		popup.open()
	return

/obj/machinery/requests_console/Topic(href, href_list)
	if(..())	return
	usr.set_machine(src)
	add_fingerprint(usr)

	if(reject_bad_text(href_list["write"]))
		dpt = ckey(href_list["write"]) //write contains the string of the receiving department's name

		var/new_message = copytext(reject_bad_text(input(usr, "Write your message:", "Awaiting Input", "")),1,MAX_MESSAGE_LEN)
		if(new_message)
			message = new_message
			screen = 9
			if (text2num(href_list["priority"]) < 2)
				priority = -1
			else
				priority = text2num(href_list["priority"])
		else
			dpt = "";
			msgVerified = ""
			msgStamped = ""
			screen = 0
			priority = -1

	if(href_list["writeAnnouncement"])
		var/new_message = copytext(reject_bad_text(input(usr, "Write your message:", "Awaiting Input", "")),1,MAX_MESSAGE_LEN)
		if(new_message)
			message = new_message
			if (text2num(href_list["priority"]) < 2)
				priority = -1
			else
				priority = text2num(href_list["priority"])
		else
			message = ""
			announceAuth = 0
			screen = 0

	if(href_list["sendAnnouncement"])
		if(!announcementConsole)	return
		minor_announce(message, "[department] Announcement:")
		news_network.SubmitArticle(message, department, "Station Announcements", null)
		log_say("[key_name(usr)] has made a station announcement: [message]")
		message_admins("[key_name_admin(usr)] has made a station announcement.")
		announceAuth = 0
		message = ""
		screen = 0

	if( href_list["department"] && message )
		var/log_msg = message
		var/sending = message
		sending += "
"
		if (msgVerified)
			sending += msgVerified
			sending += "
"
		if (msgStamped)
			sending += msgStamped
			sending += "
"
		screen = 7 //if it's successful, this will get overrwritten (7 = unsufccessfull, 6 = successfull)
		if (sending)
			var/pass = 0
			for (var/obj/machinery/message_server/MS in world)
				if(!MS.active) continue
				MS.send_rc_message(href_list["department"],department,log_msg,msgStamped,msgVerified,priority)
				pass = 1

			if(pass)
				for (var/obj/machinery/requests_console/Console in allConsoles)
					if (ckey(Console.department) == ckey(href_list["department"]))
						switch(priority)
							if(2)		//High priority
								Console.createmessage(src, "PRIORITY Alert in [department]", sending, 2, 1)
							if(3)		// Extreme Priority
								Console.createmessage(src, "EXTREME PRIORITY Alert in [department]", sending, 3, 1)
							else		// Normal priority
								Console.createmessage(src, "Message from [department]", sending, 1, 1)
						screen = 6
						Console.light_range = 2

				switch(priority)
					if(2)
						messages += "High Priority
To: [dpt]
[sending]"
					else
						messages += "To: [dpt]
[sending]"
			else
				say("NOTICE: No server detected!")

	//Handle screen switching
	switch(text2num(href_list["setScreen"]))
		if(null)	//skip
		if(1)		//req. assistance
			screen = 1
		if(2)		//req. supplies
			screen = 2
		if(3)		//relay information
			screen = 3
//		if(4)		//write message
//			screen = 4
		if(5)		//choose priority
			screen = 5
		if(6)		//sent successfully
			screen = 6
		if(7)		//unsuccessfull; not sent
			screen = 7
		if(8)		//view messages
			screen = 8
		if(9)		//authentication
			screen = 9
		if(10)		//send announcement
			if(!announcementConsole)	return
			screen = 10
		else		//main menu
			dpt = ""
			msgVerified = ""
			msgStamped = ""
			message = ""
			priority = -1
			screen = 0

	//Handle silencing the console
	switch( href_list["setSilent"] )
		if(null)	//skip
		if("1")	silent = 1
		else	silent = 0

	updateUsrDialog()
	return

/obj/machinery/say_quote(var/text)
	var/ending = copytext(text, length(text) - 2)
	if (ending == "!!!")
		return "blares, \"[text]\""

	return "beeps, \"[text]\""

/obj/machinery/requests_console/proc/createmessage(source, title, message, priority, paper)
	var/linkedsender
	var/unlinkedsender
	if(istype(source, /obj/machinery/requests_console))
		var/obj/machinery/requests_console/sender = source
		linkedsender = "[sender.department]"
		unlinkedsender = sender.department
	else
		capitalize(source)
		linkedsender = source
		unlinkedsender = source
	capitalize(title)
	switch(priority)
		if(2)		//High priority
			if(src.newmessagepriority < 2)
				src.newmessagepriority = 2
				src.update_icon()
			if(!src.silent)
				playsound(src.loc, 'sound/machines/twobeep.ogg', 50, 1)
				say(title)
				src.messages += "High Priority
From: [linkedsender]
[message]"
			if(paper)
				var/obj/item/weapon/paper/slip = new /obj/item/weapon/paper(src.loc)
				slip.info = "High Priority
From: [unlinkedsender]
[message]"
				slip.name = "Important Message - [source]"

		if(3)		// Extreme Priority
			if(src.newmessagepriority < 3)
				src.newmessagepriority = 3
				src.update_icon()
			if(1)
				playsound(src.loc, 'sound/machines/twobeep.ogg', 50, 1)
				say(title)
			src.messages += "!!!Extreme Priority!!!
From: [linkedsender]
[message]"
			var/obj/item/weapon/paper/slip = new /obj/item/weapon/paper(src.loc)
			if(paper)
				slip.info = "!!!Extreme Priority!!!
From: [unlinkedsender]
[message]"
				slip.name = "URGENT message - [unlinkedsender]"
				var/mob/living/target = locate() in view(7,src)
				if(target)
					src.visible_message("[src] launches [slip] at [target]!")
					slip.throw_at(target, 16, 3)

		else		// Normal priority
			if(src.newmessagepriority < 1)
				src.newmessagepriority = 1
				src.update_icon()
			if(!src.silent)
				playsound(src.loc, 'sound/machines/twobeep.ogg', 50, 1)
				say(title)
			src.messages += "From: [linkedsender]
[message]"
			if(paper)
				var/obj/item/weapon/paper/slip = new /obj/item/weapon/paper(src.loc)
				slip.info = "From: [unlinkedsender]
[message]"
				slip.name = "Message - [unlinkedsender]"
	src.light_range = 2

/obj/machinery/requests_console/attackby(var/obj/item/weapon/O as obj, var/mob/user as mob, params)
	if (istype(O, /obj/item/weapon/crowbar))
		if(open)
			user << "You close the maintenance panel."
			open = 0
			icon_state="req_comp0"
		else
			user << "You open the maintenance panel."
			open = 1
			if(hackState == 0)
				icon_state="req_comp_open"
			else if(hackState == 1)
				icon_state="req_comp_rewired"
	if (istype(O, /obj/item/weapon/screwdriver))
		if(open)
			if(hackState == 0)
				user << "You modify the wiring."
				hackState = 1
				icon_state="req_comp_rewired"
			else if(hackState == 1)
				user << "You reset the wiring."
				hackState = 0
				icon_state="req_comp_open"
		else
			user << "You can't do much with that."
	update_icon()

	var/obj/item/weapon/card/id/ID = O.GetID()
	if (ID)
		if(screen == 9)
			msgVerified = "Verified by [ID.registered_name] ([ID.assignment])"
			updateUsrDialog()
		if(screen == 10)
			if (access_RC_announce in ID.access)
				announceAuth = 1
			else
				announceAuth = 0
				user << "You are not authorized to send announcements."
			updateUsrDialog()
	if (istype(O, /obj/item/weapon/stamp))
		if(screen == 9)
			var/obj/item/weapon/stamp/T = O
			msgStamped = "Stamped with the [T.name]"
			updateUsrDialog()
	return


code:
/obj/machinery/robotic_fabricator
	name = "robotic fabricator"
	icon = 'icons/obj/robotics.dmi'
	icon_state = "fab-idle"
	density = 1
	anchored = 1
	var/metal_amount = 0
	var/operating = 0
	var/obj/item/robot_parts/being_built = null
	use_power = 1
	idle_power_usage = 20
	active_power_usage = 5000

/obj/machinery/robotic_fabricator/attackby(var/obj/item/O as obj, var/mob/user as mob, params)
	if (istype(O, /obj/item/stack/sheet/metal))
		if (src.metal_amount < 150000.0)
			var/count = 0
			src.overlays += "fab-load-metal"
			spawn(15)
				if(O)
					if(!O:amount)
						return
					while(metal_amount < 150000 && O:amount)
						src.metal_amount += O:m_amt /*O:height * O:width * O:length * 100000.0*/
						O:amount--
						count++

					if (O:amount < 1)
						qdel(O)

					user << "You insert [count] metal sheet\s into \the [src]."
					src.overlays -= "fab-load-metal"
					updateDialog()
		else
			user << "\The [src] is full."

/obj/machinery/robotic_fabricator/power_change()
	if (powered())
		stat &= ~NOPOWER
	else
		stat |= NOPOWER

/obj/machinery/robotic_fabricator/attack_paw(user as mob)
	return src.attack_hand(user)

/obj/machinery/robotic_fabricator/attack_hand(user as mob)
	var/dat
	if (..())
		return

	if (src.operating)
		dat = {"
<TT>Building [src.being_built.name].

Please wait until completion...</TT>

"}
	else
		dat = {"
Metal Amount: [min(150000, src.metal_amount)] cm3 (MAX: 150,000)

Left Arm (25,000 cc metal.)

Right Arm (25,000 cc metal.)

Left Leg (25,000 cc metal.)

Right Leg (25,000 cc metal).

Chest (50,000 cc metal).

Head (50,000 cc metal).

Robot Frame (75,000 cc metal).

"}

	user << browse("<TITLE>Robotic Fabricator Control Panel</TITLE><TT>[dat]</TT>", "window=robot_fabricator")
	onclose(user, "robot_fabricator")
	return

/obj/machinery/robotic_fabricator/Topic(href, href_list)
	if (..())
		return

	usr.set_machine(src)
	src.add_fingerprint(usr)

	if (href_list["make"])
		if (!src.operating)
			var/part_type = text2num(href_list["make"])

			var/build_type = ""
			var/build_time = 200
			var/build_cost = 25000

			switch (part_type)
				if (1)
					build_type = "/obj/item/robot_parts/l_arm"
					build_time = 200
					build_cost = 10000

				if (2)
					build_type = "/obj/item/robot_parts/r_arm"
					build_time = 200
					build_cost = 10000

				if (3)
					build_type = "/obj/item/robot_parts/l_leg"
					build_time = 200
					build_cost = 10000

				if (4)
					build_type = "/obj/item/robot_parts/r_leg"
					build_time = 200
					build_cost = 10000

				if (5)
					build_type = "/obj/item/robot_parts/chest"
					build_time = 350
					build_cost = 40000

				if (6)
					build_type = "/obj/item/robot_parts/head"
					build_time = 350
					build_cost = 5000

				if (7)
					build_type = "/obj/item/robot_parts/robot_suit"
					build_time = 600
					build_cost = 15000

			var/building = text2path(build_type)
			if (!isnull(building))
				if (src.metal_amount >= build_cost)
					src.operating = 1
					src.use_power = 2

					src.metal_amount = max(0, src.metal_amount - build_cost)

					src.being_built = new building(src)

					src.overlays += "fab-active"
					src.updateUsrDialog()

					spawn (build_time)
						if (!isnull(src.being_built))
							src.being_built.loc = get_turf(src)
							src.being_built = null
						src.use_power = 1
						src.operating = 0
						src.overlays -= "fab-active"
		return

	for (var/mob/M in viewers(1, src))
		if (M.client && M.machine == src)
			src.attack_hand(M)


code:
/obj/machinery/shield
		name = "emergency energy shield"
		desc = "An energy shield used to contain hull breaches."
		icon = 'icons/effects/effects.dmi'
		icon_state = "shield-old"
		density = 1
		opacity = 0
		anchored = 1
		unacidable = 1
		var/const/max_health = 200
		var/health = max_health //The shield can only take so much beating (prevents perma-prisons)

/obj/machinery/shield/New()
	src.dir = pick(1,2,3,4)
	..()
	air_update_turf(1)

/obj/machinery/shield/Destroy()
	opacity = 0
	density = 0
	air_update_turf(1)
	..()

/obj/machinery/shield/Move()
	var/turf/T = loc
	..()
	move_update_air(T)

/obj/machinery/shield/CanPass(atom/movable/mover, turf/target, height)
	if(!height) return 0
	else return ..()

/obj/machinery/shield/CanAtmosPass(var/turf/T)
	return !density

/obj/machinery/shield/attackby(obj/item/weapon/W as obj, mob/user as mob, params)
	if(!istype(W)) return

	//Calculate damage
	var/aforce = W.force
	if(W.damtype == BRUTE || W.damtype == BURN)
		src.health -= aforce

	//Play a fitting sound
	playsound(src.loc, 'sound/effects/EMPulse.ogg', 75, 1)

	if (src.health <= 0)
		visible_message("[src] dissipates.")
		qdel(src)
		return

	opacity = 1
	spawn(20) if(src) opacity = 0
	..()

/obj/machinery/shield/bullet_act(var/obj/item/projectile/Proj)
	health -= Proj.damage
	..()
	if(health <=0)
		visible_message("The [src] dissipates.")
		qdel(src)
		return
	opacity = 1
	spawn(20) if(src) opacity = 0

/obj/machinery/shield/ex_act(severity, target)
	switch(severity)
		if(1.0)
			if (prob(75))
				qdel(src)
		if(2.0)
			if (prob(50))
				qdel(src)
		if(3.0)
			if (prob(25))
				qdel(src)
	return

/obj/machinery/shield/emp_act(severity)
	switch(severity)
		if(1)
			qdel(src)
		if(2)
			if(prob(50))
				qdel(src)

/obj/machinery/shield/blob_act()
	qdel(src)

/obj/machinery/shield/hitby(AM as mob|obj)
	//Let everyone know we've been hit!
	visible_message("[src] was hit by [AM].")

	//Super realistic, resource-intensive, real-time damage calculations.
	var/tforce = 0
	if(ismob(AM))
		tforce = 40
	else
		tforce = AM:throwforce

	src.health -= tforce

	//This seemed to be the best sound for hitting a force field.
	playsound(src.loc, 'sound/effects/EMPulse.ogg', 100, 1)

	//Handle the destruction of the shield
	if (src.health <= 0)
		visible_message("[src] dissipates.")
		qdel(src)
		return

	//The shield becomes dense to absorb the blow.. purely asthetic.
	opacity = 1
	spawn(20) if(src) opacity = 0

	..()
	return

/obj/machinery/shieldgen
		name = "anti-breach shielding projector"
		desc = "Used to seal minor hull breaches."
		icon = 'icons/obj/objects.dmi'
		icon_state = "shieldoff"
		density = 1
		opacity = 0
		anchored = 0
		pressure_resistance = 2*ONE_ATMOSPHERE
		req_access = list(access_engine)
		var/const/max_health = 100
		var/health = max_health
		var/active = 0
		var/malfunction = 0 //Malfunction causes parts of the shield to slowly dissapate
		var/list/deployed_shields = list()
		var/is_open = 0 //Whether or not the wires are exposed
		var/locked = 0
		var/shield_range = 4

/obj/machinery/shieldgen/Destroy()
	for(var/obj/machinery/shield/shield_tile in deployed_shields)
		qdel(shield_tile)
	deployed_shields = null
	..()

/obj/machinery/shieldgen/proc/shields_up()
	if(active) return 0 //If it's already turned on, how did this get called?

	src.active = 1
	update_icon()

	for(var/turf/target_tile in range(shield_range, src))
		if (istype(target_tile,/turf/space) && !(locate(/obj/machinery/shield) in target_tile))
			if (malfunction && prob(33) || !malfunction)
				deployed_shields += new /obj/machinery/shield(target_tile)

/obj/machinery/shieldgen/proc/shields_down()
	if(!active) return 0 //If it's already off, how did this get called?

	src.active = 0
	update_icon()

	for(var/obj/machinery/shield/shield_tile in deployed_shields)
		qdel(shield_tile)
	deployed_shields.Cut()

/obj/machinery/shieldgen/process()
	if(malfunction && active)
		if(deployed_shields.len && prob(5))
			qdel(pick(deployed_shields))

	return

/obj/machinery/shieldgen/proc/checkhp()
	if(health <= 30)
		src.malfunction = 1
	if(health <= 0)
		qdel(src)
	update_icon()
	return

/obj/machinery/shieldgen/ex_act(severity, target)
	switch(severity)
		if(1.0)
			src.health -= 75
			src.checkhp()
		if(2.0)
			src.health -= 30
			if (prob(15))
				src.malfunction = 1
			src.checkhp()
		if(3.0)
			src.health -= 10
			src.checkhp()
	return

/obj/machinery/shieldgen/emp_act(severity)
	switch(severity)
		if(1)
			src.health /= 2 //cut health in half
			malfunction = 1
			locked = pick(0,1)
		if(2)
			if(prob(50))
				src.health *= 0.3 //chop off a third of the health
				malfunction = 1
	checkhp()

/obj/machinery/shieldgen/attack_hand(mob/user as mob)
	if(locked)
		user << "The machine is locked, you are unable to use it."
		return
	if(is_open)
		user << "The panel must be closed before operating this machine."
		return

	if (src.active)
		user.visible_message("\icon[src] [user] deactivated the shield generator.", \
			"\icon[src] You deactivate the shield generator.", \
			"You hear heavy droning fade out.")
		src.shields_down()
	else
		if(anchored)
			user.visible_message("\icon[src] [user] activated the shield generator.", \
				"\icon[src] You activate the shield generator.", \
				"You hear heavy droning.")
			src.shields_up()
		else
			user << "The device must first be secured to the floor."
	return

/obj/machinery/shieldgen/attackby(obj/item/weapon/W as obj, mob/user as mob, params)
	if(istype(W, /obj/item/weapon/screwdriver))
		playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1)
		if(is_open)
			user << "You close the panel."
			is_open = 0
		else
			user << "You open the panel and expose the wiring."
			is_open = 1

	else if(istype(W, /obj/item/stack/cable_coil) && malfunction && is_open)
		var/obj/item/stack/cable_coil/coil = W
		if (coil.get_amount() < 1)
			user << "You need one length of cable to repair [src]."
			return
		user << "You begin to replace the wires."
		if(do_after(user, 30))
			if(coil.get_amount() < 1)
				return
			coil.use(1)
			health = max_health
			malfunction = 0
			user << "You repair \the [src]!"
			update_icon()

	else if(istype(W, /obj/item/weapon/wrench))
		if(locked)
			user << "The bolts are covered, unlocking this would retract the covers."
			return
		if(!anchored && !isinspace())
			playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1)
			user << " You secure \the [src] to the floor!"
			anchored = 1
		else if(anchored)
			playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1)
			user << " You unsecure \the [src] from the floor!"
			if(active)
				user << " \The [src] shuts off!"
				src.shields_down()
			anchored = 0

	else if(istype(W, /obj/item/weapon/card/id) || istype(W, /obj/item/device/pda))
		if(src.allowed(user))
			src.locked = !src.locked
			user << "The controls are now [src.locked ? "locked." : "unlocked."]"
		else
			user << "Access denied."

	else
		..()

/obj/machinery/shieldgen/emag_act()
	if(!malfunction)
		malfunction = 1
		update_icon()

/obj/machinery/shieldgen/update_icon()
	if(active)
		src.icon_state = malfunction ? "shieldonbr":"shieldon"
	else
		src.icon_state = malfunction ? "shieldoffbr":"shieldoff"
	return

////FIELD GEN START //shameless copypasta from fieldgen, powersink, and grille
#define maxstoredpower 500
/obj/machinery/shieldwallgen
		name = "shield generator"
		desc = "A shield generator."
		icon = 'icons/obj/stationobjs.dmi'
		icon_state = "Shield_Gen"
		anchored = 0
		density = 1
		req_access = list(access_teleporter)
		var/active = 0
		var/power = 0
		var/steps = 0
		var/last_check = 0
		var/check_delay = 10
		var/recalc = 0
		var/locked = 1
		var/destroyed = 0
//		var/maxshieldload = 200
		var/obj/structure/cable/attached		// the attached cable
		var/storedpower = 0
		flags = CONDUCT
		use_power = 0

/obj/machinery/shieldwallgen/proc/power()
	if(!anchored)
		power = 0
		return 0
	var/turf/T = src.loc

	var/obj/structure/cable/C = T.get_cable_node()
	var/datum/powernet/PN
	if(C)	PN = C.powernet		// find the powernet of the connected cable

	if(!PN)
		power = 0
		return 0

	var/surplus = max(PN.avail-PN.load, 0)
	var/shieldload = min(rand(50,200), surplus)
	if(shieldload==0 && !storedpower)		// no cable or no power, and no power stored
		power = 0
		return 0
	else
		power = 1	// IVE GOT THE POWER!
		if(PN) //runtime errors fixer. They were caused by PN.newload trying to access missing network in case of working on stored power.
			storedpower += shieldload
			PN.load += shieldload //uses powernet power.
//		message_admins("[PN.load]")
//		use_power(250) //uses APC power

/obj/machinery/shieldwallgen/attack_hand(mob/user as mob)
	if(!anchored)
		user << "The shield generator needs to be firmly secured to the floor first."
		return 1
	if(locked && !istype(user, /mob/living/silicon))
		user << "The controls are locked!"
		return 1
	if(power != 1)
		user << "The shield generator needs to be powered by wire underneath."
		return 1

	if(src.active >= 1)
		src.active = 0
		icon_state = "Shield_Gen"

		user.visible_message("[user] turned the shield generator off.", \
			"You turn off the shield generator.", \
			"You hear heavy droning fade out.")
		src.cleanup()
	else
		src.active = 1
		icon_state = "Shield_Gen +a"
		user.visible_message("[user] turned the shield generator on.", \
			"You turn on the shield generator.", \
			"You hear heavy droning.")
	src.add_fingerprint(user)

/obj/machinery/shieldwallgen/process()
	power()
	if(power)
		storedpower -= 50 //this way it can survive longer and survive at all
	if(storedpower >= maxstoredpower)
		storedpower = maxstoredpower
	if(storedpower <= 0)
		storedpower = 0
//	if(shieldload >= maxshieldload) //there was a loop caused by specifics of process(), so this was needed.
//		shieldload = maxshieldload

	if(src.active == 1)
		if(!anchored)
			src.active = 0
			return
		setup_field(1)
		setup_field(2)
		setup_field(4)
		setup_field(8)
		src.active = 2
	if(src.active >= 1)
		if(src.power == 0)
			src.visible_message("The [src.name] shuts down due to lack of power!", \
				"You hear heavy droning fade out")
			icon_state = "Shield_Gen"
			src.active = 0
			src.cleanup(1)
			src.cleanup(2)
			src.cleanup(4)
			src.cleanup(8)

/obj/machinery/shieldwallgen/proc/setup_field(var/NSEW = 0)
	var/turf/T = src.loc
	var/turf/T2 = src.loc
	var/obj/machinery/shieldwallgen/G
	var/steps = 0
	var/oNSEW = 0

	if(!NSEW)//Make sure its ran right
		return

	if(NSEW == 1)
		oNSEW = 2
	else if(NSEW == 2)
		oNSEW = 1
	else if(NSEW == 4)
		oNSEW = 8
	else if(NSEW == 8)
		oNSEW = 4

	for(var/dist = 0, dist <= 9, dist += 1) // checks out to 8 tiles away for another generator
		T = get_step(T2, NSEW)
		T2 = T
		steps += 1
		if(locate(/obj/machinery/shieldwallgen) in T)
			G = (locate(/obj/machinery/shieldwallgen) in T)
			steps -= 1
			if(!G.active)
				return
			G.cleanup(oNSEW)
			break

	if(isnull(G))
		return

	T2 = src.loc

	for(var/dist = 0, dist < steps, dist += 1) // creates each field tile
		var/field_dir = get_dir(T2,get_step(T2, NSEW))
		T = get_step(T2, NSEW)
		T2 = T
		var/obj/machinery/shieldwall/CF = new/obj/machinery/shieldwall/(src, G) //(ref to this gen, ref to connected gen)
		CF.loc = T
		CF.dir = field_dir

/obj/machinery/shieldwallgen/attackby(obj/item/W, mob/user, params)
	if(istype(W, /obj/item/weapon/wrench))
		if(active)
			user << "Turn off the field generator first."
			return

		else if(!anchored && !isinspace()) //Can't fasten this thing in space
			playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
			user << "You secure the external reinforcing bolts to the floor."
			anchored = 1
			return

		else //You can unfasten it tough, if you somehow manage to fasten it.
			playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
			user << "You undo the external reinforcing bolts."
			anchored = 0
			return

	if(istype(W, /obj/item/weapon/card/id)||istype(W, /obj/item/device/pda))
		if (src.allowed(user))
			src.locked = !src.locked
			user << "Controls are now [src.locked ? "locked." : "unlocked."]"
		else
			user << "Access denied."

	else
		add_fingerprint(user)
		..()

/obj/machinery/shieldwallgen/proc/cleanup(var/NSEW)
	var/obj/machinery/shieldwall/F
	var/obj/machinery/shieldwallgen/G
	var/turf/T = src.loc
	var/turf/T2 = src.loc

	for(var/dist = 0, dist <= 9, dist += 1) // checks out to 8 tiles away for fields
		T = get_step(T2, NSEW)
		T2 = T
		if(locate(/obj/machinery/shieldwall) in T)
			F = (locate(/obj/machinery/shieldwall) in T)
			qdel(F)

		if(locate(/obj/machinery/shieldwallgen) in T)
			G = (locate(/obj/machinery/shieldwallgen) in T)
			if(!G.active)
				break

/obj/machinery/shieldwallgen/Destroy()
	src.cleanup(1)
	src.cleanup(2)
	src.cleanup(4)
	src.cleanup(8)
	..()

/obj/machinery/shieldwallgen/bullet_act(var/obj/item/projectile/Proj)
	storedpower -= Proj.damage
	..()
	return

//////////////Containment Field START
/obj/machinery/shieldwall
		name = "shield"
		desc = "An energy shield."
		icon = 'icons/effects/effects.dmi'
		icon_state = "shieldwall"
		anchored = 1
		density = 1
		unacidable = 1
		light_range = 3
		var/needs_power = 0
		var/active = 1
//		var/power = 10
		var/delay = 5
		var/last_active
		var/mob/U
		var/obj/machinery/shieldwallgen/gen_primary
		var/obj/machinery/shieldwallgen/gen_secondary

/obj/machinery/shieldwall/New(var/obj/machinery/shieldwallgen/A, var/obj/machinery/shieldwallgen/B)
	..()
	src.gen_primary = A
	src.gen_secondary = B
	if(A && B)
		needs_power = 1

/obj/machinery/shieldwall/attack_hand(mob/user as mob)
	return

/obj/machinery/shieldwall/process()
	if(needs_power)
		if(isnull(gen_primary)||isnull(gen_secondary))
			qdel(src)
			return

		if(!(gen_primary.active)||!(gen_secondary.active))
			qdel(src)
			return
//
		if(prob(50))
			gen_primary.storedpower -= 10
		else
			gen_secondary.storedpower -=10

/obj/machinery/shieldwall/bullet_act(var/obj/item/projectile/Proj)
	if(needs_power)
		var/obj/machinery/shieldwallgen/G
		if(prob(50))
			G = gen_primary
		else
			G = gen_secondary
		G.storedpower -= Proj.damage
	..()
	return

/obj/machinery/shieldwall/ex_act(severity, target)
	if(needs_power)
		var/obj/machinery/shieldwallgen/G
		switch(severity)
			if(1.0) //big boom
				if(prob(50))
					G = gen_primary
				else
					G = gen_secondary
				G.storedpower -= 200

			if(2.0) //medium boom
				if(prob(50))
					G = gen_primary
				else
					G = gen_secondary
				G.storedpower -= 50

			if(3.0) //lil boom
				if(prob(50))
					G = gen_primary
				else
					G = gen_secondary
				G.storedpower -= 20
	return

/obj/machinery/shieldwall/CanPass(atom/movable/mover, turf/target, height=0)
	if(height==0) return 1

	if(istype(mover) && mover.checkpass(PASSGLASS))
		return prob(20)
	else
		if (istype(mover, /obj/item/projectile))
			return prob(10)
		else
			return !src.density


code:
/*******************************\
|		  Slot Machines		  	|
|	  Original code by Glloyd	|
|	  Tgstation port by Miauw	|
\*******************************/

#define SPIN_PRICE 5
#define SMALL_PRIZE 400
#define BIG_PRIZE 1000
#define JACKPOT 10000
#define SPIN_TIME 65 //As always, deciseconds.
#define REEL_DEACTIVATE_DELAY 7
#define SEVEN "7"

/obj/machinery/computer/slot_machine
	name = "slot machine"
	desc = "Gambling for the antisocial."
	icon = 'icons/obj/economy.dmi'
	icon_state = "slots1"
	anchored = 1
	density = 1
	use_power = 1
	idle_power_usage = 50
	circuit = /obj/item/weapon/circuitboard/slot_machine
	var/money = 3000 //How much money it has CONSUMED
	var/plays = 0
	var/working = 0
	var/balance = 0 //How much money is in the machine, ready to be CONSUMED.
	var/jackpots = 0
	var/list/coinvalues = list()
	var/list/reels = list(list("", "", "") = 0, list("", "", "") = 0, list("", "", "") = 0, list("", "", "") = 0, list("", "", "") = 0)
	var/list/symbols = list(SEVEN = 1, "&" = 2, "@" = 2, "$" = 2, "?" = 2, "#" = 2, "!" = 2, "%" = 2) //if people are winning too much, multiply every number in this list by 2 and see if they are still winning too much.

/obj/machinery/computer/slot_machine/New()
	..()
	jackpots = rand(1, 4) //false hope
	plays = rand(75, 200)

	toggle_reel_spin(1) //The reels won't spin unless we activate them

	var/list/reel = reels[1]
	for(var/i = 0, i < reel.len, i++) //Populate the reels.
		randomize_reels()

	toggle_reel_spin(0)

	for(var/cointype in typesof(/obj/item/weapon/coin))
		var/obj/item/weapon/coin/C = new cointype(src)
		coinvalues["[cointype]"] = C.value
		qdel(C)

/obj/machinery/computer/slot_machine/process()
	. = ..() //Sanity checks.
	if(!.)
		return .

	money++ //SPESSH MAJICKS

/obj/machinery/computer/slot_machine/update_icon()
	if(stat & NOPOWER)
		icon_state = "slots0"

	else if(stat & BROKEN)
		icon_state = "slotsb"

	else if(working)
		icon_state = "slots2"

	else
		icon_state = "slots1"

/obj/machinery/computer/slot_machine/power_change()
	..()
	update_icon()

/obj/machinery/computer/slot_machine/attackby(obj/item/I, mob/living/user, params)
	if(istype(I, /obj/item/weapon/coin))
		var/obj/item/weapon/coin/C = I
		if(prob(2))
			user.drop_item()
			C.loc = loc
			C.throw_at(user, 3, 10)
			if(prob(10))
				balance = max(balance - SPIN_PRICE, 0)
			user << "[src] spits your coin back out!"

		else
			user.drop_item()
			user << "You insert a [C.cmineral] coin into [src]'s slot!"
			balance += C.value
			qdel(C)

		return

	else if(!balance) //to prevent coins from magically disappearing
		..()

/obj/machinery/computer/slot_machine/emag_act()
	if(!emagged)
		emagged = 1
		var/datum/effect/effect/system/spark_spread/spark_system = new /datum/effect/effect/system/spark_spread()
		spark_system.set_up(4, 0, src.loc)
		spark_system.start()
		playsound(src.loc, "sparks", 50, 1)

/obj/machinery/computer/slot_machine/attack_hand(mob/living/user)
	. = ..() //Sanity checks.
	if(.)
		return .

	interact(user)

/obj/machinery/computer/slot_machine/interact(mob/living/user)
	var/reeltext = {"
	/*****^*****^*****^*****^*****\\

	| \[[reels[1][1]]\] | \[[reels[2][1]]\] | \[[reels[3][1]]\] | \[[reels[4][1]]\] | \[[reels[5][1]]\] |

	| \[[reels[1][2]]\] | \[[reels[2][2]]\] | \[[reels[3][2]]\] | \[[reels[4][2]]\] | \[[reels[5][2]]\] |

	| \[[reels[1][3]]\] | \[[reels[2][3]]\] | \[[reels[3][3]]\] | \[[reels[4][3]]\] | \[[reels[5][3]]\] |

	\\*****v*****v*****v*****v*****/

	"}

	var/dat
	if(working)
		dat = reeltext

	else
		dat = {"Five credits to play!

		Prize Money Available: [money] (jackpot payout is ALWAYS 100%!)

		Credit Remaining: [balance]

		[plays] players have tried their luck today, and [jackpots] have won a jackpot!

		Play!

		[reeltext]

		Refund balance
"}

	var/datum/browser/popup = new(user, "slotmachine", "Slot Machine")
	popup.set_content(dat)
	popup.set_title_image(user.browse_rsc_icon(icon, icon_state))
	popup.open()

/obj/machinery/computer/slot_machine/Topic(href, href_list)
	. = ..() //Sanity checks.
	if(.)
		return .

	if(href_list["spin"])
		spin(usr)

	else if(href_list["refund"])
		give_coins(balance)
		balance = 0

/obj/machinery/computer/slot_machine/emp_act(severity)
	if(stat & (NOPOWER|BROKEN))
		return
	if(prob(15 * severity))
		return
	if(prob(1)) // :^)
		emagged = 1
	var/severity_ascending = 4 - severity
	money = max(rand(money - (200 * severity_ascending), money + (200 * severity_ascending)), 0)
	balance = max(rand(balance - (50 * severity_ascending), balance + (50 * severity_ascending)), 0)
	money -= max(0, give_coins(min(rand(-50, 100 * severity_ascending)), money)) //This starts at -50 because it shouldn't always dispense coins yo
	spin()

/obj/machinery/computer/slot_machine/proc/spin(mob/user)
	if(!can_spin(user))
		return

	var/the_name
	if(user)
		the_name = user.real_name
		visible_message("[user] pulls the lever and the slot machine starts spinning!")
	else
		the_name = "Exaybachay"

	balance -= SPIN_PRICE
	money += SPIN_PRICE
	plays += 1
	working = 1

	toggle_reel_spin(1)
	update_icon()
	updateDialog()

	spawn(0)
		while(working)
			randomize_reels()
			updateDialog()
			sleep(2)

	spawn(SPIN_TIME - (REEL_DEACTIVATE_DELAY * reels.len)) //WARNING: no sanity checking for user since it's not needed and would complicate things (machine should still spin even if user is gone), be wary of this if you're changing this code.
		toggle_reel_spin(0, REEL_DEACTIVATE_DELAY)
		working = 0
		give_prizes(the_name, user)
		update_icon()
		updateDialog()

/obj/machinery/computer/slot_machine/proc/can_spin(mob/user)
	if(stat & NOPOWER)
		user << "The slot machine has no power!"
	if(stat & BROKEN)
		user << "The slot machine is broken!"
	if(working)
		user << "You need to wait until the machine stops spinning before you can play again!"
		return 0
	if(balance < SPIN_PRICE)
		user << "Insufficient money to play!"
		return 0
	return 1

/obj/machinery/computer/slot_machine/proc/toggle_reel_spin(value, delay = 0) //value is 1 or 0 aka on or off
	for(var/list/reel in reels)
		reels[reel] = value
		sleep(delay)

/obj/machinery/computer/slot_machine/proc/randomize_reels()

	for(var/reel in reels)
		if(reels[reel])
			reel[3] = reel[2]
			reel[2] = reel[1]
			reel[1] = pick(symbols)

/obj/machinery/computer/slot_machine/proc/give_prizes(usrname, mob/user)
	var/linelength = get_lines()

	if(reels[1][2] + reels[2][2] + reels[3][2] + reels[4][2] + reels[5][2] == "[SEVEN][SEVEN][SEVEN][SEVEN][SEVEN]")
		visible_message("[src] says, 'JACKPOT! You win [money] credits worth of coins!'")
		priority_announce("Congratulations to [user ? user.real_name : usrname] for winning the jackpot at the slot machine in [get_area(src)]!")
		jackpots += 1
		balance += money - give_coins(JACKPOT)
		money = 0

		for(var/i = 0, i < 5, i++)
			var/cointype = pick(typesof(/obj/item/weapon/coin) - /obj/item/weapon/coin)
			var/obj/item/weapon/coin/C = new cointype(loc)
			random_step(C, 2, 50)

	else if(linelength == 5)
		visible_message("[src] says, 'Big Winner! You win a thousand credits worth of coins!'")
		give_money(BIG_PRIZE)

	else if(linelength == 4)
		visible_message("[src] says, 'Winner! You win four hundred credits worth of coins!'")
		give_money(SMALL_PRIZE)

	else if(linelength == 3)
		user << "You win three free games!"
		balance += SPIN_PRICE * 4
		money = max(money - SPIN_PRICE * 4, money)

	else
		user << "No luck!"

/obj/machinery/computer/slot_machine/proc/get_lines()
	var/amountthesame

	for(var/i = 1, i <= 3, i++)
		var/inputtext = reels[1][i] + reels[2][i] + reels[3][i] + reels[4][i] + reels[5][i]
		for(var/symbol in symbols)
			var/j = 3 //The lowest value we have to check for.
			var/symboltext = symbol + symbol + symbol
			while(j <= 5)
				if(findtext(inputtext, symboltext))
					amountthesame = max(j, amountthesame)
				j++
				symboltext += symbol

			if(amountthesame)
				break

	return amountthesame

/obj/machinery/computer/slot_machine/proc/give_money(amount)
	var/amount_to_give = money >= amount ? amount : money
	var/surplus = amount_to_give - give_coins(amount_to_give)
	money = max(0, money - amount)
	balance += surplus

/obj/machinery/computer/slot_machine/proc/give_coins(amount)
	var/cointype = emagged ? /obj/item/weapon/coin/iron : /obj/item/weapon/coin/silver

	if(!emagged)
		amount = dispense(amount, cointype, null, 0)

	else
		var/mob/living/target = locate() in range(src, 2)

		amount = dispense(amount, cointype, target, 1)

	return amount

/obj/machinery/computer/slot_machine/proc/dispense(amount = 0, cointype = /obj/item/weapon/coin/silver, mob/living/target, throwit = 0)
	var/value = coinvalues["[cointype]"]

	while(amount >= value)
		var/obj/item/weapon/coin/C = new cointype(loc) //DOUBLE THE PAIN
		amount -= value
		if(throwit && target)
			C.throw_at(target, 3, 10)
		else
			random_step(C, 2, 40)

	return amount

#undef SEVEN
#undef SPIN_TIME
#undef JACKPOT
#undef BIG_PRIZE
#undef SMALL_PRIZE
#undef SPIN_PRICE


code:
/obj/machinery/space_heater
	anchored = 0
	density = 1
	icon = 'icons/obj/atmos.dmi'
	icon_state = "sheater0"
	name = "space heater"
	desc = "Made by Space Amish using traditional space techniques, this heater is guaranteed not to set the station on fire."
	var/obj/item/weapon/stock_parts/cell/cell
	var/on = 0
	var/open = 0
	var/set_temperature = 50		// in celcius, add T0C for kelvin
	var/heating_power = 40000

/obj/machinery/space_heater/New()
	..()
	cell = new(src)
	cell.charge = 1000
	cell.maxcharge = 1000
	update_icon()
	return

/obj/machinery/space_heater/update_icon()
	overlays.Cut()
	icon_state = "sheater[on]"
	if(open)
		overlays  += "sheater-open"
	return

/obj/machinery/space_heater/examine(mob/user)

	..()
	user << "The heater is [on ? "on" : "off"] and the hatch is [open ? "open" : "closed"]."
	if(open)
		user << "A power cell is [cell ? "installed" : "missing"]."
	else
		user << "The charge meter reads [cell ? round(cell.percent(),1) : 0]%."

/obj/machinery/space_heater/emp_act(severity)
	if(stat & (BROKEN|NOPOWER))
		..(severity)
		return
	if(cell)
		cell.emp_act(severity)
	..(severity)

/obj/machinery/space_heater/attackby(obj/item/I, mob/user, params)
	if(istype(I, /obj/item/weapon/stock_parts/cell))
		if(open)
			if(cell)
				user << "There is already a power cell inside."
				return
			else
				// insert cell
				var/obj/item/weapon/stock_parts/cell/C = usr.get_active_hand()
				if(istype(C))
					user.drop_item()
					cell = C
					C.loc = src
					C.add_fingerprint(usr)

					user.visible_message("[user] inserts a power cell into [src].", "You insert the power cell into [src].")
		else
			user << "The hatch must be open to insert a power cell."
			return
	else if(istype(I, /obj/item/weapon/screwdriver))
		open = !open
		user.visible_message("[user] [open ? "opens" : "closes"] the hatch on \the [src].", "You [open ? "open" : "close"] the hatch on \the [src].")
		update_icon()
		if(!open && user.machine == src)
			user << browse(null, "window=spaceheater")
			user.unset_machine()
	else
		..()
	return

/obj/machinery/space_heater/attack_hand(mob/user as mob)
	src.add_fingerprint(user)
	if(open)

		var/dat
		dat = "Power cell: "
		if(cell)
			dat += "Installed
"
		else
			dat += "Removed
"

		dat += "Power Level: [cell ? round(cell.percent(),1) : 0]%

"

		dat += "Set Temperature: "

		dat += "-"

		dat += " [set_temperature]°C "
		dat += "+
"

		user.set_machine(src)
		user << browse("<TITLE>Space Heater Control Panel</TITLE><TT>[dat]</TT>", "window=spaceheater")
		onclose(user, "spaceheater")

	else
		on = !on
		user.visible_message("[user] switches [on ? "on" : "off"] \the [src].","You switch [on ? "on" : "off"] \the [src].")
		update_icon()
	return

/obj/machinery/space_heater/Topic(href, href_list)
	if(..())
		return
	usr.set_machine(src)

	switch(href_list["op"])

		if("temp")
			var/value = text2num(href_list["val"])

			// limit to 20-90 degC
			set_temperature = dd_range(20, 90, set_temperature + value)

		if("cellremove")
			if(open && cell && !usr.get_active_hand())
				cell.updateicon()
				usr.put_in_hands(cell)
				cell.add_fingerprint(usr)
				cell = null
				usr.visible_message("[usr] removes the power cell from \the [src].", "You remove the power cell from \the [src].")

		if("cellinstall")
			if(open && !cell)
				var/obj/item/weapon/stock_parts/cell/C = usr.get_active_hand()
				if(istype(C))
					usr.drop_item()
					cell = C
					C.loc = src
					C.add_fingerprint(usr)

					usr.visible_message("[usr] inserts a power cell into \the [src].", "You insert the power cell into \the [src].")

	updateDialog()

/obj/machinery/space_heater/process()
	if(on)
		if(cell && cell.charge > 0)

			var/turf/simulated/L = loc
			if(istype(L))
				var/datum/gas_mixture/env = L.return_air()
				if(env.temperature < (set_temperature+T0C))

					var/transfer_moles = 0.25 * env.total_moles()

					var/datum/gas_mixture/removed = env.remove(transfer_moles)

					//world << "got [transfer_moles] moles at [removed.temperature]"

					if(removed)

						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
							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
						cell.use(heating_power/20000)

						//world << "now at [removed.temperature]"

					env.merge(removed)
					air_update_turf()

					//world << "turf now at [env.temperature]"

		else
			on = 0
			update_icon()

	return


code:
#define CHARS_PER_LINE 5
#define FONT_SIZE "5pt"
#define FONT_COLOR "#09f"
#define FONT_STYLE "Arial Black"
#define SCROLL_SPEED 2

// Status display
// (formerly Countdown timer display)

// Use to show shuttle ETA/ETD times
// Alert status
// And arbitrary messages set by comms computer

/obj/machinery/status_display
	icon = 'icons/obj/status_display.dmi'
	icon_state = "frame"
	name = "status display"
	anchored = 1
	density = 0
	use_power = 1
	idle_power_usage = 10
	var/mode = 1	// 0 = Blank
					// 1 = Shuttle timer
					// 2 = Arbitrary message(s)
					// 3 = alert picture
					// 4 = Supply shuttle timer

	var/picture_state	// icon_state of alert picture
	var/message1 = ""	// message line 1
	var/message2 = ""	// message line 2
	var/index1			// display index for scrolling messages or 0 if non-scrolling
	var/index2

	var/frequency = 1435		// radio frequency
	var/supply_display = 0		// true if a supply shuttle display

	var/friendc = 0      // track if Friend Computer mode

	maptext_height = 26
	maptext_width = 32

	// new display
	// register for radio system

/obj/machinery/status_display/New()
	..()
	spawn(5)	// must wait for map loading to finish
		if(radio_controller)
			radio_controller.add_object(src, frequency)

/obj/machinery/status_display/Destroy()
	if(radio_controller)
		radio_controller.remove_object(src,frequency)
	..()

// timed process

/obj/machinery/status_display/process()
	if(stat & NOPOWER)
		remove_display()
		return
	update()

/obj/machinery/status_display/emp_act(severity)
	if(stat & (BROKEN|NOPOWER))
		..(severity)
		return
	set_picture("ai_bsod")
	..(severity)

// set what is displayed

/obj/machinery/status_display/proc/update()
	if(friendc && mode!=4) //Makes all status displays except supply shuttle timer display the eye -- Urist
		set_picture("ai_friend")
		return

	switch(mode)
		if(0)				//blank
			remove_display()
		if(1)				//emergency shuttle timer
			if(SSshuttle.emergency.timer)
				var/line1
				var/line2 = get_shuttle_timer()
				switch(SSshuttle.emergency.mode)
					if(SHUTTLE_RECALL)
						line1 = "-RCL-"
					if(SHUTTLE_CALL)
						line1 = "-ETA-"
					if(SHUTTLE_DOCKED)
						line1 = "-ETD-"
					if(SHUTTLE_ESCAPE)
						line1 = "-ESC-"
					if(SHUTTLE_STRANDED)
						line1 = "-ERR-"
						line2 = "??:??"
				if(length(line2) > CHARS_PER_LINE)
					line2 = "Error!"
				update_display(line1, line2)
			else
				remove_display()
		if(2)				//custom messages
			var/line1
			var/line2

			if(!index1)
				line1 = message1
			else
				line1 = copytext(message1+"|"+message1, index1, index1+CHARS_PER_LINE)
				var/message1_len = length(message1)
				index1 += SCROLL_SPEED
				if(index1 > message1_len)
					index1 -= message1_len

			if(!index2)
				line2 = message2
			else
				line2 = copytext(message2+"|"+message2, index2, index2+CHARS_PER_LINE)
				var/message2_len = length(message2)
				index2 += SCROLL_SPEED
				if(index2 > message2_len)
					index2 -= message2_len
			update_display(line1, line2)
		if(4)				// supply shuttle timer
			var/line1
			var/line2
			if(SSshuttle.supply.mode == SHUTTLE_IDLE)
				if(SSshuttle.supply.z == ZLEVEL_STATION)
					line1 = "CARGO"
					line2 = "Docked"
			else
				line1 = "CARGO"
				line2 = get_supply_shuttle_timer()
				if(lentext(line2) > CHARS_PER_LINE)
					line2 = "Error"

			update_display(line1, line2)

/obj/machinery/status_display/examine(mob/user)
	. = ..()
	switch(mode)
		if(1,2,4)
			user << "The display says:
\t<xmp>[message1]</xmp>
\t<xmp>[message2]</xmp>"

/obj/machinery/status_display/proc/set_message(m1, m2)
	if(m1)
		index1 = (length(m1) > CHARS_PER_LINE)
		message1 = m1
	else
		message1 = ""
		index1 = 0

	if(m2)
		index2 = (length(m2) > CHARS_PER_LINE)
		message2 = m2
	else
		message2 = ""
		index2 = 0

/obj/machinery/status_display/proc/set_picture(state)
	picture_state = state
	remove_display()
	overlays += image('icons/obj/status_display.dmi', icon_state=picture_state)

/obj/machinery/status_display/proc/update_display(line1, line2)
	var/new_text = {"
[line1]
[line2]
"}
	if(maptext != new_text)
		maptext = new_text

/obj/machinery/status_display/proc/get_shuttle_timer()
	var/timeleft = SSshuttle.emergency.timeLeft()
	if(timeleft > 0)
		return "[add_zero(num2text((timeleft / 60) % 60),2)]:[add_zero(num2text(timeleft % 60), 2)]"
	return "00:00"

/obj/machinery/status_display/proc/get_supply_shuttle_timer()
	var/timeleft = SSshuttle.supply.timeLeft()
	if(timeleft > 0)
		return "[add_zero(num2text((timeleft / 60) % 60),2)]:[add_zero(num2text(timeleft % 60), 2)]"
	return "00:00"

/obj/machinery/status_display/proc/remove_display()
	if(overlays.len)
		overlays.Cut()
	if(maptext)
		maptext = ""

/obj/machinery/status_display/receive_signal(datum/signal/signal)

	switch(signal.data["command"])
		if("blank")
			mode = 0

		if("shuttle")
			mode = 1

		if("message")
			mode = 2
			set_message(signal.data["msg1"], signal.data["msg2"])

		if("alert")
			mode = 3
			set_picture(signal.data["picture_state"])

		if("supply")
			if(supply_display)
				mode = 4

/obj/machinery/ai_status_display
	icon = 'icons/obj/status_display.dmi'
	desc = "A small screen which the AI can use to present itself."
	icon_state = "frame"
	name = "\improper AI display"
	anchored = 1
	density = 0

	var/mode = 0	// 0 = Blank
					// 1 = AI emoticon
					// 2 = Blue screen of death

	var/picture_state	// icon_state of ai picture

	var/emotion = "Neutral"

/obj/machinery/ai_status_display/process()
	if(stat & NOPOWER)
		overlays.Cut()
		return

	update()

/obj/machinery/ai_status_display/emp_act(severity)
	if(stat & (BROKEN|NOPOWER))
		..(severity)
		return
	set_picture("ai_bsod")
	..(severity)

/obj/machinery/ai_status_display/proc/update()

	if(mode==0) //Blank
		overlays.Cut()
		return

	if(mode==1)	// AI emoticon
		switch(emotion)
			if("Very Happy")
				set_picture("ai_veryhappy")
			if("Happy")
				set_picture("ai_happy")
			if("Neutral")
				set_picture("ai_neutral")
			if("Unsure")
				set_picture("ai_unsure")
			if("Confused")
				set_picture("ai_confused")
			if("Sad")
				set_picture("ai_sad")
			if("BSOD")
				set_picture("ai_bsod")
			if("Blank")
				set_picture("ai_off")
			if("Problems?")
				set_picture("ai_trollface")
			if("Awesome")
				set_picture("ai_awesome")
			if("Dorfy")
				set_picture("ai_urist")
			if("Facepalm")
				set_picture("ai_facepalm")
			if("Friend Computer")
				set_picture("ai_friend")
			if("Blue Glow")
				set_picture("ai_sal")
			if("Red Glow")
				set_picture("ai_hal")

		return

	if(mode==2)	// BSOD
		set_picture("ai_bsod")
		return

/obj/machinery/ai_status_display/proc/set_picture(var/state)
	picture_state = state
	if(overlays.len)
		overlays.Cut()
	overlays += image('icons/obj/status_display.dmi', icon_state=picture_state)

#undef CHARS_PER_LINE
#undef FOND_SIZE
#undef FONT_COLOR
#undef FONT_STYLE
#undef SCROLL_SPEED


code:
//////////////////////////////////////
// SUIT STORAGE UNIT /////////////////
//////////////////////////////////////

/obj/machinery/suit_storage_unit
	name = "suit storage unit"
	desc = "An industrial U-Stor-It Storage unit designed to accomodate all kinds of space suits. Its on-board equipment also allows the user to decontaminate the contents through a UV-ray purging cycle. There's a warning label dangling from the control pad, reading \"STRICTLY NO BIOLOGICALS IN THE CONFINES OF THE UNIT\"."
	icon = 'icons/obj/suitstorage.dmi'
	icon_state = "close"
	anchored = 1
	density = 1
	var/mob/living/OCCUPANT = null
	var/obj/item/clothing/suit/space/SUIT = null
	var/SUIT_TYPE = null
	var/obj/item/clothing/head/helmet/space/HELMET = null
	var/HELMET_TYPE = null
	var/obj/item/clothing/mask/MASK = null  //All the stuff that's gonna be stored insiiiiiiiiiiiiiiiiiiide, nyoro~n
	var/MASK_TYPE = null //Erro's idea on standarising SSUs whle keeping creation of other SSU types easy: Make a child SSU, name it something then set the TYPE vars to your desired suit output. New() should take it from there by itself.
	var/obj/item/STORAGE = null  //One-slot storage slot for anything... food not recommended
	var/STORAGE_TYPE = null
	var/isopen = 0
	var/islocked = 0
	var/isUV = 0
	var/ispowered = 1 //starts powered
	var/isbroken = 0
	var/issuperUV = 0
	var/panelopen = 0
	var/safetieson = 1
	var/cycletime_left = 0

//The units themselves/////////////////

/obj/machinery/suit_storage_unit/standard_unit
	SUIT_TYPE = /obj/item/clothing/suit/space/eva
	HELMET_TYPE = /obj/item/clothing/head/helmet/space/eva
	MASK_TYPE = /obj/item/clothing/mask/breath

/obj/machinery/suit_storage_unit/captain
	SUIT_TYPE = /obj/item/clothing/suit/space/captain
	HELMET_TYPE = /obj/item/clothing/head/helmet/space/captain
	MASK_TYPE = /obj/item/clothing/mask/gas
	STORAGE_TYPE = /obj/item/weapon/tank/jetpack/oxygen

/obj/machinery/suit_storage_unit/engine
	SUIT_TYPE = /obj/item/clothing/suit/space/hardsuit
	MASK_TYPE = /obj/item/clothing/mask/breath

/obj/machinery/suit_storage_unit/ce
	SUIT_TYPE = /obj/item/clothing/suit/space/hardsuit/elite
	MASK_TYPE = /obj/item/clothing/mask/breath
	STORAGE_TYPE= /obj/item/clothing/shoes/magboots/advance

/obj/machinery/suit_storage_unit/security
	SUIT_TYPE = /obj/item/clothing/suit/space/hardsuit/security
	MASK_TYPE = /obj/item/clothing/mask/gas/sechailer

/obj/machinery/suit_storage_unit/hos
	SUIT_TYPE = /obj/item/clothing/suit/space/hardsuit/security/hos
	MASK_TYPE = /obj/item/clothing/mask/gas/sechailer

/obj/machinery/suit_storage_unit/atmos
	SUIT_TYPE = /obj/item/clothing/suit/space/hardsuit/atmos
	MASK_TYPE = /obj/item/clothing/mask/gas
	STORAGE_TYPE = /obj/item/weapon/watertank/atmos

/obj/machinery/suit_storage_unit/mining
	SUIT_TYPE = /obj/item/clothing/suit/space/hardsuit/mining
	MASK_TYPE = /obj/item/clothing/mask/breath

/obj/machinery/suit_storage_unit/cmo
	SUIT_TYPE = /obj/item/clothing/suit/space/hardsuit/medical
	MASK_TYPE = /obj/item/clothing/mask/breath

/obj/machinery/suit_storage_unit/syndicate
	SUIT_TYPE = /obj/item/clothing/suit/space/hardsuit/syndi
	MASK_TYPE = /obj/item/clothing/mask/gas/syndicate
	STORAGE_TYPE = /obj/item/weapon/tank/jetpack/oxygen/harness

/obj/machinery/suit_storage_unit/ertCom
	SUIT_TYPE = /obj/item/clothing/suit/space/hardsuit/ert
	MASK_TYPE = /obj/item/clothing/mask/breath
	STORAGE_TYPE = /obj/item/weapon/tank/internals/emergency_oxygen/double

/obj/machinery/suit_storage_unit/ertSec
	SUIT_TYPE = /obj/item/clothing/suit/space/hardsuit/ert/sec
	MASK_TYPE = /obj/item/clothing/mask/breath
	STORAGE_TYPE = /obj/item/weapon/tank/internals/emergency_oxygen/double

/obj/machinery/suit_storage_unit/ertEngi
	SUIT_TYPE = /obj/item/clothing/suit/space/hardsuit/ert/engi
	MASK_TYPE = /obj/item/clothing/mask/breath
	STORAGE_TYPE = /obj/item/weapon/tank/internals/emergency_oxygen/double

/obj/machinery/suit_storage_unit/ertMed
	SUIT_TYPE = /obj/item/clothing/suit/space/hardsuit/ert/med
	MASK_TYPE = /obj/item/clothing/mask/breath
	STORAGE_TYPE = /obj/item/weapon/tank/internals/emergency_oxygen/double

/obj/machinery/suit_storage_unit/New()
	src.update_icon()
	if(SUIT_TYPE)
		SUIT = new SUIT_TYPE(src)
	if(HELMET_TYPE)
		HELMET = new HELMET_TYPE(src)
	if(MASK_TYPE)
		MASK = new MASK_TYPE(src)
	if(STORAGE_TYPE)
		STORAGE = new STORAGE_TYPE(src)

/obj/machinery/suit_storage_unit/update_icon() //overlays yaaaay - Jordie
	src.overlays = 0

	if(!isopen)
		overlays += "close"
	if(OCCUPANT)
		overlays += "human"
	if(OCCUPANT && isUV)
		overlays += "uvhuman"
	if(isUV)
		overlays += "uv"
	if(issuperUV && isUV)
		overlays += "super"
	if(isopen)
		overlays += "open"
		if(SUIT)
			overlays += "suit"
		if(HELMET)
			overlays += "helm"
		if(STORAGE)
			overlays += "storage"
		if(isbroken)
			overlays += "broken"
	return

/obj/machinery/suit_storage_unit/power_change()
	..()
	ispowered = !(stat & NOPOWER)
	if((stat & NOPOWER) && isopen)
		dump_everything()
	update_icon()

/obj/machinery/suit_storage_unit/ex_act(severity, target)
	switch(severity)
		if(1.0)
			if(prob(50))
				src.dump_everything() //So suits dont survive all the time
			qdel(src)
			return
		if(2.0)
			if(prob(50))
				src.dump_everything()
				qdel(src)
			return
		else
			return
	return

/obj/machinery/suit_storage_unit/attack_hand(mob/user as mob)
	var/dat
	if(..())
		return
	if(stat & NOPOWER)
		return
	if(src.panelopen) //The maintenance panel is open. Time for some shady stuff
		dat+= "<TITLE>Suit storage unit: Maintenance panel</TITLE>"
		dat+= "Maintenance panel controls
"
		dat+= "The panel is ridden with controls, button and meters, labeled in strange signs and symbols that
you cannot understand. Probably the manufactoring world's language.
 Among other things, a few controls catch your eye.

"
		dat+= text("A small dial with a \"�\" symbol embroidded on it. It's pointing towards a gauge that reads [].
  Turn towards []
",(src.issuperUV ? "15nm" : "185nm"),src,(src.issuperUV ? "185nm" : "15nm") )
		dat+= text("A thick old-style button, with 2 grimy LED lights next to it. The [] LED is on.
Press button",(src.safetieson? "GREEN" : "RED"),src)
		dat+= text("

Close panel", user)
		//user << browse(dat, "window=ssu_m_panel;size=400x500")
		//onclose(user, "ssu_m_panel")
	else if(src.isUV) //The thing is running its cauterisation cycle. You have to wait.
		dat += "<TITLE>Suit storage unit</TITLE>"
		dat+= "Unit is cauterising contents with selected UV ray intensity. Please wait.
"
		//dat+= "Cycle end in: [src.cycletimeleft()] seconds. "
		//user << browse(dat, "window=ssu_cycling_panel;size=400x500")
		//onclose(user, "ssu_cycling_panel")

	else
		if(!src.isbroken)
			dat+= "<TITLE>Suit storage unit</TITLE>"
			dat+= "U-Stor-It Suit Storage Unit, model DS1900
"
			dat+= "Welcome to the Unit control panel.
"
			dat+= text("Helmet storage compartment: []
",(src.HELMET ? HELMET.name : "No helmet detected.") )
			if(HELMET && src.isopen)
				dat+=text("Dispense helmet
",src)
			dat+= text("Suit storage compartment: []
",(src.SUIT ? SUIT.name : "No exosuit detected.") )
			if(SUIT && src.isopen)
				dat+=text("Dispense suit
",src)
			dat+= text("Breathmask storage compartment: []
",(src.MASK ? MASK.name : "No breathmask detected.") )
			if(MASK && src.isopen)
				dat+=text("Dispense mask
",src)
			dat+= text("Auxiliary storage compartment: []
",(src.STORAGE ? STORAGE.name : "Contents empty.") )
			if(STORAGE && src.isopen)
				dat+=text("Eject contents
",src)
			if(src.OCCUPANT)
				dat+= "
WARNING: Biological entity detected inside the Unit's storage. Please remove.
"
				dat+= "Eject extra load"
			dat+= text("
Unit is: [] - [] Unit ",(src.isopen ? "Open" : "Closed"),src,(src.isopen ? "Close" : "Open"))
			if(src.isopen)
				dat+="
"
			else
				dat+= text(" - *[] Unit*
",src,(src.islocked ? "Unlock" : "Lock") )
			dat+= text("Unit status: []",(src.islocked? "**LOCKED**
" : "**UNLOCKED**
") )
			dat+= text("Start Disinfection cycle
",src)
			dat += text("

Close control panel", user)
			//user << browse(dat, "window=Suit Storage Unit;size=400x500")
			//onclose(user, "Suit Storage Unit")
		else //Ohhhh shit it's dirty or broken! Let's inform the guy.
			dat+= "<TITLE>Suit storage unit</TITLE>"
			dat+= "Unit chamber is too contaminated to continue usage. Please call for a qualified individual to perform maintenance.

"
			dat+= text("
Close control panel", user)
			//user << browse(dat, "window=suit_storage_unit;size=400x500")
			//onclose(user, "suit_storage_unit")

	var/datum/browser/popup = new(user, "suit_storage_unit", "Suit Storage Unit", 440, 500)
	popup.set_content(dat)
	popup.set_title_image(user.browse_rsc_icon(src.icon, src.icon_state))
	popup.open()
	return

/obj/machinery/suit_storage_unit/Topic(href, href_list) //I fucking HATE this proc
	if(..())
		return
	if(usr == src.OCCUPANT) //No unlocking yourself out!
		return
	if ((usr.contents.Find(src) || ((get_dist(src, usr) <= 1) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon/ai)))
		usr.set_machine(src)
		if (href_list["toggleUV"])
			src.toggleUV(usr)
		if (href_list["togglesafeties"])
			src.togglesafeties(usr)
		if (href_list["dispense_helmet"])
			src.dispense_helmet(usr)
		if (href_list["dispense_suit"])
			src.dispense_suit(usr)
		if (href_list["dispense_mask"])
			src.dispense_mask(usr)
		if (href_list["eject_storage"])
			src.eject_storage(usr)
		if (href_list["toggle_open"])
			src.toggle_open(usr)
		if (href_list["toggle_lock"])
			src.toggle_lock(usr)
		if (href_list["start_UV"])
			src.start_UV(usr)
		if (href_list["eject_guy"])
			src.eject_occupant(usr)
		src.updateUsrDialog()
		src.update_icon()
	/*if (href_list["refresh"])
		src.updateUsrDialog()*/
	src.add_fingerprint(usr)
	return

/obj/machinery/suit_storage_unit/proc/toggleUV(mob/user as mob)
//	var/protected = 0
//	var/mob/living/carbon/human/H = user
	if(!src.panelopen)
		return

	/*if(istype(H)) //Let's check if the guy's wearing electrically insulated gloves
		if(H.gloves)
			var/obj/item/clothing/gloves/G = H.gloves
			if(istype(G,/obj/item/clothing/gloves/yellow))
				protected = 1

	if(!protected)
		playsound(src.loc, "sparks", 75, 1, -1)
		user << "You try to touch the controls but you get zapped. There must be a short circuit somewhere."
		return*/
	else  //welp, the guy is protected, we can continue
		if(src.issuperUV)
			user << "You slide the dial back towards \"185nm\"."
			src.issuperUV = 0
		else
			user << "You crank the dial all the way up to \"15nm\"."
			src.issuperUV = 1
		return

/obj/machinery/suit_storage_unit/proc/togglesafeties(mob/user as mob)
//	var/protected = 0
//	var/mob/living/carbon/human/H = user
	if(!src.panelopen) //Needed check due to bugs
		return

	/*if(istype(H)) //Let's check if the guy's wearing electrically insulated gloves
		if(H.gloves)
			var/obj/item/clothing/gloves/G = H.gloves
			if(istype(G,/obj/item/clothing/gloves/yellow) )
				protected = 1

	if(!protected)
		playsound(src.loc, "sparks", 75, 1, -1)
		user << "You try to touch the controls but you get zapped. There must be a short circuit somewhere."
		return*/
	else
		user << "You push the button. The coloured LED next to it changes."
		src.safetieson = !src.safetieson

/obj/machinery/suit_storage_unit/proc/dispense_helmet()
	eject(HELMET)
	HELMET = null

/obj/machinery/suit_storage_unit/proc/dispense_suit()
	eject(SUIT)
	SUIT = null

/obj/machinery/suit_storage_unit/proc/dispense_mask()
	eject(MASK)
	MASK = null

/obj/machinery/suit_storage_unit/proc/eject_storage()
	eject(STORAGE)
	STORAGE = null

/obj/machinery/suit_storage_unit/proc/eject(atom/movable/ITEM)
	if(!loc || !ITEM)
		return
	ITEM.loc = src.loc

/obj/machinery/suit_storage_unit/proc/dump_everything()
	for(var/obj/item/ITEM in src)
		eject(ITEM)
	src.SUIT = null
	src.HELMET = null
	src.MASK = null
	src.STORAGE = null
	if(src.OCCUPANT)
		src.eject_occupant(OCCUPANT)
	return

/obj/machinery/suit_storage_unit/proc/toggle_open(mob/user as mob)
	if(src.islocked || src.isUV)
		user << "Unable to open unit."
		return 0
	if(src.OCCUPANT)
		src.eject_occupant(user)
		return 1  // eject_occupant opens the door, so we need to return
	src.isopen = !src.isopen
	return 1

/obj/machinery/suit_storage_unit/proc/toggle_lock(mob/user as mob)
	if(src.OCCUPANT && src.safetieson)
		user << "The Unit's safety protocols disallow locking when a biological form is detected inside its compartments."
		return
	if(src.isopen)
		return
	src.islocked = !src.islocked
	return

/obj/machinery/suit_storage_unit/proc/start_UV(mob/user as mob)
	if(src.isUV || src.isopen) //I'm bored of all these sanity checks
		return
	if(src.OCCUPANT && src.safetieson)
		user << "WARNING: Biological entity detected in the confines of the Unit's storage. Cannot initiate cycle."
		return
	if(!src.HELMET && !src.MASK && !src.SUIT && !src.STORAGE && !src.OCCUPANT ) //shit's empty yo
		user << "Unit storage bays empty. Nothing to disinfect -- Aborting."
		return
	user << "You start the Unit's cauterisation cycle."
	src.cycletime_left = 20
	src.isUV = 1
	if(src.OCCUPANT && !src.islocked)
		src.islocked = 1 //Let's lock it for good measure
	src.update_icon()
	src.updateUsrDialog()

	var/i //our counter
	spawn(0)
		for(i=0,i<4,++i)
			sleep(50)
			if(src.OCCUPANT)
				var/burndamage = rand(6,10)
				if(src.issuperUV)
					burndamage = rand(28,35)
				if(iscarbon(OCCUPANT))
					OCCUPANT.take_organ_damage(0,burndamage)
					OCCUPANT.emote("scream")
				else
					OCCUPANT.take_organ_damage(burndamage)
			if(i==3) //End of the cycle
				if(!src.issuperUV)
					for(var/obj/item/ITEM in src)
						ITEM.clean_blood()
					if(istype(STORAGE, /obj/item/weapon/reagent_containers/food))
						del(STORAGE)
				else //It was supercycling, destroy everything
					src.HELMET = null
					src.SUIT = null
					src.MASK = null
					del(STORAGE)
					visible_message("With a loud whining noise, the Suit Storage Unit's door grinds open. Puffs of ashen smoke come out of its chamber.", 3)
					src.isbroken = 1
					src.isopen = 1
					src.islocked = 0
					src.eject_occupant(OCCUPANT) //Mixing up these two lines causes bug. DO NOT DO IT.
				src.isUV = 0 //Cycle ends
		src.update_icon()
		src.updateUsrDialog()
		return

/obj/machinery/suit_storage_unit/proc/cycletimeleft()
	if(src.cycletime_left >= 1)
		src.cycletime_left--
	return src.cycletime_left

/obj/machinery/suit_storage_unit/proc/eject_occupant(mob/user as mob)
	if (src.islocked)
		return

	if (!src.OCCUPANT)
		return
//	for(var/obj/O in src)
//		O.loc = src.loc

	if (src.OCCUPANT.client)
		if(user != OCCUPANT)
			OCCUPANT << "The machine kicks you out!"
		if(user.loc != src.loc)
			OCCUPANT << "You leave the not-so-cozy confines of the SSU."

		src.OCCUPANT.client.eye = src.OCCUPANT.client.mob
		src.OCCUPANT.client.perspective = MOB_PERSPECTIVE
	if(src.OCCUPANT.loc == src)
		src.OCCUPANT.loc = src.loc
	src.OCCUPANT = null
	if(!src.isopen)
		src.isopen = 1
	src.update_icon()
	return

/obj/machinery/suit_storage_unit/container_resist()
	var/mob/living/user = usr
	if(islocked)
		user.changeNext_move(CLICK_CD_BREAKOUT)
		user.last_special = world.time + CLICK_CD_BREAKOUT
		var/breakout_time = 2
		user << "You start kicking against the doors to escape! (This will take about [breakout_time] minutes.)"
		visible_message("You see [user] kicking against the doors of \the [src]!")
		if(do_after(user,(breakout_time*60*10)))
			if(!user || user.stat != CONSCIOUS || user.loc != src || isopen || !islocked)
				return
			else
				isopen = 1
				islocked = 0
				visible_message("[user] successfully broke out of [src]!")

		else
			return
	src.eject_occupant(user)
	add_fingerprint(user)
	src.updateUsrDialog()
	src.update_icon()
	return

/obj/machinery/suit_storage_unit/MouseDrop_T(mob/M as mob, mob/user as mob)
	store_mob(M, user)

/obj/machinery/suit_storage_unit/proc/store_mob(mob/living/M as mob, mob/user as mob)
	if(!istype(M))
		return
	if (user.stat != 0)
		return
	if (!src.isopen)
		user << "The unit's doors are shut."
		return
	if (!src.ispowered || src.isbroken)
		user << "The unit is not operational."
		return
	if ( (src.OCCUPANT) || (src.HELMET) || (src.SUIT) || (src.STORAGE))
		user << "It's too cluttered inside to fit in!"
		return
	if(M == user)
		visible_message("[user] starts squeezing into the suit storage unit!", 3)
	else
		visible_message("[user] starts putting [M.name] into the Suit Storage Unit.", 3)
	if(do_mob(user, M, 10))
		user.stop_pulling()
		if(M.client)
			M.client.perspective = EYE_PERSPECTIVE
			M.client.eye = src
		M.loc = src
		src.OCCUPANT = M
		src.isopen = 0 //Close the thing after the guy gets inside
		src.update_icon()

		src.add_fingerprint(user)
		src.updateUsrDialog()
		return
	return

/obj/machinery/suit_storage_unit/attackby(obj/item/I as obj, mob/user as mob, params)
	if(!src.ispowered)
		if(istype(I, /obj/item/weapon/crowbar) && !isopen)
			if(toggle_open(user))
				dump_everything()
				user << text("You pry \the [src] open.")
				update_icon()
		return
	if(istype(I, /obj/item/weapon/screwdriver))
		src.panelopen = !src.panelopen
		playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1)
		user << text("You [] the unit's maintenance panel.",(src.panelopen ? "open up" : "close") )
		src.updateUsrDialog()
		return
	if ( istype(I, /obj/item/weapon/grab) )
		var/obj/item/weapon/grab/G = I
		store_mob(G.affecting, user)
		return
	if( istype(I,/obj/item/clothing/suit/space) )
		if(!src.isopen || src.isbroken)
			return
		var/obj/item/clothing/suit/space/S = I
		if(src.SUIT)
			user << "The unit already contains a suit."
			return
		if(!user.drop_item())
			user << "\The [S] is stuck to your hand, you cannot put it in the Suit Storage Unit!"
			return
		user << "You load the [S.name] into the suit storage compartment."
		S.loc = src
		src.SUIT = S
		src.update_icon()
		src.updateUsrDialog()
		return
	if( istype(I,/obj/item/clothing/head/helmet) )
		if(!src.isopen || src.isbroken)
			return
		var/obj/item/clothing/head/helmet/H = I
		if(src.HELMET)
			user << "The unit already contains a helmet."
			return
		if(!user.drop_item())
			user << "\The [H] is stuck to your hand, you cannot put it in the Suit Storage Unit!"
			return
		user << "You load the [H.name] into the helmet storage compartment."
		H.loc = src
		src.HELMET = H
		src.update_icon()
		src.updateUsrDialog()
		return
	if( istype(I,/obj/item/clothing/mask) )
		if(!src.isopen || src.isbroken)
			return
		var/obj/item/clothing/mask/M = I
		if(src.MASK)
			user << "The unit already contains a mask."
			return
		if(!user.drop_item())
			user << "\The [M] is stuck to your hand, you cannot put it in the Suit Storage Unit!"
			return
		user << "You load the [M.name] into the mask storage compartment."
		M.loc = src
		src.MASK = M
		src.update_icon()
		src.updateUsrDialog()
		return
	if( istype(I,/obj/item) )
		if(!src.isopen || src.isbroken)
			return
		var/obj/item/ITEM = I
		if(src.STORAGE)
			user << "The auxiliary storage compartment is full."
			return
		if(!user.drop_item())
			user << "\The [ITEM] is stuck to your hand, you cannot put it in the Suit Storage Unit!"
			return
		user << "You load the [ITEM.name] into the auxiliary storage compartment."
		ITEM.loc = src
		src.STORAGE = ITEM
	src.update_icon()
	src.updateUsrDialog()
	return

/obj/machinery/suit_storage_unit/attack_ai(mob/user as mob)
	return src.attack_hand(user)

/obj/machinery/suit_storage_unit/attack_paw(mob/user as mob)
	user << "The console controls are far too complicated for your tiny brain!"
	return

//////////////////////////////REMINDER: Make it lock once you place some fucker inside.


code:
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:31

//  Beacon randomly spawns in space
//	When a non-traitor (no special role in /mind) uses it, he is given the choice to become a traitor
//	If he accepts there is a random chance he will be accepted, rejected, or rejected and killed
//	Bringing certain items can help improve the chance to become a traitor

/obj/machinery/syndicate_beacon
	name = "ominous beacon"
	desc = "This looks suspicious..."
	icon = 'icons/obj/device.dmi'
	icon_state = "syndbeacon"

	anchored = 1
	density = 1

	var/temptext = ""
	var/selfdestructing = 0
	var/charges = 1

/obj/machinery/syndicate_beacon/attack_hand(var/mob/user as mob)
	usr.set_machine(src)
	var/dat = "Scanning [pick("retina pattern", "voice print", "fingerprints", "dna sequence")]...
Identity confirmed,
"
	if(istype(user, /mob/living/carbon/human) || istype(user, /mob/living/silicon/ai))
		if(is_special_character(user))
			dat += "Operative record found. Greetings, Agent [user.name].
"
		else if(charges < 1)
			dat += "<TT>Connection severed.</TT>
"
		else
			var/honorific = "Mr."
			if(user.gender == FEMALE)
				honorific = "Ms."
			dat += "Identity not found in operative database. What can the Syndicate do for you today, [honorific] [user.name]?
"
			if(!selfdestructing)
				dat += "

\"[pick("I want to switch teams.", "I want to work for you.", "Let me join you.", "I can be of use to you.", "You want me working for you, and here's why...", "Give me an objective.", "How's the 401k over at the Syndicate?")]\"
"
	dat += temptext
	user << browse(dat, "window=syndbeacon")
	onclose(user, "syndbeacon")

/obj/machinery/syndicate_beacon/Topic(href, href_list)
	if(..())
		return
	if(href_list["betraitor"])
		if(charges < 1)
			src.updateUsrDialog()
			return
		var/mob/M = locate(href_list["traitormob"])
		if(M.mind.special_role)
			temptext = "We have no need for you at this time. Have a pleasant day.
"
			src.updateUsrDialog()
			return
		charges -= 1
		switch(rand(1,2))
			if(1)
				temptext = "Double-crosser. You planned to betray us from the start. Allow us to repay the favor in kind."
				src.updateUsrDialog()
				spawn(rand(50,200)) selfdestruct()
				return
		if(istype(M, /mob/living/carbon/human))
			var/mob/living/carbon/human/N = M
			ticker.mode.equip_traitor(N)
			ticker.mode.traitors += N.mind
			N.mind.special_role = "traitor"
			var/objective = "Free Objective"
			switch(rand(1,100))
				if(1 to 50)
					objective = "Steal [pick("a hand teleporter", "the Captain's antique laser gun", "a jetpack", "the Captain's ID", "the Captain's jumpsuit")]."
				if(51 to 60)
					objective = "Destroy 70% or more of the station's plasma tanks."
				if(61 to 70)
					objective = "Cut power to 80% or more of the station's tiles."
				if(71 to 80)
					objective = "Destroy the AI."
				if(81 to 90)
					objective = "Kill all monkeys aboard the station."
				else
					objective = "Make certain at least 80% of the station evacuates on the shuttle."
			var/datum/objective/custom_objective = new(objective)
			custom_objective.owner = N.mind
			N.mind.objectives += custom_objective

			var/datum/objective/escape/escape_objective = new
			escape_objective.owner = N.mind
			N.mind.objectives += escape_objective

			M << "You have joined the ranks of the Syndicate and become a traitor to the station!"

			var/obj_count = 1
			for(var/datum/objective/OBJ in M.mind.objectives)
				M << "Objective #[obj_count]: [OBJ.explanation_text]"
				obj_count++

	src.updateUsrDialog()
	return

/obj/machinery/syndicate_beacon/proc/selfdestruct()
	selfdestructing = 1
	spawn() explosion(src.loc, rand(3,8), rand(1,3), 1, 10)

////////////////////////////////////////
//Singularity beacon
////////////////////////////////////////
/obj/machinery/power/singularity_beacon
	name = "ominous beacon"
	desc = "This looks suspicious..."
	icon = 'icons/obj/singularity.dmi'
	icon_state = "beacon"

	anchored = 0
	density = 1
	layer = MOB_LAYER - 0.1 //so people can't hide it and it's REALLY OBVIOUS
	stat = 0

	var/active = 0
	var/icontype = "beacon"

/obj/machinery/power/singularity_beacon/proc/Activate(mob/user = null)
	if(surplus() < 1500)
		if(user) user << "The connected wire doesn't have enough current."
		return
	for(var/obj/singularity/singulo in world)
		if(singulo.z == z)
			singulo.target = src
	icon_state = "[icontype]1"
	active = 1
	machines |= src
	if(user)
		user << "You activate the beacon."

/obj/machinery/power/singularity_beacon/proc/Deactivate(mob/user = null)
	for(var/obj/singularity/singulo in world)
		if(singulo.target == src)
			singulo.target = null
	icon_state = "[icontype]0"
	active = 0
	if(user)
		user << "You deactivate the beacon."

/obj/machinery/power/singularity_beacon/attack_ai(mob/user as mob)
	return

/obj/machinery/power/singularity_beacon/attack_hand(var/mob/user as mob)
	if(anchored)
		return active ? Deactivate(user) : Activate(user)
	else
		user << "You need to screw the beacon to the floor first!"
		return

/obj/machinery/power/singularity_beacon/attackby(obj/item/weapon/W as obj, mob/user as mob, params)
	if(istype(W,/obj/item/weapon/screwdriver))
		if(active)
			user << "You need to deactivate the beacon first!"
			return

		if(anchored)
			anchored = 0
			user << "You unscrew the beacon from the floor."
			disconnect_from_network()
			return
		else
			if(!connect_to_network())
				user << "This device must be placed over an exposed cable."
				return
			anchored = 1
			user << "You screw the beacon to the floor and attach the cable."
			return
	..()
	return

/obj/machinery/power/singularity_beacon/Destroy()
	if(active)
		Deactivate()
	..()

//stealth direct power usage
/obj/machinery/power/singularity_beacon/process()
	if(!active)
		return PROCESS_KILL
	else
		if(surplus() > 1500)
			add_load(1500)
		else
			Deactivate()

/obj/machinery/power/singularity_beacon/syndicate
	icontype = "beaconsynd"
	icon_state = "beaconsynd0"

// SINGULO BEACON SPAWNER
/obj/item/device/sbeacondrop
	name = "suspicious beacon"
	icon = 'icons/obj/radio.dmi'
	icon_state = "beacon"
	desc = "A label on it reads: Warning: Activating this device will send a special beacon to your location."
	origin_tech = "bluespace=1;syndicate=7"
	w_class = 2
	var/droptype = /obj/machinery/power/singularity_beacon/syndicate

/obj/item/device/sbeacondrop/attack_self(mob/user as mob)
	if(user)
		user << "Locked In."
		new droptype( user.loc )
		playsound(src, 'sound/effects/pop.ogg', 100, 1, 1)
		qdel(src)
	return

/obj/item/device/sbeacondrop/bomb
	desc = "A label on it reads: Warning: Activating this device will send a high-ordinance explosive to your location."
	droptype = /obj/machinery/syndicatebomb