You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

483 lines
13 KiB

  1. /obj/machinery/door/window
  2. name = "interior door"
  3. desc = "A strong door."
  4. icon = 'icons/obj/doors/windoor.dmi'
  5. icon_state = "left"
  6. layer = ABOVE_WINDOW_LAYER
  7. closingLayer = ABOVE_WINDOW_LAYER
  8. resistance_flags = ACID_PROOF
  9. var/base_state = "left"
  10. max_integrity = 150 //If you change this, consider changing ../door/window/brigdoor/ max_integrity at the bottom of this .dm file
  11. integrity_failure = 0
  12. armor = list("melee" = 20, "bullet" = 50, "laser" = 50, "energy" = 50, "bomb" = 10, "bio" = 100, "rad" = 100, "fire" = 70, "acid" = 100)
  13. visible = FALSE
  14. flags_1 = ON_BORDER_1
  15. opacity = 0
  16. CanAtmosPass = ATMOS_PASS_PROC
  17. interaction_flags_machine = INTERACT_MACHINE_WIRES_IF_OPEN | INTERACT_MACHINE_ALLOW_SILICON | INTERACT_MACHINE_OPEN_SILICON | INTERACT_MACHINE_REQUIRES_SILICON | INTERACT_MACHINE_OPEN
  18. var/obj/item/electronics/airlock/electronics = null
  19. var/reinf = 0
  20. var/shards = 2
  21. var/rods = 2
  22. var/cable = 1
  23. var/list/debris = list()
  24. /obj/machinery/door/window/Initialize(mapload, set_dir)
  25. . = ..()
  26. flags_1 &= ~PREVENT_CLICK_UNDER_1
  27. if(set_dir)
  28. setDir(set_dir)
  29. if(req_access && req_access.len)
  30. icon_state = "[icon_state]"
  31. base_state = icon_state
  32. for(var/i in 1 to shards)
  33. debris += new /obj/item/shard(src)
  34. if(rods)
  35. debris += new /obj/item/stack/rods(src, rods)
  36. if(cable)
  37. debris += new /obj/item/stack/cable_coil(src, cable)
  38. /obj/machinery/door/window/ComponentInitialize()
  39. . = ..()
  40. AddComponent(/datum/component/ntnet_interface)
  41. /obj/machinery/door/window/Destroy()
  42. density = FALSE
  43. QDEL_LIST(debris)
  44. if(obj_integrity == 0)
  45. playsound(src, "shatter", 70, TRUE)
  46. electronics = null
  47. return ..()
  48. /obj/machinery/door/window/update_icon_state()
  49. if(density)
  50. icon_state = base_state
  51. else
  52. icon_state = "[base_state]open"
  53. SSdemo.mark_dirty(src)
  54. /obj/machinery/door/window/proc/open_and_close()
  55. if(!open())
  56. return
  57. autoclose = TRUE
  58. if(check_access(null))
  59. sleep(50)
  60. else //secure doors close faster
  61. sleep(20)
  62. if(!density && autoclose) //did someone change state while we slept?
  63. close()
  64. /obj/machinery/door/window/Bumped(atom/movable/AM)
  65. if( operating || !density )
  66. return
  67. if (!( ismob(AM) ))
  68. if(ismecha(AM))
  69. var/obj/mecha/mecha = AM
  70. if(mecha.occupant && allowed(mecha.occupant))
  71. open_and_close()
  72. else
  73. do_animate("deny")
  74. return
  75. if (!( SSticker ))
  76. return
  77. var/mob/M = AM
  78. if(M.restrained() || ((isdrone(M) || iscyborg(M)) && M.stat))
  79. return
  80. bumpopen(M)
  81. /obj/machinery/door/window/bumpopen(mob/user)
  82. if( operating || !density )
  83. return
  84. add_fingerprint(user)
  85. if(!requiresID())
  86. user = null
  87. if(allowed(user))
  88. open_and_close()
  89. else
  90. do_animate("deny")
  91. return
  92. /obj/machinery/door/window/CanAllowThrough(atom/movable/mover, turf/target)
  93. . = ..()
  94. if(istype(mover) && (mover.pass_flags & PASSGLASS))
  95. return TRUE
  96. if(get_dir(loc, target) == dir) //Make sure looking at appropriate border
  97. return
  98. if(istype(mover, /obj/structure/window))
  99. var/obj/structure/window/W = mover
  100. if(!valid_window_location(loc, W.ini_dir))
  101. return FALSE
  102. else if(istype(mover, /obj/structure/windoor_assembly))
  103. var/obj/structure/windoor_assembly/W = mover
  104. if(!valid_window_location(loc, W.ini_dir))
  105. return FALSE
  106. else if(istype(mover, /obj/machinery/door/window) && !valid_window_location(loc, mover.dir))
  107. return FALSE
  108. else
  109. return TRUE
  110. /obj/machinery/door/window/CanAtmosPass(turf/T)
  111. if(get_dir(loc, T) == dir)
  112. return !density
  113. else
  114. return 1
  115. //used in the AStar algorithm to determinate if the turf the door is on is passable
  116. /obj/machinery/door/window/CanAStarPass(obj/item/card/id/ID, to_dir)
  117. return !density || (dir != to_dir) || (check_access(ID) && hasPower())
  118. /obj/machinery/door/window/CheckExit(atom/movable/mover as mob|obj, turf/target)
  119. if(istype(mover) && (mover.pass_flags & PASSGLASS))
  120. return 1
  121. if(get_dir(loc, target) == dir)
  122. return !density
  123. else
  124. return 1
  125. /obj/machinery/door/window/open(forced=FALSE)
  126. if (operating) //doors can still open when emag-disabled
  127. return 0
  128. if(!forced)
  129. if(!hasPower())
  130. return 0
  131. if(forced < 2)
  132. if(obj_flags & EMAGGED)
  133. return 0
  134. if(!operating) //in case of emag
  135. operating = TRUE
  136. do_animate("opening")
  137. playsound(src, 'sound/machines/windowdoor.ogg', 100, TRUE)
  138. icon_state ="[base_state]open"
  139. sleep(10)
  140. density = FALSE
  141. air_update_turf(1)
  142. update_freelook_sight()
  143. if(operating == 1) //emag again
  144. operating = FALSE
  145. return 1
  146. /obj/machinery/door/window/close(forced=FALSE)
  147. if (operating)
  148. return 0
  149. if(!forced)
  150. if(!hasPower())
  151. return 0
  152. if(forced < 2)
  153. if(obj_flags & EMAGGED)
  154. return 0
  155. operating = TRUE
  156. do_animate("closing")
  157. playsound(src, 'sound/machines/windowdoor.ogg', 100, TRUE)
  158. icon_state = base_state
  159. density = TRUE
  160. air_update_turf(1)
  161. update_freelook_sight()
  162. sleep(10)
  163. operating = FALSE
  164. return 1
  165. /obj/machinery/door/window/play_attack_sound(damage_amount, damage_type = BRUTE, damage_flag = 0)
  166. switch(damage_type)
  167. if(BRUTE)
  168. playsound(src, 'sound/effects/glasshit.ogg', 90, TRUE)
  169. if(BURN)
  170. playsound(src, 'sound/items/welder.ogg', 100, TRUE)
  171. /obj/machinery/door/window/deconstruct(disassembled = TRUE)
  172. if(!(flags_1 & NODECONSTRUCT_1) && !disassembled)
  173. for(var/obj/fragment in debris)
  174. fragment.forceMove(get_turf(src))
  175. transfer_fingerprints_to(fragment)
  176. debris -= fragment
  177. qdel(src)
  178. /obj/machinery/door/window/narsie_act()
  179. add_atom_colour("#7D1919", FIXED_COLOUR_PRIORITY)
  180. /obj/machinery/door/window/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
  181. if(exposed_temperature > T0C + (reinf ? 1600 : 800))
  182. take_damage(round(exposed_volume / 200), BURN, 0, 0)
  183. ..()
  184. /obj/machinery/door/window/emag_act(mob/user)
  185. if(!operating && density && !(obj_flags & EMAGGED))
  186. obj_flags |= EMAGGED
  187. operating = TRUE
  188. flick("[base_state]spark", src)
  189. playsound(src, "sparks", 75, TRUE)
  190. sleep(6)
  191. operating = FALSE
  192. desc += "<BR><span class='warning'>Its access panel is smoking slightly.</span>"
  193. open(2)
  194. /obj/machinery/door/window/attackby(obj/item/I, mob/living/user, params)
  195. if(operating)
  196. return
  197. add_fingerprint(user)
  198. if(!(flags_1&NODECONSTRUCT_1))
  199. if(I.tool_behaviour == TOOL_SCREWDRIVER)
  200. if(density || operating)
  201. to_chat(user, "<span class='warning'>You need to open the door to access the maintenance panel!</span>")
  202. return
  203. I.play_tool_sound(src)
  204. panel_open = !panel_open
  205. to_chat(user, "<span class='notice'>You [panel_open ? "open":"close"] the maintenance panel of the [name].</span>")
  206. return
  207. if(I.tool_behaviour == TOOL_CROWBAR)
  208. if(panel_open && !density && !operating)
  209. user.visible_message("<span class='notice'>[user] removes the electronics from the [name].</span>", \
  210. "<span class='notice'>You start to remove electronics from the [name]...</span>")
  211. if(I.use_tool(src, user, 40, volume=50))
  212. if(panel_open && !density && !operating && loc)
  213. var/obj/structure/windoor_assembly/WA = new /obj/structure/windoor_assembly(loc)
  214. switch(base_state)
  215. if("left")
  216. WA.facing = "l"
  217. if("right")
  218. WA.facing = "r"
  219. if("leftsecure")
  220. WA.facing = "l"
  221. WA.secure = TRUE
  222. if("rightsecure")
  223. WA.facing = "r"
  224. WA.secure = TRUE
  225. WA.setAnchored(TRUE)
  226. WA.state= "02"
  227. WA.setDir(dir)
  228. WA.ini_dir = dir
  229. WA.update_icon()
  230. WA.created_name = name
  231. if(obj_flags & EMAGGED)
  232. to_chat(user, "<span class='warning'>You discard the damaged electronics.</span>")
  233. qdel(src)
  234. return
  235. to_chat(user, "<span class='notice'>You remove the airlock electronics.</span>")
  236. var/obj/item/electronics/airlock/ae
  237. if(!electronics)
  238. ae = new/obj/item/electronics/airlock(drop_location())
  239. if(req_one_access)
  240. ae.one_access = 1
  241. ae.accesses = req_one_access
  242. else
  243. ae.accesses = req_access
  244. else
  245. ae = electronics
  246. electronics = null
  247. ae.forceMove(drop_location())
  248. qdel(src)
  249. return
  250. return ..()
  251. /obj/machinery/door/window/interact(mob/user) //for sillycones
  252. try_to_activate_door(user)
  253. /obj/machinery/door/window/try_to_activate_door(mob/user)
  254. if (..())
  255. autoclose = FALSE
  256. /obj/machinery/door/window/try_to_crowbar(obj/item/I, mob/user)
  257. if(!hasPower())
  258. if(density)
  259. open(2)
  260. else
  261. close(2)
  262. else
  263. to_chat(user, "<span class='warning'>The door's motors resist your efforts to force it!</span>")
  264. /obj/machinery/door/window/do_animate(animation)
  265. switch(animation)
  266. if("opening")
  267. flick("[base_state]opening", src)
  268. if("closing")
  269. flick("[base_state]closing", src)
  270. if("deny")
  271. flick("[base_state]deny", src)
  272. /obj/machinery/door/window/check_access_ntnet(datum/netdata/data)
  273. return !requiresID() || ..()
  274. /obj/machinery/door/window/ntnet_receive(datum/netdata/data)
  275. // Check if the airlock is powered.
  276. if(!hasPower())
  277. return
  278. // Check packet access level.
  279. if(!check_access_ntnet(data))
  280. return
  281. // Handle received packet.
  282. var/command = lowertext(data.data["data"])
  283. var/command_value = lowertext(data.data["data_secondary"])
  284. switch(command)
  285. if("open")
  286. if(command_value == "on" && !density)
  287. return
  288. if(command_value == "off" && density)
  289. return
  290. if(density)
  291. INVOKE_ASYNC(src, .proc/open)
  292. else
  293. INVOKE_ASYNC(src, .proc/close)
  294. if("touch")
  295. INVOKE_ASYNC(src, .proc/open_and_close)
  296. /obj/machinery/door/window/brigdoor
  297. name = "secure door"
  298. icon_state = "leftsecure"
  299. base_state = "leftsecure"
  300. var/id = null
  301. max_integrity = 300 //Stronger doors for prison (regular window door health is 200)
  302. reinf = 1
  303. explosion_block = 1
  304. /obj/machinery/door/window/brigdoor/security/cell
  305. name = "cell door"
  306. desc = "For keeping in criminal scum."
  307. req_access = list(ACCESS_BRIG)
  308. /obj/machinery/door/window/brigdoor/security/holding
  309. name = "holding cell door"
  310. req_one_access = list(ACCESS_SEC_DOORS, ACCESS_LAWYER) //love for the lawyer
  311. /obj/machinery/door/window/northleft
  312. dir = NORTH
  313. /obj/machinery/door/window/eastleft
  314. dir = EAST
  315. /obj/machinery/door/window/westleft
  316. dir = WEST
  317. /obj/machinery/door/window/southleft
  318. dir = SOUTH
  319. /obj/machinery/door/window/northright
  320. dir = NORTH
  321. icon_state = "right"
  322. base_state = "right"
  323. /obj/machinery/door/window/eastright
  324. dir = EAST
  325. icon_state = "right"
  326. base_state = "right"
  327. /obj/machinery/door/window/westright
  328. dir = WEST
  329. icon_state = "right"
  330. base_state = "right"
  331. /obj/machinery/door/window/southright
  332. dir = SOUTH
  333. icon_state = "right"
  334. base_state = "right"
  335. /obj/machinery/door/window/brigdoor/northleft
  336. dir = NORTH
  337. /obj/machinery/door/window/brigdoor/eastleft
  338. dir = EAST
  339. /obj/machinery/door/window/brigdoor/westleft
  340. dir = WEST
  341. /obj/machinery/door/window/brigdoor/southleft
  342. dir = SOUTH
  343. /obj/machinery/door/window/brigdoor/northright
  344. dir = NORTH
  345. icon_state = "rightsecure"
  346. base_state = "rightsecure"
  347. /obj/machinery/door/window/brigdoor/eastright
  348. dir = EAST
  349. icon_state = "rightsecure"
  350. base_state = "rightsecure"
  351. /obj/machinery/door/window/brigdoor/westright
  352. dir = WEST
  353. icon_state = "rightsecure"
  354. base_state = "rightsecure"
  355. /obj/machinery/door/window/brigdoor/southright
  356. dir = SOUTH
  357. icon_state = "rightsecure"
  358. base_state = "rightsecure"
  359. /obj/machinery/door/window/brigdoor/security/cell/northleft
  360. dir = NORTH
  361. /obj/machinery/door/window/brigdoor/security/cell/eastleft
  362. dir = EAST
  363. /obj/machinery/door/window/brigdoor/security/cell/westleft
  364. dir = WEST
  365. /obj/machinery/door/window/brigdoor/security/cell/southleft
  366. dir = SOUTH
  367. /obj/machinery/door/window/brigdoor/security/cell/northright
  368. dir = NORTH
  369. icon_state = "rightsecure"
  370. base_state = "rightsecure"
  371. /obj/machinery/door/window/brigdoor/security/cell/eastright
  372. dir = EAST
  373. icon_state = "rightsecure"
  374. base_state = "rightsecure"
  375. /obj/machinery/door/window/brigdoor/security/cell/westright
  376. dir = WEST
  377. icon_state = "rightsecure"
  378. base_state = "rightsecure"
  379. /obj/machinery/door/window/brigdoor/security/cell/southright
  380. dir = SOUTH
  381. icon_state = "rightsecure"
  382. base_state = "rightsecure"
  383. /obj/machinery/door/window/brigdoor/security/holding/northleft
  384. dir = NORTH
  385. /obj/machinery/door/window/brigdoor/security/holding/eastleft
  386. dir = EAST
  387. /obj/machinery/door/window/brigdoor/security/holding/westleft
  388. dir = WEST
  389. /obj/machinery/door/window/brigdoor/security/holding/southleft
  390. dir = SOUTH
  391. /obj/machinery/door/window/brigdoor/security/holding/northright
  392. dir = NORTH
  393. icon_state = "rightsecure"
  394. base_state = "rightsecure"
  395. /obj/machinery/door/window/brigdoor/security/holding/eastright
  396. dir = EAST
  397. icon_state = "rightsecure"
  398. base_state = "rightsecure"
  399. /obj/machinery/door/window/brigdoor/security/holding/westright
  400. dir = WEST
  401. icon_state = "rightsecure"
  402. base_state = "rightsecure"
  403. /obj/machinery/door/window/brigdoor/security/holding/southright
  404. dir = SOUTH
  405. icon_state = "rightsecure"
  406. base_state = "rightsecure"