From e50df3c08438d85643b03b407cbe00a067a5ac07 Mon Sep 17 00:00:00 2001 From: Toastical <20125180+Toastical@users.noreply.github.com> Date: Thu, 24 Jul 2025 17:31:05 +0300 Subject: [PATCH] Migrate Rapid Cable Layer to new attack chain and fix inhands not getting updated (#29840) * migrated rcl to new attack chain * improved messages --- code/game/objects/items/weapons/RCL.dm | 67 +++++++++++++++----------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/code/game/objects/items/weapons/RCL.dm b/code/game/objects/items/weapons/RCL.dm index d97ec8f6cea..b509cba8bee 100644 --- a/code/game/objects/items/weapons/RCL.dm +++ b/code/game/objects/items/weapons/RCL.dm @@ -15,39 +15,46 @@ var/active = FALSE var/obj/structure/cable/last = null var/obj/item/stack/cable_coil/loaded = null + new_attack_chain = TRUE /obj/item/rcl/Initialize(mapload) . = ..() AddComponent(/datum/component/two_handed) -/obj/item/rcl/attackby__legacy__attackchain(obj/item/W, mob/user) - if(istype(W, /obj/item/stack/cable_coil)) - var/obj/item/stack/cable_coil/C = W - if(!loaded) - if(user.drop_item()) - loaded = W - loaded.forceMove(src) - loaded.max_amount = max_amount //We store a lot. - else - to_chat(user, "[user.get_active_hand()] is stuck to your hand!") - return - else - if(loaded.amount < max_amount) - var/amount = min(loaded.amount + C.get_amount(), max_amount) - C.use(amount - loaded.amount) - loaded.amount = amount - else - return - update_icon(UPDATE_ICON_STATE) - to_chat(user, "You add the cables to [src]. It now contains [loaded.amount].") +/obj/item/rcl/item_interaction(mob/living/user, obj/item/used, list/modifiers) + if(!istype(used, /obj/item/stack/cable_coil)) + return ..() + + var/obj/item/stack/cable_coil/coil = used + if(!loaded) + if(!user.transfer_item_to(coil, src)) + to_chat(user, "[coil] is stuck to your hand!") + return ITEM_INTERACT_COMPLETE + loaded = coil + loaded.max_amount = max_amount //We store a lot. else - ..() + if(loaded.amount >= max_amount) + to_chat(user, "You cannot fit any more cable on [src]!") + return ITEM_INTERACT_COMPLETE + + var/amount = min(loaded.amount + coil.get_amount(), max_amount) + coil.use(amount - loaded.amount) + loaded.amount = amount + refresh_icon(user) + to_chat(user, "You add the cables to [src]. It now contains [loaded.amount].") + return ITEM_INTERACT_COMPLETE + +/obj/item/rcl/proc/refresh_icon(mob/user) + update_icon(UPDATE_ICON_STATE) + user.update_inv_l_hand() + user.update_inv_r_hand() /obj/item/rcl/screwdriver_act(mob/user, obj/item/I) if(!loaded) + to_chat(user, "There's no cable to remove!") return . = TRUE - if(!I.use_tool(src, user, 0, volume = I.tool_volume)) + if(!I.use_tool(src, user, FALSE, volume = I.tool_volume)) return to_chat(user, "You loosen the securing screws on the side, allowing you to lower the guiding edge and retrieve the wires.") while(loaded.amount > 30) //There are only two kinds of situations: "nodiff" (60,90), or "diff" (31-59, 61-89) @@ -62,12 +69,14 @@ loaded.forceMove(user.loc) user.put_in_hands(loaded) loaded = null - update_icon(UPDATE_ICON_STATE) + refresh_icon(user) /obj/item/rcl/examine(mob/user) . = ..() if(loaded) . += "It contains [loaded.amount]/[max_amount] cables." + else + . += "It's empty!" /obj/item/rcl/Destroy() QDEL_NULL(loaded) @@ -95,10 +104,10 @@ item_state = "rcl-0" /obj/item/rcl/proc/is_empty(mob/user, loud = 1) - update_icon(UPDATE_ICON_STATE) + refresh_icon(user) if(!loaded || !loaded.amount) if(loud) - to_chat(user, "The last of the cables unreel from [src].") + to_chat(user, "The last of the cables unreel from [src]!") if(loaded) qdel(loaded) loaded = null @@ -110,8 +119,10 @@ active = FALSE last = null -/obj/item/rcl/attack_self__legacy__attackchain(mob/user) - ..() +/obj/item/rcl/activate_self(mob/user) + if(..()) + return FINISH_ATTACK + active = HAS_TRAIT(src, TRAIT_WIELDED) if(!active) last = null @@ -127,7 +138,7 @@ /obj/item/rcl/proc/trigger(mob/user) if(is_empty(user, 0)) - to_chat(user, "\The [src] is empty!") + to_chat(user, "[src] is empty!") return if(last) if(get_dist(last, user) == 1) //hacky, but it works