From fb15d92d5727915afb1f57b0736fde2ffe9dfad7 Mon Sep 17 00:00:00 2001 From: Citinited Date: Mon, 26 Nov 2018 00:19:49 +0000 Subject: [PATCH] Fixes issue with duct tape bypassing walls --- code/datums/components/ducttape.dm | 27 +++++++++++++++++++++------ code/game/objects/items.dm | 3 ++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/code/datums/components/ducttape.dm b/code/datums/components/ducttape.dm index c69e90efaf7..71e2be992ab 100644 --- a/code/datums/components/ducttape.dm +++ b/code/datums/components/ducttape.dm @@ -11,6 +11,7 @@ RegisterSignal(parent, COMSIG_PARENT_EXAMINE, .proc/add_tape_text) RegisterSignal(parent, COMSIG_OBJ_UPDATE_ICON, .proc/add_tape_overlay) RegisterSignal(parent, COMSIG_ITEM_AFTERATTACK, .proc/afterattack) + RegisterSignal(parent, COMSIG_ITEM_PICKUP, .proc/pick_up) I.update_icon() //Do this first so the action button preoperly shows the icon var/datum/action/item_action/remove_tape/RT = new(I) if(I.loc == user) @@ -38,18 +39,32 @@ user.transfer_fingerprints_to(I) Destroy() -/datum/component/ducttape/proc/afterattack(datum/source, atom/target, mob/user, proximity, params) +/datum/component/ducttape/proc/afterattack(obj/item/I, atom/target, mob/user, proximity, params) if(!proximity) return if(!isturf(target)) return + if(!user.unEquip(I)) + return + var/turf/source_turf = get_turf(I) + var/turf/target_turf = target var/list/clickparams = params2list(params) var/x_offset = text2num(clickparams["icon-x"]) - 16 var/y_offset = text2num(clickparams["icon-y"]) - 16 - var/turf/T = target - var/obj/item/I = source - to_chat(user, "You stick [I] to [T].") - user.unEquip(I) - I.forceMove(T) + if(target_turf != get_turf(I)) //Trying to stick it on a wall, don't move it to the actual wall or you can move the item through it. Instead set the pixels as appropriate + var/target_direction = get_dir(source_turf, target_turf)//The direction we clicked + if(target_direction & EAST) + x_offset += 32 + else if(target_direction & WEST) + x_offset -= 32 + if(target_direction & NORTH) + y_offset += 32 + else if(target_direction & SOUTH) + y_offset -= 32 + to_chat(user, "You stick [I] to [target_turf].") I.pixel_x = x_offset I.pixel_y = y_offset + +/datum/component/ducttape/proc/pick_up(obj/item/I, mob/user) + I.pixel_x = initial(I.pixel_x) + I.pixel_y = initial(I.pixel_y) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 40b3ff692be..dda149b88e2 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -255,6 +255,7 @@ var/global/image/fire_overlay = image("icon" = 'icons/goonstation/effects/fire.d return 0 pickup(user) + add_fingerprint(user) user.put_in_active_hand(src) return 1 @@ -332,7 +333,7 @@ var/global/image/fire_overlay = image("icon" = 'icons/goonstation/effects/fire.d // called just as an item is picked up (loc is not yet changed) /obj/item/proc/pickup(mob/user) - return + SEND_SIGNAL(src, COMSIG_ITEM_PICKUP, user) // called when this item is removed from a storage item, which is passed on as S. The loc variable is already set to the new destination before this is called. /obj/item/proc/on_exit_storage(obj/item/storage/S as obj)