Files
Bubberstation/code/game/atom/atom_tool_acts.dm
SkyratBot b15b16976a [MIRROR] Attack chain refactoring: Broadening tool_act into item_interact, moving some item interactions to... atom/item_interact / item/interact_with_atom [MDB IGNORE] (#25516)
* Attack chain refactoring: Broadening `tool_act` into `item_interact`, moving some item interactions to... `atom/item_interact` / `item/interact_with_atom`

* Patches up merge skew (#80197)

## About The Pull Request

Yeah #79968 (1e76fd70b4) was not
compatible with master but no one said anything on the PR so i got
jebaited into merging it. The code should be up to the same standards
per the documentation I read (preventing thwacking the target in certain
situations while not returning anything in other situations)

master will definitely compile now though

* Patches up merge skew

* Merge conflicts

* Modular adjustments

* Removes this entirely duplicated proc...

* Update tool_override.dm

* Update weldingtool.dm

* Update tool_override.dm

* Update tool_override.dm

* Nope. Copy paste begone.

A skyrat edit is so much easier to deal with here

* Update brand_intelligence.dm

---------

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Giz <13398309+vinylspiders@users.noreply.github.com>
2023-12-09 08:22:19 -05:00

181 lines
7.3 KiB
Plaintext

/**
* ## Item interaction
*
* Handles non-combat iteractions of a tool on this atom,
* such as using a tool on a wall to deconstruct it,
* or scanning someone with a health analyzer
*
* This can be overridden to add custom item interactions to this atom
*
* Do not call this directly
*/
/atom/proc/item_interaction(mob/living/user, obj/item/tool, list/modifiers, is_right_clicking)
SHOULD_CALL_PARENT(TRUE)
PROTECTED_PROC(TRUE)
var/is_left_clicking = !is_right_clicking
var/early_sig_return = NONE
if(is_left_clicking)
early_sig_return = SEND_SIGNAL(src, COMSIG_ATOM_ITEM_INTERACTION, user, tool, modifiers) \
| SEND_SIGNAL(tool, COMSIG_ITEM_INTERACTING_WITH_ATOM, user, src, modifiers)
else
early_sig_return = SEND_SIGNAL(src, COMSIG_ATOM_ITEM_INTERACTION_SECONDARY, user, tool, modifiers) \
| SEND_SIGNAL(tool, COMSIG_ITEM_INTERACTING_WITH_ATOM_SECONDARY, user, src, modifiers)
if(early_sig_return)
return early_sig_return
var/interact_return = is_left_clicking \
? tool.interact_with_atom(src, user) \
: tool.interact_with_atom_secondary(src, user)
if(interact_return)
return interact_return
var/tool_type = tool.tool_behaviour
if(!tool_type) // here on only deals with ... tools
return NONE
var/list/processing_recipes = list()
var/signal_result = is_left_clicking \
? SEND_SIGNAL(src, COMSIG_ATOM_TOOL_ACT(tool_type), user, tool, processing_recipes) \
: SEND_SIGNAL(src, COMSIG_ATOM_SECONDARY_TOOL_ACT(tool_type), user, tool)
if(signal_result)
return signal_result
if(length(processing_recipes))
process_recipes(user, tool, processing_recipes)
if(QDELETED(tool))
return ITEM_INTERACT_SUCCESS // Safe-ish to assume that if we deleted our item something succeeded
var/act_result = NONE // or FALSE, or null, as some things may return
switch(tool_type)
if(TOOL_CROWBAR)
act_result = is_left_clicking ? crowbar_act(user, tool) : crowbar_act_secondary(user, tool)
if(TOOL_MULTITOOL)
act_result = is_left_clicking ? multitool_act(user, tool) : multitool_act_secondary(user, tool)
if(TOOL_SCREWDRIVER)
act_result = is_left_clicking ? screwdriver_act(user, tool) : screwdriver_act_secondary(user, tool)
if(TOOL_WRENCH)
act_result = is_left_clicking ? wrench_act(user, tool) : wrench_act_secondary(user, tool)
if(TOOL_WIRECUTTER)
act_result = is_left_clicking ? wirecutter_act(user, tool) : wirecutter_act_secondary(user, tool)
if(TOOL_WELDER)
act_result = is_left_clicking ? welder_act(user, tool) : welder_act_secondary(user, tool)
if(TOOL_ANALYZER)
act_result = is_left_clicking ? analyzer_act(user, tool) : analyzer_act_secondary(user, tool)
// SKYRAT EDIT ADDITION START - SKYRAT TOOLS
if(TOOL_BILLOW)
act_result = is_left_clicking ? billow_act(user, tool) : billow_act_secondary(user, tool)
if(TOOL_TONG)
act_result = is_left_clicking ? tong_act(user, tool) : tong_act_secondary(user, tool)
if(TOOL_HAMMER)
act_result = is_left_clicking ? hammer_act(user, tool) : hammer_act_secondary(user, tool)
if(TOOL_BLOWROD)
act_result = is_left_clicking ? blowrod_act(user, tool) : blowrod_act_secondary(user, tool)
// SKYRAT EDIT ADDITION END
if(!act_result)
return NONE
// A tooltype_act has completed successfully
if(is_left_clicking)
log_tool("[key_name(user)] used [tool] on [src] at [AREACOORD(src)]")
SEND_SIGNAL(tool, COMSIG_TOOL_ATOM_ACTED_PRIMARY(tool_type), src)
else
log_tool("[key_name(user)] used [tool] on [src] (right click) at [AREACOORD(src)]")
SEND_SIGNAL(tool, COMSIG_TOOL_ATOM_ACTED_SECONDARY(tool_type), src)
return act_result
/**
* Called when this item is being used to interact with an atom,
* IE, a mob is clicking on an atom with this item.
*
* Return an ITEM_INTERACT_ flag in the event the interaction was handled, to cancel further interaction code.
* Return NONE to allow default interaction / tool handling.
*/
/obj/item/proc/interact_with_atom(atom/interacting_with, mob/living/user)
return NONE
/**
* Called when this item is being used to interact with an atom WITH RIGHT CLICK,
* IE, a mob is right clicking on an atom with this item.
*
* Default behavior has it run the same code as left click.
*
* Return an ITEM_INTERACT_ flag in the event the interaction was handled, to cancel further interaction code.
* Return NONE to allow default interaction / tool handling.
*/
/obj/item/proc/interact_with_atom_secondary(atom/interacting_with, mob/living/user)
return interact_with_atom(interacting_with, user)
/*
* Tool-specific behavior procs.
*
* Return an ITEM_INTERACT_ flag to handle the event, or NONE to allow the mob to attack the atom.
* Returning TRUE will also cancel attacks. It is equivalent to an ITEM_INTERACT_ flag. (This is legacy behavior, and is not to be relied on)
* Returning FALSE or null will also allow the mob to attack the atom. (This is also legacy behavior)
*/
/// Called on an object when a tool with crowbar capabilities is used to left click an object
/atom/proc/crowbar_act(mob/living/user, obj/item/tool)
return
/// Called on an object when a tool with crowbar capabilities is used to right click an object
/atom/proc/crowbar_act_secondary(mob/living/user, obj/item/tool)
return
/// Called on an object when a tool with multitool capabilities is used to left click an object
/atom/proc/multitool_act(mob/living/user, obj/item/tool)
return
/// Called on an object when a tool with multitool capabilities is used to right click an object
/atom/proc/multitool_act_secondary(mob/living/user, obj/item/tool)
return
///Check if an item supports a data buffer (is a multitool)
/atom/proc/multitool_check_buffer(user, obj/item/multitool, silent = FALSE)
if(!istype(multitool, /obj/item/multitool))
if(user && !silent)
to_chat(user, span_warning("[multitool] has no data buffer!"))
return FALSE
return TRUE
/// Called on an object when a tool with screwdriver capabilities is used to left click an object
/atom/proc/screwdriver_act(mob/living/user, obj/item/tool)
return
/// Called on an object when a tool with screwdriver capabilities is used to right click an object
/atom/proc/screwdriver_act_secondary(mob/living/user, obj/item/tool)
return
/// Called on an object when a tool with wrench capabilities is used to left click an object
/atom/proc/wrench_act(mob/living/user, obj/item/tool)
return
/// Called on an object when a tool with wrench capabilities is used to right click an object
/atom/proc/wrench_act_secondary(mob/living/user, obj/item/tool)
return
/// Called on an object when a tool with wirecutter capabilities is used to left click an object
/atom/proc/wirecutter_act(mob/living/user, obj/item/tool)
return
/// Called on an object when a tool with wirecutter capabilities is used to right click an object
/atom/proc/wirecutter_act_secondary(mob/living/user, obj/item/tool)
return
/// Called on an object when a tool with welder capabilities is used to left click an object
/atom/proc/welder_act(mob/living/user, obj/item/tool)
return
/// Called on an object when a tool with welder capabilities is used to right click an object
/atom/proc/welder_act_secondary(mob/living/user, obj/item/tool)
return
/// Called on an object when a tool with analyzer capabilities is used to left click an object
/atom/proc/analyzer_act(mob/living/user, obj/item/tool)
return
/// Called on an object when a tool with analyzer capabilities is used to right click an object
/atom/proc/analyzer_act_secondary(mob/living/user, obj/item/tool)
return