Skip to content

Commit

Permalink
Merge pull request #3543 from TalkingCactus/deadbolt
Browse files Browse the repository at this point in the history
adds deadbolts
  • Loading branch information
TalkingCactus authored Oct 22, 2023
2 parents 25b8afb + 302d2c2 commit dfd00d5
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 67 deletions.
69 changes: 67 additions & 2 deletions code/game/objects/items/lock.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/// This list isn't used for anything lmfao
GLOBAL_LIST_EMPTY(global_locks)

/obj/item/lock_construct
name = "\improper lock"
icon = 'icons/obj/lock.dmi'
Expand All @@ -25,6 +27,7 @@ GLOBAL_LIST_EMPTY(global_locks)
to_chat(user, span_notice("You fashion \the [I] to unlock \the [src]"))
K.lock_data = lock_data
K.desc = "A simple key for locks. It has [K.lock_data] engraved on it."
playsound(get_turf(src), "sound/f13items/flashlight_off.ogg", 25, FALSE, -4)
else
to_chat(user, span_warning("\The [I] already unlocks something..."))
return
Expand All @@ -36,17 +39,21 @@ GLOBAL_LIST_EMPTY(global_locks)
return
..()

/obj/item/lock_construct/proc/check_key(obj/item/key/K, mob/user = null)
/obj/item/lock_construct/proc/check_key(obj/item/key/K, mob/user = null,atom/movable/D)
if(K.lock_data == src.lock_data) //if the key matches us
if(locked)
user.visible_message(span_warning("[user] unlocks \the [src]."))
locked = FALSE
else
user.visible_message(span_warning("[user] locks \the [src]."))
locked = TRUE
playsound(get_turf(src), "sound/f13items/flashlight_off.ogg", 50, FALSE)
if(D)
D.do_squish(0.9,0.9,0.25 SECONDS)
else
to_chat(user, span_warning("This is the wrong key!"))

/// Always returns true. Very cool.
/obj/item/lock_construct/proc/check_locked()
return locked

Expand All @@ -62,7 +69,7 @@ GLOBAL_LIST_EMPTY(global_locks)
var/result = do_after(user, time_to_open, target = A)
prying = FALSE
if(result)
user.visible_message(span_notice("[src] breaks off [A] and falls to pieces."))
user.visible_message(span_notice("[src] breaks off [A] and falls to the ground."))
return TRUE
return FALSE

Expand Down Expand Up @@ -91,3 +98,61 @@ GLOBAL_LIST_EMPTY(global_locks)
S.lock_data = src.lock_data
else
return ..()

//// Deadbolt / Barrel Bolt / Bolt Lock / Etc
//// Basically just a keyless lock that can only be opened from one direction. Useful for mappers.

/obj/item/lock_bolt
name = "bolt lock"
desc = "This simple lock doesn't need a key, but it can only be manipulated from one side of a door."
icon = 'icons/obj/lock.dmi'
icon_state = "deadbolt_mapping"
w_class = WEIGHT_CLASS_SMALL
dir = SOUTH
/// This variable will set itself, do not touch it in the map editor >:(
var/mapped = FALSE
var/prying = FALSE
var/locked = FALSE

//Exclusively used for mapping rooms that should start locked.
/obj/item/lock_bolt/prelocked
locked = TRUE

/obj/item/lock_bolt/Initialize(mapload)
. = ..()
icon_state = "deadbolt"
GLOB.global_locks += src
if(mapload && isturf(loc))//Mapped on a turf. Ignores deadbolts inside of containers and what not.
mapped = TRUE
var/obj/structure/simple_door/SD = locate(/obj/structure/simple_door) in loc
if(SD && SD.can_have_lock)
name = "[SD.name] [name]" //Give this lock a unique name so it can be tracked easier
SD.attach_deadbolt(src, FALSE, null, mapped)

/obj/item/lock_bolt/Destroy()
..()
GLOB.global_locks -= src

/obj/item/lock_bolt/proc/pry_off(mob/living/user, atom/A)
if(!prying)
user.visible_message(span_notice("[user] starts prying [src] off [A]."), \
span_notice("You start prying [src] off [A]."))
var/time_to_open = 50
if(locked)
time_to_open = 500
playsound(src, 'sound/machines/airlock_alien_prying.ogg',100,1) //is it aliens or just the CE being a dick?
prying = TRUE
var/result = do_after(user, time_to_open, target = A)
prying = FALSE
if(result)
user.visible_message(span_notice("[src] breaks off [A] and falls to the ground."))
return TRUE
return FALSE

/obj/item/lock_bolt/proc/ToggleLock(mob/user)
if(locked)
user.visible_message(span_warning("[user] unlocks \the [src]."))
locked = FALSE
else
user.visible_message(span_warning("[user] locks \the [src]."))
locked = TRUE
5 changes: 3 additions & 2 deletions code/game/objects/items/stacks/sheets/sheet_types.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ GLOBAL_LIST_INIT(metal_recipes, list ( \
new/datum/stack_recipe("field arrowhead", /obj/item/stack/arrowhead/field, 1, 1, time = 1 SECONDS), \
null, \
new/datum/stack_recipe("lock", /obj/item/lock_construct, 1), \
new/datum/stack_recipe("coffee pot", /obj/item/crafting/coffee_pot, 1), \
new/datum/stack_recipe("lunchbox", /obj/item/crafting/lunchbox, 1), \
new/datum/stack_recipe("key", /obj/item/key, 1), \
new/datum/stack_recipe("key chain", /obj/item/storage/keys_set, 1), \
new/datum/stack_recipe("bolt lock", /obj/item/lock_bolt, 1), \
new/datum/stack_recipe("coffee pot", /obj/item/crafting/coffee_pot, 1), \
new/datum/stack_recipe("lunchbox", /obj/item/crafting/lunchbox, 1), \
null, \
new/datum/stack_recipe("seed extractor", /obj/structure/legion_extractor, 6, one_per_turf = TRUE, on_floor = TRUE), \
null, \
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/fence.dm
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
close_sound = "sound/f13machines/doorchainlink_close.ogg"
opacity = FALSE
base_opacity = FALSE
can_hold_padlock = TRUE
can_have_lock = TRUE
opening_time = 3
closing_time = 2
hard_open = 0
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/railings.dm
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
close_sound = "sound/machines/door_close.ogg"
opacity = FALSE
base_opacity = FALSE
can_hold_padlock = TRUE
can_have_lock = TRUE


//Yellow rail
Expand Down
2 changes: 1 addition & 1 deletion code/modules/fallout/obj/door_keys.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
if(id)
attach_id(id)
var/obj/structure/simple_door/D = locate(/obj/structure/simple_door) in loc
if(istype(D) && D.can_hold_padlock)
if(istype(D) && D.can_have_lock)
D.attach_padlock(src, TRUE)

/obj/item/lock/attackby(obj/item/W, mob/user, params)
Expand Down
Loading

0 comments on commit dfd00d5

Please sign in to comment.