Files
Polaris/code/game/machinery/teleporter.dm
petethegoat@gmail.com a80e46c078 Fixed issue 222.
Improved closet/secure closet/crate code a bit. (Updated the paths on the map.)

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@2585 316c924e-a436-60f5-8080-3fe189b3f50e
2011-12-01 20:02:43 +00:00

315 lines
8.9 KiB
Plaintext

/obj/machinery/computer/teleporter
name = "Teleporter"
desc = "Used to control a linked teleportation Hub and Station."
icon_state = "teleport"
circuit = "/obj/item/weapon/circuitboard/teleporter"
var/obj/item/locked = null
var/id = null
/obj/machinery/computer/teleporter/New()
src.id = text("[]", rand(1000, 9999))
..()
return
/obj/machinery/computer/teleporter/attackby(I as obj, user as mob)
if (istype(I, /obj/item/weapon/card/data/))
var/obj/item/weapon/card/data/M = I
if(stat & (NOPOWER|BROKEN) & (M.function != "teleporter"))
src.attack_hand()
var/obj/S = null
for(var/obj/effect/landmark/sloc in world)
if (sloc.name != M.data)
continue
if (locate(/mob) in sloc.loc)
continue
S = sloc
break
if (!S)
S = locate("landmark*[M.data]") // use old stype
if (istype(S, /obj/effect/landmark/) && istype(S.loc, /turf))
usr.loc = S.loc
del(I)
return
else
..()
return
/obj/machinery/computer/teleporter/attack_paw()
src.attack_hand()
/obj/machinery/computer/teleporter/security/attackby(obj/item/weapon/W)
src.attack_hand()
/obj/machinery/computer/teleporter/security/attack_paw()
src.attack_hand()
/obj/machinery/teleport/station/attack_ai()
src.attack_hand()
/obj/machinery/computer/teleporter/attack_hand()
if(stat & (NOPOWER|BROKEN))
return
var/list/L = list()
var/list/areaindex = list()
for(var/obj/item/device/radio/beacon/R in world)
var/turf/T = get_turf(R)
if (!T) continue
if(T.z == 2) continue
var/tmpname = T.loc.name
if(areaindex[tmpname])
tmpname = "[tmpname] ([++areaindex[tmpname]])"
else
areaindex[tmpname] = 1
L[tmpname] = R
for (var/obj/item/weapon/implant/tracking/I in world)
if (!I.implanted || !ismob(I.loc))
continue
else
var/mob/M = I.loc
if (M.stat == 2)
if (M.timeofdeath + 6000 < world.time)
continue
var/turf/T = get_turf(M)
if(T) continue
if(T.z == 2) continue
var/tmpname = M.real_name
if(areaindex[tmpname])
tmpname = "[tmpname] ([++areaindex[tmpname]])"
else
areaindex[tmpname] = 1
L[tmpname] = I
var/desc = input("Please select a location to lock in.", "Locking Computer") in L
src.locked = L[desc]
for(var/mob/O in hearers(src, null))
O.show_message("\blue Locked In", 2)
src.add_fingerprint(usr)
return
/obj/machinery/computer/teleporter/verb/set_id(t as text)
set category = "Object"
set name = "Set teleporter ID"
set src in oview(1)
set desc = "ID Tag:"
if(stat & (NOPOWER|BROKEN) || !istype(usr,/mob/living))
return
if (t)
src.id = t
return
/proc/find_loc(obj/R as obj)
if (!R) return null
var/turf/T = R.loc
while(!istype(T, /turf))
T = T.loc
if(!T || istype(T, /area)) return null
return T
/obj/machinery/teleport/hub/Bumped(M as mob|obj)
spawn()
if (src.icon_state == "tele1")
teleport(M)
use_power(5000)
return
/obj/machinery/teleport/hub/proc/teleport(atom/movable/M as mob|obj)
var/atom/l = src.loc
var/obj/machinery/computer/teleporter/com = locate(/obj/machinery/computer/teleporter, locate(l.x - 2, l.y, l.z))
if (!com)
return
if (!com.locked)
for(var/mob/O in hearers(src, null))
O.show_message("\red Failure: Cannot authenticate locked on coordinates. Please reinstate coordinate matrix.")
return
if (istype(M, /atom/movable))
if(prob(5) && !accurate) //oh dear a problem, put em in deep space
do_teleport(M, locate(rand(5, world.maxx - 5), rand(5, world.maxy - 5), 3), 2)
else
do_teleport(M, com.locked) //dead-on precision
else
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, src)
s.start()
for(var/mob/B in hearers(src, null))
B.show_message("\blue Test fire completed.")
return
/*
/proc/do_teleport(atom/movable/M as mob|obj, atom/destination, precision)
if(istype(M, /obj/effect))
del(M)
return
if (istype(M, /obj/item/weapon/disk/nuclear)) // Don't let nuke disks get teleported --NeoFite
for(var/mob/O in viewers(M, null))
O.show_message(text("\red <B>The [] bounces off of the portal!</B>", M.name), 1)
return
if (istype(M, /mob/living))
var/mob/living/MM = M
if(MM.check_contents_for(/obj/item/weapon/disk/nuclear))
MM << "\red Something you are carrying seems to be unable to pass through the portal. Better drop it if you want to go through."
return
var/disky = 0
for (var/atom/O in M.contents) //I'm pretty sure this accounts for the maximum amount of container in container stacking. --NeoFite
if (istype(O, /obj/item/weapon/storage) || istype(O, /obj/item/weapon/gift))
for (var/obj/OO in O.contents)
if (istype(OO, /obj/item/weapon/storage) || istype(OO, /obj/item/weapon/gift))
for (var/obj/OOO in OO.contents)
if (istype(OOO, /obj/item/weapon/disk/nuclear))
disky = 1
if (istype(OO, /obj/item/weapon/disk/nuclear))
disky = 1
if (istype(O, /obj/item/weapon/disk/nuclear))
disky = 1
if (istype(O, /mob/living))
var/mob/living/MM = O
if(MM.check_contents_for(/obj/item/weapon/disk/nuclear))
disky = 1
if (disky)
for(var/mob/P in viewers(M, null))
P.show_message(text("\red <B>The [] bounces off of the portal!</B>", M.name), 1)
return
//Bags of Holding cause bluespace teleportation to go funky. --NeoFite
if (istype(M, /mob/living))
var/mob/living/MM = M
if(MM.check_contents_for(/obj/item/weapon/storage/backpack/holding))
MM << "\red The Bluespace interface on your Bag of Holding interferes with the teleport!"
precision = rand(1,100)
if (istype(M, /obj/item/weapon/storage/backpack/holding))
precision = rand(1,100)
for (var/atom/O in M.contents) //I'm pretty sure this accounts for the maximum amount of container in container stacking. --NeoFite
if (istype(O, /obj/item/weapon/storage) || istype(O, /obj/item/weapon/gift))
for (var/obj/OO in O.contents)
if (istype(OO, /obj/item/weapon/storage) || istype(OO, /obj/item/weapon/gift))
for (var/obj/OOO in OO.contents)
if (istype(OOO, /obj/item/weapon/storage/backpack/holding))
precision = rand(1,100)
if (istype(OO, /obj/item/weapon/storage/backpack/holding))
precision = rand(1,100)
if (istype(O, /obj/item/weapon/storage/backpack/holding))
precision = rand(1,100)
if (istype(O, /mob/living))
var/mob/living/MM = O
if(MM.check_contents_for(/obj/item/weapon/storage/backpack/holding))
precision = rand(1,100)
var/turf/destturf = get_turf(destination)
var/tx = destturf.x + rand(precision * -1, precision)
var/ty = destturf.y + rand(precision * -1, precision)
var/tmploc
if (ismob(destination.loc)) //If this is an implant.
tmploc = locate(tx, ty, destturf.z)
else
tmploc = locate(tx, ty, destination.z)
if(tx == destturf.x && ty == destturf.y && (istype(destination.loc, /obj/structure/closet) || istype(destination.loc, /obj/structure/closet/secure_closet)))
tmploc = destination.loc
if(tmploc==null)
return
M.loc = tmploc
sleep(2)
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, M)
s.start()
return
*/
/obj/machinery/teleport/station/attackby(var/obj/item/weapon/W)
src.attack_hand()
/obj/machinery/teleport/station/attack_paw()
src.attack_hand()
/obj/machinery/teleport/station/attack_ai()
src.attack_hand()
/obj/machinery/teleport/station/attack_hand()
if(engaged)
src.disengage()
else
src.engage()
/obj/machinery/teleport/station/proc/engage()
if(stat & (BROKEN|NOPOWER))
return
var/atom/l = src.loc
var/atom/com = locate(/obj/machinery/teleport/hub, locate(l.x + 1, l.y, l.z))
if (com)
com.icon_state = "tele1"
use_power(5000)
for(var/mob/O in hearers(src, null))
O.show_message("\blue Teleporter engaged!", 2)
src.add_fingerprint(usr)
src.engaged = 1
return
/obj/machinery/teleport/station/proc/disengage()
if(stat & (BROKEN|NOPOWER))
return
var/atom/l = src.loc
var/atom/com = locate(/obj/machinery/teleport/hub, locate(l.x + 1, l.y, l.z))
if (com)
com.icon_state = "tele0"
for(var/mob/O in hearers(src, null))
O.show_message("\blue Teleporter disengaged!", 2)
src.add_fingerprint(usr)
src.engaged = 0
return
/obj/machinery/teleport/station/verb/testfire()
set name = "Test Fire Teleporter"
set category = "Object"
set src in oview(1)
if(stat & (BROKEN|NOPOWER) || !istype(usr,/mob/living))
return
var/atom/l = src.loc
var/obj/machinery/teleport/hub/com = locate(/obj/machinery/teleport/hub, locate(l.x + 1, l.y, l.z))
if (com && !active)
active = 1
for(var/mob/O in hearers(src, null))
O.show_message("\blue Test firing!", 2)
com.teleport()
use_power(5000)
spawn(30)
active=0
src.add_fingerprint(usr)
return
/obj/machinery/teleport/station/power_change()
..()
if(stat & NOPOWER)
icon_state = "controller-p"
var/obj/machinery/teleport/hub/com = locate(/obj/machinery/teleport/hub, locate(x + 1, y, z))
if(com)
com.icon_state = "tele0"
else
icon_state = "controller"
/obj/effect/laser/Bump()
src.range--
return
/obj/effect/laser/Move()
src.range--
return
/atom/proc/laserhit(L as obj)
return 1