Attack chain refactoring: Broadening tool_act into item_interact, moving some item interactions to... atom/item_interact / item/interact_with_atom (#79968)

## About The Pull Request

Implements half of this (with some minor changes): 


![image](https://github.com/tgstation/tgstation/assets/51863163/bf5cc4bb-5a1f-42e3-921d-9a57bc6096cc)

The ultimate goal of this is to split our attack chain in two: 
- One for non-combat item interactions
  - Health analyzer scanning
  - using tools on stuff
  - surgery
  - Niche other interactions
- One for combat attacking
  - Item hit thing, item deal damage. 
  - Special effects on attack would go here.  

This PR begins this by broadining tool act into item interact. 

Item interact is a catch-all proc ran at the beginning of attack chain,
before `pre_attack` and such, that handles the first part of the chain.

This allows us to easily catch item interaction and cancel the attack
part of the chain by using deliberate bitflag return values, rather than
`TRUE` / `FALSE`*.

*Because right now, `TRUE` = `cancel attack`, no matter what, which is
unclear to people.

Instead of moving as much as possible to the new proc in this PR, I
started by doing some easy, obvious things. More things can be moved in
the future, or technically they don't even need to move in a lot of
cases.

## Changelog

🆑 Melbert
refactor: Refactored some methods of items interacting with other
objects or mobs, such as surgery and health analzyers. Report if
anything seems wrong
/🆑
This commit is contained in:
MrMelbert
2023-12-08 23:50:19 -07:00
committed by GitHub
parent 65a30878cb
commit 1e76fd70b4
153 changed files with 710 additions and 609 deletions
+9 -9
View File
@@ -190,16 +190,16 @@
return
return ..()
/obj/structure/window/tool_act(mob/living/user, obj/item/tool, tool_type, is_right_clicking)
/obj/structure/window/item_interaction(mob/living/user, obj/item/tool, list/modifiers, is_right_clicking)
if(!can_be_reached(user))
return TRUE //skip the afterattack
return ITEM_INTERACT_SKIP_TO_ATTACK // Guess you get to hit it
add_fingerprint(user)
return ..()
/obj/structure/window/welder_act(mob/living/user, obj/item/tool)
if(atom_integrity >= max_integrity)
to_chat(user, span_warning("[src] is already in good condition!"))
return TOOL_ACT_TOOLTYPE_SUCCESS
return ITEM_INTERACT_SUCCESS
if(!tool.tool_start_check(user, amount = 0))
return FALSE
to_chat(user, span_notice("You begin repairing [src]..."))
@@ -207,7 +207,7 @@
atom_integrity = max_integrity
update_nearby_icons()
to_chat(user, span_notice("You repair [src]."))
return TOOL_ACT_TOOLTYPE_SUCCESS
return ITEM_INTERACT_SUCCESS
/obj/structure/window/screwdriver_act(mob/living/user, obj/item/tool)
if(obj_flags & NO_DECONSTRUCTION)
@@ -235,7 +235,7 @@
if(tool.use_tool(src, user, decon_speed, volume = 75, extra_checks = CALLBACK(src, PROC_REF(check_state_and_anchored), state, anchored)))
set_anchored(TRUE)
to_chat(user, span_notice("You fasten the frame to the floor."))
return TOOL_ACT_TOOLTYPE_SUCCESS
return ITEM_INTERACT_SUCCESS
/obj/structure/window/wrench_act(mob/living/user, obj/item/tool)
if(anchored)
@@ -245,14 +245,14 @@
to_chat(user, span_notice("You begin to disassemble [src]..."))
if(!tool.use_tool(src, user, decon_speed, volume = 75, extra_checks = CALLBACK(src, PROC_REF(check_state_and_anchored), state, anchored)))
return TOOL_ACT_TOOLTYPE_SUCCESS
return ITEM_INTERACT_SUCCESS
var/obj/item/stack/sheet/G = new glass_type(user.loc, glass_amount)
if (!QDELETED(G))
G.add_fingerprint(user)
playsound(src, 'sound/items/deconstruct.ogg', 50, TRUE)
to_chat(user, span_notice("You successfully disassemble [src]."))
qdel(src)
return TOOL_ACT_TOOLTYPE_SUCCESS
return ITEM_INTERACT_SUCCESS
/obj/structure/window/crowbar_act(mob/living/user, obj/item/tool)
if(!anchored || (obj_flags & NO_DECONSTRUCTION))
@@ -272,7 +272,7 @@
else
return FALSE
return TOOL_ACT_TOOLTYPE_SUCCESS
return ITEM_INTERACT_SUCCESS
/obj/structure/window/attackby(obj/item/I, mob/living/user, params)
if(!can_be_reached(user))
@@ -552,7 +552,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/window/unanchored/spawner, 0)
if(tool.use_tool(src, user, 10 SECONDS, volume = 75, extra_checks = CALLBACK(src, PROC_REF(check_state_and_anchored), state, anchored)))
state = RWINDOW_SECURE
to_chat(user, span_notice("You pry the window back into the frame."))
return TOOL_ACT_TOOLTYPE_SUCCESS
return ITEM_INTERACT_SUCCESS
/obj/structure/window/proc/cool_bolts()
if(state == RWINDOW_BOLTS_HEATED)