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

150 lines
3.9 KiB
Plaintext

//GUNCASES//
/obj/structure/guncase
name = "gun locker"
desc = "A locker that holds guns."
icon = 'icons/obj/storage/closet.dmi'
icon_state = "shotguncase"
anchored = FALSE
density = TRUE
opacity = FALSE
var/case_type = ""
var/gun_category = /obj/item/gun
var/open = TRUE
var/capacity = 4
/obj/structure/guncase/Initialize(mapload)
. = ..()
if(mapload)
for(var/obj/item/I in loc.contents)
if(istype(I, gun_category))
I.forceMove(src)
if(contents.len >= capacity)
break
update_appearance()
/obj/structure/guncase/update_overlays()
. = ..()
if(case_type && LAZYLEN(contents))
var/mutable_appearance/gun_overlay = mutable_appearance(icon, case_type)
for(var/i in 1 to contents.len)
gun_overlay.pixel_w = 3 * (i - 1)
. += new /mutable_appearance(gun_overlay)
. += "[icon_state]_[open ? "open" : "door"]"
/obj/structure/guncase/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
if(iscyborg(user) || isalien(user))
return NONE
if(istype(tool, gun_category) && open)
if(LAZYLEN(contents) == capacity)
to_chat(user, span_warning("[src] is full."))
return ITEM_INTERACT_BLOCKING
if(!user.transferItemToLoc(tool, src))
return ITEM_INTERACT_BLOCKING
to_chat(user, span_notice("You place [tool] in [src]."))
update_appearance()
return ITEM_INTERACT_SUCCESS
if(!user.combat_mode)
open = !open
update_appearance()
return ITEM_INTERACT_SUCCESS
return NONE
/obj/structure/guncase/attack_hand(mob/user, list/modifiers)
. = ..()
if(.)
return
if(iscyborg(user) || isalien(user))
return
if(contents.len && open)
show_menu(user)
else
open = !open
update_appearance()
/obj/structure/guncase/attack_hand_secondary(mob/user, list/modifiers)
if(iscyborg(user) || isalien(user))
return ..()
open = !open
update_appearance()
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
/**
* show_menu: Shows a radial menu to a user consisting of an available weaponry for taking
*
* Arguments:
* * user The mob to which we are showing the radial menu
*/
/obj/structure/guncase/proc/show_menu(mob/user)
if(!LAZYLEN(contents))
return
var/list/display_names = list()
var/list/items = list()
for(var/i in 1 to length(contents))
var/obj/item/thing = contents[i]
display_names["[thing.name] ([i])"] = REF(thing)
var/image/item_image = image(icon = thing.icon, icon_state = thing.icon_state)
if(length(thing.overlays))
item_image.copy_overlays(thing)
items += list("[thing.name] ([i])" = item_image)
var/pick = show_radial_menu(user, src, items, custom_check = CALLBACK(src, PROC_REF(check_menu), user), radius = 36, require_near = TRUE)
if(!pick)
return
var/weapon_reference = display_names[pick]
var/obj/item/weapon = locate(weapon_reference) in contents
if(!istype(weapon))
return
if(!user.put_in_hands(weapon))
weapon.forceMove(get_turf(src))
/**
* check_menu: Checks if we are allowed to interact with a radial menu
*
* Arguments:
* * user The mob interacting with a menu
*/
/obj/structure/guncase/proc/check_menu(mob/living/carbon/human/user)
if(!open)
return FALSE
if(!istype(user))
return FALSE
if(user.incapacitated)
return FALSE
return TRUE
/obj/structure/guncase/Exited(atom/movable/gone, direction)
. = ..()
update_appearance()
/obj/structure/guncase/contents_explosion(severity, target)
switch(severity)
if(EXPLODE_DEVASTATE)
SSexplosions.high_mov_atom += contents
if(EXPLODE_HEAVY)
SSexplosions.med_mov_atom += contents
if(EXPLODE_LIGHT)
SSexplosions.low_mov_atom += contents
/obj/structure/guncase/shotgun
name = "shotgun locker"
desc = "A locker that holds shotguns."
case_type = "shotgun"
gun_category = /obj/item/gun/ballistic/shotgun
/obj/structure/guncase/ecase
name = "energy gun locker"
desc = "A locker that holds energy guns."
case_type = "egun"
gun_category = /obj/item/gun/energy/e_gun
/obj/structure/guncase/wt550
name = "WT-550 gun locker"
desc = "A locker that holds WT-550 rifles."
case_type = "wt550"