mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-28 02:53:11 +00:00
[MIRROR] Locks & Keys (#7018)
Co-authored-by: Heroman3003 <31296024+Heroman3003@users.noreply.github.com> Co-authored-by: Raeschen <rycoop29@gmail.com>
This commit is contained in:
10
code/game/objects/items/weapons/keys.dm
Normal file
10
code/game/objects/items/weapons/keys.dm
Normal file
@@ -0,0 +1,10 @@
|
||||
/obj/item/weapon/simple_key
|
||||
name = "key"
|
||||
desc = "A plain, old-timey key, as one might use to unlock a door."
|
||||
icon = 'icons/obj/keys.dmi'
|
||||
icon_state = "key_basetype"
|
||||
drop_sound = 'sound/items/drop/ring.ogg'
|
||||
pickup_sound = 'sound/items/pickup/ring.ogg'
|
||||
w_class = ITEMSIZE_TINY
|
||||
var/keyverb = "uses" //so simple_keys can be keycards instead, if desired
|
||||
var/key_id = "placeholder_DONOTUSE" //needs to match the associated door's LOCK_ID var
|
||||
@@ -16,6 +16,10 @@
|
||||
var/knock_sound = 'sound/machines/door/knock_glass.ogg'
|
||||
var/knock_hammer_sound = 'sound/weapons/sonic_jackhammer.ogg'
|
||||
|
||||
var/locked = FALSE //has the door been locked?
|
||||
var/lock_id = null //does the door have an associated key?
|
||||
var/keysound = 'sound/items/toolbelt_equip.ogg'
|
||||
|
||||
/obj/structure/simple_door/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume)
|
||||
TemperatureAct(exposed_temperature)
|
||||
|
||||
@@ -99,6 +103,9 @@
|
||||
var/mob/M = user
|
||||
if(!material.can_open_material_door(user))
|
||||
return
|
||||
if(locked && state == 0)
|
||||
to_chat(M,"<span class='warning'>It's locked!</span>")
|
||||
return
|
||||
if(world.time - user.last_bumped <= 60)
|
||||
return
|
||||
if(M.client)
|
||||
@@ -149,13 +156,24 @@
|
||||
|
||||
/obj/structure/simple_door/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
|
||||
if(istype(W,/obj/item/weapon/pickaxe))
|
||||
if(istype(W,/obj/item/weapon/simple_key))
|
||||
var/obj/item/weapon/simple_key/key = W
|
||||
if(state)
|
||||
to_chat(user,"<span class='notice'>\The [src] must be closed in order for you to lock it.</span>")
|
||||
else if(key.key_id != src.lock_id)
|
||||
to_chat(user,"<span class='warning'>The [key] doesn't fit \the [src]'s lock!</span>")
|
||||
else if(key.key_id == src.lock_id)
|
||||
visible_message("<span class='notice'>[user] [key.keyverb] \the [key] and [locked ? "unlocks" : "locks"] \the [src].</span>")
|
||||
locked = !locked
|
||||
playsound(src, keysound,100, 1)
|
||||
return
|
||||
if(istype(W,/obj/item/weapon/pickaxe) && breakable)
|
||||
var/obj/item/weapon/pickaxe/digTool = W
|
||||
visible_message("<span class='danger'>[user] starts digging [src]!</span>")
|
||||
if(do_after(user,digTool.digspeed*hardness) && src)
|
||||
visible_message("<span class='danger'>[user] finished digging [src]!</span>")
|
||||
Dismantle()
|
||||
else if(istype(W,/obj/item/weapon)) //not sure, can't not just weapons get passed to this proc?
|
||||
else if(istype(W,/obj/item/weapon) && breakable) //not sure, can't not just weapons get passed to this proc?
|
||||
hardness -= W.force/10
|
||||
visible_message("<span class='danger'>[user] hits [src] with [W]!</span>")
|
||||
if(material == get_material_by_name("resin"))
|
||||
@@ -165,7 +183,7 @@
|
||||
else
|
||||
playsound(src, 'sound/weapons/smash.ogg', 50, 1)
|
||||
CheckHardness()
|
||||
else if(istype(W,/obj/item/weapon/weldingtool))
|
||||
else if(istype(W,/obj/item/weapon/weldingtool) && breakable)
|
||||
var/obj/item/weapon/weldingtool/WT = W
|
||||
if(material.ignition_point && WT.remove_fuel(0, user))
|
||||
TemperatureAct(150)
|
||||
|
||||
Reference in New Issue
Block a user