Screwdrivers can now be recycled in autolathes (#21629)

* screwdriver can be put into autolathe

* Redundant and misspelt  comment

* minutia

Co-authored-by: JimKil3 <47290811+JimKil3@users.noreply.github.com>

* add COMSIG_TOOL_ATTACK

* tools can be inserted on harm intent

* use signal to allow screwdriver to be inserted into the autolathe

* accidental spaces

* parenthesis for clarity

* snake_case 1

Co-authored-by: JimKil3 <47290811+JimKil3@users.noreply.github.com>

* snake_case 2

Co-authored-by: JimKil3 <47290811+JimKil3@users.noreply.github.com>

* dont direct istype check the screwdriver

* . defaults to null

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>

* add SIGNAL_HANDLER to the proc that handles a signal

---------

Co-authored-by: JimKil3 <47290811+JimKil3@users.noreply.github.com>
Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
This commit is contained in:
Fridge Burns
2023-08-12 12:21:17 -05:00
committed by GitHub
parent 4748736c9e
commit 2f711fb321
4 changed files with 20 additions and 1 deletions
+3
View File
@@ -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]:
+3
View File
@@ -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.
+3 -1
View File
@@ -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
+11
View File
@@ -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))