From 318aa3a268b0a23b7d82146baa94d54894fe8bc9 Mon Sep 17 00:00:00 2001 From: NovaBot <154629622+NovaBot13@users.noreply.github.com> Date: Thu, 4 Jul 2024 02:45:47 -0400 Subject: [PATCH 1/2] [MIRROR] Improve bedsheet interactions [MDB IGNORE] (#3515) * Improve bedsheet interactions (#84505) ## About The Pull Request This pr simply adds drop/pickup sounds to bedsheets, replaces its `attackby(...)` and `attack_secondary(...)` with `item_interaction(...)` and `interact_with_atom_secondary(...)`, and makes tucking in match the bedsheet `pixel_z` with that of the living we're tucking in. It also removes a check that's no longer needed to allow for telekinetically tucking someone in. First bit of note, we use `item_interaction(...)` instead of `wirecutters_act(...)`/`tool_act(...)` as I think tearing up the bedsheets should be the interaction in combat mode too, and everything under `tool_act(...)` only gets called with combat mode being off. Second bit of note, we remove the `!user.CanReach(target)` check from tucking people in, as I believe that's no longer necessary here. This allows us to tuck people in telekinetically, given the bedsheets are adjacent to the one we're tucking in. Finally, we match the bedsheets' `pixel_z` with that of the living we're tucking in by setting it directly, and also reset it directly when we smooth the sheets. I know the elevation element exists, but I believe that only cares about living instances, and besides that really we only want this to be set when tucking someone in rather than always. Most importantly, it works. ## Why It's Good For The Game Using the new item interaction code is better than `attackby(...)` and such. Cloth sounds are nicer than no sounds, and make sense given they're, well, cloth. Tucking someone in with telekinesis is funny. Previously, bedsheets would not offset their `pixel_z` to match that of the living they're tucking in, meaning if you were to say rest upon a table the bedsheets would always be awkwardly offset. This fixes that. ## Changelog :cl: code: Moved bedsheet interactions to the item interaction code. Please report any issues. fix: Bedsheets adjust their offset to match that of the living they're tucking in. sound: Bedsheets use the cloth drop/pickup sounds instead of being silent. qol: You can tuck someone in telekinetically. /:cl: --------- Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> * Improve bedsheet interactions --------- Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> Co-authored-by: NovaBot13 --- code/game/objects/structures/bedsheet_bin.dm | 61 ++++++++++++-------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/code/game/objects/structures/bedsheet_bin.dm b/code/game/objects/structures/bedsheet_bin.dm index 32ed0d14d87..7980e85afbc 100644 --- a/code/game/objects/structures/bedsheet_bin.dm +++ b/code/game/objects/structures/bedsheet_bin.dm @@ -12,6 +12,8 @@ LINEN BINS righthand_file = 'icons/mob/inhands/items/bedsheet_righthand.dmi' icon_state = "sheetwhite" inhand_icon_state = "sheetwhite" + drop_sound = 'sound/items/handling/cloth_drop.ogg' + pickup_sound = 'sound/items/handling/cloth_pickup.ogg' slot_flags = ITEM_SLOT_NECK layer = BELOW_MOB_LAYER throwforce = 0 @@ -57,20 +59,38 @@ LINEN BINS return NONE -/obj/item/bedsheet/attack_secondary(mob/living/target, mob/living/user, params) - if(!user.CanReach(target)) - return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN - if(target.body_position != LYING_DOWN) - return ..() +/obj/item/bedsheet/interact_with_atom_secondary(atom/interacting_with, mob/living/user, list/modifiers) + if(!isliving(interacting_with)) + return NONE + var/mob/living/to_cover = interacting_with + if(to_cover.body_position != LYING_DOWN) + return ITEM_INTERACT_BLOCKING if(!user.dropItemToGround(src)) - return ..() + return ITEM_INTERACT_BLOCKING - forceMove(get_turf(target)) + forceMove(get_turf(to_cover)) balloon_alert(user, "covered") - coverup(target) + coverup(to_cover) add_fingerprint(user) - return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN + return ITEM_INTERACT_SUCCESS + +/obj/item/bedsheet/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + // Handle wirecutters here so we still tear it up in combat mode + if(tool.tool_behaviour != TOOL_WIRECUTTER && !tool.get_sharpness()) + return NONE + + // We cannot get free cloth from holograms + if(flags_1 & HOLOGRAM_1) + return ITEM_INTERACT_BLOCKING + + var/obj/item/stack/shreds = new stack_type(get_turf(src), stack_amount) + if(!QDELETED(shreds)) // Stacks merged + transfer_fingerprints_to(shreds) + shreds.add_fingerprint(user) + to_chat(user, span_notice("You tear [src] up.")) + qdel(src) + return ITEM_INTERACT_SUCCESS /obj/item/bedsheet/attack_self(mob/living/user) if(!user.CanReach(src)) //No telekinetic grabbing. @@ -83,10 +103,15 @@ LINEN BINS coverup(user) add_fingerprint(user) +/obj/item/bedsheet/click_alt(mob/living/user) + setDir(REVERSE_DIR(dir)) + return CLICK_ACTION_SUCCESS + /obj/item/bedsheet/proc/coverup(mob/living/sleeper) layer = ABOVE_MOB_LAYER pixel_x = 0 pixel_y = 0 + pixel_z = sleeper.pixel_z // Account for possible mob elevation balloon_alert(sleeper, "covered") var/angle = sleeper.lying_prev dir = angle2dir(angle + 180) // 180 flips it to be the same direction as the mob @@ -107,6 +132,7 @@ LINEN BINS balloon_alert(sleeper, "smoothed sheets") layer = initial(layer) SET_PLANE_IMPLICIT(src, initial(plane)) + pixel_z = 0 signal_sleeper = null // We need to do this in case someone picks up a bedsheet while a mob is covered up @@ -120,24 +146,9 @@ LINEN BINS UnregisterSignal(sleeper, COMSIG_MOVABLE_MOVED) UnregisterSignal(sleeper, COMSIG_LIVING_SET_BODY_POSITION) UnregisterSignal(sleeper, COMSIG_QDELETING) + pixel_z = 0 signal_sleeper = null -/obj/item/bedsheet/attackby(obj/item/I, mob/user, params) - if(I.tool_behaviour == TOOL_WIRECUTTER || I.get_sharpness()) - if (!(flags_1 & HOLOGRAM_1)) - var/obj/item/stack/shreds = new stack_type(get_turf(src), stack_amount) - if(!QDELETED(shreds)) //stacks merged - transfer_fingerprints_to(shreds) - shreds.add_fingerprint(user) - qdel(src) - to_chat(user, span_notice("You tear [src] up.")) - else - return ..() - -/obj/item/bedsheet/click_alt(mob/living/user) - dir = REVERSE_DIR(dir) - return CLICK_ACTION_SUCCESS - /obj/item/bedsheet/blue icon_state = "sheetblue" inhand_icon_state = "sheetblue" From 214d95cf53a27714fff2886b0aedb63fc822a20a Mon Sep 17 00:00:00 2001 From: ArkStation-Bot <55AAh@protonmail.com> Date: Thu, 4 Jul 2024 12:05:39 +0300 Subject: [PATCH 2/2] [MIRROR] Improve bedsheet interactions [MDB IGNORE]