var/global/list/valid_abandoned_crate_types = typesof(/obj/structure/closet/crate/secure/loot)-/obj/structure/closet/crate/secure/loot
/obj/structure/closet/crate/secure/loot
name = "abandoned crate"
desc = "What could be inside?"
icon_state = "rustysecurecrate"
icon_opened = "rustysecurecrateopen"
icon_closed = "rustysecurecrate"
var/code = null
var/lastattempt = null
var/attempts = 3
locked = 1
var/min = 1
var/max = 10
/obj/structure/closet/crate/secure/loot/New()
..()
code = rand(min,max)
/obj/structure/closet/crate/secure/loot/attack_hand(mob/user as mob)
if(locked)
to_chat(user, "The crate is locked with a Deca-code lock.")
var/input = input(usr, "Enter digit from [min] to [max].", "Deca-Code Lock", "") as num
if(in_range(src, user))
input = clamp(input, 0, 10)
if (input == code)
to_chat(user, "The crate unlocks!")
locked = 0
else if (input == null || input > max || input < min)
to_chat(user, "You leave the crate alone.")
else
to_chat(user, "A red light flashes.")
lastattempt = input
attempts--
if (attempts == 0)
to_chat(user, "The crate's anti-tamper system activates!")
var/turf/T = get_turf(src.loc)
explosion(T, 0, 0, 0, 1)
for(var/item in contents)
qdel(item)
qdel(src)
return
else
to_chat(user, "You attempt to interact with the device using a hand gesture, but it appears this crate is from before the DECANECT came out.")
return
else
return ..()
/obj/structure/closet/crate/secure/loot/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(locked)
if (istype(W, /obj/item/device/multitool))
to_chat(user, "DECA-CODE LOCK REPORT:")
if (attempts == 1)
to_chat(user, "* Anti-Tamper Bomb will activate on next failed access attempt.")
else
to_chat(user, "* Anti-Tamper Bomb will activate after [src.attempts] failed access attempts.")
if (lastattempt == null)
to_chat(user, " has been made to open the crate thus far.")
return
// hot and cold
if (code > lastattempt)
to_chat(user, "* Last access attempt lower than expected code.")
else
to_chat(user, "* Last access attempt higher than expected code.")
else
..()
else
..()