From fcef7ada8f6c7a2591397a9c9ea5d3326f0ec029 Mon Sep 17 00:00:00 2001 From: Xufysz <8283338+Xufysz@users.noreply.github.com> Date: Mon, 28 Aug 2023 21:31:41 +0100 Subject: [PATCH] 3291 - Fixes the ability to manipulate a dummy from a distance using the tablet (#4268) # About the pull request Closes #3291 This code fixes an issue where you can manipulate a dummy at a distance. # Explain why it's good for the game N/A, an issue was raised for it. # Testing Photographs and Procedure https://github.com/cmss13-devs/cmss13/assets/8283338/40e61fb6-c833-4faa-a0fe-e2423ba7870e # Changelog :cl: fix: Fixes admin training dummy interaction distance /:cl: --- .../objects/items/devices/dummy_tablet.dm | 24 ++++++++++++++++++- .../living/carbon/human/human_attackhand.dm | 2 +- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/code/game/objects/items/devices/dummy_tablet.dm b/code/game/objects/items/devices/dummy_tablet.dm index 92cfa4b90e26..d1036ebfa93b 100644 --- a/code/game/objects/items/devices/dummy_tablet.dm +++ b/code/game/objects/items/devices/dummy_tablet.dm @@ -12,6 +12,20 @@ linked_dummy = null . = ..() +/** + * Checks if the user is adjacent to the dummy + * + * Returns TRUE if the user is adjacent to the dummy, FALSE otherwise + * + * * arg-1: The user + */ +/obj/item/device/professor_dummy_tablet/proc/is_adjacent_to_dummy(mob/user) + if (get_dist(linked_dummy, user) > 1) + to_chat(user, "You are too far away to use the tablet.") + return FALSE + + return TRUE + /obj/item/device/professor_dummy_tablet/proc/link_mob(mob/living/carbon/human/H) linked_dummy = H @@ -20,6 +34,12 @@ interact(user) /obj/item/device/professor_dummy_tablet/interact(mob/user as mob) + if (isnull(linked_dummy)) + return + + if (!is_adjacent_to_dummy(user)) + return + user.set_interaction(src) var/dat = "