Erthilo
2012-05-21 20:29:35 +01:00
parent 7894a7e0ef
commit c84aa96cc4
22 changed files with 876 additions and 611 deletions
+164 -224
View File
@@ -1,221 +1,11 @@
/obj/item/clothing/suit/storage
var/obj/screen/storage/boxes
var/obj/screen/close/closer
var/obj/slot1
var/obj/slot2
/obj/item/clothing/suit/storage/New()
src.boxes = new /obj/screen/storage( )
src.boxes.name = "storage"
src.boxes.master = src
src.boxes.icon_state = "block"
src.boxes.screen_loc = "7,7 to 9,7"
src.boxes.layer = 19
src.closer = new /obj/screen/close( )
src.closer.master = src
src.closer.icon_state = "x"
src.closer.layer = 20
src.closer.screen_loc = "9,7"
/obj/item/clothing/suit/storage/proc/view_inv(mob/user as mob)
if(!user.client)
return
user.client.screen += src.boxes
user.client.screen += src.closer
user.client.screen += src.contents
/obj/item/clothing/suit/storage/proc/close(mob/user as mob)
if(!user.client)
return
user.client.screen -= src.boxes
user.client.screen -= src.closer
user.client.screen -= src.contents
/obj/item/clothing/suit/storage/MouseDrop(atom/over_object)
if(ishuman(usr))
var/mob/living/carbon/human/M = usr
if (!( istype(over_object, /obj/screen) ))
return ..()
playsound(src.loc, "rustle", 50, 1, -5)
if ((!( M.restrained() ) && !( M.stat ) && M.wear_suit == src))
if (over_object.name == "r_hand")
if (!( M.r_hand ))
M.u_equip(src)
M.r_hand = src
else
if (over_object.name == "l_hand")
if (!( M.l_hand ))
M.u_equip(src)
M.l_hand = src
M.update_clothing()
src.add_fingerprint(usr)
return
if(over_object == usr && in_range(src, usr) || usr.contents.Find(src))
src.view_inv(M)
src.orient_objs(7,7,9,7)
return
return
/obj/item/clothing/suit/storage/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(W.w_class > 2 || src.loc == W )
return
if(istype(W,/obj/item/weapon/evidencebag) && src.loc != user)
return
if(src.contents.len >= 2)
user << "\red There's nowhere to place that!"
return
user.u_equip(W)
W.loc = src
if ((user.client && user.s_active != src))
user.client.screen -= W
else if(user.s_active == src)
close(user)
view_inv(user)
orient2hud(user)
W.dropped(user)
/obj/item/clothing/suit/storage/attack_paw(mob/user as mob)
playsound(src.loc, "rustle", 50, 1, -5)
return attack_hand(user)
/obj/item/clothing/suit/storage/attack_hand(mob/user as mob)
playsound(src.loc, "rustle", 50, 1, -5)
if (src.loc == user)
if (user.s_active)
user.s_active.close(user)
src.show_to(user)
else
..()
for(var/mob/M in range(1))
if (M.s_active == src)
src.close(M)
src.orient2hud(user)
src.add_fingerprint(user)
return
/obj/item/clothing/suit/storage/proc/orient2hud(mob/user as mob)
if (src == user.l_hand)
src.orient_objs(3, 4, 3, 3)
else if (src == user.r_hand)
src.orient_objs(1, 4, 1, 3)
else if (istype(user,/mob/living/carbon/human) && src == user:wear_suit)
src.orient_objs(1, 3, 2, 3)
else
src.orient_objs(4, 3, 4, 2)
return
/obj/item/clothing/suit/storage/proc/orient_objs(tx, ty, mx, my)
var/cx = tx
var/cy = ty
src.boxes.screen_loc = "[tx],[ty] to [mx],[my]"
for(var/obj/O in src.contents)
O.screen_loc = "[cx],[cy]"
O.layer = 20
cx++
if (cx > mx)
cx = tx
cy--
src.closer.screen_loc = "[mx+1],[my]"
return
/obj/item/clothing/suit/storage/proc/show_to(mob/user as mob)
for(var/obj/item/weapon/mousetrap/MT in src)
if(MT.armed)
for(var/mob/O in viewers(user, null))
if(O == user)
user.show_message(text("\red <B>You reach into the [src.name], but there was a live mousetrap in there!</B>"), 1)
else
user.show_message(text("\red <B>[user] reaches into the [src.name] and sets off a hidden mousetrap!</B>"), 1)
MT.loc = user.loc
MT.triggered(user, user.hand ? "l_hand" : "r_hand")
MT.layer = OBJ_LAYER
return
user.client.screen -= src.boxes
user.client.screen -= src.closer
user.client.screen -= src.contents
user.client.screen += src.boxes
user.client.screen += src.closer
user.client.screen += src.contents
user.s_active = src
return
/*/obj/item/clothing/suit/storage/New()
src.boxes = new /obj/screen/storage( )
src.boxes.name = "storage"
src.boxes.master = src
src.boxes.icon_state = "block"
src.boxes.screen_loc = "7,7 to 10,8"
src.boxes.layer = 19
src.closer = new /obj/screen/close( )
src.closer.master = src
src.closer.icon_state = "x"
src.closer.layer = 20
spawn( 5 )
src.orient_objs(7, 8, 10, 7)
return
return
/obj/item/clothing/suit/storage/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(can_hold.len)
var/ok = 0
for(var/A in can_hold)
if(istype(W, text2path(A) )) ok = 1
if(!ok)
user << "\red This container cannot hold [W]."
return
if (src.contents.len >= 7)
return
if ((W.w_class >= 3 || istype(W, /obj/item/weapon/storage) || src.loc == W))
return
user.u_equip(W)
W.loc = src
if ((user.client && user.s_active != src))
user.client.screen -= W
src.orient2hud(user)
W.dropped(user)
add_fingerprint(user)
if (istype(W, /obj/item/weapon/gun/energy/crossbow)) return //STEALTHY
for(var/mob/O in viewers(user, null))
O.show_message(text("\blue [] has added [] to []!", user, W, src), 1)
//Foreach goto(139)
return
/obj/item/clothing/suit/storage/dropped(mob/user as mob)
src.orient_objs(7, 8, 10, 7)
return
/obj/item/clothing/suit/storage/MouseDrop(over_object, src_location, over_location)
..()
if ((over_object == usr && (in_range(src, usr) || usr.contents.Find(src))))
if (usr.s_active)
usr.s_active.close(usr)
src.show_to(usr)
return
/obj/item/clothing/suit/storage/attack_paw(mob/user as mob)
playsound(src.loc, "rustle", 50, 1, -5)
return src.attack_hand(user)
return
/obj/item/clothing/suit/storage/attack_hand(mob/user as mob)
playsound(src.loc, "rustle", 50, 1, -5)
if (src.loc == user)
if (user.s_active)
user.s_active.close(user)
src.show_to(user)
else
..()
for(var/mob/M in range(1))
if (M.s_active == src)
src.close(M)
//Foreach goto(76)
src.orient2hud(user)
src.add_fingerprint(user)
return
var/list/can_hold = new/list() //List of objects which this item can store (if set, it can't store anything else)
var/list/cant_hold = new/list() //List of objects which this item can't store (in effect only if can_hold isn't set)
var/max_w_class = 2 //Max size of objects that this object can store (in effect only if can_hold isn't set)
var/max_combined_w_class = 4 //The sum of the w_classes of all the items in this storage item.
var/storage_slots = 2 //The number of storage slots in this container.
var/obj/screen/storage/boxes = null
var/obj/screen/close/closer = null
/obj/item/clothing/suit/storage/proc/return_inv()
@@ -267,19 +57,169 @@
user.s_active = null
return
/obj/item/weapon/storage/proc/orient_objs(tx, ty, mx, my)
//This proc draws out the inventory and places the items on it. tx and ty are the upper left tile and mx, my are the bottm right.
//The numbers are calculated from the bottom-left The bottom-left slot being 1,1.
/obj/item/clothing/suit/storage/proc/orient_objs(tx, ty, mx, my)
var/cx = tx
var/cy = ty
src.boxes.screen_loc = text("[],[] to [],[]", tx, ty, mx, my)
src.boxes.screen_loc = text("[tx]:,[ty] to [mx],[my]")
for(var/obj/O in src.contents)
O.screen_loc = text("[],[]", cx, cy)
O.screen_loc = text("[cx],[cy]")
O.layer = 20
cx++
if (cx > mx)
cx = tx
cy--
//Foreach goto(56)
src.closer.screen_loc = text("[],[]", mx, my)
src.closer.screen_loc = text("[mx+1],[my]")
return
*/
//This proc draws out the inventory and places the items on it. It uses the standard position.
/obj/item/clothing/suit/storage/proc/standard_orient_objs(var/rows,var/cols)
var/cx = 4
var/cy = 2+rows
src.boxes.screen_loc = text("4:16,2:16 to [4+cols]:16,[2+rows]:16")
for(var/obj/O in src.contents)
O.screen_loc = text("[cx]:16,[cy]:16")
O.layer = 20
cx++
if (cx > (4+cols))
cx = 4
cy--
src.closer.screen_loc = text("[4+cols+1]:16,2:16")
return
//This proc determins the size of the inventory to be displayed. Please touch it only if you know what you're doing.
/obj/item/clothing/suit/storage/proc/orient2hud(mob/user as mob)
//var/mob/living/carbon/human/H = user
var/row_num = 0
var/col_count = min(7,storage_slots) -1
if (contents.len > 7)
row_num = round((contents.len-1) / 7) // 7 is the maximum allowed width.
src.standard_orient_objs(row_num,col_count)
return
//This proc is called when you want to place an item into the storage item.
/obj/item/clothing/suit/storage/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(istype(W,/obj/item/weapon/evidencebag) && src.loc != user)
return
..()
if(isrobot(user))
user << "\blue You're a robot. No."
return //Robots can't interact with storage items.
if(src.loc == W)
return //Means the item is already in the storage item
if(contents.len >= storage_slots)
user << "\red The [src] is full, make some space."
return //Storage item is full
if(can_hold.len)
var/ok = 0
for(var/A in can_hold)
if(istype(W, text2path(A) ))
ok = 1
break
if(!ok)
user << "\red This [src] cannot hold [W]."
return
for(var/A in cant_hold) //Check for specific items which this container can't hold.
if(istype(W, text2path(A) ))
user << "\red This [src] cannot hold [W]."
return
if (W.w_class > max_w_class)
user << "\red This [W] is too big for this [src]"
return
var/sum_w_class = W.w_class
for(var/obj/item/I in contents)
sum_w_class += I.w_class //Adds up the combined w_classes which will be in the storage item if the item is added to it.
if(sum_w_class > max_combined_w_class)
user << "\red The [src] is full, make some space."
return
if(W.w_class >= src.w_class && (istype(W, /obj/item/weapon/storage)))
if(!istype(src, /obj/item/weapon/storage/backpack/holding)) //bohs should be able to hold backpacks again. The override for putting a boh in a boh is in backpack.dm.
user << "\red The [src] cannot hold [W] as it's a storage item of the same size."
return //To prevent the stacking of the same sized items.
user.u_equip(W)
W.loc = src
if ((user.client && user.s_active != src))
user.client.screen -= W
src.orient2hud(user)
W.dropped(user)
add_fingerprint(user)
/obj/item/weapon/storage/dropped(mob/user as mob)
return
/obj/item/clothing/suit/storage/MouseDrop(atom/over_object)
if(ishuman(usr))
var/mob/living/carbon/human/M = usr
if (!( istype(over_object, /obj/screen) ))
return ..()
playsound(src.loc, "rustle", 50, 1, -5)
if ((!( M.restrained() ) && !( M.stat ) && M.wear_suit == src))
if (over_object.name == "r_hand")
if (!( M.r_hand ))
M.u_equip(src)
M.r_hand = src
else
if (over_object.name == "l_hand")
if (!( M.l_hand ))
M.u_equip(src)
M.l_hand = src
M.update_clothing()
src.add_fingerprint(usr)
return
if(over_object == usr && in_range(src, usr) || usr.contents.Find(src))
usr.s_active.close(usr)
src.show_to(usr)
return
/obj/item/clothing/suit/storage/attack_paw(mob/user as mob)
//playsound(src.loc, "rustle", 50, 1, -5) // what
return src.attack_hand(user)
/obj/item/clothing/suit/storage/attack_hand(mob/user as mob)
playsound(src.loc, "rustle", 50, 1, -5)
src.orient2hud(user)
if (src.loc == user)
if (user.s_active)
user.s_active.close(user)
src.show_to(user)
else
..()
for(var/mob/M in range(1))
if (M.s_active == src)
src.close(M)
src.add_fingerprint(user)
return
/obj/item/clothing/suit/storage/New()
src.boxes = new /obj/screen/storage( )
src.boxes.name = "storage"
src.boxes.master = src
src.boxes.icon_state = "block"
src.boxes.screen_loc = "7,7 to 10,8"
src.boxes.layer = 19
src.closer = new /obj/screen/close( )
src.closer.master = src
src.closer.icon_state = "x"
src.closer.layer = 20
orient2hud()
return
/obj/item/weapon/storage/emp_act(severity)
if(!istype(src.loc, /mob/living))
for(var/obj/O in contents)
O.emp_act(severity)
..()
+25 -30
View File
@@ -62,11 +62,11 @@
return
//This proc draws out the inventory and places the items on it. tx and ty are the upper left tile and mx, my are the bottm right.
//The numbers are calculated from the bottom-left (Right hand slot on the map) being 1,1.
//The numbers are calculated from the bottom-left The bottom-left slot being 1,1.
/obj/item/weapon/storage/proc/orient_objs(tx, ty, mx, my)
var/cx = tx
var/cy = ty
src.boxes.screen_loc = text("[tx],[ty] to [mx],[my]")
src.boxes.screen_loc = text("[tx]:,[ty] to [mx],[my]")
for(var/obj/O in src.contents)
O.screen_loc = text("[cx],[cy]")
O.layer = 20
@@ -77,23 +77,29 @@
src.closer.screen_loc = text("[mx+1],[my]")
return
//This proc draws out the inventory and places the items on it. It uses the standard position.
/obj/item/weapon/storage/proc/standard_orient_objs(var/rows,var/cols)
var/cx = 4
var/cy = 2+rows
src.boxes.screen_loc = text("4:16,2:16 to [4+cols]:16,[2+rows]:16")
for(var/obj/O in src.contents)
O.screen_loc = text("[cx]:16,[cy]:16")
O.layer = 20
cx++
if (cx > (4+cols))
cx = 4
cy--
src.closer.screen_loc = text("[4+cols+1]:16,2:16")
return
//This proc determins the size of the inventory to be displayed. Please touch it only if you know what you're doing.
/obj/item/weapon/storage/proc/orient2hud(mob/user as mob)
var/mob/living/carbon/human/H = user
var/col_num = 0
var/row_count = min(7,storage_slots) -1 //For belts, the meanings of the two variables are inverted, so we don't have to declare new ones
//var/mob/living/carbon/human/H = user
var/row_num = 0
var/col_count = min(7,storage_slots) -1
if (contents.len > 7)
col_num = round((contents.len-1) / 7) // 7 is the maximum allowed column height for r_hand, l_hand and back storage items.
if (src == user.l_hand)
src.orient_objs(3-col_num, 3+row_count, 3, 3)
else if(src == user.r_hand)
src.orient_objs(1, 3+row_count, 1+col_num, 3)
else if(src == user.back)
src.orient_objs(4-col_num, 3+row_count, 4, 3)
else if(istype(user, /mob/living/carbon/human) && src == H.belt)//only humans have belts
src.orient_objs(1, 3+col_num, 1+row_count, 3)
else
src.orient_objs(5, 10+col_num, 5 + row_count, 10)
row_num = round((contents.len-1) / 7) // 7 is the maximum allowed width.
src.standard_orient_objs(row_num,col_count)
return
//This proc is called when you want to place an item into the storage item.
@@ -186,15 +192,11 @@
return
/obj/item/weapon/storage/dropped(mob/user as mob)
var/col_num = 0
var/row_count = min(7,storage_slots) -1
if (contents.len > 7)
col_num = round((contents.len-1) / 7) // 7 is the maximum allowed column height for r_hand, l_hand and back storage items.
src.orient_objs(5, 10+col_num, 5 + row_count, 10)
return
/obj/item/weapon/storage/MouseDrop(over_object, src_location, over_location)
..()
orient2hud(usr)
if ((over_object == usr && (in_range(src, usr) || usr.contents.Find(src))))
if (usr.s_active)
usr.s_active.close(usr)
@@ -244,14 +246,7 @@
src.closer.master = src
src.closer.icon_state = "x"
src.closer.layer = 20
spawn( 5 )
var/col_num = 0
var/row_count = min(7,storage_slots) -1
if (contents.len > 7)
if(contents.len % 7)
col_num = round(contents.len / 7) // 7 is the maximum allowed column height for r_hand, l_hand and back storage items.
src.orient_objs(5, 10+col_num, 5 + row_count, 10)
return
orient2hud()
return
/obj/item/weapon/storage/emp_act(severity)
@@ -442,4 +437,4 @@
..()
return
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////