/* CONTAINS: SAFES FLOOR SAFES */ //SAFES /obj/structure/safe name = "safe" desc = "A huge chunk of metal with a dial embedded in it. Fine print on the dial reads \"Scarborough Arms - 2 tumbler safe, guaranteed thermite resistant, explosion resistant, and assistant resistant.\"" icon = 'icons/obj/safe.dmi' icon_state = "safe" anchored = 1 density = 1 var/broken = FALSE //is the tumbler broken into var/open = 0 //is the safe open? var/tumbler_1_pos //the tumbler position- from 0 to 71 var/tumbler_1_open //the tumbler position to open at- 0 to 71 var/tumbler_2_pos var/tumbler_2_open var/dial = 0 //where is the dial pointing? var/space = 0 //the combined w_class of everything in the safe var/maxspace = 24 //the maximum combined w_class of stuff in the safe // Variables (Drill) var/obj/item/thermal_drill/drill // The currently placed thermal drill, if any. var/time_to_drill = 300 SECONDS // Drill duration of the current thermal drill. var/last_drill_time = 0 // Last world.time the drill time was checked. Used to reduce time_to_drill accurately var/image/drill_overlay // The drill overlay image to display during the drilling process. var/drill_x_offset = -13 // The X pixel offset for the drill var/drill_y_offset = -3 // The Y pixel offset for the drill /obj/structure/safe/Initialize() . = ..() tumbler_1_pos = rand(0, 71) tumbler_1_open = rand(0, 71) tumbler_2_pos = rand(0, 71) tumbler_2_open = min(71 , max( 1 , abs(tumbler_1_open + rand(-34, 34)))) for(var/obj/item/I in loc) if(space >= maxspace) return if(I.w_class + space <= maxspace) space += I.w_class I.forceMove(src) /obj/structure/safe/examine(mob/user) . = ..() if(broken) to_chat(user, SPAN_WARNING("\The [src]'s locking system has been drilled open!")) else if(time_to_drill < 300 SECONDS) var/time_left = max(round(time_to_drill / 10), 0) to_chat(user, SPAN_WARNING("There are only [time_left] second\s of drilling left until \the [src] is broken!")) /obj/structure/safe/Destroy() if(drill) drill.forceMove(loc) drill = null return ..() /obj/structure/safe/proc/check_unlocked(mob/user as mob, canhear) if(user && canhear) if(tumbler_1_pos == tumbler_1_open) to_chat(user, SPAN_NOTICE("You hear a [pick("tonk", "krunk", "plunk")] from [src].")) if(tumbler_2_pos == tumbler_2_open) to_chat(user, SPAN_NOTICE("You hear a [pick("tink", "krink", "plink")] from [src].")) if(tumbler_1_pos == tumbler_1_open && tumbler_2_pos == tumbler_2_open) if(user) visible_message("[pick("Spring", "Sprang", "Sproing", "Clunk", "Krunk")]!") return 1 return 0 /obj/structure/safe/proc/decrement(num) num -= 1 if(num < 0) num = 71 return num /obj/structure/safe/proc/increment(num) num += 1 if(num > 71) num = 0 return num /obj/structure/safe/update_icon() if(open) if(broken) icon_state = "[initial(icon_state)]-open-broken" else icon_state = "[initial(icon_state)]-open" else if(broken) icon_state = "[initial(icon_state)]-broken" else icon_state = initial(icon_state) cut_overlay(drill_overlay) if(istype(drill, /obj/item/thermal_drill)) var/drill_icon = istype(drill, /obj/item/thermal_drill/diamond_drill) ? "d" : "h" var/state = "[initial(icon_state)]_[drill_icon]-drill-[isprocessing ? "on" : "off"]" drill_overlay = image(icon = 'icons/effects/drill.dmi', icon_state = state, pixel_x = drill_x_offset, pixel_y = drill_y_offset) add_overlay(drill_overlay) /obj/structure/safe/attack_hand(mob/user as mob) if(drill) switch(alert("What would you like to do?", "Thermal Drill", "Turn [isprocessing ? "Off" : "On"]", "Remove Drill", "Cancel")) if("Turn On") if(!drill || isprocessing) return if(broken) to_chat(user, SPAN_WARNING("\The [src] is already broken open!")) return if(do_after(user, 2 SECONDS)) if(!drill || isprocessing) return if(broken) return last_drill_time = world.time START_PROCESSING(SSprocessing, src) update_icon() if("Turn Off") if(!drill || !isprocessing) return if(do_after(user, 2 SECONDS)) if(!drill || !isprocessing) return STOP_PROCESSING(SSprocessing, src) update_icon() if("Remove Drill") if(isprocessing) to_chat(user, SPAN_WARNING("You cannot remove the drill while it's running!")) else if(do_after(user, 2 SECONDS)) if(isprocessing) return user.put_in_hands(drill) drill = null update_icon() if("Cancel") return else user.set_machine(src) var/dat = "
| [P.name] |