Files
Bubberstation/code/game/objects/items/storage/boxes/service_boxes.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

258 lines
8.1 KiB
Plaintext

// This file contains all boxes used by the Service department and its purpose on the station.
// Because we want to avoid some sort of "miscellaneous" file, let's put all the bureaucracy (pens and stuff) and the HoP's stuff here as well.
/obj/item/storage/box/drinkingglasses
name = "box of drinking glasses"
desc = "It has a picture of drinking glasses on it."
illustration = "drinkglass"
/obj/item/storage/box/drinkingglasses/PopulateContents()
for(var/i in 1 to 6)
new /obj/item/reagent_containers/cup/glass/drinkingglass(src)
/obj/item/storage/box/cups
name = "box of paper cups"
desc = "It has pictures of paper cups on the front."
illustration = "cup"
/obj/item/storage/box/cups/PopulateContents()
for(var/i in 1 to 7)
new /obj/item/reagent_containers/cup/glass/sillycup(src)
//Some spare PDAs in a box
/obj/item/storage/box/pdas
name = "spare PDAs"
desc = "A box of spare PDA microcomputers."
illustration = "pda"
/obj/item/storage/box/pdas/PopulateContents()
for(var/i in 1 to 4)
new /obj/item/modular_computer/pda(src)
/obj/item/storage/box/ids
name = "box of spare IDs"
desc = "Has so many empty IDs."
illustration = "id"
/obj/item/storage/box/ids/PopulateContents()
for(var/i in 1 to 7)
new /obj/item/card/id/advanced(src)
/obj/item/storage/box/silver_ids
name = "box of spare silver IDs"
desc = "Shiny IDs for important people."
illustration = "id"
/obj/item/storage/box/silver_ids/PopulateContents()
for(var/i in 1 to 7)
new /obj/item/card/id/advanced/silver(src)
/obj/item/storage/box/mousetraps
name = "box of Pest-B-Gon mousetraps"
desc = "<span class='alert'>Keep out of reach of children.</span>"
illustration = "mousetrap"
/obj/item/storage/box/mousetraps/PopulateContents()
for(var/i in 1 to 6)
new /obj/item/assembly/mousetrap(src)
/obj/item/storage/box/snappops
name = "snap pop box"
desc = "Eight wrappers of fun! Ages 8 and up. Not suitable for children."
icon = 'icons/obj/toys/toy.dmi'
icon_state = "spbox"
illustration = ""
/obj/item/storage/box/snappops/Initialize(mapload)
. = ..()
atom_storage.set_holdable(/obj/item/toy/snappop)
atom_storage.max_slots = 8
/obj/item/storage/box/snappops/PopulateContents()
for(var/i in 1 to 8)
new /obj/item/toy/snappop(src)
/obj/item/storage/box/matches
name = "matchbox"
desc = "A small box of Almost But Not Quite Plasma Premium Matches."
icon = 'icons/obj/cigarettes.dmi'
icon_state = "matchbox"
inhand_icon_state = "zippo"
lefthand_file = 'icons/mob/inhands/items_lefthand.dmi'
righthand_file = 'icons/mob/inhands/items_righthand.dmi'
worn_icon_state = "lighter"
w_class = WEIGHT_CLASS_TINY
slot_flags = ITEM_SLOT_BELT
drop_sound = 'sound/items/handling/matchbox_drop.ogg'
pickup_sound = 'sound/items/handling/matchbox_pickup.ogg'
custom_price = PAYCHECK_CREW * 0.4
base_icon_state = "matchbox"
illustration = null
/obj/item/storage/box/matches/Initialize(mapload)
. = ..()
atom_storage.max_slots = 10
atom_storage.set_holdable(/obj/item/match)
/obj/item/storage/box/matches/storage_insert_on_interacted_with(datum/storage, obj/item/inserted, mob/living/user)
return !istype(inserted, /obj/item/match)
/obj/item/storage/box/matches/PopulateContents()
for(var/i in 1 to 10)
new /obj/item/match(src)
/obj/item/storage/box/matches/item_interaction(mob/living/user, obj/item/match/match, list/modifiers)
if(istype(match))
match.matchignite()
return ITEM_INTERACT_SUCCESS
return NONE
/obj/item/storage/box/matches/update_icon_state()
. = ..()
switch(length(contents))
if(10)
icon_state = base_icon_state
if(5 to 9)
icon_state = "[base_icon_state]_almostfull"
if(1 to 4)
icon_state = "[base_icon_state]_almostempty"
if(0)
icon_state = "[base_icon_state]_e"
/obj/item/storage/box/lights
name = "box of replacement bulbs"
desc = "This box is shaped on the inside so that only light tubes and bulbs fit."
inhand_icon_state = "syringe_kit"
lefthand_file = 'icons/mob/inhands/equipment/medical_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/medical_righthand.dmi'
foldable_result = /obj/item/stack/sheet/cardboard //BubbleWrap
illustration = "light"
/obj/item/storage/box/lights/Initialize(mapload)
. = ..()
atom_storage.max_slots = 21
atom_storage.set_holdable(list(/obj/item/light/tube, /obj/item/light/bulb))
atom_storage.max_total_storage = 21
atom_storage.allow_quick_gather = FALSE //temp workaround to re-enable filling the light replacer with the box
/obj/item/storage/box/lights/bulbs/PopulateContents()
for(var/i in 1 to 21)
new /obj/item/light/bulb(src)
/obj/item/storage/box/lights/tubes
name = "box of replacement tubes"
illustration = "lighttube"
/obj/item/storage/box/lights/tubes/PopulateContents()
for(var/i in 1 to 21)
new /obj/item/light/tube(src)
/obj/item/storage/box/lights/mixed
name = "box of replacement lights"
illustration = "lightmixed"
/obj/item/storage/box/lights/mixed/PopulateContents()
for(var/i in 1 to 14)
new /obj/item/light/tube(src)
for(var/i in 1 to 7)
new /obj/item/light/bulb(src)
/obj/item/storage/box/fountainpens
name = "box of fountain pens"
illustration = "fpen"
/obj/item/storage/box/fountainpens/PopulateContents()
for(var/i in 1 to 7)
new /obj/item/pen/fountain(src)
/obj/item/storage/box/dishdrive
name = "DIY Dish Drive Kit"
desc = "Contains everything you need to build your own Dish Drive!"
custom_premium_price = PAYCHECK_CREW * 3
/obj/item/storage/box/dishdrive/PopulateContents()
var/static/items_inside = list(
/obj/item/circuitboard/machine/dish_drive = 1,
/obj/item/screwdriver = 1,
/obj/item/stack/cable_coil/five = 1,
/obj/item/stack/sheet/glass = 1,
/obj/item/stack/sheet/iron/five = 1,
/obj/item/stock_parts/servo = 1,
/obj/item/stock_parts/matter_bin = 2,
/obj/item/wrench = 1,
)
generate_items_inside(items_inside,src)
/obj/item/storage/box/actionfigure
name = "box of action figures"
desc = "The latest set of collectable action figures."
icon_state = "box"
/obj/item/storage/box/actionfigure/PopulateContents()
for(var/i in 1 to 4)
var/random_figure = pick(subtypesof(/obj/item/toy/figure))
new random_figure(src)
/obj/item/storage/box/tail_pin
name = "pin the tail on the corgi supplies"
desc = "For ages 10 and up. ...Why is this even on a space station? Aren't you a little old for babby games?" //Intentional typo.
custom_price = PAYCHECK_COMMAND * 1.25
/obj/item/storage/box/tail_pin/PopulateContents()
for(var/i in 1 to 3)
new /obj/item/poster/tail_board(src)
new /obj/item/tail_pin(src)
/obj/item/storage/box/party_poppers
name = "box of party poppers"
desc = "Turn any event into a celebration and ensure the janitor stays busy."
/obj/item/storage/box/party_poppers/PopulateContents()
for(var/i in 1 to 5)
new /obj/item/reagent_containers/spray/chemsprayer/party(src)
/obj/item/storage/box/balloons
name = "box of long balloons"
desc = "A completely randomized and wacky box of long balloons, harvested straight from balloon farms on the clown planet."
illustration = "balloon"
/obj/item/storage/box/balloons/Initialize(mapload)
. = ..()
atom_storage.max_slots = 24
atom_storage.set_holdable(list(/obj/item/toy/balloon/long))
atom_storage.max_total_storage = 24
atom_storage.allow_quick_gather = FALSE
/obj/item/storage/box/balloons/PopulateContents()
for(var/i in 1 to 24)
new /obj/item/toy/balloon/long(src)
/obj/item/storage/box/stickers
name = "box of stickers"
desc = "A box full of random stickers. Do give to the clown."
/obj/item/storage/box/stickers/proc/generate_non_contraband_stickers_list()
var/list/allowed_stickers = list()
for(var/obj/item/sticker/sticker_type as anything in subtypesof(/obj/item/sticker))
if(!sticker_type::contraband)
allowed_stickers += sticker_type
return allowed_stickers
/obj/item/storage/box/stickers/PopulateContents()
var/static/list/non_contraband
if(isnull(non_contraband))
non_contraband = generate_non_contraband_stickers_list()
for(var/i in 1 to rand(4, 8))
var/type = pick(non_contraband)
new type(src)
/obj/item/storage/box/stickers/googly
name = "box of googly eye stickers"
desc = "Turn anything and everything into something vaguely alive!"
/obj/item/storage/box/stickers/googly/PopulateContents()
for(var/i in 1 to 6)
new /obj/item/sticker/googly(src)