Files
Leland KembleandGitHub 06608081d2 Moves a greater manyer morer things from attackby() to item_interaction() (#96739)
## About The Pull Request

50 files, plus additonal file that was necessary because I slightly
refactored windoor construction. This ended up like three and a half
times larger than most of the other ones, I really wasn't meaning for
that to happen. Maybe its because I more vigorously enforced the empty
line after every return thing. The only way to find out is to read 1700
lines of changes, and I don't feel like doing that again. I pinky
promise it all works, and I've tested every item changed individually.

Changes beyond conversion:
You can't welder down reinforced falsewalls anymore, pretty sure it was
an oversight because they're supposed to be taken down by wirecutters
You can right click to close gun lockers with an empty hand, because
otherwise you can't close the lockers at all if there's a gun in them
Meatspikes no longer runtime on construction due to the old trick of
balloon alert + qdel
Windoor assembly no longer SUCKS DICK!!, it's no longer storing
essentially a boolean in an undocumented number in a string, it no
longer requires a VERB to flip its direction.
on a related note, the creator of the windoor assembly construction
steps has been sent to live on a farm far out in the country

Also, a quick note about how these prs are gonna fuck everything up
until they're all together. There's a lot more places where `attackby()`
is directly called than I would have assumed, and given as those are
being changed to call `item_interaction()` potentially(usually) in a
different pr than the pr in which that atom's `attackby()` is actually
converted, that function's not going to work at all until both are
merged. The good news is that almost every instance this is happening,
it's pure convenience, where the user would have access to both items
anyway and could just manually call the attack chain by clicking them
together. Instances where this is not the case are being skipped over
until they can be packaged together to avoid the issue, but I'm not
bothering to do this on ones where the desync won't make an interaction
actually unusable, because that would require me to turn a 1700 line pr
into a 3500 line pr and I really was aiming for like 500

## Why It's Good For The Game

Ignore the paragraph about how I expect this to create a hostage
situation where the only fix to the bugs I make is to merge my other
prs, and instead think about how cool swing combat would be and how much
you want it

## Changelog
🆑
fix: you now can only use a wirecutter to take down a reinforced
falsewall
fix: meatspikes no longer runtime on construction
fix: you no longer have to use a verb that you can't use to flip windoor
assemblies

qol: you can right click a gun locker to close it

code: 50 files have been moved from attackby() to item_interaction()
/🆑
2026-07-16 15:07:43 +02:00

299 lines
8.8 KiB
Plaintext

/obj/structure/fireaxecabinet
name = "fire axe cabinet"
desc = "There is a small label that reads \"For Emergency use only\" along with details for safe use of the axe. As if."
icon = 'icons/obj/wallmounts.dmi'
icon_state = "fireaxe"
anchored = TRUE
density = FALSE
armor_type = /datum/armor/structure_fireaxecabinet
max_integrity = 150
integrity_failure = 0.33
custom_materials = /obj/item/wallframe/fireaxecabinet::custom_materials
/// Do we need to be unlocked to be opened.
var/locked = TRUE
/// Are we opened, can someone take the held item out.
var/open = FALSE
/// The item we're holding.
var/obj/item/held_item
/// The path of the item we spawn and can hold.
var/item_path = /obj/item/fireaxe
/// Overlay we get when the item is inside us.
var/item_overlay = "axe"
/// Whether we should populate our own contents on Initialize()
var/populate_contents = TRUE
/// The tool behavior necessary to unlock the cabinet
var/unlocking_tool_behavior = TOOL_MULTITOOL
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/fireaxecabinet, 32)
/datum/armor/structure_fireaxecabinet
melee = 50
bullet = 20
energy = 100
bomb = 10
fire = 90
acid = 50
/obj/structure/fireaxecabinet/Initialize(mapload)
. = ..()
if(populate_contents)
held_item = new item_path(src)
update_appearance()
if(mapload)
find_and_mount_on_atom()
/obj/structure/fireaxecabinet/Destroy()
if(held_item)
QDEL_NULL(held_item)
return ..()
/obj/structure/fireaxecabinet/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
if(iscyborg(user) || tool.tool_behaviour == unlocking_tool_behavior)
toggle_lock(user)
return ITEM_INTERACT_SUCCESS
if(istype(tool, /obj/item/stack/sheet/glass) && broken)
var/obj/item/stack/sheet/glass/glass_stack = tool
if(glass_stack.get_amount() < 2)
balloon_alert(user, "need more glass!")
return ITEM_INTERACT_BLOCKING
balloon_alert(user, "repairing")
if(!glass_stack.use_tool(src, user, 2 SECONDS, 2))
return ITEM_INTERACT_BLOCKING
broken = FALSE
repair_damage(max_integrity - get_integrity())
update_appearance()
return ITEM_INTERACT_SUCCESS
if(open || broken)
if(!istype(tool, item_path) || held_item)
if(!broken)
toggle_open() // Unsure why this is desired behaviour
return ITEM_INTERACT_SUCCESS
return ITEM_INTERACT_BLOCKING
if(HAS_TRAIT(tool, TRAIT_WIELDED))
balloon_alert(user, "unwield it!")
return ITEM_INTERACT_BLOCKING
if(!user.transferItemToLoc(tool, src))
return ITEM_INTERACT_BLOCKING
held_item = tool
update_appearance()
return ITEM_INTERACT_SUCCESS
return NONE
/obj/structure/fireaxecabinet/welder_act(mob/living/user, obj/item/tool)
if(user.combat_mode || broken)
return ITEM_INTERACT_SKIP_TO_ATTACK
if(atom_integrity == max_integrity)
balloon_alert(user, "already repaired!")
return ITEM_INTERACT_BLOCKING
if(!tool.tool_start_check(user, amount = 2))
return ITEM_INTERACT_BLOCKING
balloon_alert(user, "repairing...")
if(!tool.use_tool(src, user, 4 SECONDS, volume= 50, amount = 2))
return ITEM_INTERACT_BLOCKING
repair_damage(max_integrity - get_integrity())
update_appearance()
balloon_alert(user, "repaired")
return ITEM_INTERACT_SUCCESS
/obj/structure/fireaxecabinet/Exited(atom/movable/gone, direction)
if(gone == held_item)
held_item = null
update_appearance()
return ..()
/obj/structure/fireaxecabinet/play_attack_sound(damage_amount, damage_type = BRUTE, damage_flag = 0)
switch(damage_type)
if(BRUTE)
if(broken)
playsound(loc, 'sound/effects/hit_on_shattered_glass.ogg', 90, TRUE)
else
playsound(loc, 'sound/effects/glass/glasshit.ogg', 90, TRUE)
if(BURN)
playsound(src.loc, 'sound/items/tools/welder.ogg', 100, TRUE)
/obj/structure/fireaxecabinet/take_damage(damage_amount, damage_type = BRUTE, damage_flag = 0, sound_effect = TRUE, attack_dir)
if(open)
return
. = ..()
if(.)
update_appearance()
/obj/structure/fireaxecabinet/atom_break(damage_flag)
. = ..()
if(!broken)
update_appearance()
broken = TRUE
playsound(src, 'sound/effects/glass/glassbr3.ogg', 100, TRUE)
new /obj/item/shard(loc)
new /obj/item/shard(loc)
/obj/structure/fireaxecabinet/atom_deconstruct(disassembled = TRUE)
if(held_item && loc)
held_item.forceMove(loc)
new /obj/item/wallframe/fireaxecabinet(loc)
/obj/structure/fireaxecabinet/blob_act(obj/structure/blob/B)
if(held_item)
held_item.forceMove(loc)
qdel(src)
/obj/structure/fireaxecabinet/attack_hand(mob/user, list/modifiers)
. = ..()
if(.)
return
if((open || broken) && held_item)
user.put_in_hands(held_item)
add_fingerprint(user)
update_appearance()
return
toggle_open(user)
/obj/structure/fireaxecabinet/attack_hand_secondary(mob/user, list/modifiers)
toggle_open(user)
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
/obj/structure/fireaxecabinet/attack_paw(mob/living/user, list/modifiers)
return attack_hand(user, modifiers)
/obj/structure/fireaxecabinet/attack_ai(mob/user)
toggle_lock(user)
return
/obj/structure/fireaxecabinet/attack_tk(mob/user)
. = COMPONENT_CANCEL_ATTACK_CHAIN
toggle_open(user)
/obj/structure/fireaxecabinet/update_overlays()
. = ..()
if(held_item)
. += item_overlay
var/hp_percent = (atom_integrity/max_integrity) * 100
if(open)
if(broken)
. += "glass4_raised"
return
switch(hp_percent)
if(-INFINITY to 40)
. += "glass3_raised"
if(40 to 60)
. += "glass2_raised"
if(60 to 80)
. += "glass1_raised"
if(80 to INFINITY)
. += "glass_raised"
return
if(broken)
. += "glass4"
else
switch(hp_percent)
if(-INFINITY to 40)
. += "glass3"
if(40 to 60)
. += "glass2"
if(60 to 80)
. += "glass1"
if(80 to INFINITY)
. += "glass"
. += locked ? "locked" : "unlocked"
/obj/structure/fireaxecabinet/proc/toggle_lock(mob/user)
to_chat(user, span_notice("Resetting circuitry..."))
playsound(src, 'sound/machines/locktoggle.ogg', 50, TRUE)
if(do_after(user, 2 SECONDS, target = src))
to_chat(user, span_notice("You [locked ? "disable" : "re-enable"] the locking modules."))
locked = !locked
update_appearance()
/obj/structure/fireaxecabinet/proc/toggle_open(mob/user)
if(locked)
balloon_alert(user, "won't budge!")
return
else
open = !open
playsound(src, 'sound/machines/click.ogg', 30, TRUE)
update_appearance()
return
/obj/structure/fireaxecabinet/empty
populate_contents = FALSE
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/fireaxecabinet/empty, 32)
/obj/item/wallframe/fireaxecabinet
name = "fire axe cabinet"
desc = "Home to a window's greatest nightmare. Apply to wall to use."
icon = 'icons/obj/wallmounts.dmi'
icon_state = "fireaxe"
result_path = /obj/structure/fireaxecabinet/empty
pixel_shift = 32
custom_materials = list(/datum/material/glass = SHEET_MATERIAL_AMOUNT * 5.1, /datum/material/alloy/plasteel = SHEET_MATERIAL_AMOUNT * 5, /datum/material/iron = SMALL_MATERIAL_AMOUNT)
/obj/structure/fireaxecabinet/mechremoval
name = "mech removal tool cabinet"
desc = "There is a small label that reads \"For Emergency use only\" along with details for safe use of the tool. As if."
icon_state = "mechremoval"
item_path = /obj/item/crowbar/mechremoval
item_overlay = "crowbar"
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/fireaxecabinet/mechremoval, 32)
/obj/structure/fireaxecabinet/mechremoval/atom_deconstruct(disassembled = TRUE)
if(held_item && loc)
held_item.forceMove(loc)
new /obj/item/wallframe/fireaxecabinet/mechremoval(loc)
/obj/structure/fireaxecabinet/mechremoval/empty
populate_contents = FALSE
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/fireaxecabinet/mechremoval/empty, 32)
/obj/item/wallframe/fireaxecabinet/mechremoval
name = "mech removal tool cabinet"
desc = "Home to a very special crowbar. Apply to wall to use."
icon_state = "mechremoval"
result_path = /obj/structure/fireaxecabinet/mechremoval/empty
/obj/structure/fireaxecabinet/jawsofrecovery
name = "jaws of recovery tool cabinet"
desc = "There is a small label that reads \"For Emergency use only\" along with details for safe use of the jaws of recovery. \
The lock seems to require...a surgical drill bit to unlock? You have no idea who thought this was a good idea."
icon_state = "jaws_of_recovery"
item_path = /obj/item/crowbar/power/paramedic
item_overlay = "jaws"
unlocking_tool_behavior = TOOL_DRILL
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/fireaxecabinet/jawsofrecovery, 32)
/obj/structure/fireaxecabinet/jawsofrecovery/atom_deconstruct(disassembled = TRUE)
if(held_item && loc)
held_item.forceMove(loc)
new /obj/item/wallframe/fireaxecabinet/jawsofrecovery(loc)
/obj/structure/fireaxecabinet/jawsofrecovery/empty
populate_contents = FALSE
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/fireaxecabinet/jawsofrecovery/empty, 32)
/obj/item/wallframe/fireaxecabinet/jawsofrecovery
name = "jaws of recovery tool cabinet"
desc = "Home to the paramedic's jaws of recovery. Apply to wall to use."
icon_state = "jaws_of_recovery"
result_path = /obj/structure/fireaxecabinet/jawsofrecovery/empty