diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm index 82e32759e41..76b3f6c2601 100644 --- a/code/__DEFINES/dcs/signals.dm +++ b/code/__DEFINES/dcs/signals.dm @@ -564,6 +564,9 @@ #define COMSIG_TOOL_IN_USE "tool_in_use" ///from base of [/obj/item/proc/tool_start_check]: (mob/living/user) #define COMSIG_TOOL_START_USE "tool_start_use" +///from base of [/obj/item/proc/tool_attack_chain]: (atom/tool, mob/user) +#define COMSIG_TOOL_ATTACK "tool_attack" + #define COMPONENT_CANCEL_TOOLACT (1<<0) ///from [/obj/item/proc/disableEmbedding]: #define COMSIG_ITEM_DISABLE_EMBED "item_disable_embed" ///from [/obj/effect/mine/proc/triggermine]: diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index 43c69084ec0..c62e0d41790 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -10,6 +10,9 @@ /obj/item/proc/tool_attack_chain(mob/user, atom/target) if(!tool_behaviour) return FALSE + if(SEND_SIGNAL(target, COMSIG_TOOL_ATTACK, src, user) & COMPONENT_CANCEL_TOOLACT) + return FALSE + return target.tool_act(user, src, tool_behaviour) // Called when the item is in the active hand, and clicked; alternately, there is an 'activate held object' verb or you can hit pagedown. diff --git a/code/datums/components/material_container.dm b/code/datums/components/material_container.dm index 70ee460d5e0..82df42a0a82 100644 --- a/code/datums/components/material_container.dm +++ b/code/datums/components/material_container.dm @@ -65,7 +65,9 @@ var/list/tc = allowed_typecache if(disable_attackby) return - if(user.a_intent != INTENT_HELP) + // Allow tools to be inserted on harm and help intent since they might be used for construction + // otherwise user needs to be on help intent + if(!((I.tool_behaviour && user.a_intent == INTENT_HARM) || user.a_intent == INTENT_HELP)) return if(I.flags & ABSTRACT) return diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm index 1f7256f4b9c..a1025f9ee26 100644 --- a/code/game/machinery/autolathe.dm +++ b/code/game/machinery/autolathe.dm @@ -50,6 +50,8 @@ component_parts += new /obj/item/stack/sheet/glass(null) RefreshParts() + RegisterSignal(src, COMSIG_TOOL_ATTACK, PROC_REF(on_tool_attack)) + wires = new(src) files = new /datum/research/autolathe(src) matching_designs = list() @@ -77,6 +79,15 @@ materials.retrieve_all() return ..() +/obj/machinery/autolathe/proc/on_tool_attack(datum/source, atom/tool, mob/user) + SIGNAL_HANDLER + var/obj/item/I = tool + if(!istype(I)) + return + // Allows screwdrivers to be recycled on harm intent + if(I.tool_behaviour == TOOL_SCREWDRIVER && user.a_intent == INTENT_HARM) + return COMPONENT_CANCEL_TOOLACT + /obj/machinery/autolathe/interact(mob/user) if(shocked && !(stat & NOPOWER)) if(shock(user, 50))