Files
Bubberstation/code/game/objects/items/bodybag.dm
MrMelbert ff6b41aa07 Afterattack is dead, long live Afterattack (#83818)
## About The Pull Request

- Afterattack is a very simple proc now: All it does is this, and all
it's used for is for having a convenient place to put effects an item
does after a successful attack (IE, the attack was not blocked)


![image](https://github.com/tgstation/tgstation/assets/51863163/1e70f7be-0990-4827-a60a-0c9dd0e0ee49)

- An overwhelming majority of afterattack implementations have been
moved to `interact_with_atom` or the new `ranged_interact_with_atom`

I have manually tested many of the refactored procs but there was 200+
so it's kinda hard

## Why It's Good For The Game

Afterattack is one of the worst parts of the attack chain, as it
simultaneously serves as a way of doing random interactions NOT AT ALL
related to attacks (despite the name) while ALSO serving as the defacto
way to do a ranged interaction with an item

This means careless coders (most of them) may throw stuff in afterattack
without realizing how wide reaching it is, which causes bugs. By making
two well defined, separate procs for handing adjacent vs ranged
interactions, it becomes WAY WAY WAY more easy to develop for.

If you want to do something when you click on something else and you're
adjacent, use `interact_with_atom`
If you want to do something when you click on something else and you're
not adjacent, use 'ranged_interact_with_atom`

This does result in some instances of boilerplate as shown here:


![image](https://github.com/tgstation/tgstation/assets/51863163/a7e469dd-115e-4e5b-88e0-0c664619c878)

But I think it's acceptable, feel free to oppose if you don't I'm sure
we can think of another solution

~~Additionally it makes it easier to implement swing combat. That's a
bonus I guess~~

## Changelog

🆑 Melbert
refactor: Over 200 item interactions have been refactored to use a
newer, easier-to-use system. Report any oddities with using items on
other objects you may see (such as surgery, reagent containers like cups
and spray bottles, or construction devices), especially using something
at range (such as guns or chisels)
refactor: Item-On-Modsuit interactions have changed slightly. While on
combat mode, you will attempt to "use" the item on the suit instead of
inserting it into the suit's storage. This means being on combat mode
while the suit's panel is open will block you from inserting items
entirely via click (but other methods such as hotkey, clicking on the
storage boxes, and mousedrop will still work).
refactor: The detective's scanner will now be inserted into storage
items if clicked normally, and will scan the storage item if on combat
mode
/🆑
2024-06-11 21:58:09 -07:00

140 lines
6.0 KiB
Plaintext

/obj/item/bodybag
name = "body bag"
desc = "A folded bag designed for the storage and transportation of cadavers."
icon = 'icons/obj/medical/bodybag.dmi'
icon_state = "bodybag_folded"
w_class = WEIGHT_CLASS_SMALL
///Stored path we use for spawning a new body bag entity when unfolded.
var/unfoldedbag_path = /obj/structure/closet/body_bag
/obj/item/bodybag/attack_self(mob/user)
if(user.is_holding(src))
deploy_bodybag(user, get_turf(user))
else
deploy_bodybag(user, get_turf(src))
/obj/item/bodybag/interact_with_atom(atom/interacting_with, mob/living/user, flags)
if(isopenturf(interacting_with))
deploy_bodybag(user, interacting_with)
return ITEM_INTERACT_SUCCESS
return NONE
/obj/item/bodybag/attempt_pickup(mob/user)
// can't pick ourselves up if we are inside of the bodybag, else very weird things may happen
if(contains(user))
return TRUE
return ..()
/**
* Creates a new body bag item when unfolded, at the provided location, replacing the body bag item.
* * mob/user: User opening the body bag.
* * atom/location: the place/entity/mob where the body bag is being deployed from.
*/
/obj/item/bodybag/proc/deploy_bodybag(mob/user, atom/location)
var/obj/structure/closet/body_bag/item_bag = new unfoldedbag_path(location)
item_bag.open(user)
item_bag.add_fingerprint(user)
item_bag.foldedbag_instance = src
moveToNullspace()
return item_bag
/obj/item/bodybag/suicide_act(mob/living/user)
if(isopenturf(user.loc))
user.visible_message(span_suicide("[user] is crawling into [src]! It looks like [user.p_theyre()] trying to commit suicide!"))
var/obj/structure/closet/body_bag/R = new unfoldedbag_path(user.loc)
R.add_fingerprint(user)
qdel(src)
user.forceMove(R)
playsound(src, 'sound/items/zip.ogg', 15, TRUE, -3)
return OXYLOSS
// Bluespace bodybag
/obj/item/bodybag/bluespace
name = "bluespace body bag"
desc = "A folded bluespace body bag designed for the storage and transportation of cadavers."
icon = 'icons/obj/medical/bodybag.dmi'
icon_state = "bluebodybag_folded"
unfoldedbag_path = /obj/structure/closet/body_bag/bluespace
w_class = WEIGHT_CLASS_SMALL
item_flags = NO_MAT_REDEMPTION
/obj/item/bodybag/bluespace/examine(mob/user)
. = ..()
if(contents.len)
var/s = contents.len == 1 ? "" : "s"
. += span_notice("You can make out the shape[s] of [contents.len] object[s] through the fabric.")
/obj/item/bodybag/bluespace/Destroy()
for(var/atom/movable/A in contents)
A.forceMove(get_turf(src))
if(isliving(A))
to_chat(A, span_notice("You suddenly feel the space around you torn apart! You're free!"))
return ..()
/obj/item/bodybag/bluespace/deploy_bodybag(mob/user, atom/location)
var/obj/structure/closet/body_bag/item_bag = new unfoldedbag_path(location)
for(var/atom/movable/inside in contents)
inside.forceMove(item_bag)
if(isliving(inside))
to_chat(inside, span_notice("You suddenly feel air around you! You're free!"))
item_bag.open(user)
item_bag.add_fingerprint(user)
item_bag.foldedbag_instance = src
moveToNullspace()
return item_bag
/obj/item/bodybag/bluespace/container_resist_act(mob/living/user)
if(user.incapacitated())
to_chat(user, span_warning("You can't get out while you're restrained like this!"))
return
user.changeNext_move(CLICK_CD_BREAKOUT)
user.last_special = world.time + CLICK_CD_BREAKOUT
to_chat(user, span_notice("You claw at the fabric of [src], trying to tear it open..."))
to_chat(loc, span_warning("Someone starts trying to break free of [src]!"))
if(!do_after(user, 12 SECONDS, src, timed_action_flags = (IGNORE_TARGET_LOC_CHANGE|IGNORE_HELD_ITEM)))
return
// you are still in the bag? time to go unless you KO'd, honey!
// if they escape during this time and you rebag them the timer is still clocking down and does NOT reset so they can very easily get out.
if(user.incapacitated())
to_chat(loc, span_warning("The pressure subsides. It seems that they've stopped resisting..."))
return
loc.visible_message(span_warning("[user] suddenly appears in front of [loc]!"), span_userdanger("[user] breaks free of [src]!"))
qdel(src)
/obj/item/bodybag/environmental
name = "environmental protection bag"
desc = "A folded, reinforced bag designed to protect against exoplanetary environmental storms."
icon = 'icons/obj/medical/bodybag.dmi'
icon_state = "envirobag_folded"
unfoldedbag_path = /obj/structure/closet/body_bag/environmental
w_class = WEIGHT_CLASS_NORMAL //It's reinforced and insulated, like a beefed-up sleeping bag, so it has a higher bulkiness than regular bodybag
resistance_flags = ACID_PROOF | FIRE_PROOF | FREEZE_PROOF
/obj/item/bodybag/environmental/nanotrasen
name = "elite environmental protection bag"
desc = "A folded, heavily reinforced, and insulated bag, capable of fully isolating its contents from external factors."
icon_state = "ntenvirobag_folded"
unfoldedbag_path = /obj/structure/closet/body_bag/environmental/nanotrasen
resistance_flags = ACID_PROOF | FIRE_PROOF | FREEZE_PROOF | LAVA_PROOF
/obj/item/bodybag/environmental/prisoner
name = "prisoner transport bag"
desc = "Intended for transport of prisoners through hazardous environments, this folded environmental protection bag comes with straps to keep an occupant secure."
icon = 'icons/obj/medical/bodybag.dmi'
icon_state = "prisonerenvirobag_folded"
unfoldedbag_path = /obj/structure/closet/body_bag/environmental/prisoner
/obj/item/bodybag/environmental/prisoner/pressurized
name = "pressurized prisoner transport bag"
unfoldedbag_path = /obj/structure/closet/body_bag/environmental/prisoner/pressurized
/obj/item/bodybag/environmental/prisoner/syndicate
name = "syndicate prisoner transport bag"
desc = "An alteration of Nanotrasen's environmental protection bag which has been used in several high-profile kidnappings. Designed to keep a victim unconscious, alive, and secured until they are transported to a required location."
icon = 'icons/obj/medical/bodybag.dmi'
icon_state = "syndieenvirobag_folded"
unfoldedbag_path = /obj/structure/closet/body_bag/environmental/prisoner/pressurized/syndicate
resistance_flags = ACID_PROOF | FIRE_PROOF | FREEZE_PROOF | LAVA_PROOF