mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-07-13 00:47:31 +01:00
Adds keypad maglock (#6871)
Makes maglocks mappable Add keypad maglock Add vars that let make maglocks invincible and not require power.
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
var/status = 0
|
||||
var/locked = 1
|
||||
var/hacked = 0
|
||||
var/invincible = FALSE
|
||||
var/processpower = TRUE
|
||||
var/constructionstate = 0
|
||||
var/drain_per_second = 3
|
||||
var/last_process_time = 0
|
||||
@@ -49,6 +51,22 @@
|
||||
desc += " It is painted with [department] colors."
|
||||
|
||||
update_icon()
|
||||
var/obj/machinery/door/airlock/newtarget = (locate(/obj/machinery/door/airlock) in get_turf(src))
|
||||
if(newtarget)
|
||||
var/direction = reverse_direction(dir)
|
||||
forceMove(get_step(newtarget.loc, reverse_direction(direction)))
|
||||
for (var/obj/machinery/door/airlock/A in oview(1, newtarget))
|
||||
var/rdir = get_dir(newtarget, A)
|
||||
if (istype(A, newtarget.type) && (rdir == turn(direction, -90) || rdir == turn(direction, 90)))
|
||||
if(!target_node1)
|
||||
target_node1 = A
|
||||
target_node1.bracer = src
|
||||
else
|
||||
target_node2 = A
|
||||
target_node2.bracer = src
|
||||
|
||||
status = STATUS_ACTIVE
|
||||
attach(newtarget)
|
||||
|
||||
/obj/item/device/magnetic_lock/examine(mob/user)
|
||||
..(user)
|
||||
@@ -72,9 +90,11 @@
|
||||
to_chat(user, "You remove \the [powercell].")
|
||||
powercell = null
|
||||
setconstructionstate(2)
|
||||
return TRUE
|
||||
else if (anchored)
|
||||
if (!locked)
|
||||
detach()
|
||||
return TRUE
|
||||
else
|
||||
to_chat(user, "<span class='warning'>\The [src] is locked in place!</span>")
|
||||
else
|
||||
@@ -119,6 +139,8 @@
|
||||
playsound(loc, "sound/weapons/Genhit.ogg", I.force*2.5, 1)
|
||||
return
|
||||
|
||||
if(invincible)
|
||||
return
|
||||
switch (constructionstate)
|
||||
if (0)
|
||||
if (istype(I, /obj/item/weapon/card/emag))
|
||||
@@ -208,6 +230,8 @@
|
||||
return
|
||||
|
||||
/obj/item/device/magnetic_lock/process()
|
||||
if(!processpower)
|
||||
return
|
||||
var/obj/item/weapon/cell/C = powercell // both of these are for viewing ease
|
||||
var/obj/item/weapon/cell/BU = internal_cell
|
||||
var/delta_sec = (world.time - last_process_time) / 10
|
||||
@@ -300,15 +324,16 @@
|
||||
target_node2.bracer = src
|
||||
break
|
||||
|
||||
user.visible_message("<span class='notice'>[user] attached [src] onto [newtarget] and flicks it on. The magnetic lock now seals [newtarget].</span>", "<span class='notice'>You attached [src] onto [newtarget] and switched on the magnetic lock.</span>")
|
||||
user.drop_from_inventory(src, src.loc)
|
||||
|
||||
forceMove(get_step(newtarget.loc, reverse_direction(direction)))
|
||||
set_dir(reverse_direction(direction))
|
||||
status = STATUS_ACTIVE
|
||||
attach(newtarget)
|
||||
user.visible_message("<span class='notice'>[user] attached [src] onto [newtarget] and flicks it on. The magnetic lock now seals [newtarget].</span>", "<span class='notice'>You attached [src] onto [newtarget] and switched on the magnetic lock.</span>")
|
||||
return
|
||||
|
||||
|
||||
/obj/item/device/magnetic_lock/proc/setconstructionstate(var/newstate)
|
||||
if (!powercell && newstate == 1)
|
||||
setconstructionstate(2)
|
||||
@@ -404,6 +429,8 @@
|
||||
add_overlay("overlay_deconstruct_[constructionstate]")
|
||||
|
||||
/obj/item/device/magnetic_lock/proc/takedamage(var/damage)
|
||||
if(invincible)
|
||||
return
|
||||
health -= rand(damage/2, damage)
|
||||
|
||||
if (damage >= 40 && prob(50))
|
||||
@@ -419,6 +446,72 @@
|
||||
if (prob(50))
|
||||
spark(target ? target : src, 5, alldirs)
|
||||
|
||||
/obj/item/device/magnetic_lock/keypad
|
||||
name = "magnetic door lock"
|
||||
desc = "A large, passcode locked device used for completely locking down airlocks."
|
||||
|
||||
req_access = list(access_none)
|
||||
|
||||
var/passcode = "open"
|
||||
var/configurable = TRUE
|
||||
|
||||
/obj/item/device/magnetic_lock/keypad/update_overlays()
|
||||
..()
|
||||
switch (status)
|
||||
if (STATUS_INACTIVE to STATUS_ACTIVE)
|
||||
if(istype(src, /obj/item/device/magnetic_lock/keypad))
|
||||
add_overlay("overlay_keypad")
|
||||
|
||||
|
||||
/obj/item/device/magnetic_lock/keypad/attack_self(mob/user as mob)
|
||||
var/datum/vueui/ui = SSvueui.get_open_ui(user, src)
|
||||
if(!ui)
|
||||
if(locked)
|
||||
ui = new(user, src, "misc-maglock", 300, 100, "Maglock", list())
|
||||
else
|
||||
ui = new(user, src, "misc-maglock-config", 300, 100, "Maglock configuration", list("passcode" = passcode))
|
||||
|
||||
ui.open()
|
||||
|
||||
/obj/item/device/magnetic_lock/keypad/attack_hand(var/mob/user)
|
||||
. = ..()
|
||||
if(. || !locked)
|
||||
return
|
||||
|
||||
attack_self(user)
|
||||
|
||||
/obj/item/device/magnetic_lock/keypad/Topic(href, href_list)
|
||||
var/datum/vueui/ui = href_list["vueui"]
|
||||
if(!istype(ui))
|
||||
return
|
||||
if(href_list["passcode"])
|
||||
if(lowertext(href_list["passcode"]) == passcode)
|
||||
locked = !locked
|
||||
playsound(src, 'sound/machines/ping.ogg', 30, 1)
|
||||
var/msg = "buttons on \the [src] and it [locked ? "locks" : "unlocks"] with a beep."
|
||||
var/pos_adj = "[usr.name] presses "
|
||||
var/fp_adj = "You press "
|
||||
usr.visible_message("<span class='warning'>[addtext(pos_adj, msg)]</span>", "<span class='notice'>[addtext(fp_adj, msg)]</span>")
|
||||
update_icon()
|
||||
ui.close()
|
||||
else
|
||||
playsound(src, 'sound/machines/buzz-sigh.ogg', 30, 1)
|
||||
to_chat(usr, span("warning", "\The [src] buzzes as you enter passcode."))
|
||||
return
|
||||
if(href_list["set_passcode"])
|
||||
if(!locked)
|
||||
passcode = lowertext(href_list["set_passcode"])
|
||||
ui.data["passcode"] = passcode
|
||||
to_chat(usr, "New passcode has been set.")
|
||||
ui.push_change()
|
||||
if(href_list["lock"])
|
||||
if(!locked)
|
||||
locked = !locked
|
||||
playsound(src, 'sound/machines/ping.ogg', 30, 1)
|
||||
to_chat(usr, "You have locked \the [src].")
|
||||
ui.close()
|
||||
update_icon()
|
||||
|
||||
#undef STATUS_INACTIVE
|
||||
#undef STATUS_ACTIVE
|
||||
#undef STATUS_BROKEN
|
||||
|
||||
Reference in New Issue
Block a user