code:
/obj/structure/closet/wardrobe
	name = "wardrobe"
	desc = "It's a storage unit for standard-issue Nanotrasen attire."
	icon_door = "blue"

/obj/structure/closet/wardrobe/New()
	new /obj/item/clothing/under/color/blue(src)
	new /obj/item/clothing/under/color/blue(src)
	new /obj/item/clothing/under/color/blue(src)
	new /obj/item/clothing/shoes/sneakers/brown(src)
	new /obj/item/clothing/shoes/sneakers/brown(src)
	new /obj/item/clothing/shoes/sneakers/brown(src)
	return

/obj/structure/closet/wardrobe/red
	name = "security wardrobe"
	icon_door = "red"

/obj/structure/closet/wardrobe/red/New()
	new /obj/item/weapon/storage/backpack/security(src)
	new /obj/item/weapon/storage/backpack/satchel_sec(src)
	new /obj/item/weapon/storage/backpack/dufflebag/sec(src)
	new /obj/item/weapon/storage/backpack/dufflebag/sec(src)
	new /obj/item/clothing/under/rank/security(src)
	new /obj/item/clothing/under/rank/security(src)
	new /obj/item/clothing/under/rank/security(src)
	new /obj/item/clothing/shoes/jackboots(src)
	new /obj/item/clothing/shoes/jackboots(src)
	new /obj/item/clothing/shoes/jackboots(src)
	new /obj/item/clothing/head/beret/sec(src)
	new /obj/item/clothing/head/beret/sec(src)
	new /obj/item/clothing/head/beret/sec(src)
	new /obj/item/clothing/head/soft/sec(src)
	new /obj/item/clothing/head/soft/sec(src)
	new /obj/item/clothing/head/soft/sec(src)
	new /obj/item/clothing/mask/bandana/red(src)
	new /obj/item/clothing/mask/bandana/red(src)
	return

/obj/structure/closet/wardrobe/pink
	name = "pink wardrobe"
	icon_door = "pink"

/obj/structure/closet/wardrobe/pink/New()
	new /obj/item/clothing/under/color/pink(src)
	new /obj/item/clothing/under/color/pink(src)
	new /obj/item/clothing/under/color/pink(src)
	new /obj/item/clothing/shoes/sneakers/brown(src)
	new /obj/item/clothing/shoes/sneakers/brown(src)
	new /obj/item/clothing/shoes/sneakers/brown(src)
	return

/obj/structure/closet/wardrobe/black
	name = "black wardrobe"
	icon_door = "black"

/obj/structure/closet/wardrobe/black/New()
	new /obj/item/clothing/under/color/black(src)
	new /obj/item/clothing/under/color/black(src)
	new /obj/item/clothing/under/color/black(src)
	if(prob(25))
		new /obj/item/clothing/suit/jacket/leather(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/head/that(src)
	new /obj/item/clothing/head/that(src)
	new /obj/item/clothing/head/that(src)
	new /obj/item/clothing/head/soft/black(src)
	new /obj/item/clothing/head/soft/black(src)
	new /obj/item/clothing/head/soft/black(src)
	new /obj/item/clothing/mask/bandana/black(src)
	new /obj/item/clothing/mask/bandana/black(src)
	if(prob(40))
		new /obj/item/clothing/mask/bandana/skull(src)
	return

/obj/structure/closet/wardrobe/chaplain_black
	name = "chapel wardrobe"
	desc = "It's a storage unit for Nanotrasen-approved religious attire."
	icon_door = "black"

/obj/structure/closet/wardrobe/chaplain_black/New()
	new /obj/item/clothing/under/rank/chaplain(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/suit/nun(src)
	new /obj/item/clothing/head/nun_hood(src)
	new /obj/item/clothing/suit/hooded/chaplain_hoodie(src)
	new /obj/item/clothing/suit/holidaypriest(src)
	new /obj/item/weapon/storage/backpack/cultpack (src)
	new /obj/item/weapon/storage/fancy/candle_box(src)
	new /obj/item/weapon/storage/fancy/candle_box(src)
	return

/obj/structure/closet/wardrobe/green
	name = "green wardrobe"
	icon_door = "green"

/obj/structure/closet/wardrobe/green/New()
	new /obj/item/clothing/under/color/green(src)
	new /obj/item/clothing/under/color/green(src)
	new /obj/item/clothing/under/color/green(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/mask/bandana/green(src)
	new /obj/item/clothing/mask/bandana/green(src)
	return

/obj/structure/closet/wardrobe/orange
	name = "prison wardrobe"
	desc = "It's a storage unit for Nanotrasen-regulation prisoner attire."
	icon_door = "orange"

/obj/structure/closet/wardrobe/orange/New()
	new /obj/item/clothing/under/rank/prisoner(src)
	new /obj/item/clothing/under/rank/prisoner(src)
	new /obj/item/clothing/under/rank/prisoner(src)
	new /obj/item/clothing/shoes/sneakers/orange(src)
	new /obj/item/clothing/shoes/sneakers/orange(src)
	new /obj/item/clothing/shoes/sneakers/orange(src)
	return

/obj/structure/closet/wardrobe/yellow
	name = "yellow wardrobe"
	icon_door = "yellow"

/obj/structure/closet/wardrobe/yellow/New()
	new /obj/item/clothing/under/color/yellow(src)
	new /obj/item/clothing/under/color/yellow(src)
	new /obj/item/clothing/under/color/yellow(src)
	new /obj/item/clothing/shoes/sneakers/orange(src)
	new /obj/item/clothing/shoes/sneakers/orange(src)
	new /obj/item/clothing/shoes/sneakers/orange(src)
	new /obj/item/clothing/mask/bandana/gold(src)
	new /obj/item/clothing/mask/bandana/gold(src)
	return

/obj/structure/closet/wardrobe/atmospherics_yellow
	name = "atmospherics wardrobe"
	icon_door = "atmos_wardrobe"

/obj/structure/closet/wardrobe/atmospherics_yellow/New()
	new /obj/item/clothing/under/rank/atmospheric_technician(src)
	new /obj/item/clothing/under/rank/atmospheric_technician(src)
	new /obj/item/clothing/under/rank/atmospheric_technician(src)
	new /obj/item/device/analyzer(src)
	new /obj/item/device/analyzer(src)
	new /obj/item/device/analyzer(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	return

/obj/structure/closet/wardrobe/engineering_yellow
	name = "engineering wardrobe"
	icon_door = "yellow"

/obj/structure/closet/wardrobe/engineering_yellow/New()
	new /obj/item/clothing/under/rank/engineer(src)
	new /obj/item/clothing/under/rank/engineer(src)
	new /obj/item/clothing/under/rank/engineer(src)
	new /obj/item/clothing/shoes/sneakers/orange(src)
	new /obj/item/clothing/shoes/sneakers/orange(src)
	new /obj/item/clothing/shoes/sneakers/orange(src)
	return

/obj/structure/closet/wardrobe/white
	name = "white wardrobe"
	icon_door = "white"

/obj/structure/closet/wardrobe/white/New()
	new /obj/item/clothing/under/color/white(src)
	new /obj/item/clothing/under/color/white(src)
	new /obj/item/clothing/under/color/white(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	new /obj/item/clothing/head/soft/mime(src)
	new /obj/item/clothing/head/soft/mime(src)
	new /obj/item/clothing/head/soft/mime(src)
	return

/obj/structure/closet/wardrobe/white/medical
	name = "medical doctor's wardrobe"

/obj/structure/closet/wardrobe/white/medical/New()
	new /obj/item/clothing/under/rank/nursesuit (src)
	new /obj/item/clothing/head/nursehat (src)
	new /obj/item/clothing/under/rank/medical/blue(src)
	new /obj/item/clothing/under/rank/medical/green(src)
	new /obj/item/clothing/under/rank/medical/purple(src)
	new /obj/item/clothing/suit/toggle/labcoat/emt(src)
	new /obj/item/clothing/suit/toggle/labcoat/emt(src)
	new /obj/item/clothing/suit/toggle/labcoat/emt(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/head/soft/emt(src)
	new /obj/item/clothing/head/soft/emt(src)
	new /obj/item/clothing/head/soft/emt(src)
	return

/obj/structure/closet/wardrobe/pjs
	name = "pajama wardrobe"
	icon_door = "white"

/obj/structure/closet/wardrobe/pjs/New()
	new /obj/item/clothing/under/pj/red(src)
	new /obj/item/clothing/under/pj/red(src)
	new /obj/item/clothing/under/pj/blue(src)
	new /obj/item/clothing/under/pj/blue(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	return

/obj/structure/closet/wardrobe/toxins_white
	name = "toxins wardrobe"
	icon_door = "white"

/obj/structure/closet/wardrobe/toxins_white/New()
	new /obj/item/clothing/under/rank/scientist(src)
	new /obj/item/clothing/under/rank/scientist(src)
	new /obj/item/clothing/under/rank/scientist(src)
	new /obj/item/clothing/suit/toggle/labcoat(src)
	new /obj/item/clothing/suit/toggle/labcoat(src)
	new /obj/item/clothing/suit/toggle/labcoat(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	return

/obj/structure/closet/wardrobe/robotics_black
	name = "robotics wardrobe"
	icon_door = "black"

/obj/structure/closet/wardrobe/robotics_black/New()
	new /obj/item/clothing/under/rank/roboticist(src)
	new /obj/item/clothing/under/rank/roboticist(src)
	new /obj/item/clothing/suit/toggle/labcoat(src)
	new /obj/item/clothing/suit/toggle/labcoat(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/gloves/fingerless(src)
	new /obj/item/clothing/gloves/fingerless(src)
	new /obj/item/clothing/head/soft/black(src)
	new /obj/item/clothing/head/soft/black(src)
	if(prob(40))
		new /obj/item/clothing/mask/bandana/skull(src)
	if(prob(40))
		new /obj/item/clothing/mask/bandana/skull(src)
	return

/obj/structure/closet/wardrobe/chemistry_white
	name = "chemistry wardrobe"
	icon_door = "white"

/obj/structure/closet/wardrobe/chemistry_white/New()
	new /obj/item/clothing/under/rank/chemist(src)
	new /obj/item/clothing/under/rank/chemist(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	new /obj/item/clothing/suit/toggle/labcoat/chemist(src)
	new /obj/item/clothing/suit/toggle/labcoat/chemist(src)
	new /obj/item/weapon/storage/backpack/chemistry(src)
	new /obj/item/weapon/storage/backpack/chemistry(src)
	new /obj/item/weapon/storage/backpack/satchel_chem(src)
	new /obj/item/weapon/storage/backpack/satchel_chem(src)
	return

/obj/structure/closet/wardrobe/genetics_white
	name = "genetics wardrobe"
	icon_door = "white"

/obj/structure/closet/wardrobe/genetics_white/New()
	new /obj/item/clothing/under/rank/geneticist(src)
	new /obj/item/clothing/under/rank/geneticist(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	new /obj/item/clothing/suit/toggle/labcoat/genetics(src)
	new /obj/item/clothing/suit/toggle/labcoat/genetics(src)
	new /obj/item/weapon/storage/backpack/genetics(src)
	new /obj/item/weapon/storage/backpack/genetics(src)
	new /obj/item/weapon/storage/backpack/satchel_gen(src)
	new /obj/item/weapon/storage/backpack/satchel_gen(src)
	return

/obj/structure/closet/wardrobe/virology_white
	name = "virology wardrobe"
	icon_door = "white"

/obj/structure/closet/wardrobe/virology_white/New()
	new /obj/item/clothing/under/rank/virologist(src)
	new /obj/item/clothing/under/rank/virologist(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	new /obj/item/clothing/suit/toggle/labcoat/virologist(src)
	new /obj/item/clothing/suit/toggle/labcoat/virologist(src)
	new /obj/item/clothing/mask/surgical(src)
	new /obj/item/clothing/mask/surgical(src)
	new /obj/item/weapon/storage/backpack/virology(src)
	new /obj/item/weapon/storage/backpack/virology(src)
	new /obj/item/weapon/storage/backpack/satchel_vir(src)
	new /obj/item/weapon/storage/backpack/satchel_vir(src)
	return

/obj/structure/closet/wardrobe/grey
	name = "grey wardrobe"
	icon_door = "grey"

/obj/structure/closet/wardrobe/grey/New()
	new /obj/item/clothing/under/color/grey(src)
	new /obj/item/clothing/under/color/grey(src)
	new /obj/item/clothing/under/color/grey(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/head/soft/grey(src)
	new /obj/item/clothing/head/soft/grey(src)
	new /obj/item/clothing/head/soft/grey(src)
	if(prob(50))
		new /obj/item/weapon/storage/backpack/dufflebag(src)
	if(prob(40))
		new /obj/item/clothing/mask/bandana/black(src)
		new /obj/item/clothing/mask/bandana/black(src)
	if(prob(40))
		new /obj/item/clothing/under/assistantformal(src)
	if(prob(40))
		new /obj/item/clothing/under/assistantformal(src)
	if(prob(30))
		new /obj/item/clothing/suit/hooded/wintercoat(src)
		new /obj/item/clothing/shoes/winterboots(src)
	return

/obj/structure/closet/wardrobe/mixed
	name = "mixed wardrobe"
	icon_door = "mixed"

/obj/structure/closet/wardrobe/mixed/New()
	if(prob(40))
		new /obj/item/clothing/suit/jacket(src)
	if(prob(40))
		new /obj/item/clothing/suit/jacket(src)
	new /obj/item/clothing/under/color/white(src)
	new /obj/item/clothing/under/color/blue(src)
	new /obj/item/clothing/under/color/yellow(src)
	new /obj/item/clothing/under/color/green(src)
	new /obj/item/clothing/under/color/orange(src)
	new /obj/item/clothing/under/color/pink(src)
	new /obj/item/clothing/under/color/red(src)
	new /obj/item/clothing/under/color/lightblue(src)
	new /obj/item/clothing/under/color/aqua(src)
	new /obj/item/clothing/under/color/purple(src)
	new /obj/item/clothing/under/color/lightpurple(src)
	new /obj/item/clothing/under/color/lightgreen(src)
	new /obj/item/clothing/under/color/darkblue(src)
	new /obj/item/clothing/under/color/darkred(src)
	new /obj/item/clothing/under/color/lightred(src)
	new /obj/item/clothing/mask/bandana/red(src)
	new /obj/item/clothing/mask/bandana/red(src)
	new /obj/item/clothing/mask/bandana/blue(src)
	new /obj/item/clothing/mask/bandana/blue(src)
	new /obj/item/clothing/mask/bandana/gold(src)
	new /obj/item/clothing/mask/bandana/gold(src)
	new /obj/item/clothing/shoes/sneakers/black(src)
	new /obj/item/clothing/shoes/sneakers/brown(src)
	new /obj/item/clothing/shoes/sneakers/white(src)
	if(prob(30))
		new /obj/item/clothing/suit/hooded/wintercoat(src)
		new /obj/item/clothing/shoes/winterboots(src)
	return


code:
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:32
/obj/structure/closet/crate
	name = "crate"
	desc = "A rectangular steel crate."
	icon = 'icons/obj/crates.dmi'
	var/icon_crate = "crate"
	icon_state = "crate"
	req_access = null
	var/rigged = 0
	var/sound_effect_open = 'sound/machines/click.ogg'
	var/sound_effect_close = 'sound/machines/click.ogg'
	var/obj/item/weapon/paper/manifest/manifest

/obj/structure/closet/crate/New()
	..()
	update_icon()

/obj/structure/closet/crate/update_icon()
	overlays.Cut()
	if(opened)
		icon_state = "[icon_crate]open"
	else
		icon_state = icon_crate
	if(manifest)
		overlays += "manifest"

/obj/structure/closet/crate/internals
	desc = "A internals crate."
	name = "internals crate"
	icon_crate = "o2crate"
	icon_state = "o2crate"

/obj/structure/closet/crate/trashcart
	desc = "A heavy, metal trashcart with wheels."
	name = "trash cart"
	icon_crate = "trashcart"
	icon_state = "trashcart"

/obj/structure/closet/crate/medical
	desc = "A medical crate."
	name = "medical crate"
	icon_crate = "medicalcrate"
	icon_state = "medicalcrate"

/obj/structure/closet/crate/rcd
	desc = "A crate for the storage of the RCD."
	name = "\improper RCD crate"
	icon = 'icons/obj/storage.dmi'
	icon_state = "crate"
	density = 1

/obj/structure/closet/crate/rcd
	desc = "A crate for the storage of the RCD."
	name = "\improper RCD crate"

/obj/structure/closet/crate/rcd/New()
	..()
	new /obj/item/weapon/rcd_ammo(src)
	new /obj/item/weapon/rcd_ammo(src)
	new /obj/item/weapon/rcd_ammo(src)
	new /obj/item/weapon/rcd(src)

/obj/structure/closet/crate/freezer
	desc = "A freezer."
	name = "freezer"
	icon_crate = "freezer"
	icon_state = "freezer"
	var/target_temp = T0C - 40
	var/cooling_power = 40

/obj/structure/closet/crate/freezer/return_air()
	var/datum/gas_mixture/gas = (..())
	if(!gas)	return null
	var/datum/gas_mixture/newgas = new/datum/gas_mixture()
	newgas.oxygen = gas.oxygen
	newgas.carbon_dioxide = gas.carbon_dioxide
	newgas.nitrogen = gas.nitrogen
	newgas.toxins = gas.toxins
	newgas.volume = gas.volume
	newgas.temperature = gas.temperature
	if(newgas.temperature <= target_temp)	return

	if((newgas.temperature - cooling_power) > target_temp)
		newgas.temperature -= cooling_power
	else
		newgas.temperature = target_temp
	return newgas

/obj/structure/closet/crate/radiation
	desc = "A crate with a radiation sign on it."
	name = "radioactive gear crate"
	icon_crate = "radiation"
	icon_state = "radiation"

/obj/structure/closet/crate/radiation/New()
	..()
	new /obj/item/clothing/suit/radiation(src)
	new /obj/item/clothing/head/radiation(src)
	new /obj/item/clothing/suit/radiation(src)
	new /obj/item/clothing/head/radiation(src)
	new /obj/item/clothing/suit/radiation(src)
	new /obj/item/clothing/head/radiation(src)
	new /obj/item/clothing/suit/radiation(src)
	new /obj/item/clothing/head/radiation(src)

/obj/structure/closet/crate/hydroponics
	name = "hydroponics crate"
	desc = "All you need to destroy those pesky weeds and pests."
	icon_crate = "hydrocrate"
	icon_state = "hydrocrate"

/obj/structure/closet/crate/hydroponics/prespawned

/obj/structure/closet/crate/hydroponics/prespawned/New()
	..()
	new /obj/item/weapon/reagent_containers/spray/plantbgone(src)
	new /obj/item/weapon/reagent_containers/spray/plantbgone(src)
	new /obj/item/weapon/minihoe(src)

/obj/structure/closet/crate/secure
	desc = "A secure crate."
	name = "secure crate"
	icon_crate = "securecrate"
	icon_state = "securecrate"
	var/redlight = "securecrater"
	var/greenlight = "securecrateg"
	var/sparks = "securecratesparks"
	var/emag = "securecrateemag"
	locked = 1
	health = 100

/obj/structure/closet/crate/secure/weapon
	desc = "A secure weapons crate."
	name = "weapons crate"
	icon_crate = "weaponcrate"
	icon_state = "weaponcrate"

/obj/structure/closet/crate/secure/plasma
	desc = "A secure plasma crate."
	name = "plasma crate"
	icon_crate = "plasmacrate"
	icon_state = "plasmacrate"

/obj/structure/closet/crate/secure/gear
	desc = "A secure gear crate."
	name = "gear crate"
	icon_crate = "secgearcrate"
	icon_state = "secgearcrate"

/obj/structure/closet/crate/secure/hydrosec
	desc = "A crate with a lock on it, painted in the scheme of the station's botanists."
	name = "secure hydroponics crate"
	icon_crate = "hydrosecurecrate"
	icon_state = "hydrosecurecrate"

/obj/structure/closet/crate/secure/update_icon()
	..()
	if(locked)
		overlays += redlight
	else if(broken)
		overlays += emag
	else
		overlays += greenlight

/obj/structure/closet/crate/open()
	playsound(src.loc, sound_effect_open, 15, 1, -3)
	dump_contents()
	src.opened = 1
	update_icon()
	return 1

/obj/structure/closet/crate/close()
	playsound(src.loc, sound_effect_close, 15, 1, -3)
	take_contents()
	src.opened = 0
	update_icon()
	return 1

/obj/structure/closet/crate/insert(var/atom/movable/AM, var/include_mobs = 0)

	if(contents.len >= storage_capacity)
		return -1
	if(include_mobs && isliving(AM))
		var/mob/living/L = AM
		if(L.buckled)
			return 0
	else if(isobj(AM))
		if(AM.density || AM.anchored || istype(AM,/obj/structure/closet))
			return 0
	else
		return 0

	if(istype(AM, /obj/structure/stool/bed)) //This is only necessary because of rollerbeds and swivel chairs.
		var/obj/structure/stool/bed/B = AM
		if(B.buckled_mob)
			return 0

	AM.loc = src
	return 1

/obj/structure/closet/crate/proc/tear_manifest(mob/user as mob)
	user << "You tear the manifest off of the crate."
	playsound(src.loc, 'sound/items/poster_ripped.ogg', 75, 1)
	manifest.loc = loc
	if(ishuman(user))
		user.put_in_hands(manifest)
	manifest = null
	overlays-="manifest"

/obj/structure/closet/crate/attack_hand(mob/user as mob)
	if(manifest)
		tear_manifest(user)
		return
	if(opened)
		close()
	else
		if(rigged && locate(/obj/item/device/electropack) in src)
			if(isliving(user))
				var/mob/living/L = user
				if(L.electrocute_act(17, src))
					var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
					s.set_up(5, 1, src)
					s.start()
					return
		open()
	return

/obj/structure/closet/crate/secure/attack_hand(mob/user as mob)
	if(manifest)
		tear_manifest(user)
		return
	if(locked && !broken)
		if (allowed(user))
			user << "You unlock [src]."
			src.locked = 0
			update_icon()
			add_fingerprint(user)
			return
		else
			user << "[src] is locked."
			return
	else
		..()

/obj/structure/closet/crate/secure/attackby(obj/item/weapon/W as obj, mob/user as mob, params)
	if(istype(W, /obj/item/weapon/card) && src.allowed(user) && !locked && !opened && !broken)
		user << "You lock \the [src]."
		src.locked = 1
		update_icon()
		add_fingerprint(user)
		return

	return ..()

/obj/structure/closet/crate/secure/emag_act(mob/user as mob)
	if(locked && !broken)
		src.locked = 0
		src.broken = 1
		update_icon()
		overlays += sparks
		spawn(6) overlays -= sparks //Tried lots of stuff but nothing works right. so i have to use this *sadface*
		playsound(src.loc, "sparks", 60, 1)
		user << "You unlock \the [src]."
		add_fingerprint(user)

/obj/structure/closet/crate/attack_paw(mob/user as mob)
	return attack_hand(user)

/obj/structure/closet/crate/attackby(obj/item/weapon/W as obj, mob/user as mob, params)
	if(opened)
		if(isrobot(user) && !ismommi(user))
			return
		if(!user.drop_item()) //couldn't drop the item
			user << "\The [W] is stuck to your hand, you cannot put it in \the [src]!"
			return
		if(W)
			W.loc = src.loc
	else if(istype(W, /obj/item/stack/packageWrap))
		return
	else if(istype(W, /obj/item/stack/cable_coil))
		if(rigged)
			user << "[src] is already rigged!"
			return
		var/obj/item/stack/cable_coil/C = W
		if (C.use(5))
			user << "You rig [src]."
			rigged = 1
		else
			user << "You need 5 lengths of cable to rig [src]!"
		return
	else if(istype(W, /obj/item/device/electropack))
		if(rigged)
			user  << "You attach [W] to [src]."
			user.drop_item()
			W.loc = src
			return
	else if(istype(W, /obj/item/weapon/wirecutters))
		if(rigged)
			user  << "You cut away the wiring."
			playsound(loc, 'sound/items/Wirecutter.ogg', 100, 1)
			rigged = 0
			return
	else if(!place(user, W))
		return attack_hand(user)

/obj/structure/closet/crate/secure/emp_act(severity)
	for(var/obj/O in src)
		O.emp_act(severity)
	if(!broken && !opened  && prob(50/severity))
		if(!locked)
			src.locked = 1
			update_icon()
		else
			src.locked = 0
			src.broken = 1
			update_icon()
			overlays += sparks
			spawn(6) overlays -= sparks //Tried lots of stuff but nothing works right. so i have to use this *sadface*
			playsound(src.loc, 'sound/effects/sparks4.ogg', 75, 1)
	if(!opened && prob(20/severity))
		if(!locked)
			open()
		else
			src.req_access = list()
			src.req_access += pick(get_all_accesses())
	..()

license: mit


code:
/obj/structure/largecrate
	name = "large crate"
	desc = "A hefty wooden crate."
	icon = 'icons/obj/crates.dmi'
	icon_state = "densecrate"
	density = 1
	var/obj/item/weapon/paper/manifest/manifest

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

/obj/structure/largecrate/update_icon()
	..()
	overlays.Cut()
	if(manifest)
		overlays += "manifest"

/obj/structure/largecrate/attack_hand(mob/user as mob)
	if(manifest)
		user << "You tear the manifest off of the crate."
		playsound(src.loc, 'sound/items/poster_ripped.ogg', 75, 1)
		manifest.loc = loc
		if(ishuman(user))
			user.put_in_hands(manifest)
		manifest = null
		update_icon()
		return
	else
		user << "You need a crowbar to pry this open!"
		return

/obj/structure/largecrate/attackby(obj/item/weapon/W as obj, mob/user as mob, params)
	if(istype(W, /obj/item/weapon/crowbar))
		if(manifest)
			manifest.loc = loc
			manifest = null
			update_icon()
		new /obj/item/stack/sheet/mineral/wood(src)
		var/turf/T = get_turf(src)
		for(var/obj/O in contents)
			O.loc = T
		user.visible_message("[user] pries \the [src] open.", \
							 "You pry open \the [src].", \
							 "You hear splitting wood.")
		playsound(src.loc, 'sound/items/Deconstruct.ogg', 75, 1)
		qdel(src)
	else
		return attack_hand(user)

/obj/structure/largecrate/mule
	icon_state = "mulecrate"


code:
/obj/structure/displaycase
	name = "display case"
	icon = 'icons/obj/stationobjs.dmi'
	icon_state = "glassbox1"
	desc = "A display case for prized possessions. Hooked up with an anti-theft system."
	density = 1
	anchored = 1
	unacidable = 1//Dissolving the case would also delete the gun.
	var/health = 30
	var/occupied = 1
	var/destroyed = 0

/obj/structure/displaycase/ex_act(severity, target)
	switch(severity)
		if (1)
			new /obj/item/weapon/shard( src.loc )
			if (occupied)
				new /obj/item/weapon/gun/energy/laser/captain( src.loc )
				occupied = 0
			qdel(src)
		if (2)
			if (prob(50))
				src.health -= 15
				src.healthcheck()
		if (3)
			if (prob(50))
				src.health -= 5
				src.healthcheck()

/obj/structure/displaycase/bullet_act(var/obj/item/projectile/Proj)
	if((Proj.damage_type == BRUTE || Proj.damage_type == BURN))
		health -= Proj.damage
	..()
	src.healthcheck()
	return

/obj/structure/displaycase/blob_act()
	if (prob(75))
		new /obj/item/weapon/shard( src.loc )
		if (occupied)
			new /obj/item/weapon/gun/energy/laser/captain( src.loc )
			occupied = 0
		qdel(src)

/obj/structure/displaycase/proc/healthcheck()
	if (src.health <= 0)
		if (!( src.destroyed ))
			src.density = 0
			src.destroyed = 1
			new /obj/item/weapon/shard( src.loc )
			playsound(src, "shatter", 70, 1)
			update_icon()

			//Activate Anti-theft
			var/area/alarmed = get_area(src)
			alarmed.burglaralert(src)
			playsound(src, "sound/effects/alert.ogg", 50, 1)

	else
		playsound(src.loc, 'sound/effects/Glasshit.ogg', 75, 1)
	return

/obj/structure/displaycase/update_icon()
	if(src.destroyed)
		src.icon_state = "glassboxb[src.occupied]"
	else
		src.icon_state = "glassbox[src.occupied]"
	return

/obj/structure/displaycase/attackby(obj/item/weapon/W as obj, mob/user as mob, params)
	user.changeNext_move(CLICK_CD_MELEE)
	src.health -= W.force
	src.healthcheck()
	..()
	return

/obj/structure/displaycase/attack_paw(mob/user as mob)
	return src.attack_hand(user)

/obj/structure/displaycase/attack_hand(mob/user as mob)
	user.changeNext_move(CLICK_CD_MELEE)
	if (src.destroyed && src.occupied)
		new /obj/item/weapon/gun/energy/laser/captain( src.loc )
		user << "You deactivate the hover field built into the case."
		src.occupied = 0
		src.add_fingerprint(user)
		update_icon()
		return
	else
		user.visible_message("[user] kicks the display case.", \
						 "You kick the display case.")
		src.health -= 2
		healthcheck()
		return


code:
obj/structure/door_assembly
	icon = 'icons/obj/doors/door_assembly.dmi'

	name = "airlock assembly"
	icon_state = "door_as_0"
	anchored = 0
	density = 1
	var/state = 0
	var/mineral = null
	var/typetext = ""
	var/icontext = ""
	var/base_icon_state = "door_as_"
	var/glass_base_icon_state = "door_as_g"
	var/obj/item/weapon/airlock_electronics/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

obj/structure/door_assembly/New()
	base_icon_state = copytext(icon_state,1,lentext(icon_state))

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

/obj/structure/door_assembly/door_assembly_com
	name = "command airlock assembly"
	icon_state = "door_as_com1"
	glass_base_icon_state = "door_as_gcom"
	typetext = "command"
	icontext = "com"
	glass_type = /obj/machinery/door/airlock/glass_command
	airlock_type = /obj/machinery/door/airlock/command
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_com/glass
	mineral = "glass"
	icon_state = "door_as_gcom1"

/obj/structure/door_assembly/door_assembly_sec
	name = "security airlock assembly"
	icon_state = "door_as_sec1"
	glass_base_icon_state = "door_as_gsec"
	typetext = "security"
	icontext = "sec"
	glass_type = /obj/machinery/door/airlock/glass_security
	airlock_type = /obj/machinery/door/airlock/security
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_sec/glass
	mineral = "glass"
	icon_state = "door_as_gsec1"

/obj/structure/door_assembly/door_assembly_eng
	name = "engineering airlock assembly"
	icon_state = "door_as_eng1"
	glass_base_icon_state = "door_as_geng"
	typetext = "engineering"
	icontext = "eng"
	glass_type = /obj/machinery/door/airlock/glass_engineering
	airlock_type = /obj/machinery/door/airlock/engineering
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_eng/glass
	mineral = "glass"
	icon_state = "door_as_geng1"

/obj/structure/door_assembly/door_assembly_min
	name = "mining airlock assembly"
	icon_state = "door_as_min1"
	glass_base_icon_state = "door_as_gmin"
	typetext = "mining"
	icontext = "min"
	glass_type = /obj/machinery/door/airlock/glass_mining
	airlock_type = /obj/machinery/door/airlock/mining
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_min/glass
	mineral = "glass"
	icon_state = "door_as_gmin1"

/obj/structure/door_assembly/door_assembly_atmo
	name = "atmospherics airlock assembly"
	icon_state = "door_as_atmo1"
	glass_base_icon_state = "door_as_gatmo"
	typetext = "atmos"
	icontext = "atmo"
	glass_type = /obj/machinery/door/airlock/glass_atmos
	airlock_type = /obj/machinery/door/airlock/atmos
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_atmo/glass
	mineral = "glass"
	icon_state = "door_as_gatmo1"

/obj/structure/door_assembly/door_assembly_research
	name = "research airlock assembly"
	icon_state = "door_as_res1"
	glass_base_icon_state = "door_as_gres"
	typetext = "research"
	icontext = "res"
	glass_type = /obj/machinery/door/airlock/glass_research
	airlock_type = /obj/machinery/door/airlock/research
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_research/glass
	mineral = "glass"
	icon_state = "door_as_gres1"

/obj/structure/door_assembly/door_assembly_science
	name = "science airlock assembly"
	icon_state = "door_as_sci1"
	glass_base_icon_state = "door_as_gsci"
	typetext = "science"
	icontext = "sci"
	glass_type = /obj/machinery/door/airlock/glass_science
	airlock_type = /obj/machinery/door/airlock/science
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_science/glass
	mineral = "glass"
	icon_state = "door_as_gsci1"

/obj/structure/door_assembly/door_assembly_med
	name = "medical airlock assembly"
	icon_state = "door_as_med1"
	glass_base_icon_state = "door_as_gmed"
	typetext = "medical"
	icontext = "med"
	glass_type = /obj/machinery/door/airlock/glass_medical
	airlock_type = /obj/machinery/door/airlock/medical
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_med/glass
	mineral = "glass"
	icon_state = "door_as_gmed1"

/obj/structure/door_assembly/door_assembly_mai
	name = "maintenance airlock assembly"
	icon_state = "door_as_mai1"
	typetext = "maintenance"
	icontext = "mai"
	airlock_type = /obj/machinery/door/airlock/maintenance
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_ext
	name = "external airlock assembly"
	icon_state = "door_as_ext1"
	typetext = "external"
	icontext = "ext"
	airlock_type = /obj/machinery/door/airlock/external
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_fre
	name = "freezer airlock assembly"
	icon_state = "door_as_fre1"
	typetext = "freezer"
	icontext = "fre"
	airlock_type = /obj/machinery/door/airlock/freezer
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_hatch
	name = "airtight hatch assembly"
	icon_state = "door_as_hatch1"
	typetext = "hatch"
	icontext = "hatch"
	airlock_type = /obj/machinery/door/airlock/hatch
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_mhatch
	name = "maintenance hatch assembly"
	icon_state = "door_as_mhatch1"
	typetext = "maintenance_hatch"
	icontext = "mhatch"
	airlock_type = /obj/machinery/door/airlock/maintenance_hatch
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_glass
	name = "glass airlock assembly"
	icon_state = "door_as_g1"
	airlock_type = /obj/machinery/door/airlock/glass
	anchored = 1
	density = 1
	state = 1
	mineral = "glass"

/obj/structure/door_assembly/door_assembly_gold
	name = "gold airlock assembly"
	icon_state = "door_as_gold1"
	airlock_type = /obj/machinery/door/airlock/gold
	anchored = 1
	density = 1
	state = 1
	mineral = "gold"

/obj/structure/door_assembly/door_assembly_silver
	name = "silver airlock assembly"
	icon_state = "door_as_silver1"
	airlock_type = /obj/machinery/door/airlock/silver
	anchored = 1
	density = 1
	state = 1
	mineral = "silver"

/obj/structure/door_assembly/door_assembly_diamond
	name = "diamond airlock assembly"
	icon_state = "door_as_diamond1"
	airlock_type = /obj/machinery/door/airlock/diamond
	anchored = 1
	density = 1
	state = 1
	mineral = "diamond"

/obj/structure/door_assembly/door_assembly_uranium
	name = "uranium airlock assembly"
	icon_state = "door_as_uranium1"
	airlock_type = /obj/machinery/door/airlock/uranium
	anchored = 1
	density = 1
	state = 1
	mineral = "uranium"

/obj/structure/door_assembly/door_assembly_plasma
	name = "plasma airlock assembly"
	icon_state = "door_as_plasma1"
	airlock_type = /obj/machinery/door/airlock/plasma
	anchored = 1
	density = 1
	state = 1
	mineral = "plasma"

/obj/structure/door_assembly/door_assembly_clown
	name = "bananium airlock assembly"
	desc = "Honk"
	icon_state = "door_as_clown1"
	airlock_type = /obj/machinery/door/airlock/clown
	anchored = 1
	density = 1
	state = 1
	mineral = "bananium"

/obj/structure/door_assembly/door_assembly_sandstone
	name = "sandstone airlock assembly"
	icon_state = "door_as_sandstone1"
	airlock_type = /obj/machinery/door/airlock/sandstone
	anchored = 1
	density = 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_state = "door_as_highsec1"
	typetext = "highsecurity"
	icontext = "highsec"
	airlock_type = /obj/machinery/door/airlock/highsecurity
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_vault
	name = "vault door assembly"
	icon_state = "door_as_vault1"
	typetext = "vault"
	icontext = "vault"
	airlock_type = /obj/machinery/door/airlock/vault
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_shuttle
	name = "shuttle airlock assembly"
	icon_state = "door_as_shuttle1"
	typetext = "shuttle"
	icontext = "shuttle"
	airlock_type = /obj/machinery/door/airlock/shuttle
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_wood
	name = "wooden airlock assembly"
	icon_state = "door_as_wood1"
	airlock_type = /obj/machinery/door/airlock/wood
	anchored = 1
	density = 1
	state = 1
	mineral = "wood"

/obj/structure/door_assembly/door_assembly_viro
	name = "virology airlock assembly"
	icon_state = "door_as_viro1"
	glass_base_icon_state = "door_as_gviro"
	typetext = "virology"
	icontext = "viro"
	glass_type = /obj/machinery/door/airlock/glass_virology
	airlock_type = /obj/machinery/door/airlock/virology
	anchored = 1
	density = 1
	state = 1

/obj/structure/door_assembly/door_assembly_viro/glass
	mineral = "glass"
	icon_state = "door_as_gviro1"

/obj/structure/door_assembly/attackby(obj/item/W as obj, mob/user as mob, 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("Default", "Engineering", "Atmospherics", "Security", "Command", "Medical", "Research", "Mining")
			else
				//These airlocks have a regular version.
				optionlist = list("Default", "Engineering", "Atmospherics", "Security", "Command", "Medical", "Research", "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)
				//For Default the standard options suffice.
				if("Engineering")
					typetext = "engineering"
					icontext = "eng"
					has_solid = 1
					has_glass = 1
				if("Atmospherics")
					typetext = "atmos"
					icontext = "atmo"
					has_solid = 1
					has_glass = 1
				if("Security")
					typetext = "security"
					icontext = "sec"
					has_solid = 1
					has_glass = 1
				if("Command")
					typetext = "command"
					icontext = "com"
					has_solid = 1
					has_glass = 1
				if("Medical")
					typetext = "medical"
					icontext = "med"
					has_solid = 1
					has_glass = 1
				if("Research")
					typetext = "research"
					icontext = "res"
					has_solid = 1
					has_glass = 1
				if("Mining")
					typetext = "mining"
					icontext = "min"
					has_solid = 1
					has_glass = 1
				if("Maintenance")
					typetext = "maintenance"
					icontext = "mai"
					has_solid = 1
					has_glass = 0
				if("External")
					typetext = "external"
					icontext = "ext"
					has_solid = 1
					has_glass = 0
				if("High Security")
					typetext = "highsecurity"
					icontext = "highsec"
					has_solid = 1
					has_glass = 0
			if(has_solid)
				airlock_type = text2path("/obj/machinery/door/airlock/[typetext]")
				base_icon_state = "door_as_[icontext]"
			else
				airlock_type = /obj/machinery/door/airlock
				base_icon_state = "door_as_"

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

			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] dissassembles the airlock assembly.", \
								"You start to dissassemble the airlock assembly.")
			playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1)

			if(do_after(user, 40))
				if( !WT.isOn() )
					return
				user << " You've disassembled the airlock assembly."
				new /obj/item/stack/sheet/metal(get_turf(src), 4)
				if (mineral)
					if (mineral == "glass")
						new /obj/item/stack/sheet/rglass(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))
				if( src.anchored )
					return
				user << " You've secured 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))
			if( !src.anchored )
				return
			user << " You've unsecured 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))
			if(C.get_amount() < 1 || state != 0) return
			C.use(1)
			src.state = 1
			user << "You've wired 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))
			if( src.state != 1 )
				return
			user << " You've 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/airlock_electronics) && 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.")
		user.drop_item()
		W.loc = src

		if(do_after(user, 40))
			if( src.state != 1 )
				W.loc = src.loc
				return
			user << " You've installed the airlock electronics."
			src.state = 2
			src.name = "near finished airlock assembly"
			src.electronics = W
		else
			W.loc = src.loc

			//qdel(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))
			if( src.state != 2 )
				return
			user << " You've removed the airlock electronics."
			src.state = 1
			src.name = "wired airlock assembly"
			var/obj/item/weapon/airlock_electronics/ae
			if (!electronics)
				ae = new/obj/item/weapon/airlock_electronics( 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(G.type == /obj/item/stack/sheet/rglass)
					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))
						if(G.get_amount() < 1 || mineral) return
						user << "You've installed reinforced glass windows into the airlock assembly."
						G.use(1)
						mineral = "glass"
						name = "near finished window airlock assembly"
						//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 = ""
						base_icon_state = "door_as_[icontext]"
						glass_base_icon_state = "door_as_g[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))
							if(G.get_amount() < 2 || mineral) return
							user << "You've installed [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]")
							base_icon_state = "door_as_[M]"
							glass_base_icon_state = "door_as_g"
							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))
			if(src.loc && state == 2)
				user << " You've finished 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
				if(src.electronics.use_one_access)
					door.req_one_access = src.electronics.conf_access
				else
					door.req_access = src.electronics.conf_access
				if(created_name)
					door.name = created_name
				src.electronics.loc = door
				qdel(src)
	else
		..()
	if(mineral == "glass")
		icon_state = "[glass_base_icon_state][state]"
	else
		icon_state = "[base_icon_state][state]"
	//This updates the icon_state. They are named as "door_as1_eng" where the 1 in that example
	//represents what state it's in. So the most generic algorithm for the correct updating of
	//this is simply to change the number.


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 as mob)
	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()


code:
/obj/structure/stool/bed/chair/e_chair
	name = "electric chair"
	desc = "Looks absolutely SHOCKING!"
	icon_state = "echair0"
	var/obj/item/assembly/shock_kit/part = null
	var/last_time = 1.0

/obj/structure/stool/bed/chair/e_chair/New()
	..()
	overlays += image('icons/obj/objects.dmi', src, "echair_over", MOB_LAYER + 1, dir)
	return

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

/obj/structure/stool/bed/chair/e_chair/rotate()
	..()
	overlays.Cut()
	overlays += image('icons/obj/objects.dmi', src, "echair_over", MOB_LAYER + 1, dir)	//there's probably a better way of handling this, but eh. -Pete
	return

/obj/structure/stool/bed/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)
	var/light = A.power_light
	A.updateicon()

	flick("echair1", src)
	var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
	s.set_up(12, 1, src)
	s.start()
	if(buckled_mob)
		buckled_mob.burn_skin(85)
		buckled_mob << "You feel a deep shock course through your body!"
		sleep(1)
		buckled_mob.burn_skin(85)
	visible_message("The electric chair went off!", "You hear a deep sharp shock!")

	A.power_light = light
	A.updateicon()
	return


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.0)
			qdel(src)
			return
		if(2.0)
			if(prob(50))
				if(has_extinguisher)
					has_extinguisher.loc = src.loc
				qdel(src)
				return
		if(3.0)
			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)
			user.drop_item()
			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/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 seperate rooms."
	anchored = 1
	icon = 'icons/turf/walls.dmi'
	var/mineral = "metal"
	var/walltype = "metal"
	var/opening = 0
	density = 1
	opacity = 1
	canSmoothWith = list(
	/turf/simulated/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.
	)

/obj/structure/falsewall/New()
	..()
	relativewall_neighbours()

/obj/structure/falsewall/Destroy()

	var/temploc = loc
	loc = null

	for(var/turf/simulated/wall/W in range(temploc,1))
		W.relativewall()

	for(var/obj/structure/falsewall/W in range(temploc,1))
		W.relativewall()
	..()

/obj/structure/falsewall/relativewall()

	if(!density)
		icon_state = "[walltype]fwall_open"
		return

	var/junction = findSmoothingNeighbors()

	icon_state = "[walltype][junction]"
	return

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

	opening = 1
	if(density)
		do_the_flick()
		sleep(4)
		density = 0
		set_opacity(0)
		update_icon(0)
	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(4)
		set_opacity(1)
		update_icon()
	opening = 0

/obj/structure/falsewall/proc/do_the_flick()
	if(density)
		flick("[walltype]fwall_opening", src)
	else
		flick("[walltype]fwall_closing", src)

/obj/structure/falsewall/update_icon(relativewall = 1)//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)
		icon_state = "[walltype]0"
		if(relativewall)
			relativewall()
	else
		icon_state = "[walltype]fwall_open"

/obj/structure/falsewall/proc/ChangeToWall(delete = 1)
	var/turf/T = get_turf(src)
	if(!walltype || walltype == "metal")
		T.ChangeTurf(/turf/simulated/wall)
	else
		T.ChangeTurf(text2path("/turf/simulated/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/simulated/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/pickaxe/plasmacutter))
		dismantle(user)

	if(istype(W, /obj/item/weapon/pickaxe/drill/jackhammer) || istype(W, /obj/item/weapon/pickaxe/drill/diamonddrill))
		var/obj/item/weapon/pickaxe/drill/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)

/*
 * False R-Walls
 */

/obj/structure/falsewall/reinforced
	name = "reinforced wall"
	desc = "A huge chunk of reinforced metal used to seperate rooms."
	icon_state = "r_wall"

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

/obj/structure/falsewall/reinforced/do_the_flick()
	if(density)
		flick("frwall_opening", src)
	else
		flick("frwall_closing", src)

/obj/structure/falsewall/reinforced/update_icon(relativewall = 1)
	if(density)
		icon_state = "rwall0"
		src.relativewall()
	else
		icon_state = "frwall_open"

/obj/structure/falsewall/reinforced/relativewall()

	if(!density)
		icon_state = "frwall_open"
		return

	var/junction = 0 //will be used to determine from which side the wall is connected to other walls

	for(var/turf/simulated/wall/W in orange(src,1))
		if(abs(src.x-W.x)-abs(src.y-W.y)) //doesn't count diagonal walls
			if(src.walltype == W.walltype)//Only 'like' walls connect -Sieve
				junction |= get_dir(src,W)
	for(var/obj/structure/falsewall/W in orange(src,1))
		if(abs(src.x-W.x)-abs(src.y-W.y)) //doesn't count diagonal walls
			if(src.walltype == W.walltype)
				junction |= get_dir(src,W)
	icon_state = "rwall[junction]"
	return

/*
 * Uranium Falsewalls
 */

/obj/structure/falsewall/uranium
	name = "uranium wall"
	desc = "A wall with uranium plating. This is probably a bad idea."
	icon_state = ""
	mineral = "uranium"
	walltype = "uranium"
	var/active = null
	var/last_event = 0

/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
			for(var/mob/living/L in range(3,src))
				L.apply_effect(12,IRRADIATE,0)
			for(var/turf/simulated/wall/mineral/uranium/T in range(3,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_state = ""
	mineral = "gold"
	walltype = "gold"

/obj/structure/falsewall/silver
	name = "silver wall"
	desc = "A wall with silver plating. Shiny."
	icon_state = ""
	mineral = "silver"
	walltype = "silver"

/obj/structure/falsewall/diamond
	name = "diamond wall"
	desc = "A wall with diamond plating. You monster."
	icon_state = ""
	mineral = "diamond"
	walltype = "diamond"

/obj/structure/falsewall/plasma
	name = "plasma wall"
	desc = "A wall with plasma plating. This is definately a bad idea."
	icon_state = ""
	mineral = "plasma"
	walltype = "plasma"

/obj/structure/falsewall/plasma/attackby(obj/item/weapon/W, mob/user, params)
	if(is_hot(W) > 300)
		message_admins("Plasma falsewall ignited by [key_name(user, user.client)](?) in ([x],[y],[z] - JMP)",0,1)
		log_game("Plasma falsewall ignited by [user.ckey]([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(SPAWN_HEAT | SPAWN_TOXINS, 400)
	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()

//-----------wtf?-----------start
/obj/structure/falsewall/clown
	name = "bananium wall"
	desc = "A wall with bananium plating. Honk!"
	icon_state = ""
	mineral = "bananium"
	walltype = "bananium"

/obj/structure/falsewall/sandstone
	name = "sandstone wall"
	desc = "A wall with sandstone plating."
	icon_state = ""
	mineral = "sandstone"
	walltype = "sandstone"
//------------wtf?------------end

/obj/structure/falsewall/wood
	name = "wooden wall"
	desc = "A wall with wooden plating."
	icon_state = ""
	mineral = "wood"
	walltype = "wood"


code:
//trees
/obj/structure/flora/tree
	name = "tree"
	anchored = 1
	density = 1
	pixel_x = -16
	layer = 9

/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 = 'icons/obj/flora/pinetrees.dmi'
	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/flora/tree/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 = "rock1"
	icon = 'icons/obj/flora/rocks.dmi'
	anchored = 1

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

/obj/structure/flora/rock/pile
	name = "rocks"
	desc = "some rocks"
	icon_state = "rockpile1"

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


code:
/obj/structure/girder
	name = "girder"
	icon_state = "girder"
	anchored = 1
	density = 1
	layer = 2
	var/state = 0
	var/girderpasschance = 20 // percentage chance that a projectile passes through the girder.

/obj/structure/girder/attackby(obj/item/W as obj, mob/user as mob, params)
	add_fingerprint(user)
	if(istype(W, /obj/item/weapon/wrench) && state == 0)
		if(anchored && !istype(src,/obj/structure/girder/displaced))
			playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1)
			user << "Now disassembling the girder..."
			if(do_after(user,20))
				if(!src.loc)
					return
				user << "You dissasembled the girder!"
				new /obj/item/stack/sheet/metal(get_turf(src))
				qdel(src)
		else if(!anchored)
			if (!istype(src.loc, /turf/simulated/floor))
				usr << "A floor must be present to secure the girder!"
				return
			playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1)
			user << "Now securing the girder..."
			if(do_after(user, 20))
				if(!src.loc)
					return
				user << "You secured the girder!"
				var/obj/structure/girder/G = new (loc)
				transfer_fingerprints_to(G)
				qdel(src)

	else if(istype(W, /obj/item/weapon/pickaxe/plasmacutter))
		user << "Now slicing apart the girder..."
		if(do_after(user,15))
			if(!src.loc)
				return
			user << "You slice apart the girder!"
			new /obj/item/stack/sheet/metal(get_turf(src))
			qdel(src)

	else if(istype(W, /obj/item/weapon/pickaxe/drill/jackhammer) || istype(W, /obj/item/weapon/pickaxe/drill/diamonddrill))
		var/obj/item/weapon/pickaxe/drill/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/screwdriver) && state == 2 && istype(src,/obj/structure/girder/reinforced))
		playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1)
		user << "Now unsecuring support struts..."
		if(do_after(user,20))
			if(!src.loc)
				return
			user << "You unsecured the support struts!"
			state = 1

	else if(istype(W, /obj/item/weapon/wirecutters) && istype(src,/obj/structure/girder/reinforced) && state == 1)
		playsound(src.loc, 'sound/items/Wirecutter.ogg', 100, 1)
		user << "Now removing support struts..."
		if(do_after(user,20))
			if(!src.loc)
				return
			user << "You removed the support struts!"
			var/obj/structure/girder/G = new (loc)
			transfer_fingerprints_to(G)
			qdel(src)

	else if(istype(W, /obj/item/weapon/crowbar) && state == 0 && anchored )
		playsound(src.loc, 'sound/items/Crowbar.ogg', 100, 1)
		user << "Now dislodging the girder..."
		if(do_after(user, 20))
			if(!src.loc)
				return
			user << "You dislodged the girder!"
			var/obj/structure/girder/displaced/D = new (loc)
			transfer_fingerprints_to(D)
			qdel(src)

	else if(istype(W, /obj/item/stack/sheet))
		if (!istype(src.loc, /turf/simulated/floor))
			usr << "The girder is too unstable to build anything!"
			return

		var/obj/item/stack/sheet/S = W
		switch(S.type)

			if(/obj/item/stack/sheet/metal, /obj/item/stack/sheet/metal/cyborg)
				if(!anchored)
					if (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
						user << "You need two sheets of metal to create a false wall."
						return
				else
					if(S.get_amount() < 2)
						user << "You need two sheets of metal to finish a wall."
						return
					user << "Now adding plating..."
					if (do_after(user, 20))
						if(loc == null || S.get_amount() < 2)
							return
						S.use(2)
						user << "You added the plating!"
						var/turf/Tsrc = get_turf(src)
						Tsrc.ChangeTurf(/turf/simulated/wall)
						for(var/turf/simulated/wall/X in Tsrc.loc)
							if(X)
								transfer_fingerprints_to(X)
						qdel(src)
					return

			if(/obj/item/stack/sheet/plasteel)
				if(!anchored)
					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/obj/structure/falsewall/reinforced/FW = new (loc)
					transfer_fingerprints_to(FW)
					qdel(src)
				else
					if (src.icon_state == "reinforced") //I cant believe someone would actually write this line of code...
						if(S.amount < 1) return ..()
						user << "Now finalising reinforced wall..."
						if(do_after(user, 30))
							if(!src.loc || !S || S.amount < 1)
								return
							S.use(1)
							user << "Wall fully reinforced!"
							var/turf/Tsrc = get_turf(src)
							Tsrc.ChangeTurf(/turf/simulated/wall/r_wall)
							for(var/turf/simulated/wall/r_wall/X in Tsrc.loc)
								if(X)	transfer_fingerprints_to(X)
							qdel(src)
						return
					else
						if(S.amount < 1) return ..()
						user << "Now reinforcing girders..."
						if (do_after(user,40))
							if(!src.loc || !S || S.amount < 1)
								return
							S.use(1)
							user << "Girders reinforced!"
							var/obj/structure/girder/reinforced/R = new (loc)
							transfer_fingerprints_to(R)
							qdel(src)
						return

		if(S.sheettype)
			var/M = S.sheettype
			if(!anchored)
				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) return ..()
				user << "Now adding plating..."
				if (do_after(user,20))
					if(!src.loc || !S || S.amount < 2)
						return
					S.use(2)
					user << "You added the plating!"
					var/turf/Tsrc = get_turf(src)
					Tsrc.ChangeTurf(text2path("/turf/simulated/wall/mineral/[M]"))
					for(var/turf/simulated/wall/mineral/X in Tsrc.loc)
						if(X)	transfer_fingerprints_to(X)
					qdel(src)
				return

		add_hiddenprint(usr)

	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.
			user.drop_item()
			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/blob_act()
	if(prob(40))
		qdel(src)

/obj/structure/girder/ex_act(severity, target)
	switch(severity)
		if(1.0)
			qdel(src)
			return
		if(2.0)
			if (prob(70))
				var/remains = pick(/obj/item/stack/rods,/obj/item/stack/sheet/metal)
				new remains(loc)
				qdel(src)
			return
		if(3.0)
			if (prob(15))
				var/remains = pick(/obj/item/stack/rods,/obj/item/stack/sheet/metal)
				new remains(loc)
				qdel(src)
			return
	return

/obj/structure/girder/displaced
	name = "displaced girder"
	icon_state = "displaced"
	anchored = 0
	girderpasschance = 25

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

/obj/structure/girder/reinforced/ex_act(severity, target)
	switch(severity)
		if(1.0)
			qdel(src)
			return
		if(2.0)
			if (prob(30))
				var/remains = pick(/obj/item/stack/rods,/obj/item/stack/sheet/metal)
				new remains(loc)
				qdel(src)
			return
		if(3.0)
			if (prob(5))
				var/remains = pick(/obj/item/stack/rods,/obj/item/stack/sheet/metal)
				new remains(loc)
				qdel(src)
			return
	return

/obj/structure/cultgirder
	icon= 'icons/obj/cult.dmi'
	icon_state= "cultgirder"
	anchored = 1
	density = 1
	layer = 2

/obj/structure/cultgirder/attackby(obj/item/W as obj, mob/user as mob, params)
	if(istype(W, /obj/item/weapon/wrench))
		playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1)
		user << "Now disassembling the girder..."
		if(do_after(user,20))
			user << "You dissasembled the girder!"
			var/obj/effect/decal/remains/human/R = new (get_turf(src))
			transfer_fingerprints_to(R)
			qdel(src)

	else if(istype(W, /obj/item/weapon/pickaxe/plasmacutter))
		user << "Now slicing apart the girder..."
		if(do_after(user,15))
			user << "You slice apart the girder!"
			var/obj/effect/decal/remains/human/R = new (get_turf(src))
			transfer_fingerprints_to(R)
			qdel(src)

	else if(istype(W, /obj/item/weapon/pickaxe/drill/jackhammer) || istype(W, /obj/item/weapon/pickaxe/drill/diamonddrill))
		var/obj/item/weapon/pickaxe/drill/D = W
		user << "Your drill smashes through the girder!"
		var/obj/effect/decal/remains/human/R = new (get_turf(src))
		transfer_fingerprints_to(R)
		D.playDigSound()
		qdel(src)

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

/obj/structure/cultgirder/ex_act(severity, target)
	switch(severity)
		if(1.0)
			qdel(src)
			return
		if(2.0)
			if (prob(30))
				new /obj/effect/decal/remains/human(loc)
				qdel(src)
			return
		if(3.0)
			if (prob(5))
				new /obj/effect/decal/remains/human(loc)
				qdel(src)
			return
		else
	return


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 as mob)
	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 as mob)
	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 as mob)
	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/carbon/slime/user as mob)
	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 as mob)
	M.changeNext_move(CLICK_CD_MELEE)
	if(M.melee_damage_upper == 0)	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/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()
	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
	var/obj/item/stack/rods/newrods = new(loc)
	transfer_fingerprints_to(newrods)

/obj/structure/grille/attackby(obj/item/weapon/W as obj, mob/user as mob, 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/simulated) || anchored))
		if(!shock(user, 90))
			playsound(loc, 'sound/items/Screwdriver.ogg', 100, 1)
			anchored = !anchored
			user.visible_message("[user] [anchored ? "fastens" : "unfastens"] [src].", \
								 "You have [anchored ? "fastened [src] to" : "unfastened [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

//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))
				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 as mob, 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/effect/system/spark_spread/s = new /datum/effect/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)
	..()
	visible_message("[src] was hit by [AM].")
	var/tforce = 0
	if(ismob(AM))
		tforce = 5
	else if(isobj(AM))
		var/obj/item/I = AM
		tforce = max(0, I.throwforce * 0.5)
	playsound(loc, 'sound/effects/grillehit.ogg', 80, 1)
	health = max(0, health - tforce)
	healthcheck()


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!"
	else
		reagents.trans_to(mop, 5)	//
		user << "You wet [mop] in [src]."
		playsound(loc, 'sound/effects/slosh.ogg', 25, 1)

/obj/structure/janitorialcart/proc/put_in_cart(obj/item/I, mob/user)
	user.drop_item()
	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)
			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].")
		if(do_after(user, 30))
			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]"

//old style PIMP-CART
/obj/structure/stool/bed/chair/janicart
	name = "janicart"
	desc = "A brave janitor cyborg gave its life to produce such an amazing combination of speed and utility."
	icon = 'icons/obj/vehicles.dmi'
	icon_state = "pussywagon"
	anchored = 0
	density = 1
	var/obj/item/weapon/storage/bag/trash/mybag = null
	var/callme = "pimpin' ride"	//how do people refer to it?
	var/move_delay = 0
	var/floorbuffer = 0
	var/keytype = /obj/item/key/janitor

/obj/structure/stool/bed/chair/janicart/New()
	handle_rotation()

/obj/structure/stool/bed/chair/janicart/Move(a, b, flag)
	..()
	if(floorbuffer)
		var/turf/tile = loc
		if(isturf(tile))
			tile.clean_blood()
			if (istype(tile, /turf/simulated/floor))
				var/turf/simulated/floor/F = tile
				F.dirt = 0
			for(var/A in tile)
				if(istype(A, /obj/effect))
					if(istype(A, /obj/effect/rune) || istype(A, /obj/effect/decal/cleanable) || istype(A, /obj/effect/overlay))
						qdel(A)

/obj/structure/stool/bed/chair/janicart/examine(mob/user)
	..()
	if(floorbuffer)
		user << "It has been upgraded with a floor buffer."

/obj/structure/stool/bed/chair/janicart/attackby(obj/item/I, mob/user, params)
	if(istype(I, keytype))
		user << "Hold [I] in one of your hands while you drive this [callme]."
	else if(istype(I, /obj/item/weapon/storage/bag/trash))
		if(keytype == /obj/item/key/janitor)
			user << "You hook the trashbag onto the [callme]."
			user.drop_item()
			I.loc = src
			mybag = I
	else if(istype(I, /obj/item/janiupgrade))
		if(keytype == /obj/item/key/janitor)
			floorbuffer = 1
			qdel(I)
			user << "You upgrade the [callme] with the floor buffer."
	update_icon()

/obj/structure/stool/bed/chair/janicart/update_icon()
	overlays.Cut()
	if(mybag)
		overlays += "cart_garbage"
	if(floorbuffer)
		overlays += "cart_buffer"

/obj/structure/stool/bed/chair/janicart/attack_hand(mob/user)
	if(mybag)
		mybag.loc = get_turf(user)
		user.put_in_hands(mybag)
		mybag = null
		update_icon()
	else
		..()

/obj/structure/stool/bed/chair/janicart/relaymove(mob/user, direction)
	if(user.stat || user.stunned || user.weakened || user.paralysis)
		unbuckle_mob()
	if(istype(user.l_hand, keytype) || istype(user.r_hand, keytype))
		if(!Process_Spacemove(direction) || !has_gravity(src.loc) || move_delay)
			return
		step(src, direction)
		update_mob()
		handle_rotation()
		if(istype(src.loc, /turf/simulated))
			var/turf/simulated/T = src.loc
			if(T.wet == 2)	//Lube! Fall off!
				playsound(src, 'sound/misc/slip.ogg', 50, 1, -3)
				buckled_mob.Stun(7)
				buckled_mob.Weaken(7)
				unbuckle_mob()
				step(src, dir)
		move_delay = 1
		spawn(2)
			move_delay = 0
	else
		user << "You'll need the keys in one of your hands to drive this [callme]."

/obj/structure/stool/bed/chair/janicart/user_buckle_mob(mob/living/M, mob/user)
	if(user.incapacitated()) //user can't move the mob on the janicart's turf if incapacitated
		return
	for(var/atom/movable/A in get_turf(src)) //we check for obstacles on the turf.
		if(A.density)
			if(A != src && A != M)
				return
	M.loc = loc //we move the mob on the janicart's turf before checking if we can buckle.
	..()
	update_mob()

/obj/structure/stool/bed/chair/janicart/unbuckle_mob()
	if(buckled_mob)
		buckled_mob.pixel_x = 0
		buckled_mob.pixel_y = 0
	..()

/obj/structure/stool/bed/chair/janicart/handle_rotation()
	if((dir == SOUTH) || (dir == WEST) || (dir == EAST))
		layer = FLY_LAYER
	else
		layer = OBJ_LAYER

	if(buckled_mob)
		if(buckled_mob.loc != loc)
			buckled_mob.buckled = null //Temporary, so Move() succeeds.
			buckled_mob.buckled = src //Restoring

	update_mob()

/obj/structure/stool/bed/chair/janicart/proc/update_mob()
	if(buckled_mob)
		buckled_mob.dir = dir
		switch(dir)
			if(SOUTH)
				buckled_mob.pixel_x = 0
				buckled_mob.pixel_y = 7
			if(WEST)
				buckled_mob.pixel_x = 12
				buckled_mob.pixel_y = 7
			if(NORTH)
				buckled_mob.pixel_x = 0
				buckled_mob.pixel_y = 4
			if(EAST)
				buckled_mob.pixel_x = -12
				buckled_mob.pixel_y = 7

/obj/structure/stool/bed/chair/janicart/bullet_act(var/obj/item/projectile/Proj)
	if(buckled_mob)
		buckled_mob.bullet_act(Proj)

/obj/item/key
	name = "key"
	desc = "A small grey key."
	icon = 'icons/obj/vehicles.dmi'
	icon_state = "key"
	w_class = 1

/obj/item/key/janitor
	desc = "A keyring with a small steel key, and a pink fob reading \"Pussy Wagon\"."
	icon_state = "keyjanitor"

/obj/item/key/security
	desc = "A keyring with a small steel key, and a rubber stun baton accessory."
	icon_state = "keysec"

/obj/item/janiupgrade
	name = "floor buffer upgrade"
	desc = "An upgrade for mobile janicarts."
	icon = 'icons/obj/vehicles.dmi'
	icon_state = "upgrade"

/obj/structure/stool/bed/chair/janicart/secway
	name = "secway"
	desc = "A brave security cyborg gave its life to help you look like a complete tool."
	icon = 'icons/obj/vehicles.dmi'
	icon_state = "secway"
	callme = "secway"
	keytype = /obj/item/key/security

/obj/structure/stool/bed/chair/janicart/secway/update_mob()
	if(buckled_mob)
		buckled_mob.dir = dir
		buckled_mob.pixel_y = 4


code:
#define SKINTYPE_MONKEY 1
#define SKINTYPE_ALIEN 2
#define SKINTYPE_BEAR 3

#define MEATTYPE_MONKEY 1
#define MEATTYPE_ALIEN 2
#define MEATTYPE_BEAR 3

//////Kitchen Spike

/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
	var/meat = 0
	var/occupied = 0
	var/meattype = null
	var/skin = 0
	var/skintype = null

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

/obj/structure/kitchenspike/attackby(obj/item/weapon/grab/G as obj, mob/user as mob, params)
	if(!istype(G, /obj/item/weapon/grab))
		return
	if(istype(G.affecting, /mob/living/carbon/monkey))
		if(src.occupied == 0)
			src.icon_state = "spikebloody"
			src.occupied = 1
			src.meat = 5
			src.meattype = MEATTYPE_MONKEY
			src.skin = 1
			src.skintype = SKINTYPE_MONKEY
			for(var/mob/O in viewers(src, null))
				O.show_message(text("[user] has forced [G.affecting] onto the spike, killing them instantly!"))
			qdel(G.affecting)
			qdel(G)

		else
			user << "The spike already has something on it, finish collecting its meat first!"
	else if(istype(G.affecting, /mob/living/carbon/alien))
		if(src.occupied == 0)
			src.icon_state = "spikebloodygreen"
			src.occupied = 1
			src.meat = 5
			src.meattype = MEATTYPE_ALIEN
			src.skin = 1
			src.skintype = SKINTYPE_ALIEN
			for(var/mob/O in viewers(src, null))
				O.show_message(text("[user] has forced [G.affecting] onto the spike, killing them instantly!"))
			qdel(G.affecting)
			qdel(G)
		else
			user << "The spike already has something on it, finish collecting its meat first!"
	else if(istype(G.affecting, /mob/living/simple_animal/hostile/bear))
		if(src.occupied == 0)
			src.icon_state = "spikebloodybearz"
			src.occupied = 1
			src.meat = 5
			src.meattype = MEATTYPE_BEAR
			src.skin = 1
			src.skintype = SKINTYPE_BEAR
			for(var/mob/O in viewers(src, null))
				O.show_message(text("[user] has forced [G.affecting] onto the spike, killing them instantly!"))
			qdel(G.affecting)
			qdel(G)
		else
			user << "The spike already has something on it, finish collecting its meat first!"
	else
		user << "They are too big for the spike, try something smaller!"
		return

///obj/structure/kitchenspike/MouseDrop_T(var/atom/movable/C, mob/user)
//	if(istype(C, /obj/mob/carbon/monkey)
//	else if(istype(C, /obj/mob/carbon/alien) && !istype(C, /mob/living/carbon/alien/larva/slime))
//	else if(istype(C, /obj/livestock/spesscarp

/obj/structure/kitchenspike/attack_hand(mob/user as mob)
	if(..())
		return
	if(src.occupied)
		if(src.meattype == MEATTYPE_MONKEY && src.skintype == SKINTYPE_MONKEY)
			if(src.skin >= 1)
				src.skin--
				new /obj/item/stack/sheet/animalhide/monkey(src.loc)
				user << "You remove the hide from the monkey!"
			else if(src.meat > 1)
				src.meat--
				new /obj/item/weapon/reagent_containers/food/snacks/meat/slab/monkey(src.loc )
				usr << "You remove some meat from the monkey."
			else if(src.meat == 1)
				src.meat--
				new /obj/item/weapon/reagent_containers/food/snacks/meat/slab/monkey(src.loc)
				usr << "You remove the last piece of meat from the monkey!"
				src.icon_state = "spike"
				src.occupied = 0
		else if(src.meattype == MEATTYPE_ALIEN && src.skintype == SKINTYPE_ALIEN)
			if(src.skin >= 1)
				src.skin--
				new /obj/item/stack/sheet/animalhide/xeno(src.loc)
				user << "You remove the hide from the alien!"
			else if(src.meat > 1)
				src.meat--
				new /obj/item/weapon/reagent_containers/food/snacks/meat/slab/xeno(src.loc )
				usr << "You remove some meat from the alien."
			else if(src.meat == 1)
				src.meat--
				new /obj/item/weapon/reagent_containers/food/snacks/meat/slab/xeno(src.loc)
				usr << "You remove the last piece of meat from the alien!"
				src.icon_state = "spike"
				src.occupied = 0
		else if(src.meattype == MEATTYPE_BEAR && src.skintype == SKINTYPE_BEAR)
			if(src.skin >= 1)
				src.skin--
				new /obj/item/clothing/head/bearpelt(src.loc)
				user << "You remove the hide from the bear!"
			else if(src.meat > 1)
				src.meat--
				new /obj/item/weapon/reagent_containers/food/snacks/meat/slab/bear(src.loc )
				usr << "You remove some meat from the bear."
			else if(src.meat == 1)
				src.meat--
				new /obj/item/weapon/reagent_containers/food/snacks/meat/slab/bear(src.loc)
				usr << "You remove the last piece of meat from the bear!"
				src.icon_state = "spike"
				src.occupied = 0

#undef SKINTYPE_MONKEY
#undef SKINTYPE_ALIEN
#undef SKINTYPE_BEAR

#undef MEATTYPE_MONKEY
#undef MEATTYPE_ALIEN
#undef MEATTYPE_BEAR


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/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/attack_hand(mob/user as mob)
	if(up && down)
		switch( alert("Go up or down the ladder?", "Ladder", "Up", "Down", "Cancel") )
			if("Up")
				user.visible_message("[user] climbs up \the [src]!", \
									 "You climb up \the [src]!")
				user.loc = get_turf(up)
				up.add_fingerprint(user)
			if("Down")
				user.visible_message("[user] climbs down \the [src]!", \
									 "You climb down \the [src]!")
				user.loc = get_turf(down)
				down.add_fingerprint(user)
			if("Cancel")
				return

	else if(up)
		user.visible_message("[user] climbs up \the [src]!", \
							 "You climb up \the [src]!")
		user.loc = get_turf(up)
		up.add_fingerprint(user)

	else if(down)
		user.visible_message("[user] climbs down \the [src]!", \
							 "You climb down \the [src]!")
		user.loc = get_turf(down)
		down.add_fingerprint(user)

	add_fingerprint(user)

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

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


code:
/obj/structure/lamarr
	name = "lab cage"
	icon = 'icons/obj/stationobjs.dmi'
	icon_state = "labcage1"
	desc = "A glass lab container for storing interesting creatures."
	density = 1
	anchored = 1
	unacidable = 1//Dissolving the case would also delete Lamarr
	var/health = 30
	var/occupied = 1
	var/destroyed = 0

/obj/structure/lamarr/ex_act(severity, target)
	switch(severity)
		if (1)
			new /obj/item/weapon/shard( src.loc )
			Break()
			qdel(src)
		if (2)
			if (prob(50))
				src.health -= 15
				src.healthcheck()
		if (3)
			if (prob(50))
				src.health -= 5
				src.healthcheck()

/obj/structure/lamarr/bullet_act(var/obj/item/projectile/Proj)
	health -= Proj.damage
	..()
	src.healthcheck()
	return

/obj/structure/lamarr/blob_act()
	if (prob(75))
		new /obj/item/weapon/shard( src.loc )
		Break()
		qdel(src)

/obj/structure/lamarr/proc/healthcheck()
	if (src.health <= 0)
		if (!( src.destroyed ))
			src.density = 0
			src.destroyed = 1
			new /obj/item/weapon/shard( src.loc )
			playsound(src, "shatter", 70, 1)
			Break()
	else
		playsound(src.loc, 'sound/effects/Glasshit.ogg', 75, 1)
	return

/obj/structure/lamarr/update_icon()
	if(src.destroyed)
		src.icon_state = "labcageb[src.occupied]"
	else
		src.icon_state = "labcage[src.occupied]"
	return

/obj/structure/lamarr/attackby(obj/item/weapon/W as obj, mob/user as mob, params)
	user.changeNext_move(CLICK_CD_MELEE)
	src.health -= W.force
	src.healthcheck()
	..()
	return

/obj/structure/lamarr/attack_paw(mob/user as mob)
	return src.attack_hand(user)

/obj/structure/lamarr/attack_hand(mob/user as mob)
	user.changeNext_move(CLICK_CD_MELEE)
	if (src.destroyed)
		return
	else
		user.visible_message("[user] kicks the lab cage.", \
					 		"You kick the lab cage.")
		src.health -= 2
		healthcheck()
		return

/obj/structure/lamarr/proc/Break()
	if(occupied)
		var/obj/item/clothing/mask/facehugger/A = new /obj/item/clothing/mask/facehugger( src.loc )
		A.sterile = 1
		A.name = "Lamarr"
		occupied = 0
	update_icon()
	return