Files
Bubberstation/code/game/objects/effects/portals.dm
supersayu 799c7ad2ce Replaces atom/HasEntered() with the builtin atom/movable/Crossed()
Crossed() is a byond builtin which is called automatically when two movable atoms overlap (as a side effect of Move(), but not when loc or x/y/z is changed).  Previously, turf/Entered() iterated through all objects in the turf in order to tell them an object had entered; with this change, HasEntered() becomes redundant and can be eliminated.

This may reduce lag when a large number of objects are moving in a small space (singularity, mining conveyors, etc) but should cause no changes to functionality at all.
2013-10-23 16:20:20 -04:00

59 lines
1.4 KiB
Plaintext

/obj/effect/portal
name = "portal"
desc = "Looks unstable. Best to test it with the clown."
icon = 'icons/obj/stationobjs.dmi'
icon_state = "portal"
density = 1
unacidable = 1//Can't destroy energy portals.
var/failchance = 5
var/obj/item/target = null
var/creator = null
anchored = 1.0
/obj/effect/portal/Bumped(mob/M as mob|obj)
spawn(0)
src.teleport(M)
return
return
/obj/effect/portal/Crossed(AM as mob|obj)
spawn(0)
src.teleport(AM)
return
return
/obj/effect/portal/New(loc, turf/target, creator, lifespan=300)
portals += src
src.loc = loc
src.target = target
src.creator = creator
if(lifespan > 0)
spawn(lifespan)
del(src)
return
/obj/effect/portal/Del()
portals -= src
if(istype(creator, /obj/item/weapon/hand_tele))
var/obj/item/weapon/hand_tele/O = creator
O.active_portals--
return ..()
/obj/effect/portal/proc/teleport(atom/movable/M as mob|obj)
if(istype(M, /obj/effect)) //sparks don't teleport
return
if(M.anchored&&istype(M, /obj/mecha))
return
if(icon_state == "portal1")
return
if (!( target ))
del(src)
return
if (istype(M, /atom/movable))
if(prob(failchance)) //oh dear a problem, put em in deep space
src.icon_state = "portal1"
do_teleport(M, locate(rand(5, world.maxx - 5), rand(5, world.maxy -5), 3), 0)
else
do_teleport(M, target, 1) ///You will appear adjacent to the beacon