Teleportation Fixes and Tweaks (#12103)

This commit is contained in:
Doxxmedearly
2021-06-29 06:49:23 -04:00
committed by GitHub
parent 52934f9153
commit 2843ee8db8
5 changed files with 104 additions and 46 deletions

View File

@@ -1,6 +1,9 @@
//wrapper
/proc/do_teleport(ateleatom, adestination, aprecision=0, afteleport=1, aeffectin=null, aeffectout=null, asoundin=null, asoundout=null)
new /datum/teleport/instant/science(arglist(args))
var/datum/teleport/T = new /datum/teleport/instant/science(arglist(args))
if(T.stable_creation)
return TRUE
return FALSE
/datum/teleport
var/atom/movable/teleatom //atom to teleport
@@ -11,32 +14,34 @@
var/soundin //soundfile to play before teleportation
var/soundout //soundfile to play after teleportation
var/force_teleport = 1 //if false, teleport will use Move() proc (dense objects will prevent teleportation)
var/stable_creation = TRUE //This is mostly for portals, which need to delete if the do_teleport fails, due to inhibitors or other reasons we fail to initTeleport properly
/datum/teleport/New(ateleatom, adestination, aprecision=0, afteleport=1, aeffectin=null, aeffectout=null, asoundin=null, asoundout=null)
..()
if(!initTeleport(arglist(args)))
return 0
return 1
stable_creation = FALSE
return FALSE
return TRUE
/datum/teleport/proc/initTeleport(ateleatom,adestination,aprecision,afteleport,aeffectin,aeffectout,asoundin,asoundout)
if(!setTeleatom(ateleatom))
return 0
return FALSE
if(!setDestination(adestination))
return 0
return FALSE
if(!setPrecision(aprecision))
return 0
return FALSE
setEffects(aeffectin,aeffectout)
setForceTeleport(afteleport)
setSounds(asoundin,asoundout)
return 1
return TRUE
//must succeed
/datum/teleport/proc/setPrecision(aprecision)
if(isnum(aprecision))
precision = aprecision
return 1
return 0
return TRUE
return FALSE
/datum/teleport/proc/checkInhibitors(atom/adestination)
if(istype(adestination))
@@ -52,35 +57,43 @@
good_turfs += circlerangeturfs(get_turf(AB),9)
if(length(good_turfs) && length(bad_turfs))
good_turfs -= bad_turfs
return pick(good_turfs)
if(length(good_turfs))
return pick(good_turfs)
return adestination
//Check if we're in range of a bluespace inhibitor. We can't be teleported if we are.
/datum/teleport/proc/checkLocalInhibitors(atom/movable/teleportee)
for(var/obj/machinery/anti_bluespace/AB in range(8, teleportee))
if(AB.stat & (NOPOWER | BROKEN))
continue
else
AB.use_power(AB.active_power_usage)
return null
return teleportee
//must succeed
/datum/teleport/proc/setDestination(atom/adestination)
if(istype(adestination))
destination = checkInhibitors(adestination)
return 1
return 0
return TRUE
return FALSE
//must succeed in most cases
/datum/teleport/proc/setTeleatom(atom/movable/ateleatom)
if(!istype(ateleatom))
return 0
return FALSE
teleatom = checkInhibitors(ateleatom)
if(isturf(teleatom))
var/turf/T = teleatom
var/atom/valid_atoms = list()
for(var/atom/movable in T)
valid_atoms += T
ateleatom = pick(valid_atoms)
teleatom = checkLocalInhibitors(ateleatom)
if(isnull(teleatom))
return FALSE
if(istype(ateleatom, /obj/effect) && !istype(ateleatom, /obj/effect/dummy/chameleon))
qdel(ateleatom)
return 0
return FALSE
return 1
return TRUE
//custom effects must be properly set up first for instant-type teleports
@@ -88,22 +101,22 @@
/datum/teleport/proc/setEffects(datum/effect/effect/system/aeffectin=null,datum/effect/effect/system/aeffectout=null)
effectin = istype(aeffectin) ? aeffectin : null
effectout = istype(aeffectout) ? aeffectout : null
return 1
return TRUE
//optional
/datum/teleport/proc/setForceTeleport(afteleport)
force_teleport = afteleport
return 1
return TRUE
//optional
/datum/teleport/proc/setSounds(asoundin=null,asoundout=null)
soundin = isfile(asoundin) ? asoundin : null
soundout = isfile(asoundout) ? asoundout : null
return 1
return TRUE
//placeholder
/datum/teleport/proc/teleportChecks()
return 1
return TRUE
/datum/teleport/proc/playSpecials(atom/location,datum/effect_system/effect,sound)
if(location)
@@ -131,7 +144,7 @@
destturf = get_turf(destination)
if(!destturf || !curturf)
return 0
return FALSE
playSpecials(curturf,effectin,soundin)
@@ -259,12 +272,12 @@
destarea.Entered(teleatom)
return 1
return TRUE
/datum/teleport/proc/teleport()
if(teleportChecks())
return doTeleport()
return 0
return FALSE
/datum/teleport/instant //teleports when datum is created
@@ -279,7 +292,7 @@
var/datum/effect_system/sparks/aeffect = new(null, FALSE, 5, alldirs)
effectin = effectin || aeffect
effectout = effectout || aeffect
return 1
return TRUE
else
return ..()
@@ -294,16 +307,16 @@
if(istype(teleatom, /mob/living))
var/mob/living/MM = teleatom
to_chat(MM, "<span class='danger'>The Bluespace interface on your [teleatom] interferes with the teleport!</span>")
return 1
return TRUE
/datum/teleport/instant/science/teleportChecks()
if(istype(teleatom, /obj/item/disk/nuclear)) // Don't let nuke disks get teleported --NeoFite
teleatom.visible_message("<span class='danger'>\The [teleatom] bounces off of the portal!</span>")
return 0
return FALSE
if(isobserver(teleatom)) // do not teleport ghosts
return 0
return FALSE
if(!isemptylist(teleatom.search_contents_for(/obj/item/disk/nuclear)))
@@ -312,14 +325,14 @@
MM.visible_message("<span class='danger'>\The [MM] bounces off of the portal!</span>","<span class='warning'>Something you are carrying seems to be unable to pass through the portal. Better drop it if you want to go through.</span>")
else
teleatom.visible_message("<span class='danger'>\The [teleatom] bounces off of the portal!</span>")
return 0
return FALSE
if(isAdminLevel(destination.z)) //centcomm z-level
if(!isemptylist(teleatom.search_contents_for(/obj/item/storage/backpack/holding)))
teleatom.visible_message("<span class='danger'>\The [teleatom] bounces off of the portal!</span>")
return 0
return FALSE
if(destination.z > max_default_z_level()) //Away mission z-levels
return 0
return 1
return FALSE
return TRUE