<commit_before>/obj/machinery/quantumpad
	name = "quantum pad"
	desc = "A bluespace quantum-linked telepad used for teleporting objects to other quantum pads."
	icon = 'icons/obj/telescience.dmi'
	icon_state = "qpad-idle"
	anchored = 1
	use_power = 1
	idle_power_usage = 200
	active_power_usage = 5000
	var/teleport_cooldown = 400 //30 seconds base due to base parts
	var/teleport_speed = 50
	var/last_teleport //to handle the cooldown
	var/teleporting = 0 //if it's in the process of teleporting
	var/power_efficiency = 1
	var/obj/machinery/quantumpad/linked_pad = null

/obj/machinery/quantumpad/New()
	..()
	var/obj/item/weapon/circuitboard/machine/B = new /obj/item/weapon/circuitboard/machine/quantumpad(null)
	B.apply_default_parts(src)

/obj/item/weapon/circuitboard/machine/quantumpad
	name = "circuit board (Quantum Pad)"
	build_path = /obj/machinery/quantumpad
	origin_tech = "programming=3;engineering=3;plasmatech=3;bluespace=4"
	req_components = list(
							/obj/item/weapon/ore/bluespace_crystal = 1,
							/obj/item/weapon/stock_parts/capacitor = 1,
							/obj/item/weapon/stock_parts/manipulator = 1,
							/obj/item/stack/cable_coil = 1)
	def_components = list(/obj/item/weapon/ore/bluespace_crystal = /obj/item/weapon/ore/bluespace_crystal/artificial)

/obj/machinery/quantumpad/RefreshParts()
	var/E = 0
	for(var/obj/item/weapon/stock_parts/capacitor/C in component_parts)
		E += C.rating
	power_efficiency = E
	E = 0
	for(var/obj/item/weapon/stock_parts/manipulator/M in component_parts)
		E += M.rating
	teleport_speed = initial(teleport_speed)
	teleport_speed -= (E*10)
	teleport_cooldown = initial(teleport_cooldown)
	teleport_cooldown -= (E * 100)

/obj/machinery/quantumpad/attackby(obj/item/I, mob/user, params)
	if(default_deconstruction_screwdriver(user, "pad-idle-o", "qpad-idle", I))
		return

	if(panel_open)
		if(istype(I, /obj/item/device/multitool))
			var/obj/item/device/multitool/M = I
			M.buffer = src
			user << "<span class='notice'>You save the data in the [I.name]'s buffer.</span>"
			return 1
	else if(istype(I, /obj/item/device/multitool))
		var/obj/item/device/multitool/M = I
		if(istype(M.buffer, /obj/machinery/quantumpad))
			linked_pad = M.buffer
			user << "<span class='notice'>You link the [src] to the one in the [I.name]'s buffer.</span>"
			return 1

	if(exchange_parts(user, I))
		return

	if(default_deconstruction_crowbar(I))
		return

	return ..()

/obj/machinery/quantumpad/attack_hand(mob/user)
	if(panel_open)
		user << "<span class='warning'>The panel must be closed before operating this machine!</span>"
		return

	if(!linked_pad || qdeleted(linked_pad))
		user << "<span class='warning'>There is no linked pad!</span>"
		return

	if(world.time < last_teleport + teleport_cooldown)
		user << "<span class='warning'>[src] is recharging power. Please wait [round((last_teleport + teleport_cooldown - world.time) / 10)] seconds.</span>"
		return

	if(teleporting)
		user << "<span class='warning'>[src] is charging up. Please wait.</span>"
		return

	if(linked_pad.teleporting)
		user << "<span class='warning'>Linked pad is busy. Please wait.</span>"
		return

	if(linked_pad.stat & NOPOWER)
		user << "<span class='warning'>Linked pad is not responding to ping.</span>"
		return
	src.add_fingerprint(user)
	doteleport(user)
	return

/obj/machinery/quantumpad/proc/sparks()
	var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
	s.set_up(5, 1, get_turf(src))
	s.start()

/obj/machinery/quantumpad/attack_ghost(mob/dead/observer/ghost)
	if(linked_pad)
		ghost.forceMove(get_turf(linked_pad))

/obj/machinery/quantumpad/proc/doteleport(mob/user)
	if(linked_pad)
		playsound(get_turf(src), 'sound/weapons/flash.ogg', 25, 1)
		teleporting = 1

		spawn(teleport_speed)
			if(!src || qdeleted(src))
				teleporting = 0
				return
			if(stat & NOPOWER)
				user << "<span class='warning'>[src] is unpowered!</span>"
				teleporting = 0
				return
			if(!linked_pad || qdeleted(linked_pad) || linked_pad.stat & NOPOWER)
				user << "<span class='warning'>Linked pad is not responding to ping. Teleport aborted.</span>"
				teleporting = 0
				return

			teleporting = 0
			last_teleport = world.time

			// use a lot of power
			use_power(10000 / power_efficiency)
			sparks()
			linked_pad.sparks()

			flick("qpad-beam", src)
			playsound(get_turf(src), 'sound/weapons/emitter2.ogg', 25, 1, extrarange = 3, falloff = 5)
			flick("qpad-beam", linked_pad)
			playsound(get_turf(linked_pad), 'sound/weapons/emitter2.ogg', 25, 1, extrarange = 3, falloff = 5)
			for(var/atom/movable/ROI in get_turf(src))
				// if is anchored, don't let through
				if(ROI.anchored)
					if(isliving(ROI))
						var/mob/living/L = ROI
						if(L.buckled)
							// TP people on office chairs
							if(L.buckled.anchored)
								continue
						else
							continue
					else if(!isobserver(ROI))
						continue
				do_teleport(ROI, get_turf(linked_pad))
<commit_msg>Quantum Pads can now be Renamed (#22326)<commit_after>/obj/machinery/quantumpad
	name = "quantum pad"
	desc = "A bluespace quantum-linked telepad used for teleporting objects to other quantum pads."
	icon = 'icons/obj/telescience.dmi'
	icon_state = "qpad-idle"
	anchored = 1
	use_power = 1
	idle_power_usage = 200
	active_power_usage = 5000
	unique_rename = 1
	var/teleport_cooldown = 400 //30 seconds base due to base parts
	var/teleport_speed = 50
	var/last_teleport //to handle the cooldown
	var/teleporting = 0 //if it's in the process of teleporting
	var/power_efficiency = 1
	var/obj/machinery/quantumpad/linked_pad = null

/obj/machinery/quantumpad/New()
	..()
	var/obj/item/weapon/circuitboard/machine/B = new /obj/item/weapon/circuitboard/machine/quantumpad(null)
	B.apply_default_parts(src)

/obj/item/weapon/circuitboard/machine/quantumpad
	name = "circuit board (Quantum Pad)"
	build_path = /obj/machinery/quantumpad
	origin_tech = "programming=3;engineering=3;plasmatech=3;bluespace=4"
	req_components = list(
							/obj/item/weapon/ore/bluespace_crystal = 1,
							/obj/item/weapon/stock_parts/capacitor = 1,
							/obj/item/weapon/stock_parts/manipulator = 1,
							/obj/item/stack/cable_coil = 1)
	def_components = list(/obj/item/weapon/ore/bluespace_crystal = /obj/item/weapon/ore/bluespace_crystal/artificial)

/obj/machinery/quantumpad/RefreshParts()
	var/E = 0
	for(var/obj/item/weapon/stock_parts/capacitor/C in component_parts)
		E += C.rating
	power_efficiency = E
	E = 0
	for(var/obj/item/weapon/stock_parts/manipulator/M in component_parts)
		E += M.rating
	teleport_speed = initial(teleport_speed)
	teleport_speed -= (E*10)
	teleport_cooldown = initial(teleport_cooldown)
	teleport_cooldown -= (E * 100)

/obj/machinery/quantumpad/attackby(obj/item/I, mob/user, params)
	if(default_deconstruction_screwdriver(user, "pad-idle-o", "qpad-idle", I))
		return

	if(panel_open)
		if(istype(I, /obj/item/device/multitool))
			var/obj/item/device/multitool/M = I
			M.buffer = src
			user << "<span class='notice'>You save the data in the [I.name]'s buffer.</span>"
			return 1
	else if(istype(I, /obj/item/device/multitool))
		var/obj/item/device/multitool/M = I
		if(istype(M.buffer, /obj/machinery/quantumpad))
			linked_pad = M.buffer
			user << "<span class='notice'>You link the [src] to the one in the [I.name]'s buffer.</span>"
			return 1

	if(exchange_parts(user, I))
		return

	if(default_deconstruction_crowbar(I))
		return

	return ..()

/obj/machinery/quantumpad/attack_hand(mob/user)
	if(panel_open)
		user << "<span class='warning'>The panel must be closed before operating this machine!</span>"
		return

	if(!linked_pad || qdeleted(linked_pad))
		user << "<span class='warning'>There is no linked pad!</span>"
		return

	if(world.time < last_teleport + teleport_cooldown)
		user << "<span class='warning'>[src] is recharging power. Please wait [round((last_teleport + teleport_cooldown - world.time) / 10)] seconds.</span>"
		return

	if(teleporting)
		user << "<span class='warning'>[src] is charging up. Please wait.</span>"
		return

	if(linked_pad.teleporting)
		user << "<span class='warning'>Linked pad is busy. Please wait.</span>"
		return

	if(linked_pad.stat & NOPOWER)
		user << "<span class='warning'>Linked pad is not responding to ping.</span>"
		return
	src.add_fingerprint(user)
	doteleport(user)
	return

/obj/machinery/quantumpad/proc/sparks()
	var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
	s.set_up(5, 1, get_turf(src))
	s.start()

/obj/machinery/quantumpad/attack_ghost(mob/dead/observer/ghost)
	if(linked_pad)
		ghost.forceMove(get_turf(linked_pad))

/obj/machinery/quantumpad/proc/doteleport(mob/user)
	if(linked_pad)
		playsound(get_turf(src), 'sound/weapons/flash.ogg', 25, 1)
		teleporting = 1

		spawn(teleport_speed)
			if(!src || qdeleted(src))
				teleporting = 0
				return
			if(stat & NOPOWER)
				user << "<span class='warning'>[src] is unpowered!</span>"
				teleporting = 0
				return
			if(!linked_pad || qdeleted(linked_pad) || linked_pad.stat & NOPOWER)
				user << "<span class='warning'>Linked pad is not responding to ping. Teleport aborted.</span>"
				teleporting = 0
				return

			teleporting = 0
			last_teleport = world.time

			// use a lot of power
			use_power(10000 / power_efficiency)
			sparks()
			linked_pad.sparks()

			flick("qpad-beam", src)
			playsound(get_turf(src), 'sound/weapons/emitter2.ogg', 25, 1, extrarange = 3, falloff = 5)
			flick("qpad-beam", linked_pad)
			playsound(get_turf(linked_pad), 'sound/weapons/emitter2.ogg', 25, 1, extrarange = 3, falloff = 5)
			for(var/atom/movable/ROI in get_turf(src))
				// if is anchored, don't let through
				if(ROI.anchored)
					if(isliving(ROI))
						var/mob/living/L = ROI
						if(L.buckled)
							// TP people on office chairs
							if(L.buckled.anchored)
								continue
						else
							continue
					else if(!isobserver(ROI))
						continue
				do_teleport(ROI, get_turf(linked_pad))

{'fraction_non_alphanumeric': 0.13346774193548386, 'fraction_numerical': 0.013508064516129032, 'mean_word_length': 3.992954202315048, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7569253', 'n_tokens_mistral': 4269, 'n_tokens_neox': 3670, 'n_words': 726}