Advertisement
Atskadan

Untitled

Apr 19th, 2014
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.90 KB | None | 0 0
  1. /obj/item/clothing/suit/storage
  2. var/list/can_hold = new/list() //List of objects which this item can store (if set, it can't store anything else)
  3. var/list/cant_hold = new/list() //List of objects which this item can't store (in effect only if can_hold isn't set)
  4. var/max_w_class = 2 //Max size of objects that this object can store (in effect only if can_hold isn't set)
  5. var/max_combined_w_class = 4 //The sum of the w_classes of all the items in this storage item.
  6. var/storage_slots = 2 //The number of storage slots in this container.
  7. var/obj/screen/storage/boxes = null
  8. var/obj/screen/close/closer = null
  9.  
  10. /obj/item/clothing/suit/storage/proc/return_inv()
  11.  
  12. var/list/L = list( )
  13.  
  14. L += src.contents
  15.  
  16. for(var/obj/item/weapon/storage/S in src)
  17. L += S.return_inv()
  18. for(var/obj/item/weapon/gift/G in src)
  19. L += G.gift
  20. if (istype(G.gift, /obj/item/weapon/storage))
  21. L += G.gift:return_inv()
  22. return L
  23.  
  24. /obj/item/clothing/suit/storage/proc/show_to(mob/user as mob)
  25. user.client.screen -= src.boxes
  26. user.client.screen -= src.closer
  27. user.client.screen -= src.contents
  28. user.client.screen += src.boxes
  29. user.client.screen += src.closer
  30. user.client.screen += src.contents
  31. user.s_active = src
  32. return
  33.  
  34. /obj/item/clothing/suit/storage/proc/hide_from(mob/user as mob)
  35.  
  36. if(!user.client)
  37. return
  38. user.client.screen -= src.boxes
  39. user.client.screen -= src.closer
  40. user.client.screen -= src.contents
  41. return
  42.  
  43. /obj/item/clothing/suit/storage/proc/close(mob/user as mob)
  44.  
  45. src.hide_from(user)
  46. user.s_active = null
  47. return
  48.  
  49. //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.
  50. //The numbers are calculated from the bottom-left The bottom-left slot being 1,1.
  51. /obj/item/clothing/suit/storage/proc/orient_objs(tx, ty, mx, my)
  52. var/cx = tx
  53. var/cy = ty
  54. src.boxes.screen_loc = text("[tx]:,[ty] to [mx],[my]")
  55. for(var/obj/O in src.contents)
  56. O.screen_loc = text("[cx],[cy]")
  57. O.layer = 20
  58. cx++
  59. if (cx > mx)
  60. cx = tx
  61. cy--
  62. src.closer.screen_loc = text("[mx+1],[my]")
  63. return
  64.  
  65. //This proc draws out the inventory and places the items on it. It uses the standard position.
  66. /obj/item/clothing/suit/storage/proc/standard_orient_objs(var/rows,var/cols)
  67. var/cx = 4
  68. var/cy = 2+rows
  69. src.boxes.screen_loc = text("4:16,2:16 to [4+cols]:16,[2+rows]:16")
  70. for(var/obj/O in src.contents)
  71. O.screen_loc = text("[cx]:16,[cy]:16")
  72. O.layer = 20
  73. cx++
  74. if (cx > (4+cols))
  75. cx = 4
  76. cy--
  77. src.closer.screen_loc = text("[4+cols+1]:16,2:16")
  78. return
  79.  
  80. //This proc determins the size of the inventory to be displayed. Please touch it only if you know what you're doing.
  81. /obj/item/clothing/suit/storage/proc/orient2hud(mob/user as mob)
  82. //var/mob/living/carbon/human/H = user
  83. var/row_num = 0
  84. var/col_count = min(7,storage_slots) -1
  85. if (contents.len > 7)
  86. row_num = round((contents.len-1) / 7) // 7 is the maximum allowed width.
  87. src.standard_orient_objs(row_num,col_count)
  88. return
  89.  
  90. //This proc is called when you want to place an item into the storage item.
  91. /obj/item/clothing/suit/storage/attackby(obj/item/weapon/W as obj, mob/user as mob)
  92. if(istype(W,/obj/item/weapon/evidencebag) && src.loc != user)
  93. return
  94.  
  95. ..()
  96. if(isrobot(user))
  97. user << "\blue You're a robot. No."
  98. return //Robots can't interact with storage items.
  99.  
  100. if(src.loc == W)
  101. return //Means the item is already in the storage item
  102.  
  103. if(contents.len >= storage_slots)
  104. user << "\red \The [src] is full, make some space."
  105. return //Storage item is full
  106.  
  107. if(can_hold.len)
  108. var/ok = 0
  109. for(var/A in can_hold)
  110. if(istype(W, text2path(A) ))
  111. ok = 1
  112. break
  113. if(!ok)
  114. user << "\red \The [src] cannot hold \the [W]."
  115. return
  116.  
  117. for(var/A in cant_hold) //Check for specific items which this container can't hold.
  118. if(istype(W, text2path(A) ))
  119. user << "\red \The [src] cannot hold \the [W]."
  120. return
  121.  
  122. if (W.w_class > max_w_class)
  123. user << "\red \The [W] is too big for \the [src]"
  124. return
  125.  
  126. var/sum_w_class = W.w_class
  127. for(var/obj/item/I in contents)
  128. 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.
  129.  
  130. if(sum_w_class > max_combined_w_class)
  131. user << "\red \The [src] is full, make some space."
  132. return
  133.  
  134. if(W.w_class >= src.w_class && (istype(W, /obj/item/weapon/storage)))
  135. 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.
  136. user << "\red \The [src] cannot hold \the [W] as it's a storage item of the same size."
  137. return //To prevent the stacking of the same sized items.
  138.  
  139. user.u_equip(W)
  140. playsound(src.loc, "rustle", 50, 1, -5)
  141. W.loc = src
  142. if ((user.client && user.s_active != src))
  143. user.client.screen -= W
  144. src.orient2hud(user)
  145. W.dropped(user)
  146. add_fingerprint(user)
  147. show_to(user)
  148.  
  149.  
  150. /obj/item/weapon/storage/dropped(mob/user as mob)
  151. return
  152.  
  153. /obj/item/clothing/suit/storage/MouseDrop(atom/over_object)
  154. if(ishuman(usr))
  155. var/mob/living/carbon/human/M = usr
  156. if (!( istype(over_object, /obj/screen) ))
  157. return ..()
  158. playsound(src.loc, "rustle", 50, 1, -5)
  159. if ((!( M.restrained() ) && !( M.stat ) && M.wear_suit == src))
  160. if (over_object.name == "r_hand")
  161. M.u_equip(src)
  162. M.put_in_r_hand(src)
  163. // if (!( M.r_hand ))
  164. // M.u_equip(src)
  165. // M.r_hand = src
  166. else if (over_object.name == "l_hand")
  167. M.u_equip(src)
  168. M.put_in_l_hand(src)
  169. // if (!( M.l_hand ))
  170. // M.u_equip(src)
  171. // M.l_hand = src
  172. M.update_inv_wear_suit()
  173. src.add_fingerprint(usr)
  174. return
  175. if( (over_object == usr && in_range(src, usr) || usr.contents.Find(src)) && usr.s_active)
  176. usr.s_active.close(usr)
  177. src.show_to(usr)
  178. return
  179.  
  180. /obj/item/clothing/suit/storage/attack_paw(mob/user as mob)
  181. //playsound(src.loc, "rustle", 50, 1, -5) // what
  182. return src.attack_hand(user)
  183.  
  184. /obj/item/clothing/suit/storage/attack_hand(mob/user as mob)
  185. playsound(src.loc, "rustle", 50, 1, -5)
  186. src.orient2hud(user)
  187. if (src.loc == user)
  188. if (user.s_active)
  189. user.s_active.close(user)
  190. src.show_to(user)
  191. else
  192. ..()
  193. for(var/mob/M in range(1))
  194. if (M.s_active == src)
  195. src.close(M)
  196. src.add_fingerprint(user)
  197. return
  198.  
  199. /obj/item/clothing/suit/storage/New()
  200.  
  201. src.boxes = new /obj/screen/storage( )
  202. src.boxes.name = "storage"
  203. src.boxes.master = src
  204. src.boxes.icon_state = "block"
  205. src.boxes.screen_loc = "7,7 to 10,8"
  206. src.boxes.layer = 19
  207. src.closer = new /obj/screen/close( )
  208. src.closer.master = src
  209. src.closer.icon_state = "x"
  210. src.closer.layer = 20
  211. orient2hud()
  212. return
  213.  
  214. /obj/item/clothing/suit/emp_act(severity)
  215. if(!istype(src.loc, /mob/living))
  216. for(var/obj/O in contents)
  217. O.emp_act(severity)
  218. ..()
  219.  
  220. /obj/item/clothing/suit/hear_talk(mob/M, var/msg)
  221. for (var/atom/A in src)
  222. if(istype(A,/obj/))
  223. var/obj/O = A
  224. O.hear_talk(M, msg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement