Fixed internal storage, added coat pockets

/mob/proc/ClickOn() now checks storage levels, not just contents levels,
now allows items to be taken out of internal storage attached to another
item.
Coats now use internal storage for their pocket slots, removed duplicate
storage code.
Moved coat.dm out of it's special folder and into modules/clothing.
This commit is contained in:
Mike
2014-04-29 19:00:36 -04:00
parent 74009f8332
commit 172bda548e
7 changed files with 60 additions and 245 deletions
@@ -1,4 +1,5 @@
//A storage item intended to be used by other items to provide storage functionality.
//Types that use this should consider overriding emp_act() and hear_talk(), unless they shield their contents somehow.
/obj/item/weapon/storage/internal
var/obj/item/master_item
@@ -18,26 +19,30 @@
//Helper procs to cleanly implement internal storages - storage items that provide inventory slots for other items.
//These procs are completely optional, it is up to the master item to decide when it's storage get's opened by calling open()
//However they are helpful for allowing the master item to pretend it is a storage item itself.
//Mostly just copypasta'd from /obj/item/weapon/storage. Not sure how else to do it.
//Mostly just copypasta'd from /obj/item/weapon/storage. Not sure how else to do it, other than moving all of this into storage.dm
//If you are using these you will probably want to override attackby() as well.
//See /obj/item/clothing/suit/storage for an example.
//items that use internal storage have the option of calling this to emulate default storage MouseDrop behaviour.
//returns 1 if the master item's parent's MouseDrop() should be called, 0 otherwise. It's strange, but no other way of
//doing it without the ability to call another proc's parent, really.
/obj/item/weapon/storage/internal/proc/handle_mousedrop(mob/user as mob, obj/over_object as obj)
if (ishuman(user) || ismonkey(user)) //so monkeys can take off their backpacks -- Urist
if (istype(user.loc,/obj/mecha)) // stops inventory actions in a mech
return
return 0
if(over_object == user && Adjacent(user)) // this must come before the screen objects only block
src.open(user)
return
return 0
if (!( istype(over_object, /obj/screen) ))
return ..()
return 1
//makes sure master_item is equipped before putting it in hand, so that we can't drag it into our hand from miles away.
//there's got to be a better way of doing this...
if (!(master_item.loc == user) || (master_item.loc && master_item.loc.loc == user))
return
return 0
if (!( user.restrained() ) && !( user.stat ))
switch(over_object.name)
@@ -48,12 +53,12 @@
user.u_equip(master_item)
user.put_in_l_hand(master_item)
master_item.add_fingerprint(user)
return
return
return 0
return 0
//items that use internal storage have the option of calling this to emulate default storage attack_hand behaviour.
//returns 1 if the master item's parent's attack_hand() should be called, 0 otherwise.
//Strange, but no other way of doing it without the ability to call another proc's parent, really.
//It's strange, but no other way of doing it without the ability to call another proc's parent, really.
/obj/item/weapon/storage/internal/proc/handle_attack_hand(mob/user as mob)
if(ishuman(user))
@@ -72,7 +77,7 @@
src.open(user)
return 0
for(var/mob/M in range(1))
for(var/mob/M in range(1, master_item.loc))
if (M.s_active == src)
src.close(M)
return 1
@@ -454,4 +454,15 @@
var/obj/O = A
O.hear_talk(M, text)
//Returns the storage depth of an atom. This is the number of storage items the atom is contained in before reaching toplevel (the area).
//If user is specified, this proc returns the storage depth to the user's contents.
/atom/proc/storage_depth(mob/user=null)
var/depth = 0
var/atom/cur_atom = src
while (cur_atom && !isarea(cur_atom) && (!(user) || !(cur_atom in user.contents)))
if (istype(cur_atom.loc, /obj/item/weapon/storage))
depth++
cur_atom = cur_atom.loc
return depth