code:
/obj/structure/door_assembly
	name = "airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/public.dmi'
	icon_state = "construction"
	var/overlays_file = 'icons/obj/doors/airlocks/station/overlays.dmi'
	anchored = 0
	density = 1
	var/state = 0
	var/mineral = null
	var/typetext = ""
	var/icontext = ""
	var/obj/item/weapon/electronics/airlock/electronics = null
	var/airlock_type = /obj/machinery/door/airlock //the type path of the airlock once completed
	var/glass_type = /obj/machinery/door/airlock/glass
	var/created_name = null
	var/heat_proof_finished = 0 //whether to heat-proof the finished airlock
	var/material = null //icon state logic

/obj/structure/door_assembly/New()
	update_icon()

/obj/structure/door_assembly/door_assembly_0
	name = "airlock assembly"
	airlock_type = /obj/machinery/door/airlock
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_com
	name = "command airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/command.dmi'
	typetext = "command"
	icontext = "com"
	glass_type = /obj/machinery/door/airlock/glass_command
	airlock_type = /obj/machinery/door/airlock/command
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_com/glass
	mineral = "glass"
	material = "glass"

/obj/structure/door_assembly/door_assembly_sec
	name = "security airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/security.dmi'
	typetext = "security"
	icontext = "sec"
	glass_type = /obj/machinery/door/airlock/glass_security
	airlock_type = /obj/machinery/door/airlock/security
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_sec/glass
	mineral = "glass"
	material = "glass"

/obj/structure/door_assembly/door_assembly_eng
	name = "engineering airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/engineering.dmi'
	typetext = "engineering"
	icontext = "eng"
	glass_type = /obj/machinery/door/airlock/glass_engineering
	airlock_type = /obj/machinery/door/airlock/engineering
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_eng/glass
	mineral = "glass"
	material = "glass"

/obj/structure/door_assembly/door_assembly_min
	name = "mining airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/mining.dmi'
	typetext = "mining"
	icontext = "min"
	glass_type = /obj/machinery/door/airlock/glass_mining
	airlock_type = /obj/machinery/door/airlock/mining
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_min/glass
	mineral = "glass"
	material = "glass"

/obj/structure/door_assembly/door_assembly_atmo
	name = "atmospherics airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/atmos.dmi'
	typetext = "atmos"
	icontext = "atmo"
	glass_type = /obj/machinery/door/airlock/glass_atmos
	airlock_type = /obj/machinery/door/airlock/atmos
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_atmo/glass
	mineral = "glass"
	material = "glass"

/obj/structure/door_assembly/door_assembly_research
	name = "research airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/research.dmi'
	typetext = "research"
	icontext = "res"
	glass_type = /obj/machinery/door/airlock/glass_research
	airlock_type = /obj/machinery/door/airlock/research
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_research/glass
	mineral = "glass"
	material = "glass"

/obj/structure/door_assembly/door_assembly_science
	name = "science airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/science.dmi'
	typetext = "science"
	icontext = "sci"
	glass_type = /obj/machinery/door/airlock/glass_science
	airlock_type = /obj/machinery/door/airlock/science
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_science/glass
	mineral = "glass"
	material = "glass"

/obj/structure/door_assembly/door_assembly_med
	name = "medical airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/medical.dmi'
	typetext = "medical"
	icontext = "med"
	glass_type = /obj/machinery/door/airlock/glass_medical
	airlock_type = /obj/machinery/door/airlock/medical
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_med/glass
	mineral = "glass"
	material = "glass"

/obj/structure/door_assembly/door_assembly_mai
	name = "maintenance airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/maintenance.dmi'
	typetext = "maintenance"
	icontext = "mai"
	glass_type = /obj/machinery/door/airlock/glass_maintenance
	airlock_type = /obj/machinery/door/airlock/maintenance
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_mai/glass
	mineral = "glass"
	material = "glass"

/obj/structure/door_assembly/door_assembly_ext
	name = "external airlock assembly"
	icon = 'icons/obj/doors/airlocks/external/external.dmi'
	overlays_file = 'icons/obj/doors/airlocks/external/overlays.dmi'
	typetext = "external"
	icontext = "ext"
	glass_type = /obj/machinery/door/airlock/glass_external
	airlock_type = /obj/machinery/door/airlock/external
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_ext/glass
	mineral = "glass"
	material = "glass"

/obj/structure/door_assembly/door_assembly_fre
	name = "freezer airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/freezer.dmi'
	typetext = "freezer"
	icontext = "fre"
	airlock_type = /obj/machinery/door/airlock/freezer
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_hatch
	name = "airtight hatch assembly"
	icon = 'icons/obj/doors/airlocks/hatch/centcom.dmi'
	overlays_file = 'icons/obj/doors/airlocks/hatch/overlays.dmi'
	typetext = "hatch"
	icontext = "hatch"
	airlock_type = /obj/machinery/door/airlock/hatch
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_mhatch
	name = "maintenance hatch assembly"
	icon = 'icons/obj/doors/airlocks/hatch/maintenance.dmi'
	overlays_file = 'icons/obj/doors/airlocks/hatch/overlays.dmi'
	typetext = "maintenance_hatch"
	icontext = "mhatch"
	airlock_type = /obj/machinery/door/airlock/maintenance_hatch
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_glass
	name = "glass airlock assembly"
	icon = 'icons/obj/doors/airlocks/station2/glass.dmi'
	overlays_file = 'icons/obj/doors/airlocks/station2/overlays.dmi'
	airlock_type = /obj/machinery/door/airlock/glass
	anchored = 1
	state = 1
	mineral = "glass"
	material = "glass"

/obj/structure/door_assembly/door_assembly_gold
	name = "gold airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/gold.dmi'
	airlock_type = /obj/machinery/door/airlock/gold
	anchored = 1
	state = 1
	mineral = "gold"

/obj/structure/door_assembly/door_assembly_silver
	name = "silver airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/silver.dmi'
	airlock_type = /obj/machinery/door/airlock/silver
	anchored = 1
	state = 1
	mineral = "silver"

/obj/structure/door_assembly/door_assembly_diamond
	name = "diamond airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/diamond.dmi'
	airlock_type = /obj/machinery/door/airlock/diamond
	anchored = 1
	state = 1
	mineral = "diamond"

/obj/structure/door_assembly/door_assembly_uranium
	name = "uranium airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/uranium.dmi'
	airlock_type = /obj/machinery/door/airlock/uranium
	anchored = 1
	state = 1
	mineral = "uranium"

/obj/structure/door_assembly/door_assembly_plasma
	name = "plasma airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/plasma.dmi'
	airlock_type = /obj/machinery/door/airlock/plasma
	anchored = 1
	state = 1
	mineral = "plasma"

/obj/structure/door_assembly/door_assembly_clown
	name = "bananium airlock assembly"
	desc = "Honk"
	icon = 'icons/obj/doors/airlocks/station/bananium.dmi'
	airlock_type = /obj/machinery/door/airlock/clown
	anchored = 1
	state = 1
	mineral = "bananium"

/obj/structure/door_assembly/door_assembly_sandstone
	name = "sandstone airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/sandstone.dmi'
	airlock_type = /obj/machinery/door/airlock/sandstone
	anchored = 1
	state = 1
	mineral = "sandstone"

/obj/structure/door_assembly/door_assembly_highsecurity // Borrowing this until WJohnston makes sprites for the assembly
	name = "high security airlock assembly"
	icon = 'icons/obj/doors/airlocks/highsec/highsec.dmi'
	overlays_file = 'icons/obj/doors/airlocks/highsec/overlays.dmi'
	typetext = "highsecurity"
	icontext = "highsec"
	airlock_type = /obj/machinery/door/airlock/highsecurity
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_vault
	name = "vault door assembly"
	icon = 'icons/obj/doors/airlocks/vault/vault.dmi'
	overlays_file = 'icons/obj/doors/airlocks/vault/overlays.dmi'
	typetext = "vault"
	icontext = "vault"
	airlock_type = /obj/machinery/door/airlock/vault
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_shuttle
	name = "shuttle airlock assembly"
	icon = 'icons/obj/doors/airlocks/shuttle/shuttle.dmi'
	overlays_file = 'icons/obj/doors/airlocks/shuttle/overlays.dmi'
	typetext = "shuttle"
	icontext = "shuttle"
	airlock_type = /obj/machinery/door/airlock/shuttle
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_cult
	name = "cult airlock assembly"
	icon = 'icons/obj/doors/airlocks/cult/runed/cult.dmi'
	overlays_file = 'icons/obj/doors/airlocks/cult/runed/overlays.dmi'
	typetext = "cult"
	icontext = "cult"
	airlock_type = /obj/machinery/door/airlock/cult
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_cult/glass
	mineral = "glass"
	material = "glass"

/obj/structure/door_assembly/door_assembly_cult/unruned
	icon = 'icons/obj/doors/airlocks/cult/unruned/cult.dmi'
	overlays_file = 'icons/obj/doors/airlocks/cult/unruned/overlays.dmi'

/obj/structure/door_assembly/door_assembly_cult/unruned/glass
	mineral = "glass"
	material = "glass"

/obj/structure/door_assembly/door_assembly_wood
	name = "wooden airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/wood.dmi'
	airlock_type = /obj/machinery/door/airlock/wood
	anchored = 1
	state = 1
	mineral = "wood"

/obj/structure/door_assembly/door_assembly_viro
	name = "virology airlock assembly"
	icon = 'icons/obj/doors/airlocks/station/virology.dmi'
	typetext = "virology"
	icontext = "viro"
	glass_type = /obj/machinery/door/airlock/glass_virology
	airlock_type = /obj/machinery/door/airlock/virology
	anchored = 1
	state = 1

/obj/structure/door_assembly/door_assembly_viro/glass
	mineral = "glass"
	material = "glass"

/obj/structure/door_assembly/door_assembly_centcom
	typetext = "centcom"
	icon = 'icons/obj/doors/airlocks/centcom/centcom.dmi'
	overlays_file = 'icons/obj/doors/airlocks/centcom/overlays.dmi'
	icontext = "ele"
	airlock_type = /obj/machinery/door/airlock/centcom
	anchored = 1
	state = 1

/obj/structure/door_assembly/attackby(obj/item/W, mob/user, params)
	if(istype(W, /obj/item/weapon/pen))
		var/t = stripped_input(user, "Enter the name for the door.", src.name, src.created_name,MAX_NAME_LEN)
		if(!t)
			return
		if(!in_range(src, usr) && src.loc != usr)
			return
		created_name = t
		return

	else if(istype(W, /obj/item/weapon/airlock_painter)) // |- Ricotez
	//INFORMATION ABOUT ADDING A NEW AIRLOCK TO THE PAINT LIST:
	//If your airlock has a regular version, add it to the list with regular versions.
	//If your airlock has a glass version, add it to the list with glass versions.
	//Don't forget to also set has_solid and has_glass to the proper value.
	//Do NOT add your airlock to a list if it does not have a version for that list,
	//	or you will get broken icons.
		var/obj/item/weapon/airlock_painter/WT = W
		if(WT.can_use(user))
			var/icontype
			var/optionlist
			if(mineral && mineral == "glass")
				//These airlocks have a glass version.
				optionlist = list("Public", "Public2", "Engineering", "Atmospherics", "Security", "Command", "Medical", "Research", "Science", "Mining")
			else
				//These airlocks have a regular version.
				optionlist = list("Public", "Engineering", "Atmospherics", "Security", "Command", "Medical", "Research", "Science", "Mining", "Maintenance", "External", "High Security")

			icontype = input(user, "Please select a paintjob for this airlock.") in optionlist
			if((!in_range(src, usr) && src.loc != usr) || !WT.use(user))
				return
			var/has_solid = 0
			var/has_glass = 0
			switch(icontype)
				if("Public")
					icon = 'icons/obj/doors/airlocks/station/public.dmi'
					overlays_file = 'icons/obj/doors/airlocks/station/overlays.dmi'
					typetext = ""
					icontext = ""
					has_solid = 1
					has_glass = 1
				if("Public2")
					icon = 'icons/obj/doors/airlocks/station2/glass.dmi'
					overlays_file = 'icons/obj/doors/airlocks/station2/overlays.dmi'
					typetext = ""
					icontext = ""
					has_solid = 1
					has_glass = 1
				if("Engineering")
					icon = 'icons/obj/doors/airlocks/station/engineering.dmi'
					overlays_file = 'icons/obj/doors/airlocks/station/overlays.dmi'
					typetext = "engineering"
					icontext = "eng"
					has_solid = 1
					has_glass = 1
				if("Atmospherics")
					icon = 'icons/obj/doors/airlocks/station/atmos.dmi'
					overlays_file = 'icons/obj/doors/airlocks/station/overlays.dmi'
					typetext = "atmos"
					icontext = "atmo"
					has_solid = 1
					has_glass = 1
				if("Security")
					icon = 'icons/obj/doors/airlocks/station/security.dmi'
					overlays_file = 'icons/obj/doors/airlocks/station/overlays.dmi'
					typetext = "security"
					icontext = "sec"
					has_solid = 1
					has_glass = 1
				if("Command")
					icon = 'icons/obj/doors/airlocks/station/command.dmi'
					overlays_file = 'icons/obj/doors/airlocks/station/overlays.dmi'
					typetext = "command"
					icontext = "com"
					has_solid = 1
					has_glass = 1
				if("Medical")
					icon = 'icons/obj/doors/airlocks/station/medical.dmi'
					overlays_file = 'icons/obj/doors/airlocks/station/overlays.dmi'
					typetext = "medical"
					icontext = "med"
					has_solid = 1
					has_glass = 1
				if("Research")
					icon = 'icons/obj/doors/airlocks/station/research.dmi'
					overlays_file = 'icons/obj/doors/airlocks/station/overlays.dmi'
					typetext = "research"
					icontext = "res"
					has_solid = 1
					has_glass = 1
				if("Science")
					icon = 'icons/obj/doors/airlocks/station/science.dmi'
					overlays_file = 'icons/obj/doors/airlocks/station/overlays.dmi'
					typetext = "research"
					icontext = "res"
					has_solid = 1
					has_glass = 1
				if("Mining")
					icon = 'icons/obj/doors/airlocks/station/mining.dmi'
					overlays_file = 'icons/obj/doors/airlocks/station/overlays.dmi'
					typetext = "mining"
					icontext = "min"
					has_solid = 1
					has_glass = 1
				if("Maintenance")
					icon = 'icons/obj/doors/airlocks/station/maintenance.dmi'
					overlays_file = 'icons/obj/doors/airlocks/station/overlays.dmi'
					typetext = "maintenance"
					icontext = "mai"
					has_solid = 1
					has_glass = 0
				if("External")
					icon = 'icons/obj/doors/airlocks/external/external.dmi'
					overlays_file = 'icons/obj/doors/airlocks/external/overlays.dmi'
					typetext = "external"
					icontext = "ext"
					has_solid = 1
					has_glass = 0
				if("High Security")
					icon = 'icons/obj/doors/airlocks/highsec/highsec.dmi'
					overlays_file = 'icons/obj/doors/airlocks/highsec/overlays.dmi'
					typetext = "highsecurity"
					icontext = "highsec"
					has_solid = 1
					has_glass = 0
			if(has_solid)
				airlock_type = text2path("/obj/machinery/door/airlock/[typetext]")
			else
				airlock_type = /obj/machinery/door/airlock

			if(has_glass)
				glass_type = text2path("/obj/machinery/door/airlock/glass_[typetext]")
			else
				glass_type = /obj/machinery/door/airlock/glass

			if(mineral && mineral != "glass")
				mineral = null //I know this is stupid, but until we change glass to a boolean it's how this code works.
			user << "You change the paintjob on the airlock assembly."

	else if(istype(W, /obj/item/weapon/weldingtool) && !anchored )
		var/obj/item/weapon/weldingtool/WT = W
		if(WT.remove_fuel(0,user))
			user.visible_message("[user] disassembles the airlock assembly.", \
								"You start to disassemble the airlock assembly...")
			playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1)

			if(do_after(user, 40/W.toolspeed, target = src))
				if( !WT.isOn() )
					return
				user << "You disassemble the airlock assembly."
				new /obj/item/stack/sheet/metal(get_turf(src), 4)
				if (mineral)
					if (mineral == "glass")
						if (heat_proof_finished)
							new /obj/item/stack/sheet/rglass(get_turf(src))
						else
							new /obj/item/stack/sheet/glass(get_turf(src))
					else
						var/M = text2path("/obj/item/stack/sheet/mineral/[mineral]")
						new M(get_turf(src))
						new M(get_turf(src))
				qdel(src)
		else
			return

	else if(istype(W, /obj/item/weapon/wrench) && !anchored )
		var/door_check = 1
		for(var/obj/machinery/door/D in loc)
			if(!D.sub_door)
				door_check = 0
				break

		if(door_check)
			playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1)
			user.visible_message("[user] secures the airlock assembly to the floor.", \
								 "You start to secure the airlock assembly to the floor...", \
								 "You hear wrenching.")

			if(do_after(user, 40/W.toolspeed, target = src))
				if( src.anchored )
					return
				user << "You secure the airlock assembly."
				src.name = "secured airlock assembly"
				src.anchored = 1
		else
			user << "There is another door here!"

	else if(istype(W, /obj/item/weapon/wrench) && anchored )
		playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1)
		user.visible_message("[user] unsecures the airlock assembly from the floor.", \
							 "You start to unsecure the airlock assembly from the floor...", \
							 "You hear wrenching.")
		if(do_after(user, 40/W.toolspeed, target = src))
			if( !src.anchored )
				return
			user << "You unsecure the airlock assembly."
			src.name = "airlock assembly"
			src.anchored = 0

	else if(istype(W, /obj/item/stack/cable_coil) && state == 0 && anchored )
		var/obj/item/stack/cable_coil/C = W
		if (C.get_amount() < 1)
			user << "You need one length of cable to wire the airlock assembly!"
			return
		user.visible_message("[user] wires the airlock assembly.", \
							"You start to wire the airlock assembly...")
		if(do_after(user, 40, target = src))
			if(C.get_amount() < 1 || state != 0) return
			C.use(1)
			src.state = 1
			user << "You wire the airlock assembly."
			src.name = "wired airlock assembly"

	else if(istype(W, /obj/item/weapon/wirecutters) && state == 1 )
		playsound(src.loc, 'sound/items/Wirecutter.ogg', 100, 1)
		user.visible_message("[user] cuts the wires from the airlock assembly.", \
							"You start to cut the wires from the airlock assembly...")

		if(do_after(user, 40/W.toolspeed, target = src))
			if( src.state != 1 )
				return
			user << "You cut the wires from the airlock assembly."
			new/obj/item/stack/cable_coil(get_turf(user), 1)
			src.state = 0
			src.name = "secured airlock assembly"

	else if(istype(W, /obj/item/weapon/electronics/airlock) && state == 1 )
		playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1)
		user.visible_message("[user] installs the electronics into the airlock assembly.", \
							"You start to install electronics into the airlock assembly...")
		if(do_after(user, 40, target = src))
			if( src.state != 1 )
				return
			if(!user.drop_item())
				return

			W.loc = src
			user << "You install the airlock electronics."
			src.state = 2
			src.name = "near finished airlock assembly"
			src.electronics = W

	else if(istype(W, /obj/item/weapon/crowbar) && state == 2 )
		playsound(src.loc, 'sound/items/Crowbar.ogg', 100, 1)
		user.visible_message("[user] removes the electronics from the airlock assembly.", \
								"You start to remove electronics from the airlock assembly...")

		if(do_after(user, 40/W.toolspeed, target = src))
			if( src.state != 2 )
				return
			user << "You remove the airlock electronics."
			src.state = 1
			src.name = "wired airlock assembly"
			var/obj/item/weapon/electronics/airlock/ae
			if (!electronics)
				ae = new/obj/item/weapon/electronics/airlock( src.loc )
			else
				ae = electronics
				electronics = null
				ae.loc = src.loc
	else if(istype(W, /obj/item/stack/sheet) && !mineral)
		var/obj/item/stack/sheet/G = W
		if(G)
			if(G.get_amount() >= 1)
				if(istype(G, /obj/item/stack/sheet/rglass) || istype(G, /obj/item/stack/sheet/glass))
					playsound(src.loc, 'sound/items/Crowbar.ogg', 100, 1)
					user.visible_message("[user] adds [G.name] to the airlock assembly.", \
										"You start to install [G.name] into the airlock assembly...")
					if(do_after(user, 40, target = src))
						if(G.get_amount() < 1 || mineral) return
						if (G.type == /obj/item/stack/sheet/rglass)
							user << "You install reinforced glass windows into the airlock assembly."
							heat_proof_finished = 1 //reinforced glass makes the airlock heat-proof
							name = "near finished heat-proofed window airlock assembly"
						else
							user << "You install regular glass windows into the airlock assembly."
							name = "near finished window airlock assembly"
						G.use(1)
						mineral = "glass"
						material = "glass"
						//This list contains the airlock paintjobs that have a glass version:
						if(icontext in list("eng", "atmo", "sec", "com", "med", "res", "min"))
							src.airlock_type = text2path("/obj/machinery/door/airlock/[typetext]")
							src.glass_type = text2path("/obj/machinery/door/airlock/glass_[typetext]")
						else
							//This airlock is default or does not have a glass version, so we revert to the default glass airlock. |- Ricotez
							airlock_type = /obj/machinery/door/airlock
							glass_type = /obj/machinery/door/airlock/glass
							typetext = ""
							icontext = ""
				else if(istype(G, /obj/item/stack/sheet/mineral))
					var/M = G.sheettype
					if(G.get_amount() >= 2)
						playsound(src.loc, 'sound/items/Crowbar.ogg', 100, 1)
						user.visible_message("[user] adds [G.name] to the airlock assembly.", \
										 "You start to install [G.name] into the airlock assembly...")
						if(do_after(user, 40, target = src))
							if(G.get_amount() < 2 || mineral) return
							user << "You install [M] plating into the airlock assembly."
							G.use(2)
							mineral = "[M]"
							name = "near finished [M] airlock assembly"
							airlock_type = text2path ("/obj/machinery/door/airlock/[M]")
							glass_type = /obj/machinery/door/airlock/glass

	else if(istype(W, /obj/item/weapon/screwdriver) && state == 2 )
		playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1)
		user.visible_message("[user] finishes the airlock.", \
							 "You start finishing the airlock...")

		if(do_after(user, 40/W.toolspeed, target = src))
			if(src.loc && state == 2)
				user << "You finish the airlock."
				var/obj/machinery/door/airlock/door
				if(mineral == "glass")
					door = new src.glass_type( src.loc )
				else
					door = new src.airlock_type( src.loc )
				//door.req_access = src.req_access
				door.electronics = src.electronics
				door.heat_proof = src.heat_proof_finished
				if(src.electronics.one_access)
					door.req_one_access = src.electronics.accesses
				else
					door.req_access = src.electronics.accesses
				if(created_name)
					door.name = created_name
				src.electronics.loc = door
				qdel(src)
	else
		..()
	update_icon()

/obj/structure/door_assembly/update_icon()
	overlays.Cut()
	if(!material)
		overlays += get_airlock_overlay("fill_construction", icon)
	else
		overlays += get_airlock_overlay("[material]_construction", overlays_file)
	overlays += get_airlock_overlay("panel_c[state+1]", overlays_file)


code:
/obj/structure/dresser
	name = "dresser"
	desc = "A nicely-crafted wooden dresser. It's filled with lots of undies."
	icon = 'icons/obj/stationobjs.dmi'
	icon_state = "dresser"
	density = 1
	anchored = 1

/obj/structure/dresser/attack_hand(mob/user)
	if(!Adjacent(user))//no tele-grooming
		return
	if(ishuman(user))
		var/mob/living/carbon/human/H = user

		var/choice = input(user, "Underwear, Undershirt, or Socks?", "Changing") as null|anything in list("Underwear","Undershirt","Socks")

		if(!Adjacent(user))
			return
		switch(choice)
			if("Underwear")
				var/new_undies = input(user, "Select your underwear", "Changing")  as null|anything in underwear_list
				if(new_undies)
					H.underwear = new_undies

			if("Undershirt")
				var/new_undershirt = input(user, "Select your undershirt", "Changing") as null|anything in undershirt_list
				if(new_undershirt)
					H.undershirt = new_undershirt
			if("Socks")
				var/new_socks = input(user, "Select your socks", "Changing") as null|anything in socks_list
				if(new_socks)
					H.socks= new_socks

		add_fingerprint(H)
		H.update_body()

license: mit


code:
/obj/structure/chair/e_chair
	name = "electric chair"
	desc = "Looks absolutely SHOCKING!\nAlt-click to rotate it clockwise."
	icon_state = "echair0"
	var/obj/item/assembly/shock_kit/part = null
	var/last_time = 1
	item_chair = null

/obj/structure/chair/e_chair/New()
	..()
	overlays += image('icons/obj/chairs.dmi', src, "echair_over", MOB_LAYER + 1)

/obj/structure/chair/e_chair/attackby(obj/item/weapon/W, mob/user, params)
	if(istype(W, /obj/item/weapon/wrench))
		var/obj/structure/chair/C = new /obj/structure/chair(loc)
		playsound(loc, 'sound/items/Ratchet.ogg', 50, 1)
		C.dir = dir
		part.loc = loc
		part.master = null
		part = null
		qdel(src)

/obj/structure/chair/e_chair/proc/shock()
	if(last_time + 50 > world.time)
		return
	last_time = world.time

	// special power handling
	var/area/A = get_area(src)
	if(!isarea(A))
		return
	if(!A.powered(EQUIP))
		return
	A.use_power(EQUIP, 5000)

	flick("echair_shock", src)
	var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
	s.set_up(12, 1, src)
	s.start()
	if(buckled_mobs.len)
		for(var/m in buckled_mobs)
			var/mob/living/buckled_mob = m
			buckled_mob.electrocute_act(85, src, 1)
			buckled_mob << "You feel a deep shock course through your body!"
			spawn(1)
				buckled_mob.electrocute_act(85, src, 1)
	visible_message("The electric chair went off!", "You hear a deep sharp shock!")


code:
/obj/structure/extinguisher_cabinet
	name = "extinguisher cabinet"
	desc = "A small wall mounted cabinet designed to hold a fire extinguisher."
	icon = 'icons/obj/wallmounts.dmi'
	icon_state = "extinguisher_closed"
	anchored = 1
	density = 0
	var/obj/item/weapon/extinguisher/has_extinguisher = new/obj/item/weapon/extinguisher
	var/opened = 0

/obj/structure/extinguisher_cabinet/ex_act(severity, target)
	switch(severity)
		if(1)
			qdel(src)
			return
		if(2)
			if(prob(50))
				if(has_extinguisher)
					has_extinguisher.loc = src.loc
				qdel(src)
				return
		if(3)
			return

/obj/structure/extinguisher_cabinet/attackby(obj/item/O, mob/user, params)
	if(isrobot(user) || isalien(user))
		return
	if(istype(O, /obj/item/weapon/extinguisher))
		if(!has_extinguisher && opened)
			if(!user.drop_item())
				return
			contents += O
			has_extinguisher = O
			user << "You place [O] in [src]."
		else
			opened = !opened
	else
		opened = !opened
	update_icon()

/obj/structure/extinguisher_cabinet/attack_hand(mob/user)
	if(isrobot(user) || isalien(user))
		return
	if(has_extinguisher)
		user.put_in_hands(has_extinguisher)
		user << "You take [has_extinguisher] from [src]."
		has_extinguisher = null
		opened = 1
	else
		opened = !opened
	update_icon()

/obj/structure/extinguisher_cabinet/attack_tk(mob/user)
	if(has_extinguisher)
		has_extinguisher.loc = loc
		user << "You telekinetically remove [has_extinguisher] from [src]."
		has_extinguisher = null
		opened = 1
	else
		opened = !opened
	update_icon()

/obj/structure/extinguisher_cabinet/attack_paw(mob/user)
	attack_hand(user)
	return

/obj/structure/extinguisher_cabinet/AltClick(mob/living/user)
	if(user.incapacitated() || !Adjacent(user))
		return
	opened = !opened
	update_icon()

/obj/structure/extinguisher_cabinet/update_icon()
	if(!opened)
		icon_state = "extinguisher_closed"
		return
	if(has_extinguisher)
		if(istype(has_extinguisher, /obj/item/weapon/extinguisher/mini))
			icon_state = "extinguisher_mini"
		else
			icon_state = "extinguisher_full"
	else
		icon_state = "extinguisher_empty"


code:
/*
 * False Walls
 */
/obj/structure/falsewall
	name = "wall"
	desc = "A huge chunk of metal used to separate rooms."
	anchored = 1
	icon = 'icons/turf/walls/wall.dmi'
	icon_state = "wall"
	var/mineral = "metal"
	var/walltype = "metal"
	var/opening = 0
	density = 1
	opacity = 1

	canSmoothWith = list(
	/turf/closed/wall,
	/turf/closed/wall/r_wall,
	/obj/structure/falsewall,
	/obj/structure/falsewall/reinforced,  // WHY DO WE SMOOTH WITH FALSE R-WALLS WHEN WE DON'T SMOOTH WITH REAL R-WALLS.
	/turf/closed/wall/rust,
	/turf/closed/wall/r_wall/rust)
	smooth = SMOOTH_TRUE
	can_be_unanchored = 0

/obj/structure/falsewall/attack_hand(mob/user)
	if(opening)
		return

	opening = 1
	if(density)
		do_the_flick()
		sleep(5)
		if(!qdeleted(src))
			density = 0
			SetOpacity(0)
			update_icon()
	else
		var/srcturf = get_turf(src)
		for(var/mob/living/obstacle in srcturf) //Stop people from using this as a shield
			opening = 0
			return
		do_the_flick()
		density = 1
		sleep(5)
		if(!qdeleted(src))
			SetOpacity(1)
			update_icon()
	opening = 0

/obj/structure/falsewall/proc/do_the_flick()
	if(density)
		smooth = SMOOTH_FALSE
		clear_smooth_overlays()
		icon_state = "fwall_opening"
	else
		icon_state = "fwall_closing"

/obj/structure/falsewall/update_icon()//Calling icon_update will refresh the smoothwalls if it's closed, otherwise it will make sure the icon is correct if it's open
	if(density)
		smooth = SMOOTH_TRUE
		queue_smooth(src)
		icon_state = ""
	else
		icon_state = "fwall_open"

/obj/structure/falsewall/proc/ChangeToWall(delete = 1)
	var/turf/T = get_turf(src)
	if(!walltype || walltype == "metal")
		T.ChangeTurf(/turf/closed/wall)
	else
		T.ChangeTurf(text2path("/turf/closed/wall/mineral/[walltype]"))
	if(delete)
		qdel(src)
	return T

/obj/structure/falsewall/attackby(obj/item/weapon/W, mob/user, params)
	if(opening)
		user << "You must wait until the door has stopped moving!"
		return

	if(density)
		var/turf/T = get_turf(src)
		if(T.density)
			user << "[src] is blocked!"
			return
		if(istype(W, /obj/item/weapon/screwdriver))
			if (!istype(T, /turf/open/floor))
				user << "[src] bolts must be tightened on the floor!"
				return
			user.visible_message("[user] tightens some bolts on the wall.", "You tighten the bolts on the wall.")
			ChangeToWall()
		if(istype(W, /obj/item/weapon/weldingtool))
			var/obj/item/weapon/weldingtool/WT = W
			if(WT.remove_fuel(0,user))
				dismantle(user)
	else
		user << "You can't reach, close it first!"

	if(istype(W, /obj/item/weapon/gun/energy/plasmacutter))
		dismantle(user)

	if(istype(W, /obj/item/weapon/pickaxe/drill/jackhammer))
		var/obj/item/weapon/pickaxe/drill/jackhammer/D = W
		D.playDigSound()
		dismantle(user)

/obj/structure/falsewall/proc/dismantle(mob/user)
	user.visible_message("[user] dismantles the false wall.", "You dismantle the false wall.")
	new /obj/structure/girder/displaced(loc)
	if(mineral == "metal")
		if(istype(src, /obj/structure/falsewall/reinforced))
			new /obj/item/stack/sheet/plasteel(loc)
			new /obj/item/stack/sheet/plasteel(loc)
		else
			new /obj/item/stack/sheet/metal(loc)
			new /obj/item/stack/sheet/metal(loc)
	else
		var/P = text2path("/obj/item/stack/sheet/mineral/[mineral]")
		new P(loc)
		new P(loc)
	playsound(src, 'sound/items/Welder.ogg', 100, 1)
	qdel(src)

/obj/structure/falsewall/storage_contents_dump_act(obj/item/weapon/storage/src_object, mob/user)
	return 0

/*
 * False R-Walls
 */

/obj/structure/falsewall/reinforced
	name = "reinforced wall"
	desc = "A huge chunk of reinforced metal used to separate rooms."
	icon = 'icons/turf/walls/reinforced_wall.dmi'
	icon_state = "r_wall"
	walltype = "rwall"

/obj/structure/falsewall/reinforced/ChangeToWall(delete = 1)
	var/turf/T = get_turf(src)
	T.ChangeTurf(/turf/closed/wall/r_wall)
	if(delete)
		qdel(src)
	return T

/*
 * Uranium Falsewalls
 */

/obj/structure/falsewall/uranium
	name = "uranium wall"
	desc = "A wall with uranium plating. This is probably a bad idea."
	icon = 'icons/turf/walls/uranium_wall.dmi'
	icon_state = "uranium"
	mineral = "uranium"
	walltype = "uranium"
	var/active = null
	var/last_event = 0
	canSmoothWith = list(/obj/structure/falsewall/uranium, /turf/closed/wall/mineral/uranium)

/obj/structure/falsewall/uranium/attackby(obj/item/weapon/W, mob/user, params)
	radiate()
	..()

/obj/structure/falsewall/uranium/attack_hand(mob/user)
	radiate()
	..()

/obj/structure/falsewall/uranium/proc/radiate()
	if(!active)
		if(world.time > last_event+15)
			active = 1
			radiation_pulse(get_turf(src), 0, 3, 15, 1)
			for(var/turf/closed/wall/mineral/uranium/T in orange(1,src))
				T.radiate()
			last_event = world.time
			active = null
			return
	return
/*
 * Other misc falsewall types
 */

/obj/structure/falsewall/gold
	name = "gold wall"
	desc = "A wall with gold plating. Swag!"
	icon = 'icons/turf/walls/gold_wall.dmi'
	icon_state = "gold"
	mineral = "gold"
	walltype = "gold"
	canSmoothWith = list(/obj/structure/falsewall/gold, /turf/closed/wall/mineral/gold)

/obj/structure/falsewall/silver
	name = "silver wall"
	desc = "A wall with silver plating. Shiny."
	icon = 'icons/turf/walls/silver_wall.dmi'
	icon_state = "silver"
	mineral = "silver"
	walltype = "silver"
	canSmoothWith = list(/obj/structure/falsewall/silver, /turf/closed/wall/mineral/silver)

/obj/structure/falsewall/diamond
	name = "diamond wall"
	desc = "A wall with diamond plating. You monster."
	icon = 'icons/turf/walls/diamond_wall.dmi'
	icon_state = "diamond"
	mineral = "diamond"
	walltype = "diamond"
	canSmoothWith = list(/obj/structure/falsewall/diamond, /turf/closed/wall/mineral/diamond)

/obj/structure/falsewall/plasma
	name = "plasma wall"
	desc = "A wall with plasma plating. This is definitely a bad idea."
	icon = 'icons/turf/walls/plasma_wall.dmi'
	icon_state = "plasma"
	mineral = "plasma"
	walltype = "plasma"
	canSmoothWith = list(/obj/structure/falsewall/plasma, /turf/closed/wall/mineral/plasma)

/obj/structure/falsewall/plasma/attackby(obj/item/weapon/W, mob/user, params)
	if(W.is_hot() > 300)
		message_admins("Plasma falsewall ignited by [key_name_admin(user)](?) (FLW) in ([x],[y],[z] - JMP)",0,1)
		log_game("Plasma falsewall ignited by [key_name(user)] in ([x],[y],[z])")
		burnbabyburn()
		return
	..()

/obj/structure/falsewall/plasma/proc/burnbabyburn(user)
	playsound(src, 'sound/items/Welder.ogg', 100, 1)
	atmos_spawn_air("plasma=400;TEMP=1000")
	new /obj/structure/girder/displaced(loc)
	qdel(src)

/obj/structure/falsewall/plasma/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
	if(exposed_temperature > 300)
		burnbabyburn()

/obj/structure/falsewall/clown
	name = "bananium wall"
	desc = "A wall with bananium plating. Honk!"
	icon = 'icons/turf/walls/bananium_wall.dmi'
	icon_state = "bananium"
	mineral = "bananium"
	walltype = "bananium"
	canSmoothWith = list(/obj/structure/falsewall/clown, /turf/closed/wall/mineral/clown)

/obj/structure/falsewall/sandstone
	name = "sandstone wall"
	desc = "A wall with sandstone plating. Rough."
	icon = 'icons/turf/walls/sandstone_wall.dmi'
	icon_state = "sandstone"
	mineral = "sandstone"
	walltype = "sandstone"
	canSmoothWith = list(/obj/structure/falsewall/sandstone, /turf/closed/wall/mineral/sandstone)

/obj/structure/falsewall/wood
	name = "wooden wall"
	desc = "A wall with wooden plating. Stiff."
	icon = 'icons/turf/walls/wood_wall.dmi'
	icon_state = "wood"
	mineral = "wood"
	walltype = "wood"
	canSmoothWith = list(/obj/structure/falsewall/wood, /turf/closed/wall/mineral/wood)

/obj/structure/falsewall/iron
	name = "rough metal wall"
	desc = "A wall with rough metal plating."
	icon = 'icons/turf/walls/iron_wall.dmi'
	icon_state = "iron"
	mineral = "metal"
	walltype = "iron"
	canSmoothWith = list(/obj/structure/falsewall/iron, /turf/closed/wall/mineral/iron)
/obj/structure/falsewall/abductor
	name = "alien wall"
	desc = "A wall with alien alloy plating."
	icon = 'icons/turf/walls/abductor_wall.dmi'
	icon_state = "abductor"
	mineral = "abductor"
	walltype = "abductor"
	canSmoothWith = list(/obj/structure/falsewall/abductor, /turf/closed/wall/mineral/abductor)


code:
/obj/structure/fireaxecabinet
	name = "fire axe cabinet"
	desc = "There is small label that reads \"For Emergency use only\" along with details for safe use of the axe. As if."
	var/obj/item/weapon/twohanded/fireaxe/fireaxe = new/obj/item/weapon/twohanded/fireaxe
	icon = 'icons/obj/wallmounts.dmi'
	icon_state = "fireaxe"
	anchored = 1
	density = 0
	var/locked = 1
	var/open = 0
	var/glass_hp = 60

/obj/structure/fireaxecabinet/New()
	..()
	update_icon()

/obj/structure/fireaxecabinet/attackby(obj/item/I, mob/user, params)
	if(isrobot(user) || istype(I,/obj/item/device/multitool))
		toggle_lock(user)
		return
	if(open || glass_hp <= 0)
		if(istype(I, /obj/item/weapon/twohanded/fireaxe) && !fireaxe)
			var/obj/item/weapon/twohanded/fireaxe/F = I
			if(F.wielded)
				user << "Unwield the [F.name] first."
				return
			if(!user.drop_item())
				return
			fireaxe = F
			src.contents += F
			user << "You place the [F.name] back in the [name]."
			update_icon()
			return
		else if(glass_hp > 0)
			toggle_open()

	else if(istype(I, /obj/item/weapon))
		user.changeNext_move(CLICK_CD_MELEE)
		var/obj/item/weapon/W = I
		user.do_attack_animation(src)
		playsound(src, 'sound/effects/Glasshit.ogg', 100, 1)
		if(W.force >= 10)
			glass_hp -= W.force
			if(glass_hp <= 0)
				playsound(src, 'sound/effects/Glassbr3.ogg', 100, 1)
			update_icon()
		else
			user << "The [name]'s protective glass glances off the hit."

/obj/structure/fireaxecabinet/ex_act(severity, target)
	switch(severity)
		if(1)
			qdel(src)
			return
		if(2)
			if(prob(50) && fireaxe)
				fireaxe.loc = src.loc
				qdel(src)
				return
		if(3)
			return

/obj/structure/fireaxecabinet/bullet_act(obj/item/projectile/Proj)
	if((Proj.damage_type == BRUTE || Proj.damage_type == BURN))
		if(Proj.damage)
			glass_hp -= Proj.damage
			if(glass_hp <= 0)
				playsound(src, 'sound/effects/Glassbr3.ogg', 100, 1)
		update_icon()

/obj/structure/fireaxecabinet/blob_act()
	if(fireaxe)
		fireaxe.loc = src.loc
	qdel(src)

/obj/structure/fireaxecabinet/attack_hand(mob/user)
	if(open || glass_hp <= 0)
		if(fireaxe)
			user.put_in_hands(fireaxe)
			fireaxe = null
			user << "You take the fire axe from the [name]."
			src.add_fingerprint(user)
			update_icon()
			return
	if(locked)
		user <<" The [name] won't budge!"
		return
	else
		open = !open
		update_icon()
		return

/obj/structure/fireaxecabinet/attack_paw(mob/user)
	if(ismonkey(user)) //no fire-axe wielding aliens allowed
		attack_hand(user)
	return

/obj/structure/fireaxecabinet/attack_ai(mob/user)
	toggle_lock(user)
	return

/obj/structure/fireaxecabinet/update_icon()
	overlays.Cut()
	if(fireaxe)
		overlays += "axe"
	if(!open)
		switch(glass_hp)
			if(-INFINITY to 0)
				overlays += "glass4"
			if(1 to 20)
				overlays += "glass3"
			if(21 to 40)
				overlays += "glass2"
			if(41 to 59)
				overlays += "glass1"
			if(60)
				overlays += "glass"
		if(locked)
			overlays += "locked"
		else
			overlays += "unlocked"
	else
		overlays += "glass_raised"

/obj/structure/fireaxecabinet/proc/toggle_lock(mob/user)
	user << " Resetting circuitry..."
	playsound(src, 'sound/machines/locktoggle.ogg', 50, 1)
	if(do_after(user, 20, target = src))
		user << "You [locked ? "disable" : "re-enable"] the locking modules."
		locked = !locked
		update_icon()

/obj/structure/fireaxecabinet/verb/toggle_open()
	set name = "Open/Close"
	set category = "Object"
	set src in oview(1)

	if(locked)
		usr <<" The [name] won't budge!"
		return
	else
		open = !open
		update_icon()
		return


code:
/obj/structure/flora
	burn_state = FLAMMABLE
	burntime = 30

//trees
/obj/structure/flora/tree
	name = "tree"
	anchored = 1
	density = 1
	pixel_x = -16
	layer = 9
	var/cut = FALSE
	var/log_amount = 10

/obj/structure/flora/tree/attackby(obj/item/weapon/W, mob/user, params)
	if(!cut && log_amount)
		if(W.sharpness && W.force > 0)
			if(W.hitsound)
				playsound(get_turf(src), W.hitsound, 100, 0, 0)
			user.visible_message("[user] begins to cut down [src] with [W].","You begin to cut down [src] with [W].", "You hear the sound of cutting a tree.")
			if(do_after(user, 1000/W.force, target = user)) //5 seconds with 20 force, 8 seconds with a hatchet, 20 seconds with a shard.
				if(cut)
					return
				user.visible_message("[user] falls [src] with the [W].","You fall [src] with the [W].", "You hear the sound of a tree falling.")
				playsound(get_turf(src), 'sound/effects/meteorimpact.ogg', 100 , 0, 0)
				icon_state = "tree_stump"
				name = "stump"
				cut = TRUE
				for(var/i=1 to log_amount)
					new /obj/item/weapon/grown/log/tree(get_turf(src))

	else
		..()

/obj/structure/flora/tree/pine
	name = "pine tree"
	icon = 'icons/obj/flora/pinetrees.dmi'
	icon_state = "pine_1"

/obj/structure/flora/tree/pine/New()
	icon_state = "pine_[rand(1, 3)]"
	..()

/obj/structure/flora/tree/pine/xmas
	name = "xmas tree"
	icon_state = "pine_c"

/obj/structure/flora/tree/pine/xmas/New()
	..()
	icon_state = "pine_c"

/obj/structure/flora/tree/dead
	icon = 'icons/obj/flora/deadtrees.dmi'
	icon_state = "tree_1"

/obj/structure/festivus
	name = "festivus pole"
	icon = 'icons/obj/flora/pinetrees.dmi'
	icon_state = "festivus_pole"
	desc = "During last year's Feats of Strength the Research Director was able to suplex this passing immobile rod into a planter."

/obj/structure/flora/tree/dead/New()
	icon_state = "tree_[rand(1, 6)]"
	..()

//grass
/obj/structure/flora/grass
	name = "grass"
	icon = 'icons/obj/flora/snowflora.dmi'
	anchored = 1
	gender = PLURAL	//"this is grass" not "this is a grass"

/obj/structure/flora/grass/brown
	icon_state = "snowgrass1bb"

/obj/structure/flora/grass/brown/New()
	icon_state = "snowgrass[rand(1, 3)]bb"
	..()

/obj/structure/flora/grass/green
	icon_state = "snowgrass1gb"

/obj/structure/flora/grass/green/New()
	icon_state = "snowgrass[rand(1, 3)]gb"
	..()

/obj/structure/flora/grass/both
	icon_state = "snowgrassall1"

/obj/structure/flora/grass/both/New()
	icon_state = "snowgrassall[rand(1, 3)]"
	..()

//bushes
/obj/structure/flora/bush
	name = "bush"
	icon = 'icons/obj/flora/snowflora.dmi'
	icon_state = "snowbush1"
	anchored = 1

/obj/structure/flora/bush/New()
	icon_state = "snowbush[rand(1, 6)]"
	..()

//newbushes

/obj/structure/flora/ausbushes
	name = "bush"
	icon = 'icons/obj/flora/ausflora.dmi'
	icon_state = "firstbush_1"
	anchored = 1

/obj/structure/flora/ausbushes/New()
	if(icon_state == "firstbush_1")
		icon_state = "firstbush_[rand(1, 4)]"
	..()

/obj/structure/flora/ausbushes/reedbush
	icon_state = "reedbush_1"

/obj/structure/flora/ausbushes/reedbush/New()
	icon_state = "reedbush_[rand(1, 4)]"
	..()

/obj/structure/flora/ausbushes/leafybush
	icon_state = "leafybush_1"

/obj/structure/flora/ausbushes/leafybush/New()
	icon_state = "leafybush_[rand(1, 3)]"
	..()

/obj/structure/flora/ausbushes/palebush
	icon_state = "palebush_1"

/obj/structure/flora/ausbushes/palebush/New()
	icon_state = "palebush_[rand(1, 4)]"
	..()

/obj/structure/flora/ausbushes/stalkybush
	icon_state = "stalkybush_1"

/obj/structure/flora/ausbushes/stalkybush/New()
	icon_state = "stalkybush_[rand(1, 3)]"
	..()

/obj/structure/flora/ausbushes/grassybush
	icon_state = "grassybush_1"

/obj/structure/flora/ausbushes/grassybush/New()
	icon_state = "grassybush_[rand(1, 4)]"
	..()

/obj/structure/flora/ausbushes/fernybush
	icon_state = "fernybush_1"

/obj/structure/flora/ausbushes/fernybush/New()
	icon_state = "fernybush_[rand(1, 3)]"
	..()

/obj/structure/flora/ausbushes/sunnybush
	icon_state = "sunnybush_1"

/obj/structure/flora/ausbushes/sunnybush/New()
	icon_state = "sunnybush_[rand(1, 3)]"
	..()

/obj/structure/flora/ausbushes/genericbush
	icon_state = "genericbush_1"

/obj/structure/flora/ausbushes/genericbush/New()
	icon_state = "genericbush_[rand(1, 4)]"
	..()

/obj/structure/flora/ausbushes/pointybush
	icon_state = "pointybush_1"

/obj/structure/flora/ausbushes/pointybush/New()
	icon_state = "pointybush_[rand(1, 4)]"
	..()

/obj/structure/flora/ausbushes/lavendergrass
	icon_state = "lavendergrass_1"

/obj/structure/flora/ausbushes/lavendergrass/New()
	icon_state = "lavendergrass_[rand(1, 4)]"
	..()

/obj/structure/flora/ausbushes/ywflowers
	icon_state = "ywflowers_1"

/obj/structure/flora/ausbushes/ywflowers/New()
	icon_state = "ywflowers_[rand(1, 3)]"
	..()

/obj/structure/flora/ausbushes/brflowers
	icon_state = "brflowers_1"

/obj/structure/flora/ausbushes/brflowers/New()
	icon_state = "brflowers_[rand(1, 3)]"
	..()

/obj/structure/flora/ausbushes/ppflowers
	icon_state = "ppflowers_1"

/obj/structure/flora/ausbushes/ppflowers/New()
	icon_state = "ppflowers_[rand(1, 3)]"
	..()

/obj/structure/flora/ausbushes/sparsegrass
	icon_state = "sparsegrass_1"

/obj/structure/flora/ausbushes/sparsegrass/New()
	icon_state = "sparsegrass_[rand(1, 3)]"
	..()

/obj/structure/flora/ausbushes/fullgrass
	icon_state = "fullgrass_1"

/obj/structure/flora/ausbushes/fullgrass/New()
	icon_state = "fullgrass_[rand(1, 3)]"
	..()

/obj/structure/flora/kirbyplants
	name = "potted plant"
	icon = 'icons/obj/flora/plants.dmi'
	icon_state = "plant-01"

/obj/structure/flora/kirbyplants/dead
	name = "RD's potted plant"
	desc = "A gift from the botanical staff, presented after the RD's reassignment. There's a tag on it that says \"Y'all come back now, y'hear?\"\nIt doesn't look very healthy..."
	icon_state = "plant-25"

//a rock is flora according to where the icon file is
//and now these defines
/obj/structure/flora/rock
	name = "rock"
	desc = "a rock"
	icon_state = "rock"
	icon = 'icons/obj/flora/rocks.dmi'
	anchored = 1
	burn_state = FIRE_PROOF
	density = 1

/obj/structure/flora/rock/New()
	..()
	icon_state = "[icon_state][rand(1,5)]"

/obj/structure/flora/rock/pile
	name = "rocks"
	desc = "some rocks"
	icon_state = "rockpile"
	density = 0

/obj/structure/flora/rock/volcanic
	icon_state = "basalt"
	desc = "A volcanic rock"

/obj/structure/flora/rock/volcanic/New()
	..()
	icon_state = "[icon_state][rand(1,3)]"

/obj/structure/flora/rock/pile/volcanic
	icon_state = "lavarocks"

/obj/structure/flora/rock/pile/volcanic/New()
	..()
	icon_state = "[icon_state][rand(1,3)]"


code:
#define GIRDER_NORMAL 0
#define GIRDER_REINF_STRUTS 1
#define GIRDER_REINF 2
#define GIRDER_DISPLACED 3
#define GIRDER_DISASSEMBLED 4

/obj/structure/girder
	name = "girder"
	icon_state = "girder"
	anchored = 1
	density = 1
	layer = 2.9
	var/state = GIRDER_NORMAL
	var/girderpasschance = 20 // percentage chance that a projectile passes through the girder.
	var/can_displace = TRUE //If the girder can be moved around by wrenching it

/obj/structure/girder/attackby(obj/item/W, mob/user, params)
	add_fingerprint(user)
	if(istype(W, /obj/item/weapon/screwdriver))
		if(state == GIRDER_DISPLACED)
			playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1)
			user.visible_message("[user] disassembles the girder.", \
								"You start to disassemble the girder...", "You hear clanking and banging noises.")
			if(do_after(user, 40/W.toolspeed, target = src))
				if(state != GIRDER_DISPLACED)
					return
				state = GIRDER_DISASSEMBLED
				user << "You disassemble the girder."
				var/obj/item/stack/sheet/metal/M = new (loc, 2)
				M.add_fingerprint(user)
				qdel(src)
		else if(state == GIRDER_REINF)
			playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1)
			user << "You start unsecuring support struts..."
			if(do_after(user, 40/W.toolspeed, target = src))
				if(state != GIRDER_REINF)
					return
				user << "You unsecure the support struts."
				state = GIRDER_REINF_STRUTS

	else if(istype(W, /obj/item/weapon/wrench))
		if(state == GIRDER_DISPLACED)
			if(!istype(loc, /turf/open/floor))
				user << "A floor must be present to secure the girder!"
				return
			playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1)
			user << "You start securing the girder..."
			if(do_after(user, 40/W.toolspeed, target = src))
				user << "You secure the girder."
				var/obj/structure/girder/G = new (loc)
				transfer_fingerprints_to(G)
				qdel(src)
		else if(state == GIRDER_NORMAL && can_displace)
			playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1)
			user << "You start unsecuring the girder..."
			if(do_after(user, 40/W.toolspeed, target = src))
				user << "You unsecure the girder."
				var/obj/structure/girder/displaced/D = new (loc)
				transfer_fingerprints_to(D)
				qdel(src)

	else if(istype(W, /obj/item/weapon/gun/energy/plasmacutter))
		user << "You start slicing apart the girder..."
		playsound(src, 'sound/items/Welder.ogg', 100, 1)
		if(do_after(user, 30, target = src))
			user << "You slice apart the girder."
			var/obj/item/stack/sheet/metal/M = new (loc, 2)
			M.add_fingerprint(user)
			qdel(src)

	else if(istype(W, /obj/item/weapon/pickaxe/drill/jackhammer))
		var/obj/item/weapon/pickaxe/drill/jackhammer/D = W
		user << "You smash through the girder!"
		new /obj/item/stack/sheet/metal(get_turf(src))
		D.playDigSound()
		qdel(src)

	else if(istype(W, /obj/item/weapon/wirecutters) && state == GIRDER_REINF_STRUTS)
		playsound(src.loc, 'sound/items/Wirecutter.ogg', 100, 1)
		user << "You start removing support struts..."
		if(do_after(user, 40/W.toolspeed, target = src))
			user << "You remove the support struts."
			new /obj/item/stack/sheet/plasteel(get_turf(src))
			var/obj/structure/girder/G = new (loc)
			transfer_fingerprints_to(G)
			qdel(src)

	else if(istype(W, /obj/item/stack))
		if (istype(src.loc, /turf/closed/wall))
			user << "There is already a wall present!"
			return
		if (!istype(src.loc, /turf/open/floor))
			user << "A floor must be present to build a false wall!"
			return
		if (locate(/obj/structure/falsewall) in src.loc.contents)
			user << "There is already a false wall present!"
			return

		if(istype(W,/obj/item/stack/rods))
			var/obj/item/stack/rods/S = W
			if(state == GIRDER_DISPLACED)
				if(S.amount < 2)
					user << "You need at least two rods to create a false wall!"
					return
				user << "You start building a reinforced false wall..."
				if(do_after(user, 20, target = src))
					if(!src.loc || !S || S.amount < 2)
						return
					S.use(2)
					user << "You create a false wall. Push on it to open or close the passage."
					var/obj/structure/falsewall/iron/FW = new (loc)
					transfer_fingerprints_to(FW)
					qdel(src)
			else
				if(S.amount < 5)
					user << "You need at least five rods to add plating!"
					return
				user << "You start adding plating..."
				if (do_after(user, 40, target = src))
					if(!src.loc || !S || S.amount < 5)
						return
					S.use(5)
					user << "You add the plating."
					var/turf/T = get_turf(src)
					T.ChangeTurf(/turf/closed/wall/mineral/iron)
					transfer_fingerprints_to(T)
					qdel(src)
				return

		if(!istype(W,/obj/item/stack/sheet))
			return

		var/obj/item/stack/sheet/S = W
		if(istype(S,/obj/item/stack/sheet/metal))
			if(state == GIRDER_DISPLACED)
				if(S.get_amount() < 2)
					user << "You need two sheets of metal to create a false wall!"
					return
				user << "You start building a false wall..."
				if(do_after(user, 20, target = src))
					if(!src.loc || !S || S.get_amount() < 2)
						return
					S.use(2)
					user << "You create a false wall. Push on it to open or close the passage."
					var/obj/structure/falsewall/F = new (loc)
					transfer_fingerprints_to(F)
					qdel(src)
			else
				if(S.get_amount() < 2)
					user << "You need two sheets of metal to finish a wall!"
					return
				user << "You start adding plating..."
				if (do_after(user, 40, target = src))
					if(loc == null || S.get_amount() < 2)
						return
					S.use(2)
					user << "You add the plating."
					var/turf/T = get_turf(src)
					T.ChangeTurf(/turf/closed/wall)
					transfer_fingerprints_to(T)
					qdel(src)
				return

		if(istype(S,/obj/item/stack/sheet/plasteel))
			if(state == GIRDER_DISPLACED)
				if(S.amount < 2)
					user << "You need at least two sheets to create a false wall!"
					return
				user << "You start building a reinforced false wall..."
				if(do_after(user, 20, target = src))
					if(!src.loc || !S || S.amount < 2)
						return
					S.use(2)
					user << "You create a reinforced false wall. Push on it to open or close the passage."
					var/obj/structure/falsewall/reinforced/FW = new (loc)
					transfer_fingerprints_to(FW)
					qdel(src)
			else
				if(state == GIRDER_REINF)
					if(S.amount < 1)
						return
					user << "You start finalizing the reinforced wall..."
					if(do_after(user, 50, target = src))
						if(!src.loc || !S || S.amount < 1)
							return
						S.use(1)
						user << "You fully reinforce the wall."
						var/turf/T = get_turf(src)
						T.ChangeTurf(/turf/closed/wall/r_wall)
						transfer_fingerprints_to(T)
						qdel(src)
					return
				else
					if(S.amount < 1)
						return
					user << "You start reinforcing the girder..."
					if (do_after(user, 60, target = src))
						if(!src.loc || !S || S.amount < 1)
							return
						S.use(1)
						user << "You reinforce the girder."
						var/obj/structure/girder/reinforced/R = new (loc)
						transfer_fingerprints_to(R)
						qdel(src)
					return

		if(S.sheettype)
			var/M = S.sheettype
			if(state == GIRDER_DISPLACED)
				if(S.amount < 2)
					user << "You need at least two sheets to create a false wall!"
					return
				S.use(2)
				user << "You create a false wall. Push on it to open or close the passage."
				var/F = text2path("/obj/structure/falsewall/[M]")
				var/obj/structure/FW = new F (loc)
				transfer_fingerprints_to(FW)
				qdel(src)
			else
				if(S.amount < 2)
					user << "You need at least two sheets to add plating!"
					return
				user << "You start adding plating..."
				if (do_after(user, 40, target = src))
					if(!src.loc || !S || S.amount < 2)
						return
					S.use(2)
					user << "You add the plating."
					var/turf/T = get_turf(src)
					T.ChangeTurf(text2path("/turf/closed/wall/mineral/[M]"))
					transfer_fingerprints_to(T)
					qdel(src)
				return

		add_hiddenprint(user)

	else if(istype(W, /obj/item/pipe))
		var/obj/item/pipe/P = W
		if (P.pipe_type in list(0, 1, 5))	//simple pipes, simple bends, and simple manifolds.
			if(!user.drop_item())
				return
			P.loc = src.loc
			user << "You fit the pipe into \the [src]."
	else
		..()

/obj/structure/girder/CanPass(atom/movable/mover, turf/target, height=0)
	if(height==0)
		return 1
	if(istype(mover) && mover.checkpass(PASSGRILLE))
		return prob(girderpasschance)
	else
		if(istype(mover, /obj/item/projectile))
			return prob(girderpasschance)
		else
			return 0

/obj/structure/girder/CanAStarPass(ID, dir, caller)
	. = !density
	if(ismovableatom(caller))
		var/atom/movable/mover = caller
		. = . || mover.checkpass(PASSGRILLE)

/obj/structure/girder/blob_act()
	if(prob(40))
		qdel(src)

/obj/structure/girder/ex_act(severity, target)
	switch(severity)
		if(1)
			qdel(src)
		if(2)
			if (prob(70))
				var/remains = pick(/obj/item/stack/rods,/obj/item/stack/sheet/metal)
				new remains(loc)
				qdel(src)
		if(3)
			if (prob(40))
				var/remains = pick(/obj/item/stack/rods,/obj/item/stack/sheet/metal)
				new remains(loc)
				qdel(src)

/obj/structure/girder/narsie_act()
	if(prob(25))
		new /obj/structure/girder/cult(loc)
		qdel(src)

/obj/structure/girder/displaced
	name = "displaced girder"
	icon_state = "displaced"
	anchored = 0
	state = GIRDER_DISPLACED
	girderpasschance = 25
	layer = 2.45

/obj/structure/girder/reinforced
	name = "reinforced girder"
	icon_state = "reinforced"
	state = GIRDER_REINF
	girderpasschance = 0

/obj/structure/girder/reinforced/ex_act(severity, target)
	switch(severity)
		if(1)
			qdel(src)
		if(2)
			if (prob(50))
				var/remains = pick(/obj/item/stack/rods,/obj/item/stack/sheet/metal)
				new remains(loc)
				qdel(src)
		if(3)
			if (prob(20))
				var/remains = pick(/obj/item/stack/rods,/obj/item/stack/sheet/metal)
				new remains(loc)
				qdel(src)

//////////////////////////////////////////// cult girder //////////////////////////////////////////////

/obj/structure/girder/cult
	name = "runed girder"
	desc = "Framework made of a strange and shockingly cold metal. It doesn't seem to have any bolts."
	icon = 'icons/obj/cult.dmi'
	icon_state= "cultgirder"
	can_displace = FALSE

/obj/structure/girder/cult/attackby(obj/item/W, mob/user, params)
	add_fingerprint(user)
	if(istype(W, /obj/item/weapon/tome) && iscultist(user)) //Cultists can demolish cult girders instantly with their tomes
		user.visible_message("[user] strikes [src] with [W]!", "You demolish [src].")
		var/obj/item/stack/sheet/runed_metal/R = new(get_turf(src))
		R.amount = 2
		qdel(src)

	else if(istype(W, /obj/item/weapon/weldingtool))
		var/obj/item/weapon/weldingtool/WT = W
		if(WT.remove_fuel(0,user))
			playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1)
			user << "You start slicing apart the girder..."
			if(do_after(user, 40/W.toolspeed, target = src))
				if( !WT.isOn() )
					return
				user << "You slice apart the girder."
				var/obj/item/stack/sheet/runed_metal/R = new(get_turf(src))
				R.amount = 2
				transfer_fingerprints_to(R)
				qdel(src)

	else if(istype(W, /obj/item/weapon/gun/energy/plasmacutter))
		user << "You start slicing apart the girder..."
		playsound(src, 'sound/items/Welder.ogg', 100, 1)
		if(do_after(user, 30, target = src))
			user << "You slice apart the girder."
			var/obj/item/stack/sheet/runed_metal/R = new(get_turf(src))
			R.amount = 2
			transfer_fingerprints_to(R)
			qdel(src)

	else if(istype(W, /obj/item/weapon/pickaxe/drill/jackhammer))
		var/obj/item/weapon/pickaxe/drill/jackhammer/D = W
		user << "Your jackhammer smashes through the girder!"
		var/obj/item/stack/sheet/runed_metal/R = new(get_turf(src))
		R.amount = 2
		transfer_fingerprints_to(R)
		D.playDigSound()
		qdel(src)

	else if(istype(W, /obj/item/stack/sheet/runed_metal))
		var/obj/item/stack/sheet/runed_metal/R = W
		if(R.amount < 2)
			user << "You need at least two sheets of runed metal to construct a runed wall!"
			return 0
		user.visible_message("[user] begins laying runed metal on [src]...", "You begin constructing a runed wall...")
		if(!do_after(user, 50, target = src))
			return 0
		user.visible_message("[user] plates [src] with runed metal.", "You construct a runed wall.")
		R.use(2)
		new/turf/closed/wall/cult(get_turf(src))
		qdel(src)

	else
		..()

/obj/structure/girder/cult/narsie_act()
	return

/obj/structure/girder/cult/ex_act(severity, target)
	switch(severity)
		if(1)
			qdel(src)
		if(2)
			if(prob(30))
				new/obj/item/stack/sheet/runed_metal/(get_turf(src), 2)
				qdel(src)
		if(3)
			if(prob(5))
				new/obj/item/stack/sheet/runed_metal/(get_turf(src), 2)
				qdel(src)


code:
/obj/structure/grille
	desc = "A flimsy lattice of metal rods, with screws to secure it to the floor."
	name = "grille"
	icon = 'icons/obj/structures.dmi'
	icon_state = "grille"
	density = 1
	anchored = 1
	flags = CONDUCT
	pressure_resistance = 5*ONE_ATMOSPHERE
	layer = 2.9
	var/health = 10
	var/destroyed = 0
	var/obj/item/stack/rods/stored

/obj/structure/grille/New()
	stored = new/obj/item/stack/rods(src)
	stored.amount = 2

/obj/structure/grille/ex_act(severity, target)
	qdel(src)

/obj/structure/grille/blob_act()
	qdel(src)

/obj/structure/grille/Bumped(atom/user)
	if(ismob(user)) shock(user, 70)

/obj/structure/grille/attack_paw(mob/user)
	attack_hand(user)

/obj/structure/grille/attack_hulk(mob/living/carbon/human/user)
	..(user, 1)
	shock(user, 70)
	health -= 5
	healthcheck()

/obj/structure/grille/attack_hand(mob/living/user)
	user.changeNext_move(CLICK_CD_MELEE)
	user.do_attack_animation(src)
	playsound(loc, 'sound/effects/grillehit.ogg', 80, 1)
	user.visible_message("[user] hits [src].", \
						 "You hit [src].", \
						 "You hear twisting metal.")

	if(shock(user, 70))
		return
	else
		health -= rand(1,2)
	healthcheck()

/obj/structure/grille/attack_alien(mob/living/user)
	user.do_attack_animation(src)
	if(istype(user, /mob/living/carbon/alien/larva))
		return
	user.changeNext_move(CLICK_CD_MELEE)
	playsound(loc, 'sound/effects/grillehit.ogg', 80, 1)
	user.visible_message("[user] mangles [src].", \
						 "You mangle [src].", \
						 "You hear twisting metal.")

	if(!shock(user, 70))
		health -= 5
		healthcheck()
		return

/obj/structure/grille/attack_slime(mob/living/simple_animal/slime/user)
	user.changeNext_move(CLICK_CD_MELEE)
	user.do_attack_animation(src)
	if(!user.is_adult)
		return

	playsound(loc, 'sound/effects/grillehit.ogg', 80, 1)
	user.visible_message("[user] smashes against [src].", \
						 "You smash against [src].", \
						 "You hear twisting metal.")

	health -= rand(1,2)
	healthcheck()
	return

/obj/structure/grille/attack_animal(var/mob/living/simple_animal/M)
	M.changeNext_move(CLICK_CD_MELEE)
	if(M.melee_damage_upper == 0 || (M.melee_damage_type != BRUTE && M.melee_damage_type != BURN))
		return
	M.do_attack_animation(src)
	playsound(loc, 'sound/effects/grillehit.ogg', 80, 1)
	M.visible_message("[M] smashes against [src].", \
					  "You smash against [src].", \
					  "You hear twisting metal.")

	health -= M.melee_damage_upper
	healthcheck()
	return

/obj/structure/grille/mech_melee_attack(obj/mecha/M)
	if(..())
		playsound(loc, 'sound/effects/grillehit.ogg', 80, 1)
		health -= M.force * 0.5
		healthcheck()

/obj/structure/grille/CanPass(atom/movable/mover, turf/target, height=0)
	if(height==0) return 1
	if(istype(mover) && mover.checkpass(PASSGRILLE))
		return 1
	else
		if(istype(mover, /obj/item/projectile) && density)
			return prob(30)
		else
			return !density

/obj/structure/grille/CanAStarPass(ID, dir, caller)
	. = !density
	if(ismovableatom(caller))
		var/atom/movable/mover = caller
		. = . || mover.checkpass(PASSGRILLE)

/obj/structure/grille/bullet_act(var/obj/item/projectile/Proj)
	if(!Proj)
		return
	..()
	if((Proj.damage_type != STAMINA)) //Grilles can't be exhausted to death
		src.health -= Proj.damage*0.3
		healthcheck()
	return

/obj/structure/grille/Deconstruct()
	if(!loc) //if already qdel'd somehow, we do nothing
		return
	if(!(flags&NODECONSTRUCT))
		transfer_fingerprints_to(stored)
		var/turf/T = loc
		stored.loc = T
	..()

/obj/structure/grille/proc/Break()
	icon_state = "brokengrille"
	density = 0
	destroyed = 1
	stored.amount = 1
	if(!(flags&NODECONSTRUCT))
		var/obj/item/stack/rods/newrods = new(loc)
		transfer_fingerprints_to(newrods)

/obj/structure/grille/attackby(obj/item/weapon/W, mob/user, params)
	user.changeNext_move(CLICK_CD_MELEE)
	add_fingerprint(user)
	if(istype(W, /obj/item/weapon/wirecutters))
		if(!shock(user, 100))
			playsound(loc, 'sound/items/Wirecutter.ogg', 100, 1)
			Deconstruct()
	else if((istype(W, /obj/item/weapon/screwdriver)) && (istype(loc, /turf) || anchored))
		if(!shock(user, 90))
			playsound(loc, 'sound/items/Screwdriver.ogg', 100, 1)
			anchored = !anchored
			user.visible_message("[user] [anchored ? "fastens" : "unfastens"] [src].", \
								 "You [anchored ? "fasten [src] to" : "unfasten [src] from"] the floor.")
			return
	else if(istype(W, /obj/item/stack/rods) && destroyed)
		var/obj/item/stack/rods/R = W
		if(!shock(user, 90))
			user.visible_message("[user] rebuilds the broken grille.", \
								 "You rebuild the broken grille.")
			health = 10
			density = 1
			destroyed = 0
			icon_state = "grille"
			R.use(1)
			return
	else if(istype(W, /obj/item/weapon/rcd) && istype(loc, /turf)) //Do not attack the grille if the user is holding an RCD
		return

//window placing begin
	else if(istype(W, /obj/item/stack/sheet/rglass) || istype(W, /obj/item/stack/sheet/glass))
		if (!destroyed)
			var/obj/item/stack/ST = W
			if (ST.get_amount() < 2)
				user << "You need at least two sheets of glass for that!"
				return
			var/dir_to_set = SOUTHWEST
			if(!anchored)
				user << "[src] needs to be fastened to the floor first!"
				return
			for(var/obj/structure/window/WINDOW in loc)
				user << "There is already a window there!"
				return
			user << "You start placing the window..."
			if(do_after(user,20, target = src))
				if(!src.loc || !anchored) //Grille destroyed or unanchored while waiting
					return
				for(var/obj/structure/window/WINDOW in loc) //Another window already installed on grille
					return
				var/obj/structure/window/WD
				if(istype(W, /obj/item/stack/sheet/rglass))
					WD = new/obj/structure/window/reinforced/fulltile(loc) //reinforced window
				else
					WD = new/obj/structure/window/fulltile(loc) //normal window
				WD.dir = dir_to_set
				WD.ini_dir = dir_to_set
				WD.anchored = 0
				WD.state = 0
				ST.use(2)
				user << "You place [WD] on [src]."
			return
//window placing end

	else if(istype(W, /obj/item/weapon/shard))
		playsound(loc, 'sound/effects/grillehit.ogg', 80, 1)
		health -= W.force * 0.1
	else if(!shock(user, 70))
		switch(W.damtype)
			if(STAMINA)
				return
			if(BURN)
				playsound(loc, 'sound/items/welder.ogg', 80, 1)
			else
				playsound(loc, 'sound/effects/grillehit.ogg', 80, 1)
		health -= W.force * 0.3

	healthcheck()
	..()
	return

/obj/structure/grille/proc/healthcheck()
	if(health <= 0)
		if(!destroyed)
			Break()
		else
			if(health <= -6)
				Deconstruct()
	return

// shock user with probability prb (if all connections & power are working)
// returns 1 if shocked, 0 otherwise

/obj/structure/grille/proc/shock(mob/user, prb)
	if(!anchored || destroyed)		// anchored/destroyed grilles are never connected
		return 0
	if(!prob(prb))
		return 0
	if(!in_range(src, user))//To prevent TK and mech users from getting shocked
		return 0
	var/turf/T = get_turf(src)
	var/obj/structure/cable/C = T.get_cable_node()
	if(C)
		if(electrocute_mob(user, C, src))
			var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
			s.set_up(3, 1, src)
			s.start()
			return 1
		else
			return 0
	return 0

/obj/structure/grille/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
	if(!destroyed)
		if(exposed_temperature > T0C + 1500)
			health -= 1
			healthcheck()
	..()

/obj/structure/grille/hitby(AM as mob|obj)
	..()
	var/tforce = 0
	if(ismob(AM))
		tforce = 5
	else if(isobj(AM))
		if(prob(50))
			var/obj/item/I = AM
			tforce = max(0, I.throwforce * 0.5)
		else if(anchored && !destroyed)
			var/turf/T = get_turf(src)
			var/obj/structure/cable/C = T.get_cable_node()
			if(C)
				playsound(src.loc, 'sound/magic/LightningShock.ogg', 100, 1, extrarange = 5)
				tesla_zap(src, 3, C.powernet.avail * 0.08) //ZAP for 1/5000 of the amount of power, which is from 15-25 with 200000W
	playsound(loc, 'sound/effects/grillehit.ogg', 80, 1)
	health = max(0, health - tforce)
	healthcheck()

/obj/structure/grille/storage_contents_dump_act(obj/item/weapon/storage/src_object, mob/user)
	return 0


code:
//GUNCASES//
/obj/structure/guncase
	name = "gun locker"
	desc = "A locker that holds guns."
	icon = 'icons/obj/closet.dmi'
	icon_state = "shotguncase"
	anchored = 0
	density = 1
	opacity = 0
	var/case_type = null
	var/gun_category = /obj/item/weapon/gun
	var/open = 1
	var/capacity = 4

/obj/structure/guncase/New()
	..()
	update_icon()

/obj/structure/guncase/initialize()
	..()
	for(var/obj/item/I in loc.contents)
		if(istype(I, gun_category))
			I.loc = src
		if(contents.len >= capacity)
			break
	update_icon()

/obj/structure/guncase/update_icon()
	overlays.Cut()
	for(var/i = contents.len, i >= 1, i--)
		overlays += image(icon = src.icon, icon_state = "[case_type]", pixel_x = 4 * (i -1) )
	if(open)
		overlays += "[icon_state]_open"
	else
		overlays += "[icon_state]_door"

/obj/structure/guncase/attackby(obj/item/I, mob/user, params)
	if(isrobot(user) || isalien(user))
		return
	if(istype(I, gun_category))
		if(contents.len < capacity && open)
			if(!user.drop_item())
				return
			contents += I
			user << "You place [I] in [src]."
			update_icon()
			return

	open = !open
	update_icon()

/obj/structure/guncase/attack_hand(mob/user)
	if(isrobot(usr) || isalien(usr))
		return
	if(contents.len && open)
		ShowWindow(user)
	else
		open = !open
		update_icon()

/obj/structure/guncase/proc/ShowWindow(mob/user)
	var/dat = {"

Stored Guns

"}
	for(var/i = contents.len, i >= 1, i--)
		var/obj/item/I = contents[i]
		dat += "
[I.name]
"
	dat += "

"

	var/datum/browser/popup = new(user, "gunlocker", "
[name]
", 350, 300)
	popup.set_content(dat)
	popup.open(0)

/obj/structure/guncase/Topic(href, href_list)
	if(href_list["retrieve"])
		var/obj/item/O = locate(href_list["retrieve"])
		if(!usr.canUseTopic(src))
			return
		if(ishuman(usr))
			if(!usr.get_active_hand())
				usr.put_in_hands(O)
			else
				O.loc = get_turf(src)
			update_icon()

/obj/structure/guncase/shotgun
	name = "shotgun locker"
	desc = "A locker that holds shotguns."
	case_type = "shotgun"
	gun_category = /obj/item/weapon/gun/projectile/shotgun

/obj/structure/guncase/ecase
	name = "energy gun locker"
	desc = "A locker that holds energy guns."
	icon_state = "ecase"
	case_type = "egun"
	gun_category = /obj/item/weapon/gun/energy/gun


code:
/obj/structure/hivebot_beacon
	name = "beacon"
	desc = "Some odd beacon thing."
	icon = 'icons/mob/hivebot.dmi'
	icon_state = "def_radar-off"
	anchored = 1
	density = 1
	var/bot_type = "norm"
	var/bot_amt = 10

/obj/structure/hivebot_beacon/New()
	..()
	var/datum/effect_system/smoke_spread/smoke = new
	smoke.set_up(2, loc)
	smoke.start()
	visible_message("The [src] warps in!")
	playsound(src.loc, 'sound/effects/EMPulse.ogg', 25, 1)
	spawn(rand(10,600))
		warpbots()

/obj/structure/hivebot_beacon/proc/warpbots()
	icon_state = "def_radar"
	visible_message("The [src] turns on!")
	while(bot_amt > 0)
		bot_amt--
		switch(bot_type)
			if("norm")
				new /mob/living/simple_animal/hostile/hivebot(get_turf(src))
			if("range")
				new /mob/living/simple_animal/hostile/hivebot/range(get_turf(src))
			if("rapid")
				new /mob/living/simple_animal/hostile/hivebot/rapid(get_turf(src))
	sleep(100)
	visible_message("The [src] warps out!")
	playsound(src.loc, 'sound/effects/EMPulse.ogg', 25, 1)
	qdel(src)
	return


code:
/obj/structure/janitorialcart
	name = "janitorial cart"
	desc = "This is the alpha and omega of sanitation."
	icon = 'icons/obj/janitor.dmi'
	icon_state = "cart"
	anchored = 0
	density = 1
	flags = OPENCONTAINER
	//copypaste sorry
	var/amount_per_transfer_from_this = 5 //shit I dunno, adding this so syringes stop runtime erroring. --NeoFite
	var/obj/item/weapon/storage/bag/trash/mybag	= null
	var/obj/item/weapon/mop/mymop = null
	var/obj/item/weapon/reagent_containers/spray/cleaner/myspray = null
	var/obj/item/device/lightreplacer/myreplacer = null
	var/signs = 0
	var/const/max_signs = 4

/obj/structure/janitorialcart/New()
	create_reagents(100)

/obj/structure/janitorialcart/proc/wet_mop(obj/item/weapon/mop, mob/user)
	if(reagents.total_volume < 1)
		user << "[src] is out of water!"
		return 0
	else
		reagents.trans_to(mop, 5)
		user << "You wet [mop] in [src]."
		playsound(loc, 'sound/effects/slosh.ogg', 25, 1)
		return 1

/obj/structure/janitorialcart/proc/put_in_cart(obj/item/I, mob/user)
	if(!user.drop_item())
		return
	I.loc = src
	updateUsrDialog()
	user << "You put [I] into [src]."
	return

/obj/structure/janitorialcart/attackby(obj/item/I, mob/user, params)
	var/fail_msg = "There is already one of those in [src]!"

	if(istype(I, /obj/item/weapon/mop))
		var/obj/item/weapon/mop/m=I
		if(m.reagents.total_volume < m.reagents.maximum_volume)
			if (wet_mop(m, user))
				return
		if(!mymop)
			m.janicart_insert(user, src)
		else
			user << fail_msg

	else if(istype(I, /obj/item/weapon/storage/bag/trash))
		if(!mybag)
			var/obj/item/weapon/storage/bag/trash/t=I
			t.janicart_insert(user, src)
		else
			user <<  fail_msg
	else if(istype(I, /obj/item/weapon/reagent_containers/spray/cleaner))
		if(!myspray)
			put_in_cart(I, user)
			myspray=I
			update_icon()
		else
			user << fail_msg
	else if(istype(I, /obj/item/device/lightreplacer))
		if(!myreplacer)
			var/obj/item/device/lightreplacer/l=I
			l.janicart_insert(user,src)
		else
			user << fail_msg
	else if(istype(I, /obj/item/weapon/caution))
		if(signs < max_signs)
			put_in_cart(I, user)
			signs++
			update_icon()
		else
			user << "[src] can't hold any more signs!"
	else if(mybag)
		mybag.attackby(I, user)
	else if(istype(I, /obj/item/weapon/crowbar))
		user.visible_message("[user] begins to empty the contents of [src].", "You begin to empty the contents of [src]...")
		if(do_after(user, 30/I.toolspeed, target = src))
			usr << "You empty the contents of [src]'s bucket onto the floor."
			reagents.reaction(src.loc)
			src.reagents.clear_reagents()

/obj/structure/janitorialcart/attack_hand(mob/user)
	user.set_machine(src)
	var/dat
	if(mybag)
		dat += "[mybag.name]
"
	if(mymop)
		dat += "[mymop.name]
"
	if(myspray)
		dat += "[myspray.name]
"
	if(myreplacer)
		dat += "[myreplacer.name]
"
	if(signs)
		dat += "[signs] sign\s
"
	var/datum/browser/popup = new(user, "janicart", name, 240, 160)
	popup.set_content(dat)
	popup.open()

/obj/structure/janitorialcart/Topic(href, href_list)
	if(!in_range(src, usr))
		return
	if(!isliving(usr))
		return
	var/mob/living/user = usr
	if(href_list["garbage"])
		if(mybag)
			user.put_in_hands(mybag)
			user << "You take [mybag] from [src]."
			mybag = null
	if(href_list["mop"])
		if(mymop)
			user.put_in_hands(mymop)
			user << "You take [mymop] from [src]."
			mymop = null
	if(href_list["spray"])
		if(myspray)
			user.put_in_hands(myspray)
			user << "You take [myspray] from [src]."
			myspray = null
	if(href_list["replacer"])
		if(myreplacer)
			user.put_in_hands(myreplacer)
			user << "You take [myreplacer] from [src]."
			myreplacer = null
	if(href_list["sign"])
		if(signs)
			var/obj/item/weapon/caution/Sign = locate() in src
			if(Sign)
				user.put_in_hands(Sign)
				user << "You take \a [Sign] from [src]."
				signs--
			else
				WARNING("Signs ([signs]) didn't match contents")
				signs = 0

	update_icon()
	updateUsrDialog()

/obj/structure/janitorialcart/update_icon()
	overlays.Cut()
	if(mybag)
		overlays += "cart_garbage"
	if(mymop)
		overlays += "cart_mop"
	if(myspray)
		overlays += "cart_spray"
	if(myreplacer)
		overlays += "cart_replacer"
	if(signs)
		overlays += "cart_sign[signs]"


code:
//////Kitchen Spike

/obj/structure/kitchenspike_frame
	name = "meatspike frame"
	icon = 'icons/obj/kitchen.dmi'
	icon_state = "spikeframe"
	desc = "The frame of a meat spike."
	density = 1
	anchored = 0

/obj/structure/kitchenspike_frame/attackby(obj/item/I, mob/user, params)
	add_fingerprint(user)
	if(default_unfasten_wrench(user, I))
		return
	else if(istype(I, /obj/item/stack/rods))
		var/obj/item/stack/rods/R = I
		if(R.get_amount() >= 4)
			R.use(4)
			user << "You add spikes to the frame."
			var/obj/F = new /obj/structure/kitchenspike(src.loc,)
			transfer_fingerprints_to(F)
			qdel(src)

/obj/structure/kitchenspike
	name = "meat spike"
	icon = 'icons/obj/kitchen.dmi'
	icon_state = "spike"
	desc = "A spike for collecting meat from animals"
	density = 1
	anchored = 1
	buckle_lying = 0
	can_buckle = 1

/obj/structure/kitchenspike/attack_paw(mob/user)
	return src.attack_hand(usr)

/obj/structure/kitchenspike/attackby(obj/item/I, mob/user, params)
	if(istype(I, /obj/item/weapon/crowbar))
		if(!buckled_mobs.len)
			playsound(loc, 'sound/items/Crowbar.ogg', 100, 1)
			if(do_after(user, 20/I.toolspeed, target = src))
				user << "You pry the spikes out of the frame."
				new /obj/item/stack/rods(loc, 4)
				var/obj/F = new /obj/structure/kitchenspike_frame(src.loc,)
				transfer_fingerprints_to(F)
				qdel(src)
		else
			user << "You can't do that while something's on the spike!"
		return
	if(istype(I, /obj/item/weapon/grab))
		var/obj/item/weapon/grab/G = I
		if(istype(G.affecting, /mob/living/))
			if(!buckled_mobs.len)
				if(do_mob(user, src, 120))
					if(buckled_mobs.len) //to prevent spam/queing up attacks
						return
					if(G.affecting.buckled)
						return
					var/mob/living/H = G.affecting
					playsound(src.loc, "sound/effects/splat.ogg", 25, 1)
					H.visible_message("[user] slams [G.affecting] onto the meat spike!", "[user] slams you onto the meat spike!", "You hear a squishy wet noise.")
					H.loc = src.loc
					H.emote("scream")
					if(istype(H, /mob/living/carbon/human)) //So you don't get human blood when you spike a giant spidere
						var/turf/pos = get_turf(H)
						pos.add_blood_floor(H)
					H.adjustBruteLoss(30)
					H.buckled = src
					H.dir = 2
					buckle_mob(H, force=1)
					var/matrix/m180 = matrix(H.transform)
					m180.Turn(180)
					animate(H, transform = m180, time = 3)
					H.pixel_y = H.get_standard_pixel_y_offset(180)
					qdel(G)
					return
		user << "You can't use that on the spike!"
		return
	..()

/obj/structure/kitchenspike/user_buckle_mob(mob/living/M, mob/living/user) //Don't want them getting put on the rack other than by spiking
	return

/obj/structure/kitchenspike/user_unbuckle_mob(mob/living/buckled_mob, mob/living/carbon/human/user)
	if(buckled_mob)
		var/mob/living/M = buckled_mob
		if(M != user)
			M.visible_message(\
				"[user.name] tries to pull [M.name] free of the [src]!",\
				"[user.name] is trying to pull you off the [src], opening up fresh wounds!",\
				"You hear a squishy wet noise.")
			if(!do_after(user, 300, target = src))
				if(M && M.buckled)
					M.visible_message(\
					"[user.name] fails to free [M.name]!",\
					"[user.name] fails to pull you off of the [src].")
				return

		else
			M.visible_message(\
			"[M.name] struggles to break free from the [src]!",\
			"You struggle to break free from the [src], exacerbating your wounds! (Stay still for two minutes.)",\
			"You hear a wet squishing noise..")
			M.adjustBruteLoss(30)
			if(!do_after(M, 1200, target = src))
				if(M && M.buckled)
					M << "You fail to free yourself!"
				return
		if(!M.buckled)
			return
		var/matrix/m180 = matrix(M.transform)
		m180.Turn(180)
		animate(M, transform = m180, time = 3)
		M.pixel_y = M.get_standard_pixel_y_offset(180)
		M.adjustBruteLoss(30)
		src.visible_message(text("[M] falls free of the [src]!"))
		unbuckle_mob(M,force=1)
		M.emote("scream")
		M.AdjustWeakened(10)


code:
/obj/structure/ladder
	name = "ladder"
	desc = "A sturdy metal ladder."
	icon = 'icons/obj/structures.dmi'
	icon_state = "ladder11"
	var/id = null
	var/height = 0							//the 'height' of the ladder. higher numbers are considered physically higher
	var/obj/structure/ladder/down = null	//the ladder below this one
	var/obj/structure/ladder/up = null		//the ladder above this one

/obj/structure/ladder/unbreakable //mostly useful for awaymissions to prevent halting progress in a mission
	name = "sturdy ladder"
	desc = "An extremely sturdy metal ladder."

/obj/structure/ladder/New()
	spawn(8)
		for(var/obj/structure/ladder/L in world)
			if(L.id == id)
				if(L.height == (height - 1))
					down = L
					continue
				if(L.height == (height + 1))
					up = L
					continue

			if(up && down)	//if both our connections are filled
				break
		update_icon()

/obj/structure/ladder/update_icon()
	if(up && down)
		icon_state = "ladder11"

	else if(up)
		icon_state = "ladder10"

	else if(down)
		icon_state = "ladder01"

	else	//wtf make your ladders properly assholes
		icon_state = "ladder00"

/obj/structure/ladder/proc/go_up(mob/user,is_ghost)
	if(!is_ghost)
		show_fluff_message(1,user)
		up.add_fingerprint(user)
	user.loc = get_turf(up)

/obj/structure/ladder/proc/go_down(mob/user,is_ghost)
	if(!is_ghost)
		show_fluff_message(0,user)
		down.add_fingerprint(user)
	user.loc = get_turf(down)

/obj/structure/ladder/proc/use(mob/user,is_ghost=0)
	if(up && down)
		switch( alert("Go up or down the ladder?", "Ladder", "Up", "Down", "Cancel") )
			if("Up")
				go_up(user,is_ghost)
			if("Down")
				go_down(user,is_ghost)
			if("Cancel")
				return
	else if(up)
		go_up(user,is_ghost)
	else if(down)
		go_down(user,is_ghost)

	if(!is_ghost)
		add_fingerprint(user)

/obj/structure/ladder/attack_hand(mob/user)
	if(can_use(user))
		use(user)

/obj/structure/ladder/attack_paw(mob/user)
	return attack_hand(user)

/obj/structure/ladder/attackby(obj/item/weapon/W, mob/user, params)
	return attack_hand(user)

/obj/structure/ladder/attack_ghost(mob/dead/observer/user)
	use(user,1)

/obj/structure/ladder/proc/show_fluff_message(up,mob/user)
	if(up)
		user.visible_message("[user] climbs up \the [src].","You climb up \the [src].")
	else
		user.visible_message("[user] climbs down \the [src].","You climb down \the [src].")

/obj/structure/ladder/proc/can_use(mob/user)
	return 1

/obj/structure/ladder/unbreakable/Destroy()
	return QDEL_HINT_LETMELIVE


code:
/obj/structure/lattice
	name = "lattice"
	desc = "A lightweight support lattice. These hold our station together."
	icon = 'icons/obj/smooth_structures/lattice.dmi'
	icon_state = "lattice"
	density = 0
	anchored = 1
	layer = 2.3 //under pipes
	var/obj/item/stack/rods/stored
	canSmoothWith = list(/obj/structure/lattice,
	/turf/open/floor,
	/turf/closed/wall,
	/obj/structure/falsewall)
	smooth = SMOOTH_MORE
	//	flags = CONDUCT

/obj/structure/lattice/New()
	..()
	if(!(istype(src.loc, /turf/open/space)))
		qdel(src)
	for(var/obj/structure/lattice/LAT in src.loc)
		if(LAT != src)
			qdel(LAT)
	stored = new/obj/item/stack/rods(src)

/obj/structure/lattice/Destroy()
	qdel(stored)
	stored = null
	return ..()

/obj/structure/lattice/blob_act()
	return

/obj/structure/lattice/ex_act(severity, target)
	switch(severity)
		if(1)
			qdel(src)
			return
		if(2)
			qdel(src)
			return
		if(3)
			return
		else
	return

/obj/structure/lattice/attackby(obj/item/C, mob/user, params)
	if(istype(C, /obj/item/weapon/weldingtool))
		var/obj/item/weapon/weldingtool/WT = C
		if(WT.remove_fuel(0, user))
			user << "Slicing [name] joints ..."
			Deconstruct()
	else
		var/turf/T = get_turf(src)
		return T.attackby(C, user) //hand this off to the turf instead (for building plating, catwalks, etc)

/obj/structure/lattice/Deconstruct()
	stored.loc = get_turf(src)
	stored = null
	..()

/obj/structure/lattice/singularity_pull(S, current_size)
	if(current_size >= STAGE_FOUR)
		Deconstruct()

/obj/structure/lattice/catwalk
	name = "catwalk"
	desc = "A catwalk for easier EVA maneuvering and cable placement."
	icon = 'icons/obj/smooth_structures/catwalk.dmi'
	icon_state = "catwalk"
	smooth = SMOOTH_TRUE
	canSmoothWith = null

/obj/structure/lattice/catwalk/Move()
	var/turf/T = loc
	for(var/obj/structure/cable/C in T)
		C.Deconstruct()
	..()

/obj/structure/lattice/catwalk/Deconstruct()
	var/turf/T = loc
	for(var/obj/structure/cable/C in T)
		C.Deconstruct()
	..()


code:
//NOT using the existing /obj/machinery/door type, since that has some complications on its own, mainly based on its
//machineryness

/obj/structure/mineral_door
	name = "mineral door"
	density = 1
	anchored = 1
	opacity = 1

	icon = 'icons/obj/doors/mineral_doors.dmi'
	icon_state = "metal"

	var/mineralType = "metal"
	var/state = 0 //closed, 1 == open
	var/isSwitchingStates = 0
	var/close_delay = -1 //-1 if does not auto close.
	var/hardness = 1
	var/oreAmount = 7
	var/openSound = 'sound/effects/stonedoor_openclose.ogg'
	var/closeSound = 'sound/effects/stonedoor_openclose.ogg'

/obj/structure/mineral_door/New(location)
	..()
	icon_state = mineralType
	name = "[mineralType] door"
	air_update_turf(1)
	return

/obj/structure/mineral_door/Destroy()
	density = 0
	air_update_turf(1)
	return ..()

/obj/structure/mineral_door/Move()
	var/turf/T = loc
	..()
	move_update_air(T)

/obj/structure/mineral_door/Bumped(atom/user)
	..()
	if(!state)
		return TryToSwitchState(user)
	return

/obj/structure/mineral_door/attack_ai(mob/user) //those aren't machinery, they're just big fucking slabs of a mineral
	if(isAI(user)) //so the AI can't open it
		return
	else if(isrobot(user)) //but cyborgs can
		if(get_dist(user,src) <= 1) //not remotely though
			return TryToSwitchState(user)

/obj/structure/mineral_door/attack_paw(mob/user)
	return TryToSwitchState(user)

/obj/structure/mineral_door/attack_hand(mob/user)
	return TryToSwitchState(user)

/obj/structure/mineral_door/CanPass(atom/movable/mover, turf/target, height=0)
	if(istype(mover, /obj/effect/beam))
		return !opacity
	return !density

/obj/structure/mineral_door/CanAtmosPass()
	return !density

/obj/structure/mineral_door/proc/TryToSwitchState(atom/user)
	if(isSwitchingStates) return
	if(isliving(user))
		var/mob/living/M = user
		if(world.time - M.last_bumped <= 60) return //NOTE do we really need that?
		if(M.client)
			if(iscarbon(M))
				var/mob/living/carbon/C = M
				if(!C.handcuffed)
					SwitchState()
			else
				SwitchState()
	else if(istype(user, /obj/mecha))
		SwitchState()

/obj/structure/mineral_door/proc/SwitchState()
	if(state)
		Close()
	else
		Open()

/obj/structure/mineral_door/proc/Open()
	isSwitchingStates = 1
	playsound(loc, openSound, 100, 1)
	flick("[mineralType]opening",src)
	sleep(10)
	density = 0
	opacity = 0
	state = 1
	air_update_turf(1)
	update_icon()
	isSwitchingStates = 0

	if(close_delay != -1)
		spawn(close_delay)
			if(!isSwitchingStates && state == 1)
				Close()

/obj/structure/mineral_door/proc/Close()
	var/turf/T = get_turf(src)
	for(var/mob/living/L in T)
		return
	isSwitchingStates = 1
	playsound(loc, closeSound, 100, 1)
	flick("[mineralType]closing",src)
	sleep(10)
	density = 1
	opacity = 1
	state = 0
	air_update_turf(1)
	update_icon()
	isSwitchingStates = 0

/obj/structure/mineral_door/update_icon()
	if(state)
		icon_state = "[mineralType]open"
	else
		icon_state = mineralType

/obj/structure/mineral_door/attackby(obj/item/weapon/W, mob/user, params)
	if(istype(W,/obj/item/weapon/pickaxe))
		var/obj/item/weapon/pickaxe/digTool = W
		user << "You start digging the [name]..."
		if(do_after(user,digTool.digspeed*hardness, target = src) && src)
			user << "You finish digging."
			Dismantle()
	else if(istype(W,/obj/item/weapon)) //not sure, can't not just weapons get passed to this proc?
		hardness -= W.force/100
		user << "You hit the [name] with your [W.name]!"
		CheckHardness()
	else
		attack_hand(user)
	return

/obj/structure/mineral_door/bullet_act(obj/item/projectile/Proj)
	hardness -= Proj.damage
	..()
	CheckHardness()
	return

/obj/structure/mineral_door/proc/CheckHardness()
	if(hardness <= 0)
		Dismantle(1)

/obj/structure/mineral_door/proc/Dismantle(devastated = 0)
	if(!devastated)
		if (mineralType == "metal")
			var/ore = /obj/item/stack/sheet/metal
			for(var/i = 1, i <= oreAmount, i++)
				new ore(get_turf(src))
		else
			var/ore = text2path("/obj/item/stack/sheet/mineral/[mineralType]")
			for(var/i = 1, i <= oreAmount, i++)
				new ore(get_turf(src))
	else
		if (mineralType == "metal")
			var/ore = /obj/item/stack/sheet/metal
			for(var/i = 3, i <= oreAmount, i++)
				new ore(get_turf(src))
		else
			var/ore = text2path("/obj/item/stack/sheet/mineral/[mineralType]")
			for(var/i = 3, i <= oreAmount, i++)
				new ore(get_turf(src))
	qdel(src)

/obj/structure/mineral_door/ex_act(severity = 1)
	switch(severity)
		if(1)
			Dismantle(1)
		if(2)
			if(prob(20))
				Dismantle(1)
			else
				hardness--
				CheckHardness()
		if(3)
			hardness -= 0.1
			CheckHardness()
	return

/obj/structure/mineral_door/iron
	mineralType = "metal"
	hardness = 3

/obj/structure/mineral_door/silver
	mineralType = "silver"
	hardness = 3

/obj/structure/mineral_door/gold
	mineralType = "gold"

/obj/structure/mineral_door/uranium
	mineralType = "uranium"
	hardness = 3
	luminosity = 2

/obj/structure/mineral_door/sandstone
	mineralType = "sandstone"
	hardness = 0.5

/obj/structure/mineral_door/transparent
	opacity = 0

/obj/structure/mineral_door/transparent/Close()
	..()
	opacity = 0

/obj/structure/mineral_door/transparent/plasma
	mineralType = "plasma"

/obj/structure/mineral_door/transparent/plasma/attackby(obj/item/weapon/W, mob/user, params)
	if(W.is_hot())
		message_admins("Plasma mineral door ignited by [key_name_admin(user)](?) (FLW) in ([x],[y],[z] - JMP)",0,1)
		log_game("Plasma mineral door ignited by [key_name(user)] in ([x],[y],[z])")
		TemperatureAct(100)
	..()

/obj/structure/mineral_door/transparent/plasma/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
	if(exposed_temperature > 300)
		TemperatureAct(exposed_temperature)

/obj/structure/mineral_door/transparent/plasma/proc/TemperatureAct(temperature)
	atmos_spawn_air("plasma=500;TEMP=1000")
	hardness = 0
	CheckHardness()

/obj/structure/mineral_door/transparent/diamond
	mineralType = "diamond"
	hardness = 10

/obj/structure/mineral_door/wood
	mineralType = "wood"
	hardness = 1
	openSound = 'sound/effects/doorcreaky.ogg'
	closeSound = 'sound/effects/doorcreaky.ogg'
	burn_state = FLAMMABLE
	burntime = 30

/obj/structure/mineral_door/wood/Dismantle(devastated = 0)
	if(!devastated)
		for(var/i = 1, i <= oreAmount, i++)
			new/obj/item/stack/sheet/mineral/wood(get_turf(src))
	qdel(src)


code:
//wip wip wup
/obj/structure/mirror
	name = "mirror"
	desc = "Mirror mirror on the wall, who's the most robust of them all?"
	icon = 'icons/obj/watercloset.dmi'
	icon_state = "mirror"
	density = 0
	anchored = 1
	var/shattered = 0

/obj/structure/mirror/attack_hand(mob/user)
	if(shattered)
		return

	if(ishuman(user))
		var/mob/living/carbon/human/H = user

		var/userloc = H.loc

		//see code/modules/mob/new_player/preferences.dm at approx line 545 for comments!
		//this is largely copypasted from there.

		//handle facial hair (if necessary)
		if(H.gender == MALE)
			var/new_style = input(user, "Select a facial hair style", "Grooming")  as null|anything in facial_hair_styles_list
			if(userloc != H.loc)
				return	//no tele-grooming
			if(new_style)
				H.facial_hair_style = new_style
		else
			H.facial_hair_style = "Shaved"

		//handle normal hair
		var/new_style = input(user, "Select a hair style", "Grooming")  as null|anything in hair_styles_list
		if(userloc != H.loc)
			return	//no tele-grooming
		if(new_style)
			H.hair_style = new_style

		H.update_hair()

/obj/structure/mirror/proc/shatter()
	if(shattered)
		return
	shattered = 1
	icon_state = "mirror_broke"
	playsound(src, "shatter", 70, 1)
	desc = "Oh no, seven years of bad luck!"

/obj/structure/mirror/bullet_act(obj/item/projectile/Proj)
	if(prob(Proj.damage * 2))
		if((Proj.damage_type == BRUTE || Proj.damage_type == BURN))
			if(!shattered)
				shatter()
			else
				playsound(src, 'sound/effects/hit_on_shattered_glass.ogg', 70, 1)
	..()

/obj/structure/mirror/attackby(obj/item/I, mob/living/user, params)
	user.changeNext_move(CLICK_CD_MELEE)
	user.do_attack_animation(src)
	if(I.damtype == STAMINA)
		return
	if(shattered)
		if(istype(I, /obj/item/weapon/weldingtool))
			var/obj/item/weapon/weldingtool/WT = I
			if(WT.remove_fuel(0, user))
				user << "You begin repairing [src]..."
				playsound(src, 'sound/items/Welder.ogg', 100, 1)
				if(do_after(user, 10/I.toolspeed, target = src))
					if(!user || !WT || !WT.isOn())
						return
					user << "You repair [src]."
					shattered = 0
					icon_state = initial(icon_state)
					desc = initial(desc)
				return
		playsound(src.loc, 'sound/effects/hit_on_shattered_glass.ogg', 70, 1)
		return

	if(prob(I.force * 2))
		visible_message("[user] smashes [src] with [I].")
		shatter()
	else
		visible_message("[user] hits [src] with [I]!")
		playsound(src.loc, 'sound/effects/Glasshit.ogg', 70, 1)

/obj/structure/mirror/attack_alien(mob/living/user)
	user.changeNext_move(CLICK_CD_MELEE)
	user.do_attack_animation(src)
	if(islarva(user))
		return
	if(shattered)
		playsound(src.loc, 'sound/effects/hit_on_shattered_glass.ogg', 70, 1)
		return
	user.visible_message("[user] smashes [src]!")
	shatter()

/obj/structure/mirror/attack_animal(mob/living/user)
	if(!isanimal(user))
		return
	var/mob/living/simple_animal/M = user
	if(M.melee_damage_upper <= 0)
		return
	user.changeNext_move(CLICK_CD_MELEE)
	M.do_attack_animation(src)
	if(shattered)
		playsound(src.loc, 'sound/effects/hit_on_shattered_glass.ogg', 70, 1)
		return
	user.visible_message("[user] smashes [src]!")
	shatter()

/obj/structure/mirror/attack_slime(mob/living/user)
	user.changeNext_move(CLICK_CD_MELEE)
	user.do_attack_animation(src)
	if(shattered)
		playsound(src.loc, 'sound/effects/hit_on_shattered_glass.ogg', 70, 1)
		return
	user.visible_message("[user] smashes [src]!")
	shatter()

/obj/structure/mirror/magic
	name = "magic mirror"
	desc = "Turn and face the strange... face."
	icon_state = "magic_mirror"
	var/list/races_blacklist = list("skeleton","agent")
	var/list/choosable_races = list()

/obj/structure/mirror/magic/New()
	if(!choosable_races.len)
		for(var/speciestype in subtypesof(/datum/species))
			var/datum/species/S = new speciestype()
			if(!(S.id in races_blacklist))
				choosable_races += S.id
	..()

/obj/structure/mirror/magic/lesser/New()
	choosable_races = roundstart_species
	..()

/obj/structure/mirror/magic/badmin/New()
	for(var/speciestype in subtypesof(/datum/species))
		var/datum/species/S = new speciestype()
		choosable_races += S.id
	..()

/obj/structure/mirror/magic/attack_hand(mob/user)
	if(!ishuman(user))
		return

	var/mob/living/carbon/human/H = user

	var/choice = input(user, "Something to change?", "Magical Grooming") as null|anything in list("name", "race", "gender", "hair", "eyes")

	if(!Adjacent(user))
		return

	switch(choice)
		if("name")
			var/newname = copytext(sanitize(input(H, "Who are we again?", "Name change", H.name) as null|text),1,MAX_NAME_LEN)

			if(!newname)
				return
			if(!Adjacent(user))
				return
			H.real_name = newname
			H.name = newname
			if(H.dna)
				H.dna.real_name = newname
			if(H.mind)
				H.mind.name = newname

		if("race")
			var/newrace
			var/racechoice = input(H, "What are we again?", "Race change") as null|anything in choosable_races
			newrace = species_list[racechoice]

			if(!newrace)
				return
			if(!Adjacent(user))
				return
			H.set_species(newrace, icon_update=0)

			if(H.dna.species.use_skintones)
				var/new_s_tone = input(user, "Choose your skin tone:", "Race change")  as null|anything in skin_tones

				if(new_s_tone)
					H.skin_tone = new_s_tone
					H.dna.update_ui_block(DNA_SKIN_TONE_BLOCK)

			if(MUTCOLORS in H.dna.species.specflags)
				var/new_mutantcolor = input(user, "Choose your skin color:", "Race change") as color|null
				if(new_mutantcolor)
					var/temp_hsv = RGBtoHSV(new_mutantcolor)

					if(ReadHSV(temp_hsv)[3] >= ReadHSV("#7F7F7F")[3]) // mutantcolors must be bright
						H.dna.features["mcolor"] = sanitize_hexcolor(new_mutantcolor)

					else
						H << "Invalid color. Your color is not bright enough."

			H.update_body()
			H.update_hair()
			H.update_mutcolor()
			H.update_mutations_overlay() // no hulk lizard

		if("gender")
			if(!(H.gender in list("male", "female"))) //blame the patriarchy
				return
			if(!Adjacent(user))
				return
			if(H.gender == "male")
				if(alert(H, "Become a Witch?", "Confirmation", "Yes", "No") == "Yes")
					H.gender = "female"
					H << "Man, you feel like a woman!"
				else
					return

			else
				if(alert(H, "Become a Warlock?", "Confirmation", "Yes", "No") == "Yes")
					H.gender = "male"
					H << "Whoa man, you feel like a man!"
				else
					return
			H.dna.update_ui_block(DNA_GENDER_BLOCK)
			H.update_body()
			H.update_mutations_overlay() //(hulk male/female)

		if("hair")
			var/hairchoice = alert(H, "Hair style or hair color?", "Change Hair", "Style", "Color")
			if(!Adjacent(user))
				return
			if(hairchoice == "Style") //So you just want to use a mirror then?
				..()
			else
				var/new_hair_color = input(H, "Choose your hair color", "Hair Color") as null|color
				if(new_hair_color)
					H.hair_color = sanitize_hexcolor(new_hair_color)
					H.dna.update_ui_block(DNA_HAIR_COLOR_BLOCK)
				if(H.gender == "male")
					var/new_face_color = input(H, "Choose your facial hair color", "Hair Color") as null|color
					if(new_face_color)
						H.facial_hair_color = sanitize_hexcolor(new_face_color)
						H.dna.update_ui_block(DNA_FACIAL_HAIR_COLOR_BLOCK)
				H.update_hair()

		if("eyes")
			var/new_eye_color = input(H, "Choose your eye color", "Eye Color") as null|color
			if(!Adjacent(user))
				return
			if(new_eye_color)
				H.eye_color = sanitize_hexcolor(new_eye_color)
				H.dna.update_ui_block(DNA_EYE_COLOR_BLOCK)
				H.update_body()
	if(choice)
		curse(user)

/obj/structure/mirror/magic/proc/curse(mob/living/user)
	return


code:
/obj/structure/mopbucket
	name = "mop bucket"
	desc = "Fill it with water, but don't forget a mop!"
	icon = 'icons/obj/janitor.dmi'
	icon_state = "mopbucket"
	density = 1
	flags = OPENCONTAINER
	var/amount_per_transfer_from_this = 5	//shit I dunno, adding this so syringes stop runtime erroring. --NeoFite

/obj/structure/mopbucket/New()
	create_reagents(100)

/obj/structure/mopbucket/attackby(obj/item/I, mob/user, params)
	if(istype(I, /obj/item/weapon/mop))
		if(reagents.total_volume < 1)
			user << "[src] is out of water!"
		else
			reagents.trans_to(I, 5)
			user << "You wet [I] in [src]."
			playsound(loc, 'sound/effects/slosh.ogg', 25, 1)