diff --git a/aurora.dme b/aurora.dme index 26eeb25f..990ac4ed 100644 --- a/aurora.dme +++ b/aurora.dme @@ -565,6 +565,7 @@ #include "code\game\objects\items\trash.dm" #include "code\game\objects\items\devices\aicard.dm" #include "code\game\objects\items\devices\binoculars.dm" +#include "code\game\objects\items\devices\door_bracer.dm" #include "code\game\objects\items\devices\chameleonproj.dm" #include "code\game\objects\items\devices\debugger.dm" #include "code\game\objects\items\devices\flash.dm" diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index 8b49259e..7e15c4f9 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -51,6 +51,7 @@ var/door_sound='sound/machines/airlock.ogg' var/door_sound_distance=30 autoclose = 1 + var/obj/item/device/doorbrace/bracer = null /obj/machinery/door/airlock/command name = "Airlock" @@ -717,6 +718,15 @@ About the new airlock wires panel: set_frequency(ST.change_freq(frequency)) return + if (istype(C, /obj/item/device/doorbrace)) + if (bracer) + user << "There is already a [bracer] on [src]!" + return + + var/obj/item/device/doorbrace/newbracer = C + newbracer.attachto(src, user) + return + src.add_fingerprint(user) if((istype(C, /obj/item/weapon/weldingtool) && !( src.operating > 0 ) && src.density)) var/obj/item/weapon/weldingtool/W = C @@ -824,7 +834,7 @@ About the new airlock wires panel: playsound(src.loc, door_sound, door_sound_distance, 1) /obj/machinery/door/airlock/open(var/forced=0) - if( operating || welded || locked ) + if( operating || welded || locked || bracer) return 0 if(!forced) if( !arePowerSystemsOn() || isWireCut(AIRLOCK_WIRE_OPEN_DOOR) ) @@ -915,7 +925,9 @@ About the new airlock wires panel: break /obj/machinery/door/airlock/proc/prison_open() + if (bracer) + return src.unlock() src.open() src.lock() - return \ No newline at end of file + return diff --git a/code/game/objects/items/devices/door_bracer.dm b/code/game/objects/items/devices/door_bracer.dm new file mode 100644 index 00000000..e49da9ac --- /dev/null +++ b/code/game/objects/items/devices/door_bracer.dm @@ -0,0 +1,237 @@ +#define STATUS_INACTIVE 0 +#define STATUS_ACTIVE 1 +#define STATUS_BROKEN 2 + +#define LAYER_ATTACHED 3.2 +#define LAYER_NORMAL 3 + +/obj/item/device/doorbrace + name = "magnetic door lock" + desc = "A large, ID locked device used for completely locking down airlocks." + icon = 'icons/obj/door_braces/centcom.dmi' + icon_state = "inactive" + w_class = 3 + req_access = list(103) + + var/department = "CENTCOM" + var/status = 0 + var/constructionstate = 0 + var/obj/machinery/door/airlock/target = null + +/obj/item/device/doorbrace/security + icon = 'icons/obj/door_braces/security.dmi' + department = "Security" + req_access = list(1) + +/obj/item/device/doorbrace/engineering + icon = 'icons/obj/door_braces/engineering.dmi' + department = "Engineering" + req_access = null + req_one_access = list(11, 24) + +/obj/item/device/doorbrace/examine(mob/user) + ..(user) + + user << "\blue This device has [department] department markings on it." + +/obj/item/device/doorbrace/attack_hand(var/mob/user) + if (status == STATUS_ACTIVE) + ui_interact(user) + else + ..() + +/obj/item/device/doorbrace/attackby(var/obj/item/I, var/mob/user) + if (status == STATUS_BROKEN) + user << "[src] is broken beyond repair!" + return + + switch (constructionstate) + if (0) + if (istype(I, /obj/item/weapon/card/emag)) + var/obj/item/weapon/card/emag/emagcard = I + emagcard.uses-- + visible_message("[src] sparks and falls off the door!", "You emag [src], frying its circuitry[status == STATUS_ACTIVE ? " and making it drop onto the floor" : ""]!") + + setstatus(STATUS_BROKEN) + return + + if (status == STATUS_ACTIVE && istype(I, /obj/item/weapon/card/id)) + if (check_access(I) && !constructionstate) + user << "You swipe your [I] through [src], making it drop onto the floor with a thud." + setstatus(STATUS_INACTIVE) + return + else if (constructionstate) + user << "You cannot swipe your [I] through [src] with it partially dismantled!" + return + else + user << "A red light flashes on [src] as you swipe your [I] through it." + flick("deny",src) + return + + if (istype(I, /obj/item/weapon/screwdriver)) + user << "You unfasten and remove the plastic cover from [src], revealing a thick metal shell." + playsound(loc, 'sound/items/Screwdriver.ogg', 50, 1) + setconstructionstate(1) + return + + if (1) + if (istype(I, /obj/item/weapon/screwdriver)) + user << "You put the metal cover of back onto [src], and screw it tight." + playsound(loc, 'sound/items/Screwdriver.ogg', 50, 1) + setconstructionstate(0) + return + if (istype(I, /obj/item/weapon/weldingtool)) + var/obj/item/weapon/weldingtool/WT = I + if (WT.remove_fuel(1, user)) + user.visible_message("[user] starts welding through the metal shell of [src].", "You start welding through the metal covering of [src]") + playsound(loc, 'sound/items/Welder.ogg', 50, 1) + if (do_after(user, 25)) + user << "You are able to weld through the metal shell of [src]." + setconstructionstate(2) + return + if (2) + if (istype(I, /obj/item/weapon/crowbar)) + user << "You pry off the metal covering from [src]." + playsound(loc, 'sound/items/Crowbar.ogg', 50, 1) + setconstructionstate(3) + return + if (3) + if (istype(I, /obj/item/weapon/wirecutters)) + user << "You cut the wires connecting the [src]'s magnets to their powersupply, [status ? "rendering the device unusable." : "making the device fall off and rendering it unusable."]" + playsound(loc, 'sound/items/Wirecutter.ogg', 50, 1) + setconstructionstate(4) + return + +/obj/item/device/doorbrace/proc/attachto(var/obj/machinery/door/airlock/newtarget, var/mob/user as mob) + if (status == STATUS_BROKEN) + user << "[src] is damaged beyond repair! It cannot be used!" + return + + if (!newtarget.density || newtarget.operating) + user << "[newtarget] must be closed before you can attach [src] to it!" + return + + if (newtarget.p_open) + user << "You must close [newtarget]'s maintenance panel before attaching [src] to it!" + return + + user.visible_message("[user] starts mounting [src] onto [newtarget].", "You begin mounting [src] onto [newtarget].") + if (do_after(user, 35, 1)) + if (status == STATUS_BROKEN) + user << "[src] is damaged beyond repair! It cannot be used!" + return + + if (!newtarget.density) + user << "[newtarget] must be closed before you can attach [src] to it!" + return + + if (newtarget.p_open) + user << "You must close [newtarget]'s maintenance panel before attaching [src] to it!" + return + + user.visible_message("[user] attached [src] onto [newtarget] and flicks it on. The magnetic lock now seals [newtarget].", "You attached [src] onto [newtarget] and switched on the magnetic lock.") + user.drop_item() + + setstatus(STATUS_ACTIVE, newtarget) + return + +/obj/item/device/doorbrace/proc/setstatus(var/newstatus, var/obj/machinery/door/airlock/newtarget as obj) + switch (newstatus) + if (STATUS_INACTIVE) + if (status != STATUS_ACTIVE) + return + if (!target) + return + + detach() + icon_state = "inactive" + status = newstatus + + if (STATUS_ACTIVE) + if (status != STATUS_INACTIVE) + return + if (!newtarget) + return + + attach(newtarget) + icon_state = "active" + status = newstatus + + if (STATUS_BROKEN) + var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread + s.set_up(5, 1, src) + s.start() + spawn(5) + del(s) + + if (target) + detach() + + icon_state = "broken" + status = newstatus + +/obj/item/device/doorbrace/proc/setconstructionstate(var/newstate) + constructionstate = newstate + if (newstate == 0) + if (status == STATUS_ACTIVE) + icon_state = "active" + else + icon_state = "inactive" + else + icon_state = "construction-[constructionstate]" + +/obj/item/device/doorbrace/proc/detach() + if (target) + adjustsprite(null) + layer = LAYER_NORMAL + + target.bracer = null + + anchored = 0 + +/obj/item/device/doorbrace/proc/attach(var/obj/machinery/door/airlock/newtarget as obj) + adjustsprite(newtarget) + layer = LAYER_ATTACHED + + newtarget.bracer = src + target = newtarget + + anchored = 1 + +/obj/item/device/doorbrace/proc/adjustsprite(var/obj/target as obj) + if (target) + switch (get_dir(src, target)) + if (NORTH) + pixel_x = 0 + pixel_y = 32 + if (NORTHEAST) + pixel_x = 32 + pixel_y = 32 + if (EAST) + pixel_x = 32 + pixel_y = 0 + if (SOUTHEAST) + pixel_x = 32 + pixel_y = -32 + if (SOUTH) + pixel_x = 0 + pixel_y = -32 + if (SOUTHWEST) + pixel_x = -32 + pixel_y = -32 + if (WEST) + pixel_x = -32 + pixel_y = 0 + if (NORTHWEST) + pixel_x = -32 + pixel_y = 32 + else + pixel_x = 0 + pixel_y = 0 + +#undef STATUS_INACTIVE +#undef STATUS_ACTIVE +#undef STATUS_BROKEN + +#undef LAYER_ATTACHED +#undef LAYER_NORMAL