From 228cf39cc8d2bc189335808012d44f0f3c67b4d1 Mon Sep 17 00:00:00 2001 From: san7890 Date: Mon, 21 Nov 2022 00:20:26 -0700 Subject: [PATCH] Adds a subtype of bump teleporters that use Do_Teleport (#71248) ## About The Pull Request By adding this functionality in as a subtype, you'll be able to ensure stuff like dangerous creatures that you don't want teleported out of an away msision by adding the NO_TELEPORT trait to the mob in question (which do_teleport checks for). I also cleaned up the code while I was in there, including DMdoccing, some proc shuffling to accomodate the subtype, etc. ## Why It's Good For The Game It's a teleporter, and I think that there are valid usecases where we should do the full checks for teleportation rather than do a forceMove. ## Changelog Nothing that really affects players as far as the absolute base codebase is concerned. --- code/game/objects/effects/bump_teleporter.dm | 57 +++++++++++++++----- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/code/game/objects/effects/bump_teleporter.dm b/code/game/objects/effects/bump_teleporter.dm index d8e35280730..04dd7e4809a 100644 --- a/code/game/objects/effects/bump_teleporter.dm +++ b/code/game/objects/effects/bump_teleporter.dm @@ -1,14 +1,18 @@ +/// Abstract effect, that when a mob touches it, it will forceMove them to the teleporter-exit point (that matches the ID set map-side). /obj/effect/bump_teleporter - name = "bump-teleporter" + name = "bump teleporter (forceMove)" + desc = "Use me when you want to move every single mob without any exceptions." icon = 'icons/hud/screen_gen.dmi' icon_state = "x2" - var/id = null //id of this bump_teleporter. - var/id_target = null //id of bump_teleporter which this moves you to. invisibility = INVISIBILITY_ABSTRACT //nope, can't see this anchored = TRUE density = TRUE opacity = FALSE - + /// id of this bump_teleporter. + var/id = null + /// id of bump_teleporter which this moves you to. + var/id_target = null + /// List of all teleporters in the world. var/static/list/AllTeleporters /obj/effect/bump_teleporter/Initialize(mapload) @@ -19,19 +23,48 @@ LAZYREMOVE(AllTeleporters, src) return ..() - /obj/effect/bump_teleporter/singularity_act() return /obj/effect/bump_teleporter/singularity_pull() return -/obj/effect/bump_teleporter/Bumped(atom/movable/AM) - if(!ismob(AM)) - return - if(!id_target) +/obj/effect/bump_teleporter/Bumped(atom/movable/bumper) + if(!validate_setup(bumper)) return - for(var/obj/effect/bump_teleporter/BT in AllTeleporters) - if(BT.id == src.id_target) - AM.forceMove(BT.loc) //Teleport to location with correct id. + for(var/obj/effect/bump_teleporter/teleporter in AllTeleporters) + if(teleporter.id == id_target) + teleport_action(bumper, get_turf(teleporter)) //Teleport to location with correct id. + return + + stack_trace("Bump_teleporter [src] could not find a teleporter with id [id_target]!") + +/// Check to see if our teleporter was set up correctly mapside. Return TRUE if everything is fine, FALSE if not. +/obj/effect/bump_teleporter/proc/validate_setup(atom/movable/checkable) + var/message = "" + + if(!ismob(checkable)) + return FALSE + + if(!id_target) + message = "Bump teleporter [src] at [AREACOORD(src)] has no id_target set." + stack_trace(message) + log_mapping(message) + return FALSE + + return TRUE + +/// Actually move our target atom from one position to another. Return TRUE if everything is fine. Override this proc on subtypes for specific teleportation methods. +/obj/effect/bump_teleporter/proc/teleport_action(atom/movable/target, turf/destination) + target.forceMove(destination) + +/// Subtype that uses do_teleport instead, to leverage any NO_TELEPORT traits that you might need to add in a given map +/obj/effect/bump_teleporter/filtering + name = "bump teleporter (do_teleport)" + desc = "Use me for when you want to avoid moving mobs with certain traits, like NO_TELEPORT." + icon_state = "x4" + +/// As promised in the name of this subtype, use do_teleport to leverage all of the filtering checks that it does. +/obj/effect/bump_teleporter/filtering/teleport_action(atom/movable/target, turf/destination) + do_teleport(target, destination, channel = TELEPORT_CHANNEL_QUANTUM)