mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-16 09:34:52 +01:00
Item bank!
It always sucks when you get an item you know you would love to use in a specific scenario, but, for one reason or another, you know that's probably not happening this shift. It would be cool if you could save that thing you found until you know it's time to use it! So I made an item bank. This stores and saves a single item based on your ckey! This is intended to allow people to save an item they know they may want later but have right now. It is not intended to allow one to keep an item forever, or to store multiple items. Ultimately I think the rarity of certain items is a big part of what makes them special! But, if you find it and can't use it right now, it'd be cool if it was there for you when you can use it. Restrictions: -Any item that has been retrieved from storage can not be stored again! (To prevent people from keeping an item forever.) -One can only store any item one time per shift! (To prevent abusing possible contents of items.) -Certain items cannot be stored! (See: ID cards, pdas, communicators, radios (and their keys), holders (micros, pets, etc), most storage items, unique items, certain weapons, etc) This system stores the item type, so any modifications to the item will not be saved, it will be as if the item is new (because it is). This means that it will be possible to duplicate the contents of things that spawn with contents. I have thought some about what things this might be a concern for, but there will invariably be things that remain that this will be possible for. If it becomes a problem, it is always possible to apply further restrictions. (this is why most storage items are disallowed. Like, any medkit or gun case or things like that, would be able to duplicate their contents if they were able to be stored, and I feel like this is a better solution than making it so you cannot store something and retrieve something in the same shift.)
This commit is contained in:
@@ -0,0 +1,217 @@
|
||||
/obj/machinery/item_bank
|
||||
name = "electronic lockbox"
|
||||
desc = "A place to store things you might want later!"
|
||||
icon = 'icons/obj/stationobjs_vr.dmi'
|
||||
icon_state = "item_bank"
|
||||
idle_power_usage = 1
|
||||
active_power_usage = 5
|
||||
anchored = TRUE
|
||||
density = FALSE
|
||||
var/busy_bank = FALSE
|
||||
var/static/list/item_takers = list()
|
||||
|
||||
/obj/machinery/item_bank/proc/persist_item_savefile_path(mob/user)
|
||||
return "data/player_saves/[copytext(user.ckey, 1, 2)]/[user.ckey]/persist_item.sav"
|
||||
|
||||
/obj/machinery/item_bank/proc/persist_item_savefile_save(mob/user, obj/item/O)
|
||||
if(IsGuestKey(user.key))
|
||||
return 0
|
||||
|
||||
var/savefile/F = new /savefile(src.persist_item_savefile_path(user))
|
||||
|
||||
F["persist item"] << O.type
|
||||
F["persist name"] << initial(O.name)
|
||||
|
||||
return 1
|
||||
|
||||
// loads the savefile corresponding to the mob's ckey
|
||||
// if silent=true, report incompatible savefiles
|
||||
// returns 1 if loaded (or file was incompatible)
|
||||
// returns 0 if savefile did not exist
|
||||
|
||||
/obj/machinery/item_bank/proc/persist_item_savefile_load(mob/user, thing)
|
||||
if (IsGuestKey(user.key))
|
||||
return 0
|
||||
|
||||
var/path = src.persist_item_savefile_path(user)
|
||||
|
||||
if (!fexists(path))
|
||||
return 0
|
||||
|
||||
var/savefile/F = new /savefile(path)
|
||||
|
||||
if(!F) return 0
|
||||
|
||||
var/persist_item
|
||||
F["persist item"] >> persist_item
|
||||
|
||||
if (isnull(persist_item) || !ispath(persist_item))
|
||||
fdel(path)
|
||||
tgui_alert_async(user, "An item could not be retrieved.")
|
||||
return 0
|
||||
if(thing == "type")
|
||||
return persist_item
|
||||
if(thing == "name")
|
||||
var/persist_name
|
||||
F["persist name"] >> persist_name
|
||||
return persist_name
|
||||
|
||||
|
||||
/obj/machinery/item_bank/Initialize()
|
||||
. = ..()
|
||||
|
||||
/obj/machinery/item_bank/attack_hand(mob/living/user)
|
||||
. = ..()
|
||||
if(!ishuman(user))
|
||||
return
|
||||
if(istype(user) && Adjacent(user))
|
||||
if(inoperable() || panel_open)
|
||||
to_chat(user, "<span class='warning'>\The [src] seems to be nonfunctional...</span>")
|
||||
else
|
||||
start_using(user)
|
||||
|
||||
/obj/machinery/item_bank/proc/start_using(mob/living/user)
|
||||
if(!ishuman(user))
|
||||
return
|
||||
if(busy_bank)
|
||||
to_chat(user, "<span class='warning'>\The [src] is already in use.</span>")
|
||||
return
|
||||
if(user.ckey in item_takers)
|
||||
to_chat(user, "<span class='warning'>You have already taken something out of \the [src] this shift.</span>")
|
||||
return
|
||||
busy_bank = TRUE
|
||||
var/I = persist_item_savefile_load(user, "type")
|
||||
var/Iname = persist_item_savefile_load(user, "name")
|
||||
var/choice = tgui_alert(user, "What would you like to do [src]?", "[src]", list("Check contents", "Retrieve item", "Info", "Cancel"), timeout = 10 SECONDS)
|
||||
if(!choice || choice == "Cancel" || !Adjacent(user) || inoperable() || panel_open)
|
||||
busy_bank = FALSE
|
||||
return
|
||||
else if(choice == "Check contents" && I)
|
||||
to_chat(user, "<span class='notice'>\The [src] has \the [Iname] for you!</span>")
|
||||
busy_bank = FALSE
|
||||
else if(choice == "Retrieve item" && I)
|
||||
if(user.hands_are_full())
|
||||
to_chat(user,"<span class='notice'>Your hands are full!</span>")
|
||||
busy_bank = FALSE
|
||||
return
|
||||
choice = tgui_alert(user, "If you remove this item from the bank, it will be unable to be stored again. Do you still want to remove it?", "[src]", list("No", "Yes"), timeout = 10 SECONDS)
|
||||
icon_state = "item_bank_o"
|
||||
if(!choice || choice == "Cancel" || !Adjacent(user) || inoperable() || panel_open)
|
||||
busy_bank = FALSE
|
||||
icon_state = "item_bank"
|
||||
return
|
||||
else if(!do_after(user, 10 SECONDS, src, exclusive = TASK_ALL_EXCLUSIVE) || inoperable())
|
||||
busy_bank = FALSE
|
||||
icon_state = "item_bank"
|
||||
return
|
||||
var/obj/N = new I(get_turf(src))
|
||||
visible_message("<span class='notice'>\The [src] dispenses the [N] to \the [user].</span>")
|
||||
user.put_in_hands(N)
|
||||
N.persist_storable = FALSE
|
||||
var/path = src.persist_item_savefile_path(user)
|
||||
var/savefile/F = new /savefile(src.persist_item_savefile_path(user))
|
||||
F["persist item"] << null
|
||||
F["persist name"] << null
|
||||
fdel(path)
|
||||
item_takers += user.ckey
|
||||
busy_bank = FALSE
|
||||
icon_state = "item_bank"
|
||||
else if(choice == "Info")
|
||||
to_chat(user, "<span class='notice'>\The [src] can store a single item for you between shifts! Anything that has been retrieved from the bank cannot be stored again in the same shift. Anyone can withdraw from the bank one time per shift. Some items are not able to be accepted by the bank.</span>")
|
||||
busy_bank = FALSE
|
||||
return
|
||||
else if(!I)
|
||||
to_chat(user, "<span class='warning'>\The [src] doesn't seem to have anything for you...</span>")
|
||||
busy_bank = FALSE
|
||||
|
||||
/obj/machinery/item_bank/attackby(obj/item/O, mob/living/user)
|
||||
if(!ishuman(user))
|
||||
return
|
||||
if(busy_bank)
|
||||
to_chat(user, "<span class='warning'>\The [src] is already in use.</span>")
|
||||
return
|
||||
busy_bank = TRUE
|
||||
if(!istool(O) && O.persist_storable)
|
||||
user.visible_message("<span class='notice'>\The [user] begins storing \the [O] in \the [src].</span>","<span class='notice'>You begin storing \the [O] in \the [src].</span>")
|
||||
icon_state = "item_bank_o"
|
||||
if(!do_after(user, 10 SECONDS, src, exclusive = TASK_ALL_EXCLUSIVE) || inoperable())
|
||||
busy_bank = FALSE
|
||||
icon_state = "item_bank"
|
||||
return
|
||||
src.persist_item_savefile_save(user, O)
|
||||
user.visible_message("<span class='notice'>\The [user] stores \the [O] in \the [src].</span>","<span class='notice'>You stored \the [O] in \the [src].</span>")
|
||||
log_admin("[key_name_admin(user)] stored [O] in the item bank.")
|
||||
qdel(O)
|
||||
busy_bank = FALSE
|
||||
icon_state = "item_bank"
|
||||
else
|
||||
to_chat(user, "<span class='warning'>You cannot store \the [O]. \The [src] either does not accept that, or it has already been retrieved from storage this shift.</span>")
|
||||
busy_bank = FALSE
|
||||
|
||||
/////STORABLE ITEMS AND ALL THAT JAZZ/////
|
||||
//I am only really intending this to be used for single items. Mostly stuff you got right now, but can't/don't want to use right now.
|
||||
//It is not at all intended to be a thing that just lets you hold on to stuff forever, but just until it's the right time to use it.
|
||||
|
||||
/obj
|
||||
|
||||
var/persist_storable = TRUE //If this is true, this item can be stored in the item bank.
|
||||
//This is automatically set to false when an item is removed from storage
|
||||
|
||||
/////LIST OF STUFF WE DON'T WANT PEOPLE STORING/////
|
||||
|
||||
/obj/item/device/pda
|
||||
persist_storable = FALSE
|
||||
/obj/item/device/communicator
|
||||
persist_storable = FALSE
|
||||
/obj/item/weapon/card
|
||||
persist_storable = FALSE
|
||||
/obj/item/weapon/holder
|
||||
persist_storable = FALSE
|
||||
/obj/item/device/radio
|
||||
persist_storable = FALSE
|
||||
/obj/item/device/encryptionkey
|
||||
persist_storable = FALSE
|
||||
/obj/item/weapon/storage //There are lots of things that have stuff that we may not want people to just have. And this is mostly intended for a single thing.
|
||||
persist_storable = FALSE //And it would be annoying to go through and consider all of them, so default to disabled.
|
||||
/obj/item/weapon/storage/backpack //But we can enable some where it makes sense. Backpacks and their variants basically never start with anything in them, as an example.
|
||||
persist_storable = TRUE
|
||||
/obj/item/weapon/reagent_containers/hypospray/vial
|
||||
persist_storable = FALSE
|
||||
/obj/item/weapon/cmo_disk_holder
|
||||
persist_storable = FALSE
|
||||
/obj/item/device/defib_kit/compact/combat
|
||||
persist_storable = FALSE
|
||||
/obj/item/clothing/glasses/welding/superior
|
||||
persist_storable = FALSE
|
||||
/obj/item/clothing/shoes/magboots/adv
|
||||
persist_storable = FALSE
|
||||
/obj/item/weapon/rig
|
||||
persist_storable = FALSE
|
||||
/obj/item/clothing/head/helmet/space/void
|
||||
persist_storable = FALSE
|
||||
/obj/item/clothing/suit/space/void
|
||||
persist_storable = FALSE
|
||||
/obj/item/weapon/grab
|
||||
persist_storable = FALSE
|
||||
/obj/item/weapon/grenade
|
||||
persist_storable = FALSE
|
||||
/obj/item/weapon/hand_tele
|
||||
persist_storable = FALSE
|
||||
/obj/item/weapon/paper/dockingcodes
|
||||
persist_storable = FALSE
|
||||
/obj/item/weapon/backup_implanter
|
||||
persist_storable = FALSE
|
||||
/obj/item/weapon/disk/nuclear
|
||||
persist_storable = FALSE
|
||||
/obj/item/weapon/gun/energy/locked //These are guns with security measures on them, so let's say the box won't let you put them in there.
|
||||
persist_storable = FALSE //(otherwise explo will just put their locker/vendor guns into it every round)
|
||||
/obj/item/device/retail_scanner
|
||||
persist_storable = FALSE
|
||||
/obj/item/weapon/telecube
|
||||
persist_storable = FALSE
|
||||
/obj/item/weapon/reagent_containers/glass/bottle/adminordrazine
|
||||
persist_storable = FALSE
|
||||
/obj/item/weapon/gun/energy/sizegun/admin
|
||||
persist_storable = FALSE
|
||||
/obj/item/weapon/gun/energy/sizegun/abductor
|
||||
persist_storable = FALSE
|
||||
Reference in New Issue
Block a user