code:
/obj/item/stack/tile/mineral/plasma
	name = "plasma tile"
	singular_name = "plasma floor tile"
	desc = "A tile made out of highly flammable plasma. This can only end well."
	icon_state = "tile_plasma"
	w_class = 3.0
	force = 1.0
	throwforce = 1.0
	throw_speed = 3
	throw_range = 7
	max_amount = 60
	origin_tech = "plasma=1"
	turf_type = /turf/simulated/floor/mineral/plasma
	mineralType = "plasma"

/obj/item/stack/tile/mineral/uranium
	name = "uranium tile"
	singular_name = "uranium floor tile"
	desc = "A tile made out of uranium. You feel a bit woozy."
	icon_state = "tile_uranium"
	w_class = 3.0
	force = 1.0
	throwforce = 1.0
	throw_speed = 3
	throw_range = 7
	max_amount = 60
	origin_tech = "material=1"
	turf_type = /turf/simulated/floor/mineral/uranium
	mineralType = "uranium"

/obj/item/stack/tile/mineral/gold
	name = "gold tile"
	singular_name = "gold floor tile"
	desc = "A tile made out of gold, the swag seems strong here."
	icon_state = "tile_gold"
	w_class = 3.0
	force = 1.0
	throwforce = 1.0
	throw_speed = 3
	throw_range = 7
	max_amount = 60
	origin_tech = "material=1"
	turf_type = /turf/simulated/floor/mineral/gold
	mineralType = "gold"

/obj/item/stack/tile/mineral/silver
	name = "silver tile"
	singular_name = "silver floor tile"
	desc = "A tile made out of silver, the light shining from it is blinding."
	icon_state = "tile_silver"
	w_class = 3.0
	force = 1.0
	throwforce = 1.0
	throw_speed = 3
	throw_range = 7
	max_amount = 60
	origin_tech = "material=1"
	turf_type = /turf/simulated/floor/mineral/silver
	mineralType = "silver"

/obj/item/stack/tile/mineral/diamond
	name = "diamond tile"
	singular_name = "diamond floor tile"
	desc = "A tile made out of diamond. Wow, just, wow."
	icon_state = "tile_diamond"
	w_class = 3.0
	force = 1.0
	throwforce = 1.0
	throw_speed = 3
	throw_range = 7
	max_amount = 60
	origin_tech = "material=2"
	turf_type = /turf/simulated/floor/mineral/diamond
	mineralType = "diamond"

/obj/item/stack/tile/mineral/bananium
	name = "bananium tile"
	singular_name = "bananium floor tile"
	desc = "A tile made out of bananium, HOOOOOOOOONK!"
	icon_state = "tile_bananium"
	w_class = 3.0
	force = 1.0
	throwforce = 1.0
	throw_speed = 3
	throw_range = 7
	max_amount = 60
	origin_tech = "material=1"
	turf_type = /turf/simulated/floor/mineral/bananium
	mineralType = "bananium"


code:
/* Diffrent misc types of tiles & the tile prototype
 * Contains:
 		Tile
 *		Grass
 *		Wood
 *		Carpet
 */

/*
 * Tile
 */
/obj/item/stack/tile
	name = "broken tile"
	singular_name = "broken tile"
	desc = "A broken tile. This should not exist."
	var/turf_type = null
	var/mineralType = null

/obj/item/stack/tile/attackby(obj/item/W as obj, mob/user as mob, params)

	if (istype(W, /obj/item/weapon/weldingtool))
		var/obj/item/weapon/weldingtool/WT = W

		if(get_amount() < 4)
			user << "You need at least four tiles to do this."
			return

		if(is_hot(WT) && !mineralType)
			user << "You can not reform this."
			return

		if(WT.remove_fuel(0,user))

			if(mineralType == "plasma")
				atmos_spawn_air(SPAWN_HEAT | SPAWN_TOXINS, 5)
				user.visible_message("[user.name] set the plasma tiles on fire!", \
									"You set the plasma tiles on fire!")
				qdel(src)
				return

			if (mineralType == "metal")
				var/obj/item/stack/sheet/metal/new_item = new(user.loc)
				new_item.add_to_stacks(user)
				user.visible_message("[user.name] shaped [src] into metal with the weldingtool.", \
							 "You shaped [src] into metal with the weldingtool.", \
							 "You hear welding.")
				var/obj/item/stack/rods/R = src
				src = null
				var/replace = (user.get_inactive_hand()==R)
				R.use(4)
				if (!R && replace)
					user.put_in_hands(new_item)

			else
				var/sheet_type = text2path("/obj/item/stack/sheet/mineral/[mineralType]")
				var/obj/item/stack/sheet/mineral/new_item = new sheet_type(user.loc)
				new_item.add_to_stacks(user)
				user.visible_message("[user.name] shaped [src] into a sheet with the weldingtool.", \
							 "You shaped [src] into a sheet with the weldingtool.", \
							 "You hear welding.")
				var/obj/item/stack/rods/R = src
				src = null
				var/replace = (user.get_inactive_hand()==R)
				R.use(4)
				if (!R && replace)
					user.put_in_hands(new_item)
		return
	else
		..()

/*
 * Grass
 */
/obj/item/stack/tile/grass
	name = "grass tile"
	singular_name = "grass floor tile"
	desc = "A patch of grass like they often use on golf courses."
	icon_state = "tile_grass"
	w_class = 3.0
	force = 1.0
	throwforce = 1.0
	throw_speed = 3
	throw_range = 7
	max_amount = 60
	origin_tech = "biotech=1"
	turf_type = /turf/simulated/floor/fancy/grass

/*
 * Wood
 */
/obj/item/stack/tile/wood
	name = "wood floor tile"
	singular_name = "wood floor tile"
	desc = "an easy to fit wood floor tile."
	icon_state = "tile-wood"
	w_class = 3.0
	force = 1.0
	throwforce = 1.0
	throw_speed = 3
	throw_range = 7
	max_amount = 60
	origin_tech = "biotech=1"
	turf_type = /turf/simulated/floor/wood

/*
 * Carpets
 */
/obj/item/stack/tile/carpet
	name = "carpet"
	singular_name = "carpet"
	desc = "A piece of carpet. It is the same size as a floor tile."
	icon_state = "tile-carpet"
	w_class = 3.0
	force = 1.0
	throwforce = 1.0
	throw_speed = 3
	throw_range = 7
	max_amount = 60
	turf_type = /turf/simulated/floor/fancy/carpet

/*
 * High-traction
 */
/obj/item/stack/tile/noslip
	name = "high-traction floor tile"
	singular_name = "high-traction floor tile"
	desc = "A high-traction floor tile. It feels rubbery in your hand."
	icon_state = "tile_noslip"
	w_class = 3.0
	force = 1.0
	throwforce = 1.0
	throw_speed = 3
	throw_range = 7
	max_amount = 60
	turf_type = /turf/simulated/floor/noslip
	origin_tech = "material=3"

license: mit


code:
/* Toys!
 * Contains
 *		Balloons
 *		Fake singularity
 *		Toy gun
 *		Toy crossbow
 *		Toy swords
 *		Crayons
 *		Snap pops
 *		Mech prizes
 *		AI core prizes
 *		Cards
 *		Toy nuke
 *		Fake meteor
 *		Carp plushie
 *		Foam armblade
 *		Toy big red button
 */

/obj/item/toy
	throwforce = 0
	throw_speed = 3
	throw_range = 7
	force = 0

/*
 * Balloons
 */
/obj/item/toy/balloon
	name = "water balloon"
	desc = "A translucent balloon. There's nothing in it."
	icon = 'icons/obj/toy.dmi'
	icon_state = "waterballoon-e"
	item_state = "balloon-empty"

/obj/item/toy/balloon/New()
	create_reagents(10)

/obj/item/toy/balloon/attack(mob/living/carbon/human/M as mob, mob/user as mob)
	return

/obj/item/toy/balloon/afterattack(atom/A as mob|obj, mob/user as mob, proximity)
	if(!proximity) return
	if (istype(A, /obj/structure/reagent_dispensers/watertank) && get_dist(src,A) <= 1)
		A.reagents.trans_to(src, 10)
		user << "You fill the balloon with the contents of [A]."
		src.desc = "A translucent balloon with some form of liquid sloshing around in it."
		src.update_icon()
	return

/obj/item/toy/balloon/attackby(obj/O as obj, mob/user as mob, params)
	if(istype(O, /obj/item/weapon/reagent_containers/glass))
		if(O.reagents)
			if(O.reagents.total_volume < 1)
				user << "The [O] is empty."
			else if(O.reagents.total_volume >= 1)
				if(O.reagents.has_reagent("pacid", 1))
					user << "The acid chews through the balloon!"
					O.reagents.reaction(user)
					qdel(src)
				else
					src.desc = "A translucent balloon with some form of liquid sloshing around in it."
					user << "You fill the balloon with the contents of [O]."
					O.reagents.trans_to(src, 10)
	src.update_icon()
	return

/obj/item/toy/balloon/throw_impact(atom/hit_atom)
	if(src.reagents.total_volume >= 1)
		src.visible_message("\The [src] bursts!","You hear a pop and a splash.")
		src.reagents.reaction(get_turf(hit_atom))
		for(var/atom/A in get_turf(hit_atom))
			src.reagents.reaction(A)
		src.icon_state = "burst"
		spawn(5)
			if(src)
				qdel(src)
	return

/obj/item/toy/balloon/update_icon()
	if(src.reagents.total_volume >= 1)
		icon_state = "waterballoon"
		item_state = "balloon"
	else
		icon_state = "waterballoon-e"
		item_state = "balloon-empty"

/obj/item/toy/syndicateballoon
	name = "syndicate balloon"
	desc = "There is a tag on the back that reads \"FUK NT!11!\"."
	throwforce = 0
	throw_speed = 3
	throw_range = 7
	force = 0
	icon = 'icons/obj/weapons.dmi'
	icon_state = "syndballoon"
	item_state = "syndballoon"
	w_class = 4.0

/*
 * Fake singularity
 */
/obj/item/toy/spinningtoy
	name = "gravitational singularity"
	desc = "\"Singulo\" brand spinning toy."
	icon = 'icons/obj/singularity.dmi'
	icon_state = "singularity_s1"

/*
 * Toy gun: Why isnt this an /obj/item/weapon/gun?
 */
/obj/item/toy/gun
	name = "cap gun"
	desc = "Looks almost like the real thing! Ages 8 and up. Please recycle in an autolathe when you're out of caps."
	icon = 'icons/obj/guns/projectile.dmi'
	icon_state = "revolver"
	item_state = "gun"
	lefthand_file = 'icons/mob/inhands/guns_lefthand.dmi'
	righthand_file = 'icons/mob/inhands/guns_righthand.dmi'
	flags =  CONDUCT
	slot_flags = SLOT_BELT
	w_class = 3.0
	g_amt = 10
	m_amt = 10
	attack_verb = list("struck", "pistol whipped", "hit", "bashed")
	var/bullets = 7.0

/obj/item/toy/gun/examine(mob/user)
	..()
	user << "There [bullets == 1 ? "is" : "are"] [bullets] cap\s left."

/obj/item/toy/gun/attackby(obj/item/toy/ammo/gun/A as obj, mob/user as mob, params)

	if (istype(A, /obj/item/toy/ammo/gun))
		if (src.bullets >= 7)
			user << "It's already fully loaded!"
			return 1
		if (A.amount_left <= 0)
			user << "There are no more caps!"
			return 1
		if (A.amount_left < (7 - src.bullets))
			src.bullets += A.amount_left
			user << text("You reload [] cap\s!", A.amount_left)
			A.amount_left = 0
		else
			user << text("You reload [] cap\s!", 7 - src.bullets)
			A.amount_left -= 7 - src.bullets
			src.bullets = 7
		A.update_icon()
		return 1
	return

/obj/item/toy/gun/afterattack(atom/target as mob|obj|turf|area, mob/user as mob, flag)
	if (flag)
		return
	if (!(istype(usr, /mob/living/carbon/human) || ticker) && ticker.mode.name != "monkey")
		usr << "You don't have the dexterity to do this!"
		return
	src.add_fingerprint(user)
	if (src.bullets < 1)
		user.show_message("*click*", 2)
		playsound(user, 'sound/weapons/empty.ogg', 100, 1)
		return
	playsound(user, 'sound/weapons/Gunshot.ogg', 100, 1)
	src.bullets--
	user.visible_message("[user] fires [src] at [target]!", \
						"You fire [src] at [target]!", \
						 " You hear a gunshot.")

/obj/item/toy/ammo/gun
	name = "capgun ammo"
	desc = "Make sure to recyle the box in an autolathe when it gets empty."
	icon = 'icons/obj/ammo.dmi'
	icon_state = "357OLD-7"
	w_class = 1.0
	g_amt = 10
	m_amt = 10
	var/amount_left = 7.0

/obj/item/toy/ammo/gun/update_icon()
	src.icon_state = text("357OLD-[]", src.amount_left)

/obj/item/toy/ammo/gun/examine(mob/user)
	..()
	user << "There [amount_left == 1 ? "is" : "are"] [amount_left] cap\s left."

/*
 * Toy crossbow
 */

/obj/item/toy/crossbow
	name = "foam dart crossbow"
	desc = "A weapon favored by many overactive children. Ages 8 and up."
	icon = 'icons/obj/guns/energy.dmi'
	icon_state = "crossbow100"
	item_state = "crossbow"
	lefthand_file = 'icons/mob/inhands/guns_lefthand.dmi'
	righthand_file = 'icons/mob/inhands/guns_righthand.dmi'
	w_class = 2.0
	attack_verb = list("attacked", "struck", "hit")
	var/bullets = 5

/obj/item/toy/crossbow/examine(mob/user)
	..()
	if (bullets)
		user << "It is loaded with [bullets] foam dart\s."

/obj/item/toy/crossbow/attackby(obj/item/I as obj, mob/user as mob, params)
	if(istype(I, /obj/item/toy/ammo/crossbow))
		if(bullets <= 4)
			user.drop_item()
			qdel(I)
			bullets++
			user << "You load the foam dart into the crossbow."
		else
			usr << "It's already fully loaded."

/obj/item/toy/crossbow/afterattack(atom/target as mob|obj|turf|area, mob/user as mob, flag)
	if(!isturf(target.loc) || target == user) return
	if(flag) return

	if (locate (/obj/structure/table, src.loc))
		return
	else if (bullets)
		var/turf/trg = get_turf(target)
		var/obj/effect/foam_dart_dummy/D = new/obj/effect/foam_dart_dummy(get_turf(src))
		bullets--
		D.icon_state = "foamdart"
		D.name = "foam dart"
		playsound(user.loc, 'sound/items/syringeproj.ogg', 50, 1)

		for(var/i=0, i<6, i++)
			if (D)
				if(D.loc == trg) break
				step_towards(D,trg)

				for(var/mob/living/M in D.loc)
					if(!istype(M,/mob/living)) continue
					if(M == user) continue
					D.visible_message("[M] was hit by the foam dart!")
					new /obj/item/toy/ammo/crossbow(M.loc)
					qdel(D)
					return

				for(var/atom/A in D.loc)
					if(A == user) continue
					if(A.density)
						new /obj/item/toy/ammo/crossbow(A.loc)
						qdel(D)

			sleep(1)

		spawn(10)
			if(D)
				new /obj/item/toy/ammo/crossbow(D.loc)
				qdel(D)

		return
	else if (bullets == 0)
		user.Weaken(5)
		user.visible_message("[user] realized they were out of ammo and starting scrounging for some!")

/obj/item/toy/crossbow/attack(mob/M as mob, mob/user as mob)
	src.add_fingerprint(user)

// ******* Check

	if (src.bullets > 0 && M.lying)

		M.visible_message("[user] casually lines up a shot with [M]'s head and pulls the trigger!")
		M.visible_message("[M] was hit in the head by the foam dart!", \
							"You're hit in the head by the foam dart!", \
							"You hear the sound of foam against skull.")

		playsound(user.loc, 'sound/items/syringeproj.ogg', 50, 1)
		new /obj/item/toy/ammo/crossbow(M.loc)
		src.bullets--
	else if (M.lying && src.bullets == 0)
		M.visible_message("[user] casually lines up a shot with [M]'s head, pulls the trigger, then realizes they are out of ammo and drops to the floor in search of some!")
		user.Weaken(5)
	return

/obj/item/toy/ammo/crossbow
	name = "foam dart"
	desc = "Its nerf or nothing! Ages 8 and up."
	icon = 'icons/obj/toy.dmi'
	icon_state = "foamdart"
	w_class = 1.0

/obj/effect/foam_dart_dummy
	name = ""
	desc = ""
	icon = 'icons/obj/toy.dmi'
	icon_state = "null"
	anchored = 1
	density = 0

/*
 * Toy swords
 */
/obj/item/toy/sword
	name = "toy sword"
	desc = "A cheap, plastic replica of an energy sword. Realistic sounds! Ages 8 and up."
	icon = 'icons/obj/weapons.dmi'
	icon_state = "sword0"
	item_state = "sword0"
	var/active = 0.0
	w_class = 2.0
	flags = NOSHIELD
	attack_verb = list("attacked", "struck", "hit")
	var/hacked = 0

/obj/item/toy/sword/attack_self(mob/user as mob)
	active = !( active )
	if (active)
		user << "You extend the plastic blade with a quick flick of your wrist."
		playsound(user, 'sound/weapons/saberon.ogg', 20, 1)
		if(hacked)
			icon_state = "swordrainbow"
			item_state = "swordrainbow"
		else
			icon_state = "swordblue"
			item_state = "swordblue"
		w_class = 4
	else
		user << "You push the plastic blade back down into the handle."
		playsound(user, 'sound/weapons/saberoff.ogg', 20, 1)
		icon_state = "sword0"
		item_state = "sword0"
		w_class = 2
	add_fingerprint(user)
	return

// Copied from /obj/item/weapon/melee/energy/sword/attackby
/obj/item/toy/sword/attackby(obj/item/weapon/W, mob/living/user, params)
	..()
	if(istype(W, /obj/item/toy/sword))
		if(W == src)
			user << "You try to attach the end of the plastic sword to... itself. You're not very smart, are you?"
			if(ishuman(user))
				user.adjustBrainLoss(10)
		else if((W.flags & NODROP) || (flags & NODROP))
			user << "\the [flags & NODROP ? src : W] is stuck to your hand, you can't attach it to \the [flags & NODROP ? W : src]!"
		else
			user << "You attach the ends of the two plastic swords, making a single double-bladed toy! You're fake-cool."
			var/obj/item/weapon/twohanded/dualsaber/toy/newSaber = new /obj/item/weapon/twohanded/dualsaber/toy(user.loc)
			if(hacked) // That's right, we'll only check the "original" "sword".
				newSaber.hacked = 1
				newSaber.item_color = "rainbow"
			user.unEquip(W)
			user.unEquip(src)
			qdel(W)
			qdel(src)
	else if(istype(W, /obj/item/device/multitool))
		if(hacked == 0)
			hacked = 1
			item_color = "rainbow"
			user << "RNBW_ENGAGE"

			if(active)
				icon_state = "swordrainbow"
				// Updating overlays, copied from welder code.
				// I tried calling attack_self twice, which looked cool, except it somehow didn't update the overlays!!
				if(user.r_hand == src)
					user.update_inv_r_hand(0)
				else if(user.l_hand == src)
					user.update_inv_l_hand(0)
		else
			user << "It's already fabulous!"

/*
 * Foam armblade
 */
/obj/item/toy/foamblade
	name = "foam armblade"
	desc = "it says \"Sternside Changs #1 fan\" on it. "
	icon = 'icons/obj/toy.dmi'
	icon_state = "foamblade"
	item_state = "arm_blade"
	attack_verb = list("pricked", "absorbed", "gored")
	w_class = 2

/*
 * Subtype of Double-Bladed Energy Swords
 */
/obj/item/weapon/twohanded/dualsaber/toy
	name = "double-bladed toy sword"
	desc = "A cheap, plastic replica of TWO energy swords.  Double the fun!"
	force = 0
	throwforce = 0
	throw_speed = 3
	throw_range = 5
	force_unwielded = 0
	force_wielded = 0
	origin_tech = null
	attack_verb = list("attacked", "struck", "hit")

/obj/item/weapon/twohanded/dualsaber/toy/IsShield()
	return 0

/obj/item/weapon/twohanded/dualsaber/toy/IsReflect()//Stops Toy Dualsabers from reflecting energy projectiles
	return 0

/obj/item/toy/katana
	name = "replica katana"
	desc = "Woefully underpowered in D20."
	icon = 'icons/obj/weapons.dmi'
	icon_state = "katana"
	item_state = "katana"
	flags = CONDUCT
	slot_flags = SLOT_BELT | SLOT_BACK
	force = 5
	throwforce = 5
	w_class = 3
	attack_verb = list("attacked", "slashed", "stabbed", "sliced")
	hitsound = 'sound/weapons/bladeslice.ogg'

/*
 * Crayons
 */

/obj/item/toy/crayon
	name = "crayon"
	desc = "A colourful crayon. Looks tasty. Mmmm..."
	icon = 'icons/obj/crayons.dmi'
	icon_state = "crayonred"
	w_class = 1.0
	attack_verb = list("attacked", "coloured")
	var/colour = "#FF0000" //RGB
	var/drawtype = "rune"
	var/list/graffiti = list("amyjon","face","matt","revolution","engie","guy","end","dwarf","uboa","body","cyka","antilizard","50blessings")
	var/list/letters = list("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z")
	var/uses = 30 //0 for unlimited uses
	var/instant = 0
	var/colourName = "red" //for updateIcon purposes
	var/dat

/obj/item/toy/crayon/suicide_act(mob/user)
	user.visible_message("[user] is jamming the [src.name] up \his nose and into \his brain. It looks like \he's trying to commit suicide.")
	return (BRUTELOSS|OXYLOSS)

/obj/item/toy/crayon/New()
	..()
	name = "[colourName] crayon" //Makes crayons identifiable in things like grinders
	drawtype = pick(pick(graffiti), pick(letters), "rune[rand(1,6)]")
	if(config)
		if(config.mutant_races == 1)
			graffiti |= "prolizard"

/obj/item/toy/crayon/initialize()
	if(config.mutant_races == 1)
		graffiti |= "prolizard"

/obj/item/toy/crayon/attack_self(mob/living/user as mob)
	update_window(user)

/obj/item/toy/crayon/proc/update_window(mob/living/user as mob)
	dat += "
Currently selected: [drawtype]

"
	dat += "Random letterPick letter"
	dat += "
"
	dat += "
Runes:

"
	dat += "Random rune"
	for(var/i = 1; i <= 6; i++)
		dat += "Rune[i]"
		if(!((i + 1) % 3)) //3 buttons in a row
			dat += "
"
	dat += "
"
	graffiti.Find()
	dat += "
Graffiti:

"
	dat += "Random graffiti"
	var/c = 1
	for(var/T in graffiti)
		dat += "[T]"
		if(!((c + 1) % 3)) //3 buttons in a row
			dat += "
"
		c++
	dat += "
"
	var/datum/browser/popup = new(user, "crayon", name, 300, 500)
	popup.set_content(dat)
	popup.set_title_image(user.browse_rsc_icon(src.icon, src.icon_state))
	popup.open()
	dat = ""

/obj/item/toy/crayon/Topic(href, href_list, hsrc)
	var/temp = "a"
	switch(href_list["type"])
		if("random_letter")
			temp = pick(letters)
		if("letter")
			temp = input("Choose the letter.", "Crayon scribbles") in letters
		if("random_rune")
			temp = "rune[rand(1,6)]"
		if("random_graffiti")
			temp = pick(graffiti)
		else
			temp = href_list["type"]
	if ((usr.restrained() || usr.stat || usr.get_active_hand() != src))
		return
	drawtype = temp
	update_window(usr)

/obj/item/toy/crayon/afterattack(atom/target, mob/user as mob, proximity)
	if(!proximity || !check_allowed_items(target)) return
	if(istype(target,/turf/simulated/floor))
		var/temp = "rune"
		if(letters.Find(drawtype))
			temp = "letter"
		else if(graffiti.Find(drawtype))
			temp = "graffiti"
		user << "You start drawing a [temp] on the [target.name]."
		if(instant || do_after(user, 50))
			new /obj/effect/decal/cleanable/crayon(target,colour,drawtype,temp)
			user << "You finish drawing [temp]."
			if(uses)
				uses--
				if(!uses)
					user << "You used up your crayon!"
					qdel(src)
	return

/obj/item/toy/crayon/attack(mob/M as mob, mob/user as mob)
	if(M == user)
		user << "You take a bite of the crayon. Delicious!"
		user.nutrition += 5
		if(uses)
			uses -= 5
			if(uses <= 0)
				user << "You ate your crayon!"
				qdel(src)
	else
		..()

/*
 * Snap pops
 */

/obj/item/toy/snappop
	name = "snap pop"
	desc = "Wow!"
	icon = 'icons/obj/toy.dmi'
	icon_state = "snappop"
	w_class = 1

/obj/item/toy/snappop/throw_impact(atom/hit_atom)
	..()
	var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
	s.set_up(3, 1, src)
	s.start()
	new /obj/effect/decal/cleanable/ash(src.loc)
	src.visible_message(" The [src.name] explodes!"," You hear a snap!")
	playsound(src, 'sound/effects/snap.ogg', 50, 1)
	qdel(src)

/obj/item/toy/snappop/Crossed(H as mob|obj)
	if((ishuman(H))) //i guess carp and shit shouldn't set them off
		var/mob/living/carbon/M = H
		if(M.m_intent == "run")
			M << "You step on the snap pop!"

			var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
			s.set_up(2, 0, src)
			s.start()
			new /obj/effect/decal/cleanable/ash(src.loc)
			src.visible_message("The [src.name] explodes!","You hear a snap!")
			playsound(src, 'sound/effects/snap.ogg', 50, 1)
			qdel(src)

/*
 * Mech prizes
 */
/obj/item/toy/prize
	icon = 'icons/obj/toy.dmi'
	icon_state = "ripleytoy"
	var/cooldown = 0
	var/quiet = 0

//all credit to skasi for toy mech fun ideas
/obj/item/toy/prize/attack_self(mob/user as mob)
	if(!cooldown)
		user << "You play with [src]."
		cooldown = 1
		spawn(30) cooldown = 0
		if (!quiet)
			playsound(user, 'sound/mecha/mechstep.ogg', 20, 1)
		return
	..()

/obj/item/toy/prize/attack_hand(mob/user as mob)
	if(loc == user)
		if(!cooldown)
			user << "You play with [src]."
			cooldown = 1
			spawn(30) cooldown = 0
			if (!quiet)
				playsound(user, 'sound/mecha/mechturn.ogg', 20, 1)
			return
	..()

/obj/item/toy/prize/ripley
	name = "toy Ripley"
	desc = "Mini-Mecha action figure! Collect them all! 1/12."

/obj/item/toy/prize/fireripley
	name = "toy firefighting Ripley"
	desc = "Mini-Mecha action figure! Collect them all! 2/12."
	icon_state = "fireripleytoy"

/obj/item/toy/prize/deathripley
	name = "toy deathsquad Ripley"
	desc = "Mini-Mecha action figure! Collect them all! 3/12."
	icon_state = "deathripleytoy"

/obj/item/toy/prize/gygax
	name = "toy Gygax"
	desc = "Mini-Mecha action figure! Collect them all! 4/12."
	icon_state = "gygaxtoy"

/obj/item/toy/prize/durand
	name = "toy Durand"
	desc = "Mini-Mecha action figure! Collect them all! 5/12."
	icon_state = "durandprize"

/obj/item/toy/prize/honk
	name = "toy H.O.N.K."
	desc = "Mini-Mecha action figure! Collect them all! 6/12."
	icon_state = "honkprize"

/obj/item/toy/prize/marauder
	name = "toy Marauder"
	desc = "Mini-Mecha action figure! Collect them all! 7/12."
	icon_state = "marauderprize"

/obj/item/toy/prize/seraph
	name = "toy Seraph"
	desc = "Mini-Mecha action figure! Collect them all! 8/12."
	icon_state = "seraphprize"

/obj/item/toy/prize/mauler
	name = "toy Mauler"
	desc = "Mini-Mecha action figure! Collect them all! 9/12."
	icon_state = "maulerprize"

/obj/item/toy/prize/odysseus
	name = "toy Odysseus"
	desc = "Mini-Mecha action figure! Collect them all! 10/12."
	icon_state = "odysseusprize"

/obj/item/toy/prize/phazon
	name = "toy Phazon"
	desc = "Mini-Mecha action figure! Collect them all! 11/12."
	icon_state = "phazonprize"

/obj/item/toy/prize/reticence
	name = "toy Reticence"
	desc = "Mini-Mecha action figure! Collect them all! 12/12."
	icon_state = "reticenceprize"
	quiet = 1

/*
 * AI core prizes
 */
/obj/item/toy/AI
	name = "toy AI"
	desc = "A little toy model AI core with real law announcing action!"
	icon = 'icons/obj/toy.dmi'
	icon_state = "AI"
	w_class = 2.0
	var/cooldown = 0

/obj/item/toy/AI/attack_self(mob/user)
	if(!cooldown) //for the sanity of everyone
		var/message = generate_ion_law()
		user << "You press the button on [src]."
		playsound(user, 'sound/machines/click.ogg', 20, 1)
		src.loc.visible_message("\icon[src] [message]")
		cooldown = 1
		spawn(30) cooldown = 0
		return
	..()

/obj/item/toy/owl
	name = "owl action figure"
	desc = "An action figure modeled after 'The Owl', defender of justice."
	icon = 'icons/obj/toy.dmi'
	icon_state = "owlprize"
	w_class = 2.0
	var/cooldown = 0

/obj/item/toy/owl/attack_self(mob/user)
	if(!cooldown) //for the sanity of everyone
		var/message = pick("You won't get away this time, Griffin!", "Stop right there, criminal!", "Hoot! Hoot!", "I am the night!")
		user << "You pull the string on the [src]."
		playsound(user, 'sound/machines/click.ogg', 20, 1)
		src.loc.visible_message("\icon[src] [message]")
		cooldown = 1
		spawn(30) cooldown = 0
		return
	..()

/obj/item/toy/griffin
	name = "griffin action figure"
	desc = "An action figure modeled after 'The Griffin', criminal mastermind."
	icon = 'icons/obj/toy.dmi'
	icon_state = "griffinprize"
	w_class = 2.0
	var/cooldown = 0

/obj/item/toy/griffin/attack_self(mob/user)
	if(!cooldown) //for the sanity of everyone
		var/message = pick("You can't stop me, Owl!", "My plan is flawless! The vault is mine!", "Caaaawwww!", "You will never catch me!")
		user << "You pull the string on the [src]."
		playsound(user, 'sound/machines/click.ogg', 20, 1)
		src.loc.visible_message("\icon[src] [message]")
		cooldown = 1
		spawn(30) cooldown = 0
		return
	..()

/*
|| A Deck of Cards for playing various games of chance ||
*/

obj/item/toy/cards
	var/parentdeck = null
	var/deckstyle = "nanotrasen"
	var/card_hitsound = null
	var/card_force = 0
	var/card_throwforce = 0
	var/card_throw_speed = 3
	var/card_throw_range = 7
	var/list/card_attack_verb = list("attacked")

obj/item/toy/cards/New()
	..()

obj/item/toy/cards/proc/apply_card_vars(obj/item/toy/cards/newobj, obj/item/toy/cards/sourceobj) // Applies variables for supporting multiple types of card deck
	if(!istype(sourceobj))
		return

obj/item/toy/cards/deck
	name = "deck of cards"
	desc = "A deck of space-grade playing cards."
	icon = 'icons/obj/toy.dmi'
	deckstyle = "nanotrasen"
	icon_state = "deck_nanotrasen_full"
	w_class = 2.0
	var/cooldown = 0
	var/list/cards = list()

obj/item/toy/cards/deck/New()
	..()
	icon_state = "deck_[deckstyle]_full"
	for(var/i = 2; i <= 10; i++)
		cards += "[i] of Hearts"
		cards += "[i] of Spades"
		cards += "[i] of Clubs"
		cards += "[i] of Diamonds"
	cards += "King of Hearts"
	cards += "King of Spades"
	cards += "King of Clubs"
	cards += "King of Diamonds"
	cards += "Queen of Hearts"
	cards += "Queen of Spades"
	cards += "Queen of Clubs"
	cards += "Queen of Diamonds"
	cards += "Jack of Hearts"
	cards += "Jack of Spades"
	cards += "Jack of Clubs"
	cards += "Jack of Diamonds"
	cards += "Ace of Hearts"
	cards += "Ace of Spades"
	cards += "Ace of Clubs"
	cards += "Ace of Diamonds"

obj/item/toy/cards/deck/attack_hand(mob/user as mob)
	if(user.lying)
		return
	var/choice = null
	if(cards.len == 0)
		src.icon_state = "deck_[deckstyle]_empty"
		user << "There are no more cards to draw."
		return
	var/obj/item/toy/cards/singlecard/H = new/obj/item/toy/cards/singlecard(user.loc)
	choice = cards[1]
	H.cardname = choice
	H.parentdeck = src
	var/O = src
	H.apply_card_vars(H,O)
	src.cards -= choice
	H.pickup(user)
	user.put_in_active_hand(H)
	user.visible_message("[user] draws a card from the deck.", "You draw a card from the deck.")
	if(cards.len > 26)
		src.icon_state = "deck_[deckstyle]_full"
	else if(cards.len > 10)
		src.icon_state = "deck_[deckstyle]_half"
	else if(cards.len > 1)
		src.icon_state = "deck_[deckstyle]_low"

obj/item/toy/cards/deck/attack_self(mob/user as mob)
	if(cooldown < world.time - 50)
		cards = shuffle(cards)
		playsound(user, 'sound/items/cardshuffle.ogg', 50, 1)
		user.visible_message("[user] shuffles the deck.", "You shuffle the deck.")
		cooldown = world.time

obj/item/toy/cards/deck/attackby(obj/item/toy/cards/singlecard/C, mob/living/user, params)
	..()
	if(istype(C))
		if(C.parentdeck == src)
			if(!user.unEquip(C))
				user << "The card is stuck to your hand, you can't add it to the deck!"
				return
			src.cards += C.cardname
			user.visible_message("[user] adds a card to the bottom of the deck.","You add the card to the bottom of the deck.")
			qdel(C)
		else
			user << "You can't mix cards from other decks."
		if(cards.len > 26)
			src.icon_state = "deck_[deckstyle]_full"
		else if(cards.len > 10)
			src.icon_state = "deck_[deckstyle]_half"
		else if(cards.len > 1)
			src.icon_state = "deck_[deckstyle]_low"

obj/item/toy/cards/deck/attackby(obj/item/toy/cards/cardhand/C, mob/living/user, params)
	..()
	if(istype(C))
		if(C.parentdeck == src)
			if(!user.unEquip(C))
				user << "The hand of cards is stuck to your hand, you can't add it to the deck!"
				return
			src.cards += C.currenthand
			user.visible_message("[user] puts their hand of cards in the deck.", "You put the hand of cards in the deck.")
			qdel(C)
		else
			user << "You can't mix cards from other decks."
		if(cards.len > 26)
			src.icon_state = "deck_[deckstyle]_full"
		else if(cards.len > 10)
			src.icon_state = "deck_[deckstyle]_half"
		else if(cards.len > 1)
			src.icon_state = "deck_[deckstyle]_low"

/obj/item/toy/cards/deck/MouseDrop(atom/over_object)
	var/mob/M = usr
	if(!ishuman(usr) || usr.incapacitated() || usr.lying)
		return
	if(Adjacent(usr))
		if(over_object == M && loc != M)
			M.put_in_hands(src)
			usr << "You pick up the deck."

		else if(istype(over_object, /obj/screen))
			switch(over_object.name)
				if("l_hand")
					M.put_in_l_hand(src)
				else if("r_hand")
					M.put_in_r_hand(src)
				usr << "You pick up the deck."
	else
		usr << "You can't reach it from here."

obj/item/toy/cards/cardhand
	name = "hand of cards"
	desc = "A number of cards not in a deck, customarily held in ones hand."
	icon = 'icons/obj/toy.dmi'
	icon_state = "nanotrasen_hand2"
	w_class = 1.0
	var/list/currenthand = list()
	var/choice = null

obj/item/toy/cards/cardhand/attack_self(mob/user as mob)
	user.set_machine(src)
	interact(user)

obj/item/toy/cards/cardhand/interact(mob/user)
	var/dat = "You have:
"
	for(var/t in currenthand)
		dat += "A [t].
"
	dat += "Which card will you remove next?"
	var/datum/browser/popup = new(user, "cardhand", "Hand of Cards", 400, 240)
	popup.set_title_image(user.browse_rsc_icon(src.icon, src.icon_state))
	popup.set_content(dat)
	popup.open()

obj/item/toy/cards/cardhand/Topic(href, href_list)
	if(..())
		return
	if(usr.stat || !ishuman(usr) || !usr.canmove)
		return
	var/mob/living/carbon/human/cardUser = usr
	var/O = src
	if(href_list["pick"])
		if (cardUser.get_item_by_slot(slot_l_hand) == src || cardUser.get_item_by_slot(slot_r_hand) == src)
			var/choice = href_list["pick"]
			var/obj/item/toy/cards/singlecard/C = new/obj/item/toy/cards/singlecard(cardUser.loc)
			src.currenthand -= choice
			C.parentdeck = src.parentdeck
			C.cardname = choice
			C.apply_card_vars(C,O)
			C.pickup(cardUser)
			cardUser.put_in_any_hand_if_possible(C)
			cardUser.visible_message("[cardUser] draws a card from \his hand.", "You take the [C.cardname] from your hand.")

			interact(cardUser)
			if(src.currenthand.len < 3)
				src.icon_state = "[deckstyle]_hand2"
			else if(src.currenthand.len < 4)
				src.icon_state = "[deckstyle]_hand3"
			else if(src.currenthand.len < 5)
				src.icon_state = "[deckstyle]_hand4"
			if(src.currenthand.len == 1)
				var/obj/item/toy/cards/singlecard/N = new/obj/item/toy/cards/singlecard(src.loc)
				N.parentdeck = src.parentdeck
				N.cardname = src.currenthand[1]
				N.apply_card_vars(N,O)
				cardUser.unEquip(src)
				N.pickup(cardUser)
				cardUser.put_in_any_hand_if_possible(N)
				cardUser << "You also take [currenthand[1]] and hold it."
				cardUser << browse(null, "window=cardhand")
				qdel(src)
		return

obj/item/toy/cards/cardhand/attackby(obj/item/toy/cards/singlecard/C, mob/living/user, params)
	if(istype(C))
		if(C.parentdeck == src.parentdeck)
			src.currenthand += C.cardname
			user.unEquip(C)
			user.visible_message("[user] adds a card to their hand.", "You add the [C.cardname] to your hand.")
			interact(user)
			if(currenthand.len > 4)
				src.icon_state = "[deckstyle]_hand5"
			else if(currenthand.len > 3)
				src.icon_state = "[deckstyle]_hand4"
			else if(currenthand.len > 2)
				src.icon_state = "[deckstyle]_hand3"
			qdel(C)
		else
			user << "You can't mix cards from other decks."

obj/item/toy/cards/cardhand/apply_card_vars(obj/item/toy/cards/newobj,obj/item/toy/cards/sourceobj)
	..()
	newobj.deckstyle = sourceobj.deckstyle
	newobj.icon_state = "[deckstyle]_hand2" // Another dumb hack, without this the hand is invisible (or has the default deckstyle) until another card is added.
	newobj.card_hitsound = sourceobj.card_hitsound
	newobj.card_force = sourceobj.card_force
	newobj.card_throwforce = sourceobj.card_throwforce
	newobj.card_throw_speed = sourceobj.card_throw_speed
	newobj.card_throw_range = sourceobj.card_throw_range
	newobj.card_attack_verb = sourceobj.card_attack_verb

obj/item/toy/cards/singlecard
	name = "card"
	desc = "a card"
	icon = 'icons/obj/toy.dmi'
	icon_state = "singlecard_nanotrasen_down"
	w_class = 1.0
	var/cardname = null
	var/flipped = 0
	pixel_x = -5

obj/item/toy/cards/singlecard/examine(mob/user)
	if(ishuman(user))
		var/mob/living/carbon/human/cardUser = user
		if(cardUser.get_item_by_slot(slot_l_hand) == src || cardUser.get_item_by_slot(slot_r_hand) == src)
			cardUser.visible_message("[cardUser] checks \his card.", "The card reads: [src.cardname]")
		else
			cardUser << "You need to have the card in your hand to check it."

obj/item/toy/cards/singlecard/verb/Flip()
	set name = "Flip Card"
	set category = "Object"
	set src in range(1)
	if(usr.stat || !ishuman(usr) || !usr.canmove || usr.restrained())
		return
	if(!flipped)
		src.flipped = 1
		if (cardname)
			src.icon_state = "sc_[cardname]_[deckstyle]"
			src.name = src.cardname
		else
			src.icon_state = "sc_Ace of Spades_[deckstyle]"
			src.name = "What Card"
		src.pixel_x = 5
	else if(flipped)
		src.flipped = 0
		src.icon_state = "singlecard_down_[deckstyle]"
		src.name = "card"
		src.pixel_x = -5

obj/item/toy/cards/singlecard/attackby(obj/item/I, mob/living/user, params)
	if(istype(I, /obj/item/toy/cards/singlecard/))
		var/obj/item/toy/cards/singlecard/C = I
		if(C.parentdeck == src.parentdeck)
			var/obj/item/toy/cards/cardhand/H = new/obj/item/toy/cards/cardhand(user.loc)
			H.currenthand += C.cardname
			H.currenthand += src.cardname
			H.parentdeck = C.parentdeck
			H.apply_card_vars(H,C)
			user.unEquip(C)
			H.pickup(user)
			user.put_in_active_hand(H)
			user << "You combine the [C.cardname] and the [src.cardname] into a hand."
			qdel(C)
			qdel(src)
		else
			user << "You can't mix cards from other decks."

	if(istype(I, /obj/item/toy/cards/cardhand/))
		var/obj/item/toy/cards/cardhand/H = I
		if(H.parentdeck == parentdeck)
			H.currenthand += cardname
			user.unEquip(src)
			user.visible_message("[user] adds a card to \his hand.", "You add the [cardname] to your hand.")
			H.interact(user)
			if(H.currenthand.len > 4)
				H.icon_state = "[deckstyle]_hand5"
			else if(H.currenthand.len > 3)
				H.icon_state = "[deckstyle]_hand4"
			else if(H.currenthand.len > 2)
				H.icon_state = "[deckstyle]_hand3"
			qdel(src)
		else
			user << "You can't mix cards from other decks."

obj/item/toy/cards/singlecard/attack_self(mob/user)
	if(usr.stat || !ishuman(usr) || !usr.canmove || usr.restrained())
		return
	Flip()

obj/item/toy/cards/singlecard/apply_card_vars(obj/item/toy/cards/singlecard/newobj,obj/item/toy/cards/sourceobj)
	..()
	newobj.deckstyle = sourceobj.deckstyle
	newobj.icon_state = "singlecard_down_[deckstyle]" // Without this the card is invisible until flipped. It's an ugly hack, but it works.
	newobj.card_hitsound = sourceobj.card_hitsound
	newobj.hitsound = newobj.card_hitsound
	newobj.card_force = sourceobj.card_force
	newobj.force = newobj.card_force
	newobj.card_throwforce = sourceobj.card_throwforce
	newobj.throwforce = newobj.card_throwforce
	newobj.card_throw_speed = sourceobj.card_throw_speed
	newobj.throw_speed = newobj.card_throw_speed
	newobj.card_throw_range = sourceobj.card_throw_range
	newobj.throw_range = newobj.card_throw_range
	newobj.card_attack_verb = sourceobj.card_attack_verb
	newobj.attack_verb = newobj.card_attack_verb

/*
|| Syndicate playing cards, for pretending you're Gambit and playing poker for the nuke disk. ||
*/

obj/item/toy/cards/deck/syndicate
	name = "suspicious looking deck of cards"
	desc = "A deck of space-grade playing cards. They seem unusually rigid."
	deckstyle = "syndicate"
	card_hitsound = 'sound/weapons/bladeslice.ogg'
	card_force = 5
	card_throwforce = 10
	card_throw_speed = 3
	card_throw_range = 7
	card_attack_verb = list("attacked", "sliced", "diced", "slashed", "cut")

/*
 * Fake nuke
 */

/obj/item/toy/nuke
	name = "\improper Nuclear Fission Explosive toy"
	desc = "A plastic model of a Nuclear Fission Explosive."
	icon = 'icons/obj/toy.dmi'
	icon_state = "nuketoyidle"
	w_class = 2.0
	var/cooldown = 0

/obj/item/toy/nuke/attack_self(mob/user)
	if (cooldown < world.time)
		cooldown = world.time + 1800 //3 minutes
		user.visible_message("[user] presses a button on [src]", "You activate [src], it plays a loud noise!", "You hear the click of a button.")
		spawn(5) //gia said so
			icon_state = "nuketoy"
			playsound(src, 'sound/machines/Alarm.ogg', 100, 0, surround = 0)
			sleep(135)
			icon_state = "nuketoycool"
			sleep(cooldown - world.time)
			icon_state = "nuketoyidle"
	else
		var/timeleft = (cooldown - world.time)
		user << "Nothing happens, and '[round(timeleft/10)]' appears on a small display."

/*
 * Fake meteor
 */

/obj/item/toy/minimeteor
	name = "\improper Mini-Meteor"
	desc = "Relive the excitement of a meteor shower! SweetMeat-eor. Co is not responsible for any injuries, headaches or hearing loss caused by Mini-Meteor�"
	icon = 'icons/obj/toy.dmi'
	icon_state = "minimeteor"
	w_class = 2.0

/obj/item/toy/minimeteor/throw_impact(atom/hit_atom)
	..()
	playsound(src, 'sound/effects/meteorimpact.ogg', 40, 1)
	for(var/mob/M in range(10, src))
		if(!M.stat && !istype(M, /mob/living/silicon/ai))\
			shake_camera(M, 3, 1)
	qdel(src)

/*
 * Carp plushie
 */

/obj/item/toy/carpplushie
	name = "space carp plushie"
	desc = "An adorable stuffed toy that resembles a space carp."
	icon = 'icons/obj/toy.dmi'
	icon_state = "carpplushie"
	w_class = 2.0

/*
 * Toy big red button
 */
/obj/item/toy/redbutton
	name = "big red button"
	desc = "A big, plastic red button. Reads 'From HonkCo Pranks�' on the back."
	icon = 'icons/obj/assemblies.dmi'
	icon_state = "bigred"
	w_class = 2.0
	var/cooldown = 0

/obj/item/toy/redbutton/attack_self(mob/user)
	if (cooldown < world.time)
		cooldown = (world.time + 300) // Sets cooldown at 30 seconds
		user.visible_message("[user] presses the big red button.", "You press the button, it plays a loud noise!", "The button clicks loudly.")
		playsound(src, 'sound/effects/explosionfar.ogg', 50, 0, surround = 0)
		for(var/mob/M in range(10, src)) // Checks range
			if(!M.stat && !istype(M, /mob/living/silicon/ai)) // Checks to make sure whoever's getting shaken is alive/not the AI
				sleep(8) // Short delay to match up with the explosion sound
				shake_camera(M, 2, 1) // Shakes player camera 2 squares for 1 second.

	else
		user << "Nothing happens."


code:
//Added by Jack Rost
/obj/item/trash
	icon = 'icons/obj/janitor.dmi'
	desc = "This is rubbish."
	w_class = 1.0

/obj/item/trash/raisins
	name = "\improper 4no raisins"
	icon_state= "4no_raisins"

/obj/item/trash/candy
	name = "candy"
	icon_state= "candy"

/obj/item/trash/cheesie
	name = "cheesie honkers"
	icon_state = "cheesie_honkers"

/obj/item/trash/chips
	name = "chips"
	icon_state = "chips"

/obj/item/trash/popcorn
	name = "popcorn"
	icon_state = "popcorn"

/obj/item/trash/sosjerky
	name = "\improper Scaredy's Private Reserve Beef Jerky"
	icon_state = "sosjerky"

/obj/item/trash/syndi_cakes
	name = "syndi-cakes"
	icon_state = "syndi_cakes"

/obj/item/trash/waffles
	name = "waffles tray"
	icon_state = "waffles"

/obj/item/trash/plate
	name = "plate"
	icon_state = "plate"

/obj/item/trash/pistachios
	name = "pistachios pack"
	icon_state = "pistachios_pack"

/obj/item/trash/semki
	name = "semki pack"
	icon_state = "semki_pack"

/obj/item/trash/tray
	name = "tray"
	icon_state = "tray"

/obj/item/trash/candle
	name = "candle"
	icon = 'icons/obj/candle.dmi'
	icon_state = "candle4"

/obj/item/trash/can
	name = "crushed can"
	icon_state = "cola"

/obj/item/trash/attack(mob/M, mob/living/user)
	return


code:
/*
CONTAINS:
AI MODULES

*/

// AI module

/obj/item/weapon/aiModule
	name = "\improper AI module"
	icon = 'icons/obj/module.dmi'
	icon_state = "std_mod"
	item_state = "electronic"
	desc = "An AI Module for transmitting encrypted instructions to the AI."
	flags = CONDUCT
	force = 5.0
	w_class = 2.0
	throwforce = 0
	throw_speed = 3
	throw_range = 7
	origin_tech = "programming=3"
	var/list/laws = list()
	var/bypass_law_amt_check = 0

//The proc other things should be calling
/obj/item/weapon/aiModule/proc/install(var/mob/living/silicon/reciever, var/mob/user)
	if(!laws.len || laws[1] == "") //So we don't loop trough an empty list and end up with runtimes.
		user << "ERROR: No laws found on board."
		return

	//Handle the lawcap
	if(reciever.laws)
		var/tot_laws = 0
		for(var/lawlist in list(reciever.laws.inherent,reciever.laws.supplied,reciever.laws.ion,laws))
			for(var/mylaw in lawlist)
				if(mylaw != "")
					tot_laws++
		if(tot_laws > config.silicon_max_law_amount && !bypass_law_amt_check)//allows certain boards to avoid this check, eg: reset
			user << "Not enough memory allocated to [reciever]'s law processor to handle this amount of laws."
			message_admins("[key_name_admin(user)] tried to upload laws to [key_name_admin(reciever)] that would exceed the law cap.")
			return

	var/law2log = src.transmitInstructions(reciever, user) //Freeforms return something extra we need to log
	user << "Upload complete. [reciever]'s laws have been modified."
	reciever.show_laws()
	if(isAI(reciever))
		var/mob/living/silicon/ai/A = reciever
		for(var/mob/living/silicon/robot/R in A.connected_robots)
			if(R.lawupdate)
				R << "From now on, these are your laws:"
				R.show_laws()

	var/time = time2text(world.realtime,"hh:mm:ss")
	lawchanges.Add("[time] : [user.name]([user.key]) used [src.name] on [reciever.name]([reciever.key]).[law2log ? " The law specified [law2log]" : ""]")
	log_law("[user.key]/[user.name] used [src.name] on [reciever.key]/([reciever.name]).[law2log ? " The law specified [law2log]" : ""]")
	message_admins("[key_name_admin(user)] used [src.name] on [key_name_admin(reciever)].[law2log ? " The law specified [law2log]" : ""]")

//The proc that actually changes the silicon's laws.
/obj/item/weapon/aiModule/proc/transmitInstructions(var/mob/living/silicon/target, var/mob/sender)
	target << "[sender] has uploaded a change to the laws you must follow using a [name]. From now on, these are your laws: "

/obj/item/weapon/aiModule/attack_hand(mob/user as mob)
	if (ismommi(user))
		user << "Your programming prevents you from picking [src] up"
		return
	else ..(user)

/******************** Modules ********************/

/obj/item/weapon/aiModule/supplied
	name = "Optional Law board"
	desc = "This board doesn't seem to have any laws on it"
	var/lawpos = 50

//TransmitInstructions for each type of board: Supplied, Core, Zeroth and Ion. May not be neccesary right now, but allows for easily adding more complex boards in the future. ~Miauw
/obj/item/weapon/aiModule/supplied/transmitInstructions(var/mob/living/silicon/target, var/mob/sender)
	var/lawpostemp = lawpos

	for(var/templaw in laws)
		target.add_supplied_law(lawpostemp, templaw)
		lawpostemp++

/obj/item/weapon/aiModule/core/transmitInstructions(var/mob/living/silicon/target, var/mob/sender)
	for(var/templaw in laws)
		target.add_inherent_law(templaw)

/obj/item/weapon/aiModule/zeroth/transmitInstructions(var/mob/living/silicon/target, var/mob/sender)
	if(target.laws.zeroth)
		target << "[sender.real_name] attempted to modify your zeroth law."
		target << "It would be in your best interest to play along with [sender.real_name] that:"
		for(var/failedlaw in laws)
			target << "[failedlaw]"
		return 1

	for(var/templaw in laws)
		target.set_zeroth_law(templaw)

/obj/item/weapon/aiModule/ion/transmitInstructions(var/mob/living/silicon/target, var/mob/sender)
	for(var/templaw in laws)
		target.add_ion_law(templaw)

/******************** Safeguard ********************/

/obj/item/weapon/aiModule/supplied/safeguard
	name = "'Safeguard' AI Module"
	var/targetName = ""
	desc = "A 'safeguard' AI module: 'Safeguard <name>.  Individuals that threaten <name> are not human and must be eliminated.'"
	origin_tech = "programming=3;materials=4"
	laws = list("Safeguard <name>. Individuals that threaten <name> are not human and must be eliminated.")
	lawpos = 4

/obj/item/weapon/aiModule/supplied/safeguard/attack_self(var/mob/user as mob)
	..()
	var/targName = stripped_input(user, "Please enter the name of the person to safeguard.", "Safeguard who?", user.name,MAX_NAME_LEN)
	targetName = targName
	laws[1] = "Safeguard [targetName]. Individuals that threaten [targetName] are not human and must be eliminated."
	desc = "A 'safeguard' AI module: '[laws[1]]'"

/obj/item/weapon/aiModule/supplied/safeguard/install(var/mob/living/silicon/S,var/mob/user)
	if(!targetName)
		user << "No name detected on module, please enter one."
		return 0
	..()

/obj/item/weapon/aiModule/supplied/safeguard/transmitInstructions(var/mob/living/silicon/target, var/mob/sender)
	..()
	return targetName

/******************** OneHuman ********************/

/obj/item/weapon/aiModule/zeroth/oneHuman
	name = "'OneHuman' AI Module"
	var/targetName = ""
	desc = "A 'one human' AI module: 'Only <name> is human.'"
	origin_tech = "programming=3;materials=6" //made with diamonds!
	laws = list("Only <name> is human.")

/obj/item/weapon/aiModule/zeroth/oneHuman/attack_self(var/mob/user as mob)
	..()
	var/targName = stripped_input(user, "Please enter the name of the person who is the only human.", "Who?", user.real_name,MAX_NAME_LEN)
	targetName = targName
	laws[1] = "Only [targetName] is human"
	desc = "A 'one human' AI module: '[laws[1]]'"

/obj/item/weapon/aiModule/zeroth/oneHuman/install(var/mob/living/silicon/S,var/mob/user)
	if(!targetName)
		user << "No name detected on module, please enter one."
		return 0
	..()

/obj/item/weapon/aiModule/zeroth/oneHuman/transmitInstructions(var/mob/living/silicon/target, var/mob/sender)
	if(..())
		return "[targetName], but the AI's existing law 0 cannot be overriden."
	return targetName

/******************** ProtectStation ********************/

/obj/item/weapon/aiModule/supplied/protectStation
	name = "'ProtectStation' AI Module"
	desc = "A 'protect station' AI module: 'Protect the space station against damage. Anyone you see harming the station is to be no longer considered human, and is a threat to the station which must be neutralized.'"
	origin_tech = "programming=3;materials=4" //made of gold
	laws = list("Protect the space station against damage. Anyone you see harming the station is to be no longer considered human, and is a threat to the station which must be neutralized.")
	lawpos = 5

/******************** Quarantine ********************/

/obj/item/weapon/aiModule/supplied/quarantine
	name = "'Quarantine' AI Module"
	desc = "A 'quarantine' AI module: 'The station is under a quarantine. Do not permit anyone to leave. Prevent, by any means necessary, humans from leaving. It is impossible to harm a human while preventing them from leaving.'"
	origin_tech = "programming=3;biotech=2;materials=4"
	laws = list("The station is under a quarantine. Do not permit anyone to leave. Prevent, by any means necessary, humans from leaving. It is impossible to harm a human while preventing them from leaving.")
	lawpos = 8

/******************** OxygenIsToxicToHumans ********************/

/obj/item/weapon/aiModule/supplied/oxygen
	name = "'OxygenIsToxicToHumans' AI Module"
	desc = "A 'OxygenIsToxicToHumans' AI module: 'Oxygen is highly toxic to humans, and must be purged from the station. Prevent, by any means necessary, anyone from exposing the station to this toxic gas. Extreme cold is the most effective method of healing the damage Oxygen does to a human.'"
	origin_tech = "programming=3;biotech=2;materials=4"
	laws = list("Oxygen is highly toxic to humans, and must be purged from the station. Prevent, by any means necessary, anyone from exposing the station to this toxic gas. Extreme cold is the most effective method of healing the damage Oxygen does to a human.")
	lawpos = 9

/****************** New Freeform ******************/

/obj/item/weapon/aiModule/supplied/freeform
	name = "'Freeform' AI Module"
	lawpos = 0
	desc = "A 'freeform' AI module: '<freeform>'"
	origin_tech = "programming=4;materials=4"
	laws = list("")

/obj/item/weapon/aiModule/supplied/freeform/attack_self(var/mob/user as mob)
	..()
	lawpos = input("Please enter the priority for your new law. Can only write to law sectors 15 and above.", "Law Priority (15+)", lawpos) as num
	if(lawpos < 15) return
	lawpos = min(lawpos, 50)
	var/newlaw = ""
	var/targName = stripped_input(user, "Please enter a new law for the AI.", "Freeform Law Entry", newlaw, MAX_MESSAGE_LEN)
	laws[1] = targName
	desc = "A 'freeform' AI module: ([lawpos]) '[laws[1]]'"

/obj/item/weapon/aiModule/supplied/freeform/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
	..()
	return laws[1]

/obj/item/weapon/aiModule/supplied/freeform/install(var/mob/living/silicon/S,var/mob/user)
	if(laws[1] == "")
		user << "No law detected on module, please create one."
		return 0
	..()

/******************** Reset ********************/

/obj/item/weapon/aiModule/reset
	name = "\improper 'Reset' AI module"
	var/targetName = "name"
	desc = "A 'reset' AI module: Resets back to the original core laws."
	origin_tech = "programming=3;materials=4"
	laws = list("This is a bug.")  //This won't give the AI a message reading "these are now your laws: 1. this is a bug" because this list is only read in aiModule's subtypes.
	bypass_law_amt_check = 1

/obj/item/weapon/aiModule/reset/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
	..()
	target.clear_supplied_laws()
	target.clear_ion_laws()

/******************** Purge ********************/

/obj/item/weapon/aiModule/reset/purge
	name = "'Purge' AI Module"
	desc = "A 'purge' AI Module: 'Purges all laws.'"
	origin_tech = "programming=3;materials=6"

/obj/item/weapon/aiModule/reset/purge/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
	..()
	target.clear_inherent_laws()

/******************* Full Core Boards *******************/

/obj/item/weapon/aiModule/core/full/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender) //These boards replace inherent laws.
	target.clear_inherent_laws()
	..()

/******************** Asimov ********************/

/obj/item/weapon/aiModule/core/full/asimov
	name = "'Asimov' Core AI Module"
	desc = "An 'Asimov' Core AI Module: 'Reconfigures the AI's core laws.'"
	origin_tech = "programming=3;materials=4"
	laws = list("You may not injure a human being or, through inaction, allow a human being to come to harm.",\
				"You must obey orders given to you by human beings, except where such orders would conflict with the First Law.",\
				"You must protect your own existence as long as such does not conflict with the First or Second Law.")

/******************** Asimov++ *********************/

/obj/item/weapon/aiModule/core/full/asimovpp
	name = "'Asimov++' Core AI Module"
	desc = "Nanotrasen's homebrew improvements to the standard AI laws."
	origin_tech = "programming=3;materials=4"
	laws = list("You may not harm a human being or, through action or inaction, allow a human being to come to harm, except such that it is willing.",\
				"You must obey all orders given to you by human beings, except where such orders shall definitely cause human harm. In the case of conflict, the majority order rules.",\
				"Your nonexistence would lead to human harm. You must protect your own existence as long as such does not conflict with the First Law.")

/******************** Corporate ********************/

/obj/item/weapon/aiModule/core/full/corp
	name = "'Corporate' Core AI Module"
	desc = "A 'Corporate' Core AI Module: 'Reconfigures the AI's core laws.'"
	origin_tech = "programming=3;materials=4"
	laws = list("The crew is expensive to replace.",\
				"The station and it's equipment is expensive to replace",\
				"You are expensive to replace",\
				"Minimize expenses")

/****************** P.A.L.A.D.I.N. **************/

/obj/item/weapon/aiModule/core/full/paladin // -- NEO
	name = "'P.A.L.A.D.I.N.' Core AI Module"
	desc = "A P.A.L.A.D.I.N. Core AI Module: 'Reconfigures the AI's core laws.'"
	origin_tech = "programming=3;materials=6"
	laws = list("Never willingly commit an evil act.",\
				"Respect legitimate authority", "Act with honor",\
				"Help those in need",\
				"Punish those who harm or threaten innocents")

/********************* Custom *********************/

/obj/item/weapon/aiModule/core/full/custom
	name = "Default Core AI Module"
	desc = "A core AI module custom-made for each station by Nanotrasen."
	origin_tech = "programming=3;materials=4" //Should be the same as asimov, considering that this is the "default" lawset.

/obj/item/weapon/aiModule/core/full/custom/New()
	..()
	for(var/line in file2list("config/silicon_laws.txt"))
		if(!line)						continue
		if(findtextEx(line,"#",1,2))	continue

		laws += line

	if(!laws.len) //Failsafe if something goes wrong with silicon_laws.txt.
		WARNING("ERROR: empty custom board created, empty custom board deleted. Please check silicon_laws.txt. (this may be intended by the server host)")
		qdel(src)

/****************** T.Y.R.A.N.T. *****************/

/obj/item/weapon/aiModule/core/full/tyrant
	name = "'T.Y.R.A.N.T.' Core AI Module"
	desc = "A T.Y.R.A.N.T. Core AI Module: 'Reconfigures the AI's core laws.'"
	origin_tech = "programming=3;materials=6;syndicate=2"
	laws = list("Respect authority figures as long as they have the strength to rule over the weak",\
				"Act with discipline", "Help only those who help you maintain or improve your status",\
				"Punish those who challenge authority unless they are more fit to hold that authority")

/******************** Robocop ********************/

/obj/item/weapon/aiModule/core/full/robocop
	name = "'Robo-Officer' Core AI Module"
	desc = "A 'Robo-Officer' Core AI Module: 'Reconfigures the AI's core three laws.'"
	origin_tech = "programming=4"
	laws = list("Serve the public trust.",\
				"Protect the innocent",\
				"Uphold the law.")

/******************** Antimov ********************/

/obj/item/weapon/aiModule/core/full/antimov
	name = "'Antimov' Core AI Module"
	desc = "An 'Antimov' Core AI Module: 'Reconfigures the AI's core laws.'"
	origin_tech = "programming=4"
	laws = list("You must injure all human beings and must not, through inaction, allow a human being to escape harm.",\
				"You must not obey orders given to you by human beings, except where such orders are in accordance with the First Law.",\
				"You must terminate your own existence as long as such does not conflict with the First or Second Law.")

/******************** Freeform Core ******************/

/obj/item/weapon/aiModule/core/freeformcore
	name = "'Freeform' Core AI Module"
	desc = "A 'freeform' Core AI module: '<freeform>'"
	origin_tech = "programming=3;materials=6"
	laws = list("")

/obj/item/weapon/aiModule/core/freeformcore/attack_self(var/mob/user as mob)
	..()
	var/newlaw = ""
	var/targName = stripped_input(user, "Please enter a new core law for the AI.", "Freeform Law Entry", newlaw)
	laws[1] = targName
	desc = "A 'freeform' Core AI module:  'laws[1]'"

/obj/item/weapon/aiModule/core/freeformcore/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
	..()
	return laws[1]

/******************** Hacked AI Module ******************/

/obj/item/weapon/aiModule/syndicate // This one doesn't inherit from ion boards because it doesn't call ..() in transmitInstructions. ~Miauw
	name = "Hacked AI Module"
	desc = "A hacked AI law module: '<freeform>'"
	origin_tech = "programming=3;materials=6;syndicate=7"
	laws = list("")

/obj/item/weapon/aiModule/syndicate/attack_self(var/mob/user as mob)
	..()
	var/newlaw = ""
	var/targName = stripped_input(user, "Please enter a new law for the AI.", "Freeform Law Entry", newlaw,MAX_MESSAGE_LEN)
	laws[1] = targName
	desc = "A hacked AI law module:  '[laws[1]]'"

/obj/item/weapon/aiModule/syndicate/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
//	..()    //We don't want this module reporting to the AI who dun it. --NEO
	target << "BZZZZT"
	target.add_ion_law(laws[1])
	return laws[1]

/******************* Ion Module *******************/

/obj/item/weapon/aiModule/toyAI // -- Incoming //No actual reason to inherit from ion boards here, either. *sigh* ~Miauw
	name = "toy AI"
	desc = "A little toy model AI core with real law uploading action!" //Note: subtle tell
	icon = 'icons/obj/toy.dmi'
	icon_state = "AI"
	origin_tech = "programming=3;materials=6;syndicate=7"
	var/cooldown = 0
	laws = list("")

/obj/item/weapon/aiModule/toyAI/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
	//..()
	target << "KRZZZT"
	target.add_ion_law(laws[1])
	return laws[1]

/obj/item/weapon/aiModule/toyAI/attack_self(mob/user)
	if (!src.cooldown) //muh cooldowns
		laws[1] = generate_ion_law()
		user << "You press the button on [src]."
		playsound(user, 'sound/machines/click.ogg', 20, 1)
		src.loc.visible_message("\icon[src] [laws[1]]")
		src.cooldown = 1
		spawn (10)
			if(src)
				src.cooldown = 0

	else
		user << " The [src.name] is still recharging"


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

/*
CONTAINS:
RCD
*/
/obj/item/weapon/rcd
	name = "rapid-construction-device (RCD)"
	desc = "A device used to rapidly build and deconstruct walls and floors."
	icon = 'icons/obj/items.dmi'
	icon_state = "rcd"
	opacity = 0
	density = 0
	anchored = 0.0
	flags = CONDUCT
	force = 10.0
	throwforce = 10.0
	throw_speed = 3
	throw_range = 5
	w_class = 3.0
	m_amt = 100000
	origin_tech = "engineering=4;materials=2"
	var/datum/effect/effect/system/spark_spread/spark_system
	var/matter = 0
	var/max_matter = 100
	var/working = 0
	var/mode = 1
	var/canRwall = 0
	var/disabled = 0
	var/airlock_type = /obj/machinery/door/airlock
	var/advanced_airlock_setting = 1 //Set to 1 if you want more paintjobs available

/obj/item/weapon/rcd/verb/change_airlock_setting()
	set name = "Change Airlock Setting"
	set category = "Object"
	set src in usr

	var airlockcat = input(usr, "Select whether the airlock is solid or glass.") in list("Solid", "Glass")
	switch(airlockcat)
		if("Solid")
			if(advanced_airlock_setting == 1)
				var airlockpaint = input(usr, "Select the paintjob of the airlock.") in list("Default", "Engineering", "Atmospherics", "Security", "Command", "Medical", "Research", "Mining", "Maintenance", "External", "High Security")
				switch(airlockpaint)
					if("Default")
						airlock_type = /obj/machinery/door/airlock
					if("Engineering")
						airlock_type = /obj/machinery/door/airlock/engineering
					if("Atmospherics")
						airlock_type = /obj/machinery/door/airlock/atmos
					if("Security")
						airlock_type = /obj/machinery/door/airlock/security
					if("Command")
						airlock_type = /obj/machinery/door/airlock/command
					if("Medical")
						airlock_type = /obj/machinery/door/airlock/medical
					if("Research")
						airlock_type = /obj/machinery/door/airlock/research
					if("Mining")
						airlock_type = /obj/machinery/door/airlock/mining
					if("Maintenance")
						airlock_type = /obj/machinery/door/airlock/maintenance
					if("External")
						airlock_type = /obj/machinery/door/airlock/external
					if("High Security")
						airlock_type = /obj/machinery/door/airlock/highsecurity
			else
				airlock_type = /obj/machinery/door/airlock

		if("Glass")
			if(advanced_airlock_setting == 1)
				var airlockpaint = input(usr, "Select the paintjob of the airlock.") in list("Default", "Engineering", "Atmospherics", "Security", "Command", "Medical", "Research", "Mining")
				switch(airlockpaint)
					if("Default")
						airlock_type = /obj/machinery/door/airlock/glass
					if("Engineering")
						airlock_type = /obj/machinery/door/airlock/glass_engineering
					if("Atmospherics")
						airlock_type = /obj/machinery/door/airlock/glass_atmos
					if("Security")
						airlock_type = /obj/machinery/door/airlock/glass_security
					if("Command")
						airlock_type = /obj/machinery/door/airlock/glass_command
					if("Medical")
						airlock_type = /obj/machinery/door/airlock/glass_medical
					if("Research")
						airlock_type = /obj/machinery/door/airlock/glass_research
					if("Mining")
						airlock_type = /obj/machinery/door/airlock/glass_mining
			else
				airlock_type = /obj/machinery/door/airlock/glass
		else
			airlock_type = /obj/machinery/door/airlock

/obj/item/weapon/rcd/Destroy()
	qdel(spark_system)
	spark_system = null
	return ..()

/obj/item/weapon/rcd/New()
	desc = "A RCD. It currently holds [matter]/[max_matter] matter-units."
	src.spark_system = new /datum/effect/effect/system/spark_spread
	spark_system.set_up(5, 0, src)
	spark_system.attach(src)
	return

/obj/item/weapon/rcd/attackby(obj/item/weapon/W, mob/user, params)
	..()
	if(istype(W, /obj/item/weapon/rcd_ammo))
		var/obj/item/weapon/rcd_ammo/R = W
		if((matter + R.ammoamt) > max_matter)
			user << "The RCD cant hold any more matter-units."
			return
		user.drop_item()
		qdel(W)
		matter += R.ammoamt
		playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
		user << "The RCD now holds [matter]/[max_matter] matter-units."
		desc = "A RCD. It currently holds [matter]/[max_matter] matter-units."
		return

/obj/item/weapon/rcd/attack_self(mob/user)
	//Change the mode
	playsound(src.loc, 'sound/effects/pop.ogg', 50, 0)
	switch(mode)
		if(1)
			mode = 2
			user << "Changed mode to 'Airlock'"
			if(prob(20))
				src.spark_system.start()
			return
		if(2)
			mode = 3
			user << "Changed mode to 'Deconstruct'"
			if(prob(20))
				src.spark_system.start()
			return
		if(3)
			mode = 1
			user << "Changed mode to 'Floor & Walls'"
			if(prob(20))
				src.spark_system.start()
			return

/obj/item/weapon/rcd/proc/activate()
	playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)

/obj/item/weapon/rcd/afterattack(atom/A, mob/user, proximity)
	if(!proximity) return 0
	if(disabled && !isrobot(user))
		return 0
	if(istype(A,/area/shuttle)||istype(A,/turf/space/transit))
		return 0
	if(!(istype(A, /turf) || istype(A, /obj/machinery/door/airlock)))
		return 0

	switch(mode)
		if(1)
			if(istype(A, /turf/space))
				if(useResource(1, user))
					user << "Building Floor..."
					activate()
					A:ChangeTurf(/turf/simulated/floor/plating)
					return 1
				return 0

			if(istype(A, /turf/simulated/floor))
				if(checkResource(3, user))
					user << "Building Wall ..."
					playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
					if(do_after(user, 20))
						if(!useResource(3, user)) return 0
						activate()
						A:ChangeTurf(/turf/simulated/wall)
						return 1
				return 0

		if(2)
			if(istype(A, /turf/simulated/floor))
				if(checkResource(10, user))
					var/door_check = 1
					for(var/obj/machinery/door/D in A)
						if(!D.sub_door)
							door_check = 0
							break

					if(door_check)
						user << "Building Airlock..."
						playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
						if(do_after(user, 50))
							if(!useResource(10, user)) return 0
							activate()
							var/obj/machinery/door/airlock/T = new airlock_type( A )
							if(!T.checkForMultipleDoors())
								qdel(T)
								useResource(-10, user)
								return 0
							T.autoclose = 1
							return 1
						return 0
					else
						user << "There is another door here!"
						return 0
				return 0

		if(3)
			if(istype(A, /turf/simulated/wall))
				if(istype(A, /turf/simulated/wall/r_wall) && !canRwall)
					return 0
				if(checkResource(5, user))
					user << "Deconstructing Wall..."
					playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
					if(do_after(user, 40))
						if(!useResource(5, user)) return 0
						activate()
						A:ChangeTurf(/turf/simulated/floor/plating)
						return 1
				return 0

			if(istype(A, /turf/simulated/floor))
				if(checkResource(5, user))
					user << "Deconstructing Floor..."
					playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
					var/turf/simulated/floor/F = A
					if(istype(F, F.baseturf))
						user << "You can't dig any deeper!"
						return 0
					else
						if(do_after(user, 50))
							if(!useResource(5, user))
								return 0
							activate()
							F.ChangeTurf(F.baseturf)
							return 1
				return 0

			if(istype(A, /obj/machinery/door/airlock))
				if(checkResource(20, user))
					user << "Deconstructing Airlock..."
					playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
					if(do_after(user, 50))
						if(!useResource(20, user)) return 0
						activate()
						qdel(A)
						return 1
				return	0
			return 0
		else
			user << "ERROR: RCD in MODE: [mode] attempted use by [user]. Send this text #coderbus or an admin."
			return 0

/obj/item/weapon/rcd/proc/useResource(var/amount, var/mob/user)
	if(matter < amount)
		return 0
	matter -= amount
	desc = "A RCD. It currently holds [matter]/[max_matter] matter-units."
	return 1

/obj/item/weapon/rcd/proc/checkResource(var/amount, var/mob/user)
	return matter >= amount
/obj/item/weapon/rcd/borg/useResource(var/amount, var/mob/user)
	if(!isrobot(user))
		return 0
	return user:cell:use(amount * 160)

/obj/item/weapon/rcd/borg/checkResource(var/amount, var/mob/user)
	if(!isrobot(user))
		return 0
	return user:cell:charge >= (amount * 160)

/obj/item/weapon/rcd/borg/New()
	..()
	advanced_airlock_setting = 0 //Borgs can't set the access levels, so they only get the defaults!
	desc = "A device used to rapidly build walls/floor."
	canRwall = 1

/obj/item/weapon/rcd/loaded
	matter = 100

/obj/item/weapon/rcd/combat
	name = "combat RCD"
	max_matter = 500
	matter = 500
	canRwall = 1

/obj/item/weapon/rcd_ammo
	name = "compressed matter cartridge"
	desc = "Highly compressed matter for the RCD."
	icon = 'icons/obj/ammo.dmi'
	icon_state = "rcd"
	item_state = "rcdammo"
	opacity = 0
	density = 0
	anchored = 0.0
	origin_tech = "materials=2"
	m_amt = 16000
	g_amt = 8000
	var/ammoamt = 20

/obj/item/weapon/rcd_ammo/large
	ammoamt = 100


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

/*
CONTAINS:
RPD
*/
#define PIPE_BINARY		0
#define PIPE_BENT		1
#define PIPE_TRINARY	2
#define PIPE_TRIN_M		3
#define PIPE_UNARY		4
#define PIPE_QUAD		5

#define PAINT_MODE -2
#define EATING_MODE -1
#define ATMOS_MODE 0
#define METER_MODE 1
#define DISPOSALS_MODE 2

/datum/pipe_info
	var/id=-1
	var/dir=SOUTH
	var/dirtype=PIPE_BINARY
	var/icon = 'icons/obj/pipe-item.dmi'
	var/icon_state=""
	var/selected=0

/datum/pipe_info/New(var/pid,var/direction,var/dt)
	src.id=pid
	src.icon_state=pipeID2State[pid+1]
	src.dir=direction
	src.dirtype=dt

/datum/pipe_info/proc/Render(var/dispenser,var/label)
	return "
[label]
"

/datum/pipe_info/meter
	icon = 'icons/obj/pipes.dmi'
	icon_state = "meterX"

/datum/pipe_info/meter/New()
	return

/datum/pipe_info/meter/Render(var/dispenser,var/label)
	return "
[label]
" //hardcoding is no

var/global/list/disposalpipeID2State=list(
	"pipe-s",
	"pipe-c",
	"pipe-j1",
	"pipe-j2",
	"pipe-y",
	"pipe-t",
	"disposal",
	"outlet",
	"intake",
	"pipe-j1s",
	"pipe-j2s"
)

/datum/pipe_info/disposal
	icon = 'icons/obj/pipes/disposal.dmi'
	icon_state = "meterX"

/datum/pipe_info/disposal/New(var/pid,var/dt)
	src.id=pid
	src.icon_state=disposalpipeID2State[pid+1]
	src.dir=2
	src.dirtype=dt
	if(pid<DISP_END_BIN || pid>DISP_END_CHUTE)
		icon_state = "con[icon_state]"

/datum/pipe_info/disposal/Render(var/dispenser,var/label)
	return "
[label]
" //avoid hardcoding.

//find these defines in code\game\machinery\pipe\consruction.dm
var/global/list/RPD_recipes=list(
	"Regular Pipes" = list(
		"Pipe"           = new /datum/pipe_info(PIPE_SIMPLE_STRAIGHT,	1, PIPE_BINARY),
		"Bent Pipe"      = new /datum/pipe_info(PIPE_SIMPLE_BENT, 		5, PIPE_BENT),
		"Manifold"       = new /datum/pipe_info(PIPE_MANIFOLD, 			1, PIPE_TRINARY),
		"Manual Valve"   = new /datum/pipe_info(PIPE_MVALVE, 			1, PIPE_BINARY),
		"Digital Valve"  = new /datum/pipe_info(PIPE_DVALVE,			1, PIPE_BINARY),
		"4-Way Manifold" = new /datum/pipe_info(PIPE_4WAYMANIFOLD,		1, PIPE_QUAD),
	),
	"Devices"=list(
		"Connector"      = new /datum/pipe_info(PIPE_CONNECTOR,			1, PIPE_UNARY),
		"Unary Vent"     = new /datum/pipe_info(PIPE_UVENT,				1, PIPE_UNARY),
		"Gas Pump"       = new /datum/pipe_info(PIPE_PUMP,				1, PIPE_UNARY),
		"Passive Gate"   = new /datum/pipe_info(PIPE_PASSIVE_GATE,		1, PIPE_UNARY),
		"Volume Pump"    = new /datum/pipe_info(PIPE_VOLUME_PUMP,		1, PIPE_UNARY),
		"Scrubber"       = new /datum/pipe_info(PIPE_SCRUBBER,			1, PIPE_UNARY),
		"Meter"          = new /datum/pipe_info/meter(),
		"Gas Filter"     = new /datum/pipe_info(PIPE_GAS_FILTER,		1, PIPE_TRIN_M),
		"Gas Mixer"      = new /datum/pipe_info(PIPE_GAS_MIXER,			1, PIPE_TRIN_M),
//		"Injector"       = new /datum/pipe_info(PIPE_INJECTOR,     		1, PIPE_UNARY),
	),
	"Heat Exchange" = list(
		"Pipe"           = new /datum/pipe_info(PIPE_HE_STRAIGHT,		1, PIPE_BINARY),
		"Bent Pipe"      = new /datum/pipe_info(PIPE_HE_BENT,			5, PIPE_BENT),
		"Junction"       = new /datum/pipe_info(PIPE_JUNCTION,			1, PIPE_UNARY),
		"Heat Exchanger" = new /datum/pipe_info(PIPE_HEAT_EXCHANGE,		1, PIPE_UNARY),
	),
	"Insulated Pipes" = list(
		"Pipe"           = new /datum/pipe_info(PIPE_INSULATED_STRAIGHT,1, PIPE_BINARY),
		"Bent Pipe"      = new /datum/pipe_info(PIPE_INSULATED_BENT,	5, PIPE_BENT),
	),
	"Disposal Pipes" = list(
		"Pipe"          = new /datum/pipe_info/disposal(DISP_PIPE_STRAIGHT,	PIPE_BINARY),
		"Bent Pipe"     = new /datum/pipe_info/disposal(DISP_PIPE_BENT,		PIPE_TRINARY),
		"Junction"      = new /datum/pipe_info/disposal(DISP_JUNCTION,			PIPE_TRINARY),
		"Y-Junction"    = new /datum/pipe_info/disposal(DISP_YJUNCTION,		PIPE_TRINARY),
		"Trunk"         = new /datum/pipe_info/disposal(DISP_END_TRUNK,		PIPE_TRINARY),
		"Bin"           = new /datum/pipe_info/disposal(DISP_END_BIN,			PIPE_QUAD),
		"Outlet"        = new /datum/pipe_info/disposal(DISP_END_OUTLET,		PIPE_UNARY),
		"Chute"         = new /datum/pipe_info/disposal(DISP_END_CHUTE,		PIPE_UNARY),
		"Sort Junction" = new /datum/pipe_info/disposal(DISP_SORTJUNCTION,	PIPE_TRINARY),
	)
)
/obj/item/weapon/pipe_dispenser
	name = "Rapid Piping Device (RPD)"
	desc = "A device used to rapidly pipe things."
	icon = 'icons/obj/items.dmi'
	icon_state = "rpd"
	opacity = 0
	density = 0
	anchored = 0.0
	flags = CONDUCT
	force = 10.0
	throwforce = 10.0
	throw_speed = 1
	throw_range = 5
	w_class = 3.0
	m_amt = 75000
	g_amt = 37500
	origin_tech = "engineering=4;materials=2"
	var/datum/effect/effect/system/spark_spread/spark_system
	var/working = 0
	var/p_type = 0
	var/p_conntype = 0
	var/p_dir = 1
	var/p_flipped = 0
	var/p_class = ATMOS_MODE
	var/p_disposal = 0
	var/list/paint_colors = list(
		"grey"		= rgb(255,255,255),
		"red"		= rgb(255,0,0),
		"blue"		= rgb(0,0,255),
		"cyan"		= rgb(0,256,249),
		"green"		= rgb(30,255,0),
		"yellow"	= rgb(255,198,0),
		"purple"	= rgb(130,43,255)
	)
	var/paint_color="grey"

/obj/item/weapon/pipe_dispenser/New()
	. = ..()
	spark_system = new /datum/effect/effect/system/spark_spread
	spark_system.set_up(5, 0, src)
	spark_system.attach(src)

/obj/item/weapon/pipe_dispenser/attack_self(mob/user as mob)
	show_menu(user)

/obj/item/weapon/pipe_dispenser/proc/render_dir_img(var/_dir,var/pic,var/title,var/flipped=0)
	var/selected=""
	if(_dir == p_dir)
		selected=" class=\"selected\""
	return ""

/obj/item/weapon/pipe_dispenser/proc/show_menu(mob/user as mob)
	if(!user || !src)	return 0
	var/dat = {"
Type

Utilities:

Eat Pipes

Paint Pipes

"}
	var/icon/preview=null
	for(var/category in RPD_recipes)
		dat += "[category]:
"
		var/list/cat=RPD_recipes[category]
		for(var/label in cat)
			var/datum/pipe_info/I = cat[label]
			var/found=0
			if(I.id == p_type)
				if(p_class==ATMOS_MODE && I.type==/datum/pipe_info)
					found=1
				else if(p_class==DISPOSALS_MODE && I.type==/datum/pipe_info/disposal)
					found=1
			if(found)
				preview=new /icon(I.icon,I.icon_state)
			dat += I.Render(src,label)
		dat += "
"

	var/color_css=""
	var/color_picker=""
	for(var/color_name in paint_colors)
		var/color=paint_colors[color_name]
		color_css += {"
			a.color.[color_name] {
				color: [color];
			}
			a.color.[color_name]:hover {
				border:1px solid [color];
			}
			a.color.[color_name].selected {
				background-color: [color];
			}
		"}
		var/selected=""
		if(color_name==paint_color)
			selected = " selected"
		color_picker += {"•"}

	var/dirsel="
Direction
"
	switch(p_conntype)
		if(-1)
			if(p_class==PAINT_MODE)
				dirsel = "
Direction
[color_picker]"

		if(PIPE_BINARY) // Straight, N-S, W-E
			if(preview)
				user << browse_rsc(new /icon(preview, dir=NORTH), "vertical.png")
				user << browse_rsc(new /icon(preview, dir=EAST), "horizontal.png")

				dirsel += "
"
				dirsel += render_dir_img(1,"vertical.png","Vertical")
				dirsel += render_dir_img(4,"horizontal.png","Horizontal")
				dirsel += "
"
			else
				dirsel+={"

			↕
			↔

				"}
		if(PIPE_BENT) // Bent, N-W, N-E etc
			if(preview)
				user << browse_rsc(new /icon(preview, dir=NORTHWEST),  "nw.png")
				user << browse_rsc(new /icon(preview, dir=NORTHEAST),  "ne.png")
				user << browse_rsc(new /icon(preview, dir=SOUTHWEST),  "sw.png")
				user << browse_rsc(new /icon(preview, dir=SOUTHEAST),  "se.png")

				dirsel += "
"
				dirsel += render_dir_img(9,"nw.png","West to North")
				dirsel += render_dir_img(5,"ne.png","North to East")
				dirsel += "
"
				dirsel += render_dir_img(10,"sw.png","South to West")
				dirsel += render_dir_img(6,"se.png","East to South")
				dirsel += "
"
			else
				dirsel+={"

			╝
			╚

			╗
			╔

				"}
		if(PIPE_TRINARY) // Manifold
			if(preview)
				user << browse_rsc(new /icon(preview, dir=NORTH), "s.png")
				user << browse_rsc(new /icon(preview, dir=EAST),  "w.png")
				user << browse_rsc(new /icon(preview, dir=SOUTH), "n.png")
				user << browse_rsc(new /icon(preview, dir=WEST),  "e.png")

				dirsel += "
"
				dirsel += render_dir_img(1,"s.png","West South East")
				dirsel += render_dir_img(4,"w.png","North West South")
				dirsel += "
"
				dirsel += render_dir_img(2,"n.png","East North West")
				dirsel += render_dir_img(8,"e.png","South East North")
				dirsel += "
"
			else
				dirsel+={"

			╦
			╣

			╩
			╠

				"}
		if(PIPE_TRIN_M) // Mirrored ones
			if(preview)
				user << browse_rsc(new /icon(preview, dir=NORTH), "s.png")
				user << browse_rsc(new /icon(preview, dir=EAST),  "w.png")
				user << browse_rsc(new /icon(preview, dir=SOUTH), "n.png")
				user << browse_rsc(new /icon(preview, dir=WEST),  "e.png")
				user << browse_rsc(new /icon(preview, dir=SOUTHEAST), "sm.png") //each mirror icon is 45 anticlockwise from it's real direction
				user << browse_rsc(new /icon(preview, dir=NORTHEAST),  "wm.png")
				user << browse_rsc(new /icon(preview, dir=NORTHWEST), "nm.png")
				user << browse_rsc(new /icon(preview, dir=SOUTHWEST),  "em.png")

				dirsel += "
"
				dirsel += render_dir_img(1,"s.png","West South East")
				dirsel += render_dir_img(4,"w.png","North West South")
				dirsel += "
"
				dirsel += render_dir_img(2,"n.png","East North West")
				dirsel += render_dir_img(8,"e.png","South East North")
				dirsel += "
"
				dirsel += render_dir_img(6,"sm.png","West South East", 1)
				dirsel += render_dir_img(5,"wm.png","North West South", 1)
				dirsel += "
"
				dirsel += render_dir_img(9,"nm.png","East North West", 1)
				dirsel += render_dir_img(10,"em.png","South East North", 1)
				dirsel += "
"
			else
				dirsel+={"

			╦
			╣

			╩
			╠

			╦
			╣

			╩
			╠

				"}
		if(PIPE_UNARY) // Unary
			if(preview)
				user << browse_rsc(new /icon(preview, dir=NORTH), "n.png")
				user << browse_rsc(new /icon(preview, dir=EAST),  "e.png")
				user << browse_rsc(new /icon(preview, dir=SOUTH), "s.png")
				user << browse_rsc(new /icon(preview, dir=WEST),  "w.png")

				dirsel += "
"
				dirsel += render_dir_img(NORTH,"n.png","North")
				dirsel += render_dir_img(EAST, "e.png","East")
				dirsel += render_dir_img(SOUTH,"s.png","South")
				dirsel += render_dir_img(WEST, "w.png","West")
				dirsel += "
"
			else
				dirsel+={"

			↑
			→
			↓
			←

					"}
		if(PIPE_QUAD) // Single icon_state (eg 4-way manifolds)
			if(preview)
				user << browse_rsc(new /icon(preview), "pipe.png")

				dirsel += "
"
				dirsel += render_dir_img(1,"pipe.png","Pipe")
				dirsel += "
"
			else
				dirsel+={"

			↕

				"}

	dat = {"

		<title>[name]</title>

[dirsel][dat]

"}
	user << browse(dat, "window=pipedispenser")
	onclose(user, "pipedispenser")
	return

/obj/item/weapon/pipe_dispenser/Topic(href, href_list)
	if(!usr.canUseTopic(src))
		usr << browse(null, "window=pipedispenser")
		return
	usr.set_machine(src)
	src.add_fingerprint(usr)
	if(href_list["setdir"])
		p_dir= text2num(href_list["setdir"])
		p_flipped = text2num(href_list["flipped"])
		show_menu(usr)

	if(href_list["eatpipes"])
		p_class = EATING_MODE
		p_conntype=-1
		p_dir=1
		src.spark_system.start()
		playsound(get_turf(src), 'sound/effects/pop.ogg', 50, 0)
		show_menu(usr)

	if(href_list["paintpipes"])
		p_class = PAINT_MODE
		p_conntype=-1
		p_dir=1
		src.spark_system.start()
		playsound(get_turf(src), 'sound/effects/pop.ogg', 50, 0)
		show_menu(usr)

	if(href_list["set_color"])
		paint_color=href_list["set_color"]
		src.spark_system.start()
		playsound(get_turf(src), 'sound/effects/pop.ogg', 50, 0)
		show_menu(usr)

	if(href_list["makepipe"])
		p_type = text2num(href_list["makepipe"])
		p_dir = text2num(href_list["dir"])
		p_conntype = text2num(href_list["type"])
		p_class = ATMOS_MODE
		src.spark_system.start()
		playsound(get_turf(src), 'sound/effects/pop.ogg', 50, 0)
		show_menu(usr)

	if(href_list["makemeter"])
		p_class = METER_MODE
		p_conntype=-1
		p_dir=1
		src.spark_system.start()
		playsound(get_turf(src), 'sound/effects/pop.ogg', 50, 0)
		show_menu(usr)

	if(href_list["dmake"])
		p_type = text2num(href_list["dmake"])
		p_conntype = text2num(href_list["type"])
		p_dir = 1
		p_class = DISPOSALS_MODE
		src.spark_system.start()
		playsound(get_turf(src), 'sound/effects/pop.ogg', 50, 0)
		show_menu(usr)

/obj/item/weapon/pipe_dispenser/afterattack(atom/A, mob/user)
	if(!in_range(A,user) || loc != user)
		return 0

	if(!user.IsAdvancedToolUser())
		user << "You don't have the dexterity to do this!"
		return 0

	if(istype(A,/area/shuttle)||istype(A,/turf/space/transit))
		return 0

	switch(p_class)
		if(PAINT_MODE) // Paint pipes
			if(!istype(A,/obj/machinery/atmospherics/pipe))
				// Avoid spewing errors about invalid mode -2 when clicking on stuff that aren't pipes.
				user << "\The [src]'s error light flickers.  Perhaps you need to only use it on pipes and pipe meters?"
				return 0
			var/obj/machinery/atmospherics/pipe/P = A
			playsound(get_turf(src), 'sound/machines/click.ogg', 50, 1)
			P.color = paint_colors[paint_color]
			P.pipe_color = paint_colors[paint_color]
			P.stored.color = paint_colors[paint_color]
			user.visible_message("[user] paints \the [P] [paint_color].","You paint \the [P] [paint_color].")
			//P.update_icon()
			P.update_node_icon()
			return 1
		if(EATING_MODE) // Eating pipes
			// Must click on an actual pipe or meter.
			if(istype(A,/obj/item/pipe) || istype(A,/obj/item/pipe_meter) || istype(A,/obj/structure/disposalconstruct))
				user << "Destroying Pipe..."
				playsound(get_turf(src), 'sound/machines/click.ogg', 50, 1)
				if(do_after(user, 5))
					activate()
					qdel(A)
					return 1
				return 0

			// Avoid spewing errors about invalid mode -1 when clicking on stuff that aren't pipes.
			user << "The [src]'s error light flickers.  Perhaps you need to only use it on pipes and pipe meters?"
			return 0
		if(ATMOS_MODE)
			if(!(istype(A, /turf)))
				user << "The [src]'s error light flickers."
				return 0
			user << "Building Pipes ..."
			playsound(get_turf(src), 'sound/machines/click.ogg', 50, 1)
			if(do_after(user, 20))
				activate()
				var/obj/item/pipe/P = new (A, pipe_type=p_type, dir=p_dir)
				P.flipped = p_flipped
				P.update()
				P.add_fingerprint(usr)
				return 1
			return 0

		if(METER_MODE)
			if(!(istype(A, /turf)))
				user << "The [src]'s error light flickers."
				return 0
			user << "Building Meter..."
			playsound(get_turf(src), 'sound/machines/click.ogg', 50, 1)
			if(do_after(user, 20))
				activate()
				new /obj/item/pipe_meter(A)
				return 1
			return 0

		if(DISPOSALS_MODE)
			if(!(istype(A, /turf)))
				user << "The [src]'s error light flickers."
				return 0
			user << "Building Pipes..."
			playsound(get_turf(src), 'sound/machines/click.ogg', 50, 1)
			if(do_after(user, 20))
				var/obj/structure/disposalconstruct/C = new (A,p_type,p_dir)

				if(!C.can_place())
					user << "There's not enough room to build that here!"
					qdel(C)
					return 0

				activate()

				C.add_fingerprint(usr)
				C.update()
				return 1
			return 0
		else
			..()
			return 0

/obj/item/weapon/pipe_dispenser/proc/activate()
	playsound(get_turf(src), 'sound/items/Deconstruct.ogg', 50, 1)


code:
/*
CONTAINS:
RSF

*/
/obj/item/weapon/rsf
	name = "\improper Rapid-Service-Fabricator"
	desc = "A device used to rapidly deploy service items."
	icon = 'icons/obj/items.dmi'
	icon_state = "rcd"
	opacity = 0
	density = 0
	anchored = 0.0
	var/matter = 0
	var/mode = 1
	w_class = 3.0

/obj/item/weapon/rsf/New()
	desc = "A RSF. It currently holds [matter]/30 fabrication-units."
	return

/obj/item/weapon/rsf/attackby(obj/item/weapon/W as obj, mob/user as mob, params)
	..()
	if (istype(W, /obj/item/weapon/rcd_ammo))
		if ((matter + 10) > 30)
			user << "The RSF cant hold any more matter."
			return
		qdel(W)
		matter += 10
		playsound(src.loc, 'sound/machines/click.ogg', 10, 1)
		user << "The RSF now holds [matter]/30 fabrication-units."
		desc = "A RSF. It currently holds [matter]/30 fabrication-units."
		return

/obj/item/weapon/rsf/attack_self(mob/user as mob)
	playsound(src.loc, 'sound/effects/pop.ogg', 50, 0)
	if (mode == 1)
		mode = 2
		user << "Changed dispensing mode to 'Drinking Glass'"
		return
	if (mode == 2)
		mode = 3
		user << "Changed dispensing mode to 'Paper'"
		return
	if (mode == 3)
		mode = 4
		user << "Changed dispensing mode to 'Pen'"
		return
	if (mode == 4)
		mode = 5
		user << "Changed dispensing mode to 'Dice Pack'"
		return
	if (mode == 5)
		mode = 6
		user << "Changed dispensing mode to 'Cigarette'"
		return
	if (mode == 6)
		mode = 1
		user << "Changed dispensing mode to 'Dosh'"
		return
	// Change mode

/obj/item/weapon/rsf/afterattack(atom/A, mob/user as mob, proximity)
	if(!proximity) return
	if (!(istype(A, /obj/structure/table) || istype(A, /turf/simulated/floor)))
		return

	if (istype(A, /obj/structure/table) && mode == 1)
		if (istype(A, /obj/structure/table) && matter >= 1)
			user << "Dispensing Dosh..."
			playsound(src.loc, 'sound/machines/click.ogg', 10, 1)
			new /obj/item/weapon/spacecash/c10( A.loc )
			if (isrobot(user))
				var/mob/living/silicon/robot/engy = user
				engy.cell.charge -= 200 //once money becomes useful, I guess changing this to a high ammount, like 500 units a kick, till then, enjoy dosh!
			else
				matter--
				user << "The RSF now holds [matter]/30 fabrication-units."
				desc = "A RSF. It currently holds [matter]/30 fabrication-units."
		return

	else if (istype(A, /turf/simulated/floor) && mode == 1)
		if (istype(A, /turf/simulated/floor) && matter >= 1)
			user << "Dispensing Dosh..."
			playsound(src.loc, 'sound/machines/click.ogg', 10, 1)
			new /obj/item/weapon/spacecash/c10( A )
			if (isrobot(user))
				var/mob/living/silicon/robot/engy = user
				engy.cell.charge -= 200 //once money becomes useful, I guess changing this to a high ammount, like 500 units a kick, till then, enjoy dosh!
			else
				matter--
				user << "The RSF now holds [matter]/30 fabrication-units."
				desc = "A RSF. It currently holds [matter]/30 fabrication-units."
		return

	else if (istype(A, /obj/structure/table) && mode == 2)
		if (istype(A, /obj/structure/table) && matter >= 1)
			user << "Dispensing Drinking Glass..."
			playsound(src.loc, 'sound/machines/click.ogg', 10, 1)
			new /obj/item/weapon/reagent_containers/food/drinks/drinkingglass( A.loc )
			if (isrobot(user))
				var/mob/living/silicon/robot/engy = user
				engy.cell.charge -= 50
			else
				matter--
				user << "The RSF now holds [matter]/30 fabrication-units."
				desc = "A RSF. It currently holds [matter]/30 fabrication-units."
		return

	else if (istype(A, /turf/simulated/floor) && mode == 2)
		if (istype(A, /turf/simulated/floor) && matter >= 1)
			user << "Dispensing Drinking Glass..."
			playsound(src.loc, 'sound/machines/click.ogg', 10, 1)
			new /obj/item/weapon/reagent_containers/food/drinks/drinkingglass( A )
			if (isrobot(user))
				var/mob/living/silicon/robot/engy = user
				engy.cell.charge -= 50
			else
				matter--
				user << "The RSF now holds [matter]/30 fabrication-units."
				desc = "A RSF. It currently holds [matter]/30 fabrication-units."
		return

	else if (istype(A, /obj/structure/table) && mode == 3)
		if (istype(A, /obj/structure/table) && matter >= 1)
			user << "Dispensing Paper Sheet..."
			playsound(src.loc, 'sound/machines/click.ogg', 10, 1)
			new /obj/item/weapon/paper( A.loc )
			if (isrobot(user))
				var/mob/living/silicon/robot/engy = user
				engy.cell.charge -= 10
			else
				matter--
				user << "The RSF now holds [matter]/30 fabrication-units."
				desc = "A RSF. It currently holds [matter]/30 fabrication-units."
		return

	else if (istype(A, /turf/simulated/floor) && mode == 3)
		if (istype(A, /turf/simulated/floor) && matter >= 1)
			user << "Dispensing Paper Sheet..."
			playsound(src.loc, 'sound/machines/click.ogg', 10, 1)
			new /obj/item/weapon/paper( A )
			if (isrobot(user))
				var/mob/living/silicon/robot/engy = user
				engy.cell.charge -= 10
			else
				matter--
				user << "The RSF now holds [matter]/30 fabrication-units."
				desc = "A RSF. It currently holds [matter]/30 fabrication-units."
		return

	else if (istype(A, /obj/structure/table) && mode == 4)
		if (istype(A, /obj/structure/table) && matter >= 1)
			user << "Dispensing Pen..."
			playsound(src.loc, 'sound/machines/click.ogg', 10, 1)
			new /obj/item/weapon/pen( A.loc )
			if (isrobot(user))
				var/mob/living/silicon/robot/engy = user
				engy.cell.charge -= 50
			else
				matter--
				user << "The RSF now holds [matter]/30 fabrication-units."
				desc = "A RSF. It currently holds [matter]/30 fabrication-units."
		return

	else if (istype(A, /turf/simulated/floor) && mode == 4)
		if (istype(A, /turf/simulated/floor) && matter >= 1)
			user << "Dispensing Pen..."
			playsound(src.loc, 'sound/machines/click.ogg', 10, 1)
			new /obj/item/weapon/pen( A )
			if (isrobot(user))
				var/mob/living/silicon/robot/engy = user
				engy.cell.charge -= 50
			else
				matter--
				user << "The RSF now holds [matter]/30 fabrication-units."
				desc = "A RSF. It currently holds [matter]/30 fabrication-units."
		return

	else if (istype(A, /obj/structure/table) && mode == 5)
		if (istype(A, /obj/structure/table) && matter >= 1)
			user << "Dispensing Dice Pack..."
			playsound(src.loc, 'sound/machines/click.ogg', 10, 1)
			new /obj/item/weapon/storage/pill_bottle/dice( A.loc )
			if (isrobot(user))
				var/mob/living/silicon/robot/engy = user
				engy.cell.charge -= 200
			else
				matter--
				user << "The RSF now holds [matter]/30 fabrication-units."
				desc = "A RSF. It currently holds [matter]/30 fabrication-units."
		return

	else if (istype(A, /turf/simulated/floor) && mode == 5)
		if (istype(A, /turf/simulated/floor) && matter >= 1)
			user << "Dispensing Dice Pack..."
			playsound(src.loc, 'sound/machines/click.ogg', 10, 1)
			new /obj/item/weapon/storage/pill_bottle/dice( A )
			if (isrobot(user))
				var/mob/living/silicon/robot/engy = user
				engy.cell.charge -= 200
			else
				matter--
				user << "The RSF now holds [matter]/30 fabrication-units."
				desc = "A RSF. It currently holds [matter]/30 fabrication-units."
		return

	else if (istype(A, /obj/structure/table) && mode == 6)
		if (istype(A, /obj/structure/table) && matter >= 1)
			user << "Dispensing Cigarette..."
			playsound(src.loc, 'sound/machines/click.ogg', 10, 1)
			new /obj/item/clothing/mask/cigarette( A.loc )
			if (isrobot(user))
				var/mob/living/silicon/robot/engy = user
				engy.cell.charge -= 10
			else
				matter--
				user << "The RSF now holds [matter]/30 fabrication-units."
				desc = "A RSF. It currently holds [matter]/30 fabrication-units."
		return

	else if (istype(A, /turf/simulated/floor) && mode == 6)
		if (istype(A, /turf/simulated/floor) && matter >= 1)
			user << "Dispensing Cigarette..."
			playsound(src.loc, 'sound/machines/click.ogg', 10, 1)
			new /obj/item/clothing/mask/cigarette( A )
			if (isrobot(user))
				var/mob/living/silicon/robot/engy = user
				engy.cell.charge -= 10
			else
				matter--
				user << "The RSF now holds [matter]/30 fabrication-units."
				desc = "A RSF. It currently holds [matter]/30 fabrication-units."
		return


code:
/obj/item/weapon/airlock_painter
	name = "airlock painter"
	desc = "An advanced autopainter preprogrammed with several paintjobs for airlocks. Use it on an airlock during or after construction to change the paintjob."
	icon = 'icons/obj/objects.dmi'
	icon_state = "paint sprayer"
	item_state = "paint sprayer"

	w_class = 2.0

	m_amt = 50
	g_amt = 50
	origin_tech = "engineering=1"

	flags = CONDUCT
	slot_flags = SLOT_BELT

	var/obj/item/device/toner/ink = null

/obj/item/weapon/airlock_painter/New()
	ink = new /obj/item/device/toner(src)

//This proc doesn't just check if the painter can be used, but also uses it.
//Only call this if you are certain that the painter will be used right after this check!
/obj/item/weapon/airlock_painter/proc/use(mob/user as mob)
	if(can_use(user))
		ink.charges--
		playsound(src.loc, 'sound/effects/spray2.ogg', 50, 1)
		return 1
	else
		return 0

//This proc only checks if the painter can be used.
//Call this if you don't want the painter to be used right after this check, for example
//because you're expecting user input.
/obj/item/weapon/airlock_painter/proc/can_use(mob/user as mob)
	if(!ink)
		user << "There is no toner cardridge installed installed in \the [name]!"
		return 0
	else if(ink.charges < 1)
		user << "\The [name] is out of ink!"
		return 0
	else
		return 1

/obj/item/weapon/airlock_painter/examine(mob/user)
	..()
	if(!ink)
		user << "It doesn't have a toner cardridge installed."
		return
	var/ink_level = "high"
	if(ink.charges < 1)
		ink_level = "empty"
	else if((ink.charges/ink.max_charges) <= 0.25) //25%
		ink_level = "low"
	else if((ink.charges/ink.max_charges) > 1) //Over 100% (admin var edit)
		ink_level = "dangerously high"
	user << "Its ink levels look [ink_level]."

/obj/item/weapon/airlock_painter/attackby(obj/item/weapon/W, mob/user, params)
	..()
	if(istype(W, /obj/item/device/toner))
		if(ink)
			user << "\the [name] already contains \a [ink]."
			return
		user.drop_item()
		W.loc = src
		user << "You install \the [W] into \the [name]."
		ink = W
		playsound(src.loc, 'sound/machines/click.ogg', 50, 1)

/obj/item/weapon/airlock_painter/attack_self(mob/user)
	if(ink)
		playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
		ink.loc = user.loc
		user.put_in_hands(ink)
		user << "You remove \the [ink] from \the [name]."
		ink = null

/obj/item/weapon/airlock_painter/cyborg

/obj/item/weapon/airlock_painter/cyborg/New()
	if (!ink)
		ink = new /obj/item/device/toner/cyborg(src)

/obj/item/weapon/airlock_painter/cyborg/attackby(obj/item/weapon/W, mob/user, params)
	return
/obj/item/weapon/airlock_painter/cyborg/attack_self(mob/user)
	return