diff --git a/code/game/objects/structures/safe.dm b/code/game/objects/structures/safe.dm index 73323d92048..946e96dbca1 100644 --- a/code/game/objects/structures/safe.dm +++ b/code/game/objects/structures/safe.dm @@ -4,6 +4,11 @@ SAFES FLOOR SAFES */ +/// Chance for a sound clue +#define SOUND_CHANCE 10 +/// Explosion number threshold for opening safe +#define BROKEN_THRESHOLD 3 + //SAFES /obj/structure/safe name = "safe" @@ -14,31 +19,36 @@ FLOOR SAFES density = TRUE resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | ACID_PROOF interaction_flags_atom = INTERACT_ATOM_ATTACK_HAND | INTERACT_ATOM_UI_INTERACT - var/open = FALSE //is the safe open? - var/tumbler_1_pos //the tumbler position- from 0 to 72 - var/tumbler_1_open //the tumbler position to open at- 0 to 72 - 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 - var/explosion_count = 0 //Tough, but breakable - -/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 = rand(0, 71) - + /// The maximum combined w_class of stuff in the safe + var/maxspace = 24 + /// The amount of tumblers that will be generated + var/number_of_tumblers = 2 + /// Whether the safe is open or not + var/open = FALSE + /// Whether the safe is locked or not + var/locked = TRUE + /// The position the dial is pointing to + var/dial = 0 + /// The list of tumbler dial positions that need to be hit + var/list/tumblers = list() + /// The index in the tumblers list of the tumbler dial position that needs to be hit + var/current_tumbler_index = 1 + /// The combined w_class of everything in the safe + var/space = 0 + /// Tough, but breakable if explosion counts reaches set value + var/explosion_count = 0 /obj/structure/safe/Initialize(mapload) . = ..() + // Combination generation + for(var/i in 1 to number_of_tumblers) + tumblers.Add(rand(0, 99)) + if(!mapload) return + // Put as many items on our turf inside as possible for(var/obj/item/I in loc) if(space >= maxspace) return @@ -46,141 +56,36 @@ FLOOR SAFES space += I.w_class I.forceMove(src) - -/obj/structure/safe/proc/check_unlocked(mob/user, canhear) - if(explosion_count > 2) - return 1 - if(user && canhear) - if(tumbler_1_pos == tumbler_1_open) - to_chat(user, "You hear a [pick("tonk", "krunk", "plunk")] from [src].") - if(tumbler_2_pos == tumbler_2_open) - to_chat(user, "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 TRUE - return FALSE - -/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_state() if(open) icon_state = "[initial(icon_state)]-open" else icon_state = initial(icon_state) -/obj/structure/safe/ui_interact(mob/user) - user.set_machine(src) - var/dat = "
| [P.name] |