Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Soulifies Backpacks & Duffels #3865

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
8 changes: 4 additions & 4 deletions code/__DEFINES/storage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ GLOBAL_LIST_INIT(default_weight_class_to_volume, list(
//
#define MAX_WEIGHT_CLASS_S_CONTAINER WEIGHT_CLASS_SMALL
#define MAX_WEIGHT_CLASS_M_CONTAINER WEIGHT_CLASS_NORMAL
#define MAX_WEIGHT_CLASS_BACKPACK WEIGHT_CLASS_NORMAL
#define MAX_WEIGHT_CLASS_BACKPACK WEIGHT_CLASS_BULKY
#define MAX_WEIGHT_CLASS_DUFFEL WEIGHT_CLASS_BULKY

// max_volume for storages
#define STORAGE_VOLUME_CONTAINER_S DEFAULT_VOLUME_NORMAL //4 small items
#define STORAGE_VOLUME_CONTAINER_M (DEFAULT_VOLUME_NORMAL * 2) //8 small items
#define STORAGE_VOLUME_SATCHEL (DEFAULT_VOLUME_NORMAL * 4) //4 normal items
#define STORAGE_VOLUME_BACKPACK (DEFAULT_VOLUME_NORMAL * 6) //1.5x satchel, 3 bulky items
#define STORAGE_VOLUME_DUFFLEBAG (DEFAULT_VOLUME_NORMAL * 8) // 2 huge items, or 4 bulky items
#define STORAGE_VOLUME_BAG_OF_HOLDING (DEFAULT_VOLUME_NORMAL * 9) //1.5X backpack
#define STORAGE_VOLUME_BACKPACK (DEFAULT_VOLUME_NORMAL * 6) //1.5x satchel, 4 bulky items
#define STORAGE_VOLUME_DUFFLEBAG (DEFAULT_VOLUME_NORMAL * 12) //2X backpack, 6 bulky items
#define STORAGE_VOLUME_BAG_OF_HOLDING (DEFAULT_VOLUME_NORMAL * 9) //1.5x backpack

//Whitelist for the suit storage slot on medical suits
#define MEDICAL_SUIT_ALLOWED_ITEMS list( \
Expand Down
42 changes: 39 additions & 3 deletions code/datums/components/storage/storage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
var/list/mob/is_using //lazy list of mobs looking at the contents of this storage.

var/locked = FALSE //when locked nothing can see inside or use it.
var/locked_flavor = "locked" //prevents tochat messages related to locked from sending
var/locked_flavor = "seems to be locked!" //prevents tochat messages related to locked from sending

/// If the storage object can be accessed while equipped to slot by mob(e.g. backpack in back slot)
var/worn_access = TRUE
/// If the storage object can be accessed while being held anywhere on a mob
var/carry_access = TRUE

/// Storage flags, including what kinds of limiters we use for how many items we can hold
var/storage_flags = STORAGE_FLAGS_LEGACY_DEFAULT
Expand Down Expand Up @@ -222,7 +227,7 @@
SIGNAL_HANDLER

if(locked)
to_chat(M, "<span class='warning'>[parent] seems to be [locked_flavor]!</span>")
to_chat(M, "<span class='warning'>[parent] [locked_flavor]</span>")
return FALSE
if((M.get_active_held_item() == parent) && allow_quick_empty)
INVOKE_ASYNC(src, PROC_REF(quick_empty), M)
Expand All @@ -233,8 +238,10 @@
if(!isitem(O) || !click_gather || SEND_SIGNAL(O, COMSIG_CONTAINS_STORAGE))
return FALSE
. = COMPONENT_NO_ATTACK
if(!access_check())
return FALSE
if(locked)
to_chat(M, "<span class='warning'>[parent] seems to be [locked_flavor]!</span>")
to_chat(M, "<span class='warning'>[parent] [locked_flavor]</span>")
return FALSE
var/obj/item/I = O
if(collection_mode == COLLECT_ONE)
Expand Down Expand Up @@ -309,6 +316,8 @@
var/atom/A = parent
if(!M.canUseStorage() || !A.Adjacent(M) || M.incapacitated())
return
if(!access_check())
return FALSE
if(locked)
to_chat(M, "<span class='warning'>[parent] seems to be [locked_flavor]!</span>")
return FALSE
Expand Down Expand Up @@ -426,6 +435,8 @@
var/atom/A = parent
var/atom/dump_destination = dest_object.get_dumping_location()
if(M.CanReach(A) && dump_destination && M.CanReach(dump_destination))
if(!access_check())
return FALSE
if(locked)
to_chat(M, "<span class='warning'>[parent] seems to be [locked_flavor]!</span>")
return FALSE
Expand Down Expand Up @@ -530,6 +541,8 @@
if(locked && !force)
to_chat(M, "<span class='warning'>[parent] seems to be [locked_flavor]!</span>")
return FALSE
if(!access_check())
return FALSE
if(force || M.CanReach(parent, view_only = TRUE))
if(use_sound && !silent)
playsound(A, use_sound, 50, TRUE, -5)
Expand Down Expand Up @@ -557,6 +570,8 @@
var/atom/host = parent
if(real_location == I.loc)
return FALSE //Means the item is already in the storage item
if(!access_check())
return FALSE
if(locked)
if(M && !stop_messages)
host.add_fingerprint(M)
Expand Down Expand Up @@ -755,6 +770,8 @@

if(A.loc == user)
. = COMPONENT_NO_ATTACK_HAND
if(!access_check())
return FALSE
if(locked)
to_chat(user, "<span class='warning'>[parent] seems to be [locked_flavor]!</span>")
else
Expand Down Expand Up @@ -794,6 +811,8 @@
/datum/component/storage/proc/on_alt_click_async(datum/source, mob/user)
if(!isliving(user) || !user.CanReach(parent) || user.incapacitated())
return
if(!access_check())
return FALSE
if(locked)
to_chat(user, "<span class='warning'>[parent] seems to be [locked_flavor]!</span>")
return
Expand Down Expand Up @@ -833,3 +852,20 @@
//Gets our max volume
/datum/component/storage/proc/get_max_volume()
return max_volume || AUTO_SCALE_STORAGE_VOLUME(max_w_class, max_combined_w_class)

//checks for mob-related storage access conditions
/datum/component/storage/proc/access_check(message = TRUE)
var/atom/ourparent = parent
if(ismob(ourparent.loc))
var/mob/holder = ourparent.loc

if(!carry_access)
if(message)
to_chat(holder, span_warning( "[ourparent] is too cumbersome to open inhand, you're going to have to set it down!"))
return FALSE

if(!worn_access && !holder.held_items.Find(ourparent))
if(message)
to_chat(holder, span_warning( "Your arms aren't long enough to reach [ourparent] while it's on your back!"))
return FALSE
return TRUE
2 changes: 2 additions & 0 deletions code/game/objects/items/storage/backpack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
STR.max_volume = STORAGE_VOLUME_BACKPACK
STR.max_w_class = MAX_WEIGHT_CLASS_BACKPACK
STR.use_sound = 'sound/items/storage/unzip.ogg'
STR.worn_access = FALSE
Sun-Soaked marked this conversation as resolved.
Show resolved Hide resolved

/*
* Backpack Types
Expand Down Expand Up @@ -396,6 +397,7 @@
STR.max_w_class = MAX_WEIGHT_CLASS_DUFFEL
LAZYINITLIST(STR.exception_hold) // This code allows you to fit one mob holder into a duffel bag
STR.exception_hold += typecacheof(/obj/item/clothing/head/mob_holder)
STR.carry_access = FALSE

/obj/item/storage/backpack/duffelbag/captain
name = "captain's duffel bag"
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/storage/ration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/obj/item/reagent_containers/food,
/obj/item/ration_heater))
STR.locked = TRUE
STR.locked_flavor = "sealed closed"
STR.locked_flavor = "seems to be sealed closed!"

/obj/item/storage/ration/proc/open_ration(mob/user)
to_chat(user, "<span class='notice'>You tear open \the [src].</span>")
Expand Down
Loading