From 3793f8999f91e7d045640dc5cb2bc087497dba4f Mon Sep 17 00:00:00 2001 From: Spookerton Date: Sat, 13 Jan 2024 15:55:32 +0000 Subject: [PATCH] tweaked playsound, changes & fixes for storage items playsound and playsound_local return early on null sound sources can_hold -> contents_allowed cant_hold -> contents_banned contents_allowed & contents_banned allow null instead of empty lists collection_mode -> quick_gather_single storage items correctly respect whether they can quick gather & which quick gather mode they are in fixed quick gathering not working on turfs toggle_gathering_mode verb respects distance got rid of open_sound_played corrected comments for /obj/item/storage member vars --- code/game/objects/items.dm | 43 +++-- .../objects/items/weapons/storage/backpack.dm | 2 +- .../objects/items/weapons/storage/bags.dm | 8 +- .../objects/items/weapons/storage/belt.dm | 44 ++--- .../objects/items/weapons/storage/boxes.dm | 7 +- .../items/weapons/storage/fancy/crackers.dm | 2 +- .../items/weapons/storage/fancy/egg_box.dm | 2 +- .../items/weapons/storage/fancy/matchbox.dm | 4 +- .../objects/items/weapons/storage/firstaid.dm | 7 +- .../items/weapons/storage/laundry_basket.dm | 3 +- .../objects/items/weapons/storage/misc.dm | 4 +- .../items/weapons/storage/pill_bottle.dm | 7 +- .../objects/items/weapons/storage/secure.dm | 2 +- .../items/weapons/storage/specialized.dm | 10 +- .../objects/items/weapons/storage/storage.dm | 178 +++++++++--------- .../objects/items/weapons/storage/wallets.dm | 2 +- code/game/objects/structures/inflatable.dm | 2 +- code/game/sound.dm | 5 +- code/game/turfs/turf.dm | 13 +- .../clothing/under/accessories/storage.dm | 4 +- code/modules/detectivework/tools/crimekit.dm | 6 +- code/modules/mining/mine_turfs.dm | 6 +- code/modules/paperwork/photography.dm | 2 +- .../drinkingglass/glass_boxes.dm | 6 +- .../reagent_containers/food/snacks/bugmeat.dm | 2 +- code/modules/research/part_replacer.dm | 3 +- .../xenoarcheaology/tools/equipment.dm | 2 +- code/modules/xenoarcheaology/tools/tools.dm | 2 +- .../xenoarcheaology/tools/tools_pickaxe.dm | 3 +- maps/away/skrellscoutship/skrellscoutship.dm | 2 +- maps/torch/items/wallets.dm | 2 +- packs/factions/iccgn/tweaks.dm | 2 +- packs/factions/scga/tweaks.dm | 2 +- test/check-paths.sh | 2 +- 34 files changed, 201 insertions(+), 190 deletions(-) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 4bac7fc240d04..1896cdf412da9 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -277,31 +277,38 @@ R.activate_module(src) R.hud_used.update_robot_modules_display() -/obj/item/use_tool(obj/item/W, mob/living/user, list/click_params) - if(SSfabrication.try_craft_with(src, W, user)) - return TRUE - - if(istype(W, /obj/item/storage)) - var/obj/item/storage/S = W - if (S.collection_mode && isturf(loc)) //Mode is set to collect all items - S.gather_all(loc, user) - return TRUE +/obj/item/use_tool(obj/item/item, mob/living/user, list/click_params) + if (SSfabrication.try_craft_with(src, item, user)) + return TRUE + if (istype(item, /obj/item/storage) && isturf(loc)) + var/obj/item/storage/storage = item + if (!storage.allow_quick_gather) + return ..() + if (!storage.quick_gather_single) + storage.gather_all(loc, user) + else if (storage.can_be_inserted(src, user)) + storage.handle_item_insertion(src) + return TRUE return ..() + ///Eventually should be deleted in favor of use_tool; keeping duplicate until downstream attackbys are replaced. -/obj/item/attackby(obj/item/W, mob/living/user, list/click_params) - if(SSfabrication.try_craft_with(src, W, user)) +/obj/item/attackby(obj/item/item, mob/living/user, list/click_params) + if (SSfabrication.try_craft_with(src, item, user)) + return TRUE + if (istype(item, /obj/item/storage) && isturf(loc)) + var/obj/item/storage/storage = item + if (!storage.allow_quick_gather) + return ..() + if (!storage.quick_gather_single) + storage.gather_all(loc, user) + else if (storage.can_be_inserted(src, user)) + storage.handle_item_insertion(src) return TRUE - - if(istype(W, /obj/item/storage)) - var/obj/item/storage/S = W - if (S.collection_mode && isturf(loc)) //Mode is set to collect all items - S.gather_all(loc, user) - return TRUE - return ..() + /obj/item/can_embed() if (!canremove) return FALSE diff --git a/code/game/objects/items/weapons/storage/backpack.dm b/code/game/objects/items/weapons/storage/backpack.dm index 67c6bb1cd24c8..7454eb21dbef7 100644 --- a/code/game/objects/items/weapons/storage/backpack.dm +++ b/code/game/objects/items/weapons/storage/backpack.dm @@ -459,7 +459,7 @@ storage_slots = 5 max_w_class = ITEM_SIZE_NORMAL max_storage_space = 15 - cant_hold = list(/obj/item/storage/backpack/satchel/flat) //muh recursive backpacks + contents_banned = list(/obj/item/storage/backpack/satchel/flat) startswith = list( /obj/item/stack/tile/floor, /obj/item/crowbar diff --git a/code/game/objects/items/weapons/storage/bags.dm b/code/game/objects/items/weapons/storage/bags.dm index f683ff61e1735..d34f3bacb3e60 100644 --- a/code/game/objects/items/weapons/storage/bags.dm +++ b/code/game/objects/items/weapons/storage/bags.dm @@ -4,7 +4,6 @@ /obj/item/storage/bag allow_quick_gather = TRUE allow_quick_empty = TRUE - collection_mode = TRUE slot_flags = SLOT_BELT /obj/item/storage/bag/handle_item_insertion(obj/item/W as obj, prevent_warning = 0) @@ -49,7 +48,6 @@ w_class = ITEM_SIZE_SMALL max_w_class = ITEM_SIZE_HUGE //can fit a backpack inside a trash bag, seems right max_storage_space = DEFAULT_BACKPACK_STORAGE - can_hold = list() // any /obj/item/storage/bag/trash/update_w_class() ..() @@ -89,7 +87,6 @@ w_class = ITEM_SIZE_TINY max_w_class = ITEM_SIZE_NORMAL max_storage_space = DEFAULT_BOX_STORAGE - can_hold = list() // any // ----------------------------- // Cash Bag @@ -103,4 +100,7 @@ max_storage_space = 100 max_w_class = ITEM_SIZE_HUGE w_class = ITEM_SIZE_SMALL - can_hold = list(/obj/item/material/coin,/obj/item/spacecash) + contents_allowed = list( + /obj/item/material/coin, + /obj/item/spacecash + ) diff --git a/code/game/objects/items/weapons/storage/belt.dm b/code/game/objects/items/weapons/storage/belt.dm index f7de70a62706b..4d7613f41f192 100644 --- a/code/game/objects/items/weapons/storage/belt.dm +++ b/code/game/objects/items/weapons/storage/belt.dm @@ -56,7 +56,7 @@ var/list/can_holster //List of objects which this item can store in the designated holster slot(if unset, it will default to any holsterable items) var/sound_in = 'sound/effects/holster/holsterin.ogg' var/sound_out = 'sound/effects/holster/holsterout.ogg' - can_hold = list( + contents_allowed = list( /obj/item/melee/baton, /obj/item/melee/telebaton ) @@ -107,7 +107,7 @@ icon_state = "utilitybelt" item_state = "utility" overlay_flags = BELT_OVERLAY_ITEMS - can_hold = list( + contents_allowed = list( /obj/item/crowbar, /obj/item/screwdriver, /obj/item/weldingtool, @@ -175,7 +175,7 @@ desc = "Can hold various medical equipment." icon_state = "medicalbelt" item_state = "medical" - can_hold = list( + contents_allowed = list( /obj/item/device/scanner/health, /obj/item/reagent_containers/dropper, /obj/item/reagent_containers/glass/beaker, @@ -220,7 +220,7 @@ item_state = "security" storage_slots = 8 overlay_flags = BELT_OVERLAY_ITEMS|BELT_OVERLAY_HOLSTER - can_hold = list( + contents_allowed = list( /obj/item/crowbar, /obj/item/grenade, /obj/item/reagent_containers/spray/pepper, @@ -263,7 +263,7 @@ icon_state = "basicsecuritybelt" item_state = "basicsecurity" overlay_flags = BELT_OVERLAY_ITEMS - can_hold = list( + contents_allowed = list( /obj/item/crowbar, /obj/item/grenade, /obj/item/reagent_containers/spray/pepper, @@ -298,7 +298,7 @@ icon_state = "gearbelt" item_state = "gear" overlay_flags = BELT_OVERLAY_ITEMS - can_hold = list( + contents_allowed = list( /obj/item/device/flash, /obj/item/melee/telebaton, /obj/item/device/taperecorder, @@ -351,7 +351,7 @@ desc = "A belt used to hold most janitorial supplies." icon_state = "janibelt" item_state = "janibelt" - can_hold = list( + contents_allowed = list( /obj/item/grenade/chem_grenade, /obj/item/device/lightreplacer, /obj/item/device/flashlight, @@ -367,7 +367,7 @@ /obj/item/material/knife/folding, /obj/item/modular_computer/tablet, /obj/item/modular_computer/pda - ) + ) /obj/item/storage/belt/holster/general name = "holster belt" @@ -376,7 +376,7 @@ item_state = "command" storage_slots = 7 overlay_flags = BELT_OVERLAY_ITEMS|BELT_OVERLAY_HOLSTER - can_hold = list( + contents_allowed = list( /obj/item/device/flash, /obj/item/melee/telebaton, /obj/item/device/taperecorder, @@ -412,7 +412,7 @@ /obj/item/clothing/head/beret, /obj/item/material/knife/folding, /obj/item/device/tape - ) + ) /obj/item/storage/belt/holster/forensic name = "forensic holster belt" @@ -421,7 +421,7 @@ item_state = "forensic" storage_slots = 8 overlay_flags = BELT_OVERLAY_HOLSTER - can_hold = list( + contents_allowed = list( /obj/item/reagent_containers/spray/luminol, /obj/item/device/uv_light, /obj/item/reagent_containers/syringe, @@ -449,7 +449,7 @@ /obj/item/clothing/glasses, /obj/item/reagent_containers/spray/pepper, /obj/item/device/flash - ) + ) /obj/item/storage/belt/forensic name = "forensic belt" @@ -457,7 +457,7 @@ icon_state = "basicforensicbelt" item_state = "basicforensic" storage_slots = 8 - can_hold = list( + contents_allowed = list( /obj/item/reagent_containers/spray/luminol, /obj/item/device/uv_light, /obj/item/reagent_containers/syringe, @@ -485,7 +485,7 @@ /obj/item/clothing/glasses, /obj/item/reagent_containers/spray/pepper, /obj/item/device/flash - ) + ) /obj/item/storage/belt/holster/machete name = "machete belt" @@ -494,7 +494,7 @@ item_state = "machetebelt" storage_slots = 8 overlay_flags = BELT_OVERLAY_HOLSTER - can_hold = list( + contents_allowed = list( /obj/item/device/binoculars, /obj/item/device/camera, /obj/item/stack/flag, @@ -522,7 +522,7 @@ /obj/item/device/drone_designator, /obj/item/modular_computer/tablet, /obj/item/modular_computer/pda - ) + ) can_holster = list(/obj/item/material/hatchet/machete) sound_in = 'sound/effects/holster/sheathin.ogg' sound_out = 'sound/effects/holster/sheathout.ogg' @@ -532,9 +532,7 @@ desc = "Designed for ease of access to the shards during a fight, as to not let a single enemy spirit slip away." icon_state = "soulstonebelt" item_state = "soulstonebelt" - can_hold = list( - /obj/item/device/soulstone - ) + contents_allowed = list(/obj/item/device/soulstone) /obj/item/storage/belt/soulstone/full/New() ..() @@ -554,9 +552,7 @@ item_state = "champion" storage_slots = null max_storage_space = ITEM_SIZE_SMALL - can_hold = list( - /obj/item/clothing/mask/luchador - ) + contents_allowed = list(/obj/item/clothing/mask/luchador) /obj/item/storage/belt/holster/security/tactical name = "combat belt" @@ -583,12 +579,12 @@ item_state = "gear" storage_slots = 5 overlay_flags = BELT_OVERLAY_ITEMS - can_hold = list( + contents_allowed = list( /obj/item/grenade/chem_grenade/water, /obj/item/crowbar/emergency_forcing_tool, /obj/item/extinguisher/mini, /obj/item/inflatable/door - ) + ) /obj/item/storage/belt/fire_belt/full diff --git a/code/game/objects/items/weapons/storage/boxes.dm b/code/game/objects/items/weapons/storage/boxes.dm index bd11a0ef2dd44..9d4cef4a36566 100644 --- a/code/game/objects/items/weapons/storage/boxes.dm +++ b/code/game/objects/items/weapons/storage/boxes.dm @@ -377,7 +377,7 @@ desc = "Drymate brand monkey cubes. Just add water!" icon = 'icons/obj/food/food.dmi' icon_state = "monkeycubebox" - can_hold = list(/obj/item/reagent_containers/food/snacks/monkeycube) + contents_allowed = list(/obj/item/reagent_containers/food/snacks/monkeycube) startswith = list(/obj/item/reagent_containers/food/snacks/monkeycube/wrapped = 5) @@ -448,7 +448,7 @@ desc = "Eight wrappers of fun! Ages 8 and up. Not suitable for children." icon = 'icons/obj/toy.dmi' icon_state = "spbox" - can_hold = list(/obj/item/toy/snappop) + contents_allowed = list(/obj/item/toy/snappop) startswith = list(/obj/item/toy/snappop = 8) @@ -466,7 +466,6 @@ desc = "This box is shaped on the inside so that only light tubes and bulbs fit." item_state = "syringe_kit" allow_quick_gather = TRUE - collection_mode = TRUE /obj/item/storage/box/lights/Initialize() @@ -531,7 +530,7 @@ icon_state = "checkers" max_storage_space = 24 foldable = null - can_hold = list(/obj/item/reagent_containers/food/snacks/checker) + contents_allowed = list(/obj/item/reagent_containers/food/snacks/checker) startswith = list(/obj/item/reagent_containers/food/snacks/checker = 12, /obj/item/reagent_containers/food/snacks/checker/red = 12) diff --git a/code/game/objects/items/weapons/storage/fancy/crackers.dm b/code/game/objects/items/weapons/storage/fancy/crackers.dm index 98f29323ef33e..f74a1227cda89 100644 --- a/code/game/objects/items/weapons/storage/fancy/crackers.dm +++ b/code/game/objects/items/weapons/storage/fancy/crackers.dm @@ -7,7 +7,7 @@ max_w_class = ITEM_SIZE_TINY w_class = ITEM_SIZE_SMALL key_type = list(/obj/item/reagent_containers/food/snacks/cracker) - can_hold = list( + contents_allowed = list( /obj/item/reagent_containers/food/snacks/cracker ) startswith = list( diff --git a/code/game/objects/items/weapons/storage/fancy/egg_box.dm b/code/game/objects/items/weapons/storage/fancy/egg_box.dm index d70faad119e6e..98bba63e50cea 100644 --- a/code/game/objects/items/weapons/storage/fancy/egg_box.dm +++ b/code/game/objects/items/weapons/storage/fancy/egg_box.dm @@ -7,7 +7,7 @@ max_w_class = ITEM_SIZE_SMALL w_class = ITEM_SIZE_NORMAL key_type = list(/obj/item/reagent_containers/food/snacks/egg) - can_hold = list( + contents_allowed = list( /obj/item/reagent_containers/food/snacks/egg, /obj/item/reagent_containers/food/snacks/boiledegg ) diff --git a/code/game/objects/items/weapons/storage/fancy/matchbox.dm b/code/game/objects/items/weapons/storage/fancy/matchbox.dm index 8acd1c4381277..a503f9a4df1a6 100644 --- a/code/game/objects/items/weapons/storage/fancy/matchbox.dm +++ b/code/game/objects/items/weapons/storage/fancy/matchbox.dm @@ -7,7 +7,7 @@ max_storage_space = 10 w_class = ITEM_SIZE_SMALL slot_flags = SLOT_BELT - can_hold = list(/obj/item/flame/match) + contents_allowed = list(/obj/item/flame/match) key_type = list(/obj/item/flame/match) startswith = list(/obj/item/flame/match = 10) var/sprite_key_type_count = 3 @@ -21,7 +21,7 @@ max_storage_space = 3 w_class = ITEM_SIZE_TINY slot_flags = SLOT_EARS - can_hold = list(/obj/item/flame/match) + contents_allowed = list(/obj/item/flame/match) key_type = list(/obj/item/flame/match) startswith = list(/obj/item/flame/match = 3) diff --git a/code/game/objects/items/weapons/storage/firstaid.dm b/code/game/objects/items/weapons/storage/firstaid.dm index e624d958c93b6..071f4c5fb3cd3 100644 --- a/code/game/objects/items/weapons/storage/firstaid.dm +++ b/code/game/objects/items/weapons/storage/firstaid.dm @@ -158,7 +158,7 @@ /obj/item/reagent_containers/hypospray/autoinjector/pouch_auto/dexalin, /obj/item/stack/medical/bruise_pack ) - can_hold = list( + contents_allowed = list( /obj/item/clothing/gloves/latex, /obj/item/reagent_containers/hypospray/autoinjector, /obj/item/stack/medical/bruise_pack @@ -174,7 +174,7 @@ max_w_class = ITEM_SIZE_NORMAL max_storage_space = null w_class = ITEM_SIZE_LARGE - can_hold = list( + contents_allowed = list( /obj/item/bonesetter, /obj/item/cautery, /obj/item/circular_saw, @@ -212,11 +212,10 @@ w_class = ITEM_SIZE_LARGE max_storage_space = DEFAULT_LARGEBOX_STORAGE allow_quick_gather = TRUE - collection_mode = TRUE temperature = -16 CELSIUS matter = list(MATERIAL_PLASTIC = 350) origin_tech = list(TECH_MATERIAL = 3, TECH_POWER = 2) - can_hold = list( + contents_allowed = list( /obj/item/organ, /obj/item/reagent_containers ) diff --git a/code/game/objects/items/weapons/storage/laundry_basket.dm b/code/game/objects/items/weapons/storage/laundry_basket.dm index 37ce33a54077c..3faa256e6beec 100644 --- a/code/game/objects/items/weapons/storage/laundry_basket.dm +++ b/code/game/objects/items/weapons/storage/laundry_basket.dm @@ -16,7 +16,6 @@ storage_slots = 14 allow_quick_empty = TRUE allow_quick_gather = TRUE - collection_mode = TRUE var/linked @@ -78,8 +77,8 @@ icon = 'icons/obj/weapons/other.dmi' icon_state = "offhand" name = "second hand" - collection_mode = FALSE allow_quick_gather = FALSE + quick_gather_single = TRUE /obj/item/storage/laundry_basket/offhand/dropped(mob/user as mob) ..() diff --git a/code/game/objects/items/weapons/storage/misc.dm b/code/game/objects/items/weapons/storage/misc.dm index 64d901f006cc9..cc0df28d35713 100644 --- a/code/game/objects/items/weapons/storage/misc.dm +++ b/code/game/objects/items/weapons/storage/misc.dm @@ -30,7 +30,7 @@ icon = 'icons/obj/food/food.dmi' icon_state = "donutbox" name = "donut box" - can_hold = list(/obj/item/reagent_containers/food/snacks/donut) + contents_allowed = list(/obj/item/reagent_containers/food/snacks/donut) foldable = /obj/item/stack/material/cardboard startswith = list(/obj/item/reagent_containers/food/snacks/donut/normal = 6) @@ -61,7 +61,7 @@ throwforce = 2 slot_flags = SLOT_BELT startswith = list(/obj/item/paper/cig = 10) - can_hold = list( + contents_allowed = list( /obj/item/paper/cig, /obj/item/clothing/mask/smokable/cigarette, /obj/item/storage/cigpaper/filters diff --git a/code/game/objects/items/weapons/storage/pill_bottle.dm b/code/game/objects/items/weapons/storage/pill_bottle.dm index d55187607ee3f..cd85217e1d195 100644 --- a/code/game/objects/items/weapons/storage/pill_bottle.dm +++ b/code/game/objects/items/weapons/storage/pill_bottle.dm @@ -7,10 +7,13 @@ w_class = ITEM_SIZE_SMALL max_w_class = ITEM_SIZE_TINY max_storage_space = 21 - can_hold = list(/obj/item/reagent_containers/pill,/obj/item/dice,/obj/item/paper) + contents_allowed = list( + /obj/item/reagent_containers/pill, + /obj/item/dice, + /obj/item/paper + ) allow_quick_gather = TRUE allow_quick_empty = TRUE - collection_mode = TRUE use_sound = 'sound/effects/storage/pillbottle.ogg' matter = list(MATERIAL_PLASTIC = 250) var/wrapper_color diff --git a/code/game/objects/items/weapons/storage/secure.dm b/code/game/objects/items/weapons/storage/secure.dm index 41478a9c113e0..668efd49cf057 100644 --- a/code/game/objects/items/weapons/storage/secure.dm +++ b/code/game/objects/items/weapons/storage/secure.dm @@ -166,7 +166,7 @@ max_storage_space = 56 anchored = TRUE density = FALSE - cant_hold = list(/obj/item/storage/secure/briefcase) + contents_banned = list(/obj/item/storage/secure/briefcase) startswith = list( /obj/item/paper = 1, /obj/item/pen = 1 diff --git a/code/game/objects/items/weapons/storage/specialized.dm b/code/game/objects/items/weapons/storage/specialized.dm index 6e945ab835381..8545077f20b82 100644 --- a/code/game/objects/items/weapons/storage/specialized.dm +++ b/code/game/objects/items/weapons/storage/specialized.dm @@ -7,12 +7,11 @@ max_storage_space = 200 max_w_class = ITEM_SIZE_NORMAL w_class = ITEM_SIZE_LARGE - can_hold = list( + contents_allowed = list( /obj/item/ore ) allow_quick_gather = TRUE allow_quick_empty = TRUE - collection_mode = TRUE /obj/item/storage/evidence @@ -23,7 +22,7 @@ max_storage_space = 100 max_w_class = ITEM_SIZE_SMALL w_class = ITEM_SIZE_NORMAL - can_hold = list( + contents_allowed = list( /obj/item/sample, /obj/item/evidencebag, /obj/item/forensics, @@ -33,7 +32,6 @@ ) allow_quick_gather = TRUE allow_quick_empty = TRUE - collection_mode = TRUE /obj/item/storage/plants @@ -45,14 +43,13 @@ max_storage_space = 100 max_w_class = ITEM_SIZE_NORMAL w_class = ITEM_SIZE_NORMAL - can_hold = list( + contents_allowed = list( /obj/item/reagent_containers/food/snacks/grown, /obj/item/seeds, /obj/item/shellfish ) allow_quick_gather = TRUE allow_quick_empty = TRUE - collection_mode = TRUE /obj/item/storage/sheetsnatcher @@ -63,7 +60,6 @@ storage_ui = /datum/storage_ui/default/sheetsnatcher w_class = ITEM_SIZE_NORMAL storage_slots = 7 - collection_mode = TRUE allow_quick_gather = TRUE virtual = TRUE var/max_sheets = 300 diff --git a/code/game/objects/items/weapons/storage/storage.dm b/code/game/objects/items/weapons/storage/storage.dm index 31419ad045cea..b57d6517fe085 100644 --- a/code/game/objects/items/weapons/storage/storage.dm +++ b/code/game/objects/items/weapons/storage/storage.dm @@ -1,44 +1,88 @@ -// To clarify: -// For allow_quick_gather functionality, -// see item/attackby() (/game/objects/items.dm) -// Do not remove this functionality without good reason, cough reagent_containers cough. -// -Sayu - - /obj/item/storage name = "storage" icon = 'icons/obj/boxes.dmi' w_class = ITEM_SIZE_NORMAL - var/list/can_hold = list() //List of objects which this item can store (if set, it can't store anything else) - var/list/cant_hold = list() //List of objects which this item can't store (in effect only if can_hold isn't set) - var/max_w_class = ITEM_SIZE_SMALL //Max size of objects that this object can store (in effect only if can_hold isn't set) - var/max_storage_space = null //Total storage cost of items this can hold. Will be autoset based on storage_slots if left null. - var/storage_slots = null //The number of storage slots in this container. + /** If set, a list of paths this item can hold, disallowing all others. + May be associative, in which case the value is a limit per path. */ + var/list/contents_allowed + + /** If set, a list of paths this item cannot hold, allowing all others. + Ignored when contents_allowed is set. */ + var/list/contents_banned + + /// The largest item size that can be stored. Ignored if contents_allowed is set. + var/max_w_class = ITEM_SIZE_SMALL + + /// The space available in this item. If unset, calculate from storage_slots. + var/max_storage_space + + /// If set, the number of storage slots available. + var/storage_slots + + /// If set, this item can use the empty verb to dump its contents. + var/allow_quick_empty + + /// If set, this item can attempt to collect all items on a turf with a click. + var/allow_quick_gather - var/allow_quick_empty //Set this variable to allow the object to have the 'empty' verb, which dumps all the contents on the floor. - var/allow_quick_gather //Set this variable to allow the object to have the 'toggle mode' verb, which quickly collects all items from a tile. - ///Allows dumping the contents of storage after a duration + /// When quick gathering, falsy collects all valid items, truthy collects only one. + var/quick_gather_single + + ///Allows dumping the contents of storage after a duration. var/allow_slow_dump - var/collection_mode //0 = pick one at a time, 1 = pick all on tile - var/use_sound = "rustle" //sound played when used. null for no sound. - ///If true, will not permit use of the storage UI + /// If set, a sound to play when accessing the storage item's UI. + var/use_sound = "rustle" + + /// If truthy, disallows use of the storage UI. var/virtual - //initializes the contents of the storage with some items based on an assoc list. The assoc key must be an item path, - //the assoc value can either be the quantity, or a list whose first value is the quantity and the rest are args. + /** An optional map of (path = config) to create on initialize. Config may be a count to + create or a sublist of (count, ...args), where args is passed to each new instance */ var/list/startswith + + var/datum/storage_ui/storage_ui = /datum/storage_ui/default - var/opened = null - var/open_sound = null - ///This is to prevent open sound and use sound playing on the same click if you're opening a closed box. - var/open_sound_played = FALSE + /// True when this storage item has been opened. Used by storage/fancy. + var/opened + + /// If set, a sound to play when opening the storage item. + var/open_sound + /obj/item/storage/Destroy() QDEL_NULL(storage_ui) + return ..() + + +/obj/item/storage/Initialize() . = ..() + if (!allow_quick_empty) + verbs -= /obj/item/storage/verb/quick_empty + if (!allow_quick_gather) + verbs -= /obj/item/storage/verb/toggle_gathering_mode + if (!allow_slow_dump) + verbs -= /obj/item/storage/verb/dump_contents + if (isnull(max_storage_space) && !isnull(storage_slots)) + max_storage_space = storage_slots*BASE_STORAGE_COST(max_w_class) + storage_ui = new storage_ui(src) + prepare_ui() + if (length(startswith)) + for (var/item_path in startswith) + var/list/data = startswith[item_path] + if (islist(data)) + var/qty = data[1] + var/list/argsl = data.Copy() + argsl[1] = src + for (var/i in 1 to qty) + new item_path (arglist(argsl)) + else + for (var/i in 1 to data || 1) + new item_path (src) + update_icon() + /obj/item/storage/MouseDrop(obj/over_object as obj) if(!canremove) @@ -100,19 +144,19 @@ /obj/item/storage/proc/open(mob/user as mob) if (virtual) return - if(!opened && src.open_sound) - playsound(src.loc, src.open_sound, 50, 0, -5) - open_sound_played = TRUE + if (!opened) + var/sound = open_sound || use_sound + if (sound) + playsound(src, open_sound, 50, FALSE, -5) to_chat(user, "You open \the [src].") queue_icon_update() - if (src.use_sound && !open_sound_played) - playsound(src.loc, src.use_sound, 50, 0, -5) + opened = TRUE + else if (use_sound) + playsound(src, use_sound, 50, FALSE, -5) if (isrobot(user) && user.hud_used) var/mob/living/silicon/robot/robot = user - if(robot.shown_robot_modules) //The robot's inventory is open, need to close it first. + if (robot.shown_robot_modules) robot.hud_used.toggle_show_robot_modules() - open_sound_played = FALSE - opened = TRUE //Regular boxes don't open and close; need opened set True to once. Fancy boxes do; code handled in _fancy.dm prepare_ui() storage_ui.on_open(user) storage_ui.show_to(user) @@ -152,14 +196,14 @@ if(W.anchored) return 0 - if(length(can_hold)) - if(!is_type_in_list(W, can_hold)) - if(!stop_messages && ! istype(W, /obj/item/hand_labeler)) + if (length(contents_allowed)) + if (!is_type_in_list(W, contents_allowed)) + if (!stop_messages && ! istype(W, /obj/item/hand_labeler)) to_chat(user, SPAN_NOTICE("\The [src] cannot hold \the [W].")) return 0 - var/max_instances = can_hold[W.type] - if(max_instances && instances_of_type_in_list(W, contents) >= max_instances) - if(!stop_messages && !istype(W, /obj/item/hand_labeler)) + var/max_instances = contents_allowed[W.type] + if (max_instances && instances_of_type_in_list(W, contents) >= max_instances) + if (!stop_messages && !istype(W, /obj/item/hand_labeler)) to_chat(user, SPAN_NOTICE("\The [src] has no more space specifically for \the [W].")) return 0 @@ -175,7 +219,7 @@ stop_messages = 1 return 0 - if(length(cant_hold) && is_type_in_list(W, cant_hold)) + if(length(contents_banned) && is_type_in_list(W, contents_banned)) if(!stop_messages) to_chat(user, SPAN_NOTICE("\The [src] cannot hold \the [W].")) return 0 @@ -351,16 +395,16 @@ else to_chat(user, SPAN_NOTICE("You fail to pick anything up with \the [src].")) + /obj/item/storage/verb/toggle_gathering_mode() set name = "Switch Gathering Method" set category = "Object" - - collection_mode = !collection_mode - switch (collection_mode) - if(1) - to_chat(usr, "\The [src] now picks up all items in a tile at once.") - if(0) - to_chat(usr, "\The [src] now picks up one item at a time.") + set src in usr + quick_gather_single = !quick_gather_single + if (quick_gather_single) + to_chat(usr, "\The [src] now picks up one item at a time.") + else + to_chat(usr, "\The [src] now picks up all items in a tile.") /obj/item/storage/proc/DoQuickEmpty() @@ -406,42 +450,6 @@ else to_chat(usr, SPAN_WARNING("You need to be holding \the [src] and have an empty hand to dump its contents!")) -/obj/item/storage/Initialize() - . = ..() - if(allow_quick_empty) - verbs += /obj/item/storage/verb/quick_empty - else - verbs -= /obj/item/storage/verb/quick_empty - - if(allow_quick_gather) - verbs += /obj/item/storage/verb/toggle_gathering_mode - else - verbs -= /obj/item/storage/verb/toggle_gathering_mode - - if (allow_slow_dump) - verbs += /obj/item/storage/verb/dump_contents - else - verbs -= /obj/item/storage/verb/dump_contents - - if(isnull(max_storage_space) && !isnull(storage_slots)) - max_storage_space = storage_slots*BASE_STORAGE_COST(max_w_class) - - storage_ui = new storage_ui(src) - prepare_ui() - - if(startswith) - for(var/item_path in startswith) - var/list/data = startswith[item_path] - if(islist(data)) - var/qty = data[1] - var/list/argsl = data.Copy() - argsl[1] = src - for(var/i in 1 to qty) - new item_path(arglist(argsl)) - else - for(var/i in 1 to (isnull(data)? 1 : data)) - new item_path(src) - update_icon() /obj/item/storage/get_mechanics_info() . = ..() @@ -476,15 +484,15 @@ /obj/item/storage/proc/make_exact_fit() storage_slots = length(contents) - - can_hold.Cut() + contents_allowed = list() max_w_class = 0 max_storage_space = 0 for(var/obj/item/I in src) - can_hold[I.type]++ + contents_allowed[I.type]++ max_w_class = max(I.w_class, max_w_class) max_storage_space += I.get_storage_cost() + /** * Determines the storage depth of an atom. This is the number of storage items (`/obj/item/storage`) the atom is * contained in before reaching `container`. diff --git a/code/game/objects/items/weapons/storage/wallets.dm b/code/game/objects/items/weapons/storage/wallets.dm index f3abb46e71613..eb7c34c6cf78a 100644 --- a/code/game/objects/items/weapons/storage/wallets.dm +++ b/code/game/objects/items/weapons/storage/wallets.dm @@ -8,7 +8,7 @@ max_w_class = ITEM_SIZE_SMALL max_storage_space = ITEM_SIZE_SMALL * 3 slot_flags = SLOT_ID - can_hold = list( + contents_allowed = list( /obj/item/spacecash, /obj/item/card, /obj/item/clothing/mask/smokable, diff --git a/code/game/objects/structures/inflatable.dm b/code/game/objects/structures/inflatable.dm index ace91ab6d8cb5..c2e6a0d0c8762 100644 --- a/code/game/objects/structures/inflatable.dm +++ b/code/game/objects/structures/inflatable.dm @@ -336,5 +336,5 @@ item_state = "case" w_class = ITEM_SIZE_LARGE max_storage_space = DEFAULT_LARGEBOX_STORAGE - can_hold = list(/obj/item/inflatable) + contents_allowed = list(/obj/item/inflatable) startswith = list(/obj/item/inflatable/door = 2, /obj/item/inflatable/wall = 3) diff --git a/code/game/sound.dm b/code/game/sound.dm index 65c967015d1a0..586112b936469 100644 --- a/code/game/sound.dm +++ b/code/game/sound.dm @@ -56,7 +56,8 @@ GLOBAL_LIST_INIT(glasscrack_sound,list('sound/effects/glass_crack1.ogg','sound/e GLOBAL_LIST_INIT(tray_hit_sound,list('sound/items/trayhit1.ogg', 'sound/items/trayhit2.ogg')) /proc/playsound(atom/source, soundin, vol as num, vary, extrarange as num, falloff, is_global, frequency, is_ambiance = 0) - + if (isnull(soundin)) + return soundin = get_sfx(soundin) // same sound for everyone if(isarea(source)) @@ -77,6 +78,8 @@ GLOBAL_LIST_INIT(tray_hit_sound,list('sound/items/trayhit1.ogg', 'sound/items/tr var/global/const/FALLOFF_SOUNDS = 0.5 /mob/proc/playsound_local(turf/turf_source, soundin, vol as num, vary, frequency, falloff, is_global, extrarange) + if (isnull(soundin)) + return if(!src.client || ear_deaf > 0) return var/sound/S = soundin if(!istype(S)) diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index 5b9f7d232dace..59d977372c1d7 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -134,13 +134,16 @@ if(Adjacent(user)) attack_hand(user) -/turf/attackby(obj/item/W as obj, mob/user as mob) - if(istype(W, /obj/item/storage)) - var/obj/item/storage/S = W - if(S.collection_mode) - S.gather_all(src, user) + +/turf/use_tool(obj/item/item, mob/living/user, list/click_params) + if (istype(item, /obj/item/storage)) + var/obj/item/storage/storage = item + if (storage.allow_quick_gather && !storage.quick_gather_single) + storage.gather_all(src, user) + return TRUE return ..() + /turf/Enter(atom/movable/mover as mob|obj, atom/forget as mob|obj|turf|area) ..() diff --git a/code/modules/clothing/under/accessories/storage.dm b/code/modules/clothing/under/accessories/storage.dm index 60bbf371585eb..32c59b8c1961f 100644 --- a/code/modules/clothing/under/accessories/storage.dm +++ b/code/modules/clothing/under/accessories/storage.dm @@ -149,7 +149,7 @@ /obj/item/clothing/accessory/storage/knifeharness/Initialize() . = ..() if (container) - container.can_hold = list( + container.contents_allowed = list( /obj/item/material/hatchet, /obj/item/material/knife ) @@ -168,7 +168,7 @@ /obj/item/clothing/accessory/storage/bandolier/Initialize() . = ..() if (container) - container.can_hold = list( + container.contents_allowed = list( /obj/item/ammo_casing, /obj/item/grenade, /obj/item/material/knife, diff --git a/code/modules/detectivework/tools/crimekit.dm b/code/modules/detectivework/tools/crimekit.dm index 0bbe53b7b2d6a..25a6966f40fc0 100644 --- a/code/modules/detectivework/tools/crimekit.dm +++ b/code/modules/detectivework/tools/crimekit.dm @@ -13,8 +13,8 @@ /obj/item/forensics/sample_kit, /obj/item/forensics/sample_kit/powder, /obj/item/storage/csi_markers - ) - can_hold = list( + ) + contents_allowed = list( /obj/item/storage/box/swabs, /obj/item/storage/box/fingerprints, /obj/item/storage/box/evidence, @@ -40,4 +40,4 @@ /obj/item/device/scanner, /obj/item/modular_computer/tablet, /obj/item/evidencebag - ) + ) diff --git a/code/modules/mining/mine_turfs.dm b/code/modules/mining/mine_turfs.dm index 62e50534077e9..4ed4f2d0d8a23 100644 --- a/code/modules/mining/mine_turfs.dm +++ b/code/modules/mining/mine_turfs.dm @@ -483,20 +483,20 @@ var/global/list/mining_floors = list() else if(istype(W,/obj/item/storage/ore)) var/obj/item/storage/ore/S = W - if(S.collection_mode) + if(!S.quick_gather_single) for(var/obj/item/ore/O in contents) O.attackby(W,user) return else if(istype(W,/obj/item/storage/bag/fossils)) var/obj/item/storage/bag/fossils/S = W - if(S.collection_mode) + if(!S.quick_gather_single) for(var/obj/item/fossil/F in contents) F.attackby(W,user) return else ..(W,user) - return + /turf/simulated/floor/asteroid/proc/gets_dug() diff --git a/code/modules/paperwork/photography.dm b/code/modules/paperwork/photography.dm index c58d50013dd95..5e206f3e329f8 100644 --- a/code/modules/paperwork/photography.dm +++ b/code/modules/paperwork/photography.dm @@ -110,7 +110,7 @@ var/global/photo_count = 0 item_state = "briefcase" w_class = ITEM_SIZE_NORMAL //same as book storage_slots = DEFAULT_BOX_STORAGE //yes, that's storage_slots. Photos are w_class 1 so this has as many slots equal to the number of photos you could put in a box - can_hold = list(/obj/item/photo) + contents_allowed = list(/obj/item/photo) /obj/item/storage/photo_album/MouseDrop(obj/over_object as obj) diff --git a/code/modules/reagents/reagent_containers/drinkingglass/glass_boxes.dm b/code/modules/reagents/reagent_containers/drinkingglass/glass_boxes.dm index b499c27f6d393..285c372d246ef 100644 --- a/code/modules/reagents/reagent_containers/drinkingglass/glass_boxes.dm +++ b/code/modules/reagents/reagent_containers/drinkingglass/glass_boxes.dm @@ -1,7 +1,7 @@ /obj/item/storage/box/mixedglasses name = "glassware box" desc = "A box of assorted glassware." - can_hold = list(/obj/item/reagent_containers/food/drinks/glass2) + contents_allowed = list(/obj/item/reagent_containers/food/drinks/glass2) startswith = list( /obj/item/reagent_containers/food/drinks/glass2/square, @@ -21,7 +21,7 @@ /obj/item/storage/box/glasses name = "box of glasses" var/glass_type = /obj/item/reagent_containers/food/drinks/glass2 - can_hold = list(/obj/item/reagent_containers/food/drinks/glass2) + contents_allowed = list(/obj/item/reagent_containers/food/drinks/glass2) /obj/item/storage/box/glasses/Initialize() . = ..() @@ -65,7 +65,7 @@ /obj/item/storage/box/glass_extras name = "box of cocktail garnishings" var/extra_type = /obj/item/glass_extra - can_hold = list(/obj/item/glass_extra) + contents_allowed = list(/obj/item/glass_extra) storage_slots = 14 /obj/item/storage/box/glass_extras/Initialize() diff --git a/code/modules/reagents/reagent_containers/food/snacks/bugmeat.dm b/code/modules/reagents/reagent_containers/food/snacks/bugmeat.dm index 61379f8003eca..14ab9c8a469f8 100644 --- a/code/modules/reagents/reagent_containers/food/snacks/bugmeat.dm +++ b/code/modules/reagents/reagent_containers/food/snacks/bugmeat.dm @@ -8,7 +8,7 @@ max_w_class = ITEM_SIZE_SMALL w_class = ITEM_SIZE_NORMAL key_type = list(/obj/item/reagent_containers/food/snacks/rawcutlet/bugmeat) - can_hold = list( + contents_allowed = list( /obj/item/reagent_containers/food/snacks/rawcutlet/bugmeat, /obj/item/reagent_containers/food/snacks/cutlet/bugmeat ) diff --git a/code/modules/research/part_replacer.dm b/code/modules/research/part_replacer.dm index a5615b040ef0f..22659c8f76628 100644 --- a/code/modules/research/part_replacer.dm +++ b/code/modules/research/part_replacer.dm @@ -5,11 +5,10 @@ icon_state = "RPED" item_state = "RPED" w_class = ITEM_SIZE_HUGE - can_hold = list(/obj/item/stock_parts) + contents_allowed = list(/obj/item/stock_parts) storage_slots = 50 allow_quick_gather = TRUE allow_quick_empty = TRUE - collection_mode = TRUE max_w_class = ITEM_SIZE_NORMAL max_storage_space = 100 origin_tech = list(TECH_ENGINEERING = 4, TECH_MATERIAL = 3) diff --git a/code/modules/xenoarcheaology/tools/equipment.dm b/code/modules/xenoarcheaology/tools/equipment.dm index 2478cfbae9ec0..54c06b1153cec 100644 --- a/code/modules/xenoarcheaology/tools/equipment.dm +++ b/code/modules/xenoarcheaology/tools/equipment.dm @@ -60,7 +60,7 @@ desc = "Can hold various excavation gear." icon_state = "gearbelt" item_state = ACCESSORY_SLOT_UTILITY - can_hold = list( + contents_allowed = list( /obj/item/storage/box/samplebags, /obj/item/device/core_sampler, /obj/item/pinpointer/radio, diff --git a/code/modules/xenoarcheaology/tools/tools.dm b/code/modules/xenoarcheaology/tools/tools.dm index ea470c71fc729..8d2a4a1dedc79 100644 --- a/code/modules/xenoarcheaology/tools/tools.dm +++ b/code/modules/xenoarcheaology/tools/tools.dm @@ -17,7 +17,7 @@ storage_slots = 50 max_storage_space = 200 max_w_class = ITEM_SIZE_NORMAL - can_hold = list(/obj/item/fossil) + contents_allowed = list(/obj/item/fossil) /obj/item/storage/box/samplebags name = "sample bag box" diff --git a/code/modules/xenoarcheaology/tools/tools_pickaxe.dm b/code/modules/xenoarcheaology/tools/tools_pickaxe.dm index e8cc4856b68e8..028f9f2d259f4 100644 --- a/code/modules/xenoarcheaology/tools/tools_pickaxe.dm +++ b/code/modules/xenoarcheaology/tools/tools_pickaxe.dm @@ -176,12 +176,11 @@ storage_slots = 7 slot_flags = SLOT_BELT w_class = ITEM_SIZE_NORMAL - can_hold = list(/obj/item/pickaxe/xeno) + contents_allowed = list(/obj/item/pickaxe/xeno) max_storage_space = 18 max_w_class = ITEM_SIZE_NORMAL allow_quick_gather = TRUE allow_quick_empty = TRUE - collection_mode = TRUE startswith = list( /obj/item/pickaxe/xeno/brush, /obj/item/pickaxe/xeno/one_pick, diff --git a/maps/away/skrellscoutship/skrellscoutship.dm b/maps/away/skrellscoutship/skrellscoutship.dm index 094c9fd9c345d..630c3dcc6fa8a 100644 --- a/maps/away/skrellscoutship/skrellscoutship.dm +++ b/maps/away/skrellscoutship/skrellscoutship.dm @@ -223,7 +223,7 @@ var/global/const/access_skrellscoutship = "ACCESS_SKRELLSCOUT" item_state = "security" storage_slots = 8 overlay_flags = BELT_OVERLAY_ITEMS|BELT_OVERLAY_HOLSTER - can_hold = list( + contents_allowed = list( /obj/item/crowbar, /obj/item/grenade, /obj/item/reagent_containers/spray/pepper, diff --git a/maps/torch/items/wallets.dm b/maps/torch/items/wallets.dm index 6638e70ec32f7..b96db1ba37f41 100644 --- a/maps/torch/items/wallets.dm +++ b/maps/torch/items/wallets.dm @@ -1,6 +1,6 @@ /obj/item/storage/wallet/Initialize() . = ..() - can_hold |= list( + contents_allowed |= list( /obj/item/clothing/accessory/solgov, /obj/item/clothing/accessory/ribbon ) diff --git a/packs/factions/iccgn/tweaks.dm b/packs/factions/iccgn/tweaks.dm index 8371f17e702ea..37145945f243a 100644 --- a/packs/factions/iccgn/tweaks.dm +++ b/packs/factions/iccgn/tweaks.dm @@ -1,6 +1,6 @@ /obj/item/storage/wallet/Initialize() . = ..() - can_hold |= list( + contents_allowed |= list( /obj/item/clothing/accessory/iccgn_badge, /obj/item/clothing/accessory/iccgn_patch, /obj/item/clothing/accessory/iccgn_rank diff --git a/packs/factions/scga/tweaks.dm b/packs/factions/scga/tweaks.dm index a8e685fb26d18..5a3e49858c725 100644 --- a/packs/factions/scga/tweaks.dm +++ b/packs/factions/scga/tweaks.dm @@ -1,6 +1,6 @@ /obj/item/storage/wallet/Initialize() . = ..() - can_hold |= list( + contents_allowed |= list( /obj/item/clothing/accessory/scga_badge, /obj/item/clothing/accessory/scga_rank ) diff --git a/test/check-paths.sh b/test/check-paths.sh index e5b6f7aa8b412..654580f2b9ca9 100755 --- a/test/check-paths.sh +++ b/test/check-paths.sh @@ -57,7 +57,7 @@ exactly 0 "simulated = 0/1" 'simulated\s*=\s*\d' -P exactly 2 "var/ in proc arguments" '(^/[^/].+/.+?\(.*?)var/' -P exactly 0 "tmp/ vars" 'var.*/tmp/' -P exactly 7 "uses of .len" '\.len\b' -P -exactly 210 "attackby() override" '\/attackby\((.*)\)' -P +exactly 208 "attackby() override" '\/attackby\((.*)\)' -P exactly 15 "uses of examine()" '[.|\s]examine\(' -P # If this fails it's likely because you used '/atom/proc/examine(mob)' instead of '/proc/examinate(mob, atom)' - Exception: An examine()-proc may call other examine()-procs exactly 7 "direct modifications of overlays list" '\boverlays((\s*[|^=+&-])|(\.(Cut)|(Add)|(Copy)|(Remove)|(Remove)))' -P exactly 0 "new/list list instantiations" 'new\s*/list' -P