Merge pull request #6472 from mwerezak/evidence-bags

Fixes Evidence Bags
This commit is contained in:
Chinsky
2014-09-21 23:15:36 +04:00
2 changed files with 51 additions and 22 deletions

View File

@@ -7,14 +7,39 @@
icon_state = "evidenceobj"
item_state = ""
w_class = 2
var/obj/item/stored_item = null
/obj/item/weapon/evidencebag/afterattack(obj/item/I, mob/user as mob, proximity)
if(!proximity) return
if(!in_range(I, user))
/obj/item/weapon/evidencebag/MouseDrop(var/obj/item/I as obj)
if (!ishuman(usr))
return
if(!istype(I) || I.anchored == 1)
return ..()
var/mob/living/carbon/human/user = usr
if (!(user.l_hand == src || user.r_hand == src))
return //bag must be in your hands to use
if (isturf(I.loc))
if (!user.Adjacent(I))
return
else
//If it isn't on the floor. Do some checks to see if it's in our hands or a box. Otherwise give up.
if(istype(I.loc,/obj/item/weapon/storage)) //in a container.
var/sdepth = I.storage_depth(user)
if (sdepth == -1 || sdepth > 1)
return //too deeply nested to access
var/obj/item/weapon/storage/U = I.loc
user.client.screen -= I
U.contents.Remove(I)
else if(user.l_hand == I) //in a hand
user.drop_l_hand()
else if(user.r_hand == I) //in a hand
user.drop_r_hand()
else
return
if(!istype(I) || I.anchored)
return
if(istype(I, /obj/item/weapon/evidencebag))
user << "<span class='notice'>You find putting an evidence bag in another evidence bag to be slightly absurd.</span>"
@@ -26,19 +51,7 @@
if(contents.len)
user << "<span class='notice'>[src] already has something inside it.</span>"
return ..()
if(!isturf(I.loc)) //If it isn't on the floor. Do some checks to see if it's in our hands or a box. Otherwise give up.
if(istype(I.loc,/obj/item/weapon/storage)) //in a container.
var/obj/item/weapon/storage/U = I.loc
user.client.screen -= I
U.contents.Remove(I)
else if(user.l_hand == I) //in a hand
user.drop_l_hand()
else if(user.r_hand == I) //in a hand
user.drop_r_hand()
else
return
return
user.visible_message("[user] puts [I] into [src]", "You put [I] inside [src].",\
"You hear a rustle as someone puts something into a plastic bag.")
@@ -55,28 +68,35 @@
overlays += img
overlays += "evidence" //should look nicer for transparent stuff. not really that important, but hey.
desc = "An evidence bag containing [I]. [I.desc]"
desc = "An evidence bag containing [I]."
I.loc = src
stored_item = I
w_class = I.w_class
return
/obj/item/weapon/evidencebag/attack_self(mob/user as mob)
if(contents.len)
var/obj/item/I = contents[1]
var/obj/item/I = stored_item
user.visible_message("[user] takes [I] out of [src]", "You take [I] out of [src].",\
"You hear someone rustle around in a plastic bag, and remove something.")
overlays.Cut() //remove the overlays
user.put_in_hands(I)
w_class = 1
stored_item = null
w_class = initial(w_class)
icon_state = "evidenceobj"
desc = "An empty evidence bag."
else
user << "[src] is empty."
icon_state = "evidenceobj"
return
/obj/item/weapon/evidencebag/examine()
..()
if (stored_item) stored_item.examine()
/obj/item/weapon/storage/box/evidence
name = "evidence bag box"
desc = "A box claiming to contain evidence bags."