GLOBAL_VAR_INIT(hhStorageTurf, null) GLOBAL_VAR_INIT(hhmysteryRoomNumber, 1337) /obj/item/hilbertshotel name = "Hilbert's Hotel" desc = "A sphere of what appears to be an intricate network of bluespace. Observing it in detail seems to give you a headache as you try to comprehend the infinite amount of infinitesimally distinct points on its surface." icon_state = "hilbertshotel" w_class = WEIGHT_CLASS_SMALL resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF var/datum/map_template/hilbertshotel/hotelRoomTemp var/datum/map_template/hilbertshotel/empty/hotelRoomTempEmpty var/datum/map_template/hilbertshotel/lore/hotelRoomTempLore var/list/activeRooms = list() var/list/storedRooms = list() var/list/checked_in_ckeys = list() var/storageTurf //Lore Stuff var/ruinSpawned = FALSE var/mysteryRoom /obj/item/hilbertshotel/Initialize() . = ..() //Load templates hotelRoomTemp = new() hotelRoomTempEmpty = new() hotelRoomTempLore = new() var/area/currentArea = get_area(src) if(currentArea.type == /area/ruin/space/has_grav/hilbertresearchfacility) ruinSpawned = TRUE /obj/item/hilbertshotel/Destroy() ejectRooms() return ..() /obj/item/hilbertshotel/attack(mob/living/M, mob/living/user) if(M.mind) to_chat(user, "You invite [M] to the hotel.") promptAndCheckIn(M) else to_chat(user, "[M] is not intelligent enough to understand how to use this device!") /obj/item/hilbertshotel/attack_self(mob/user) . = ..() promptAndCheckIn(user) /obj/item/hilbertshotel/proc/promptAndCheckIn(mob/user) var/chosenRoomNumber = input(user, "What number room will you be checking into?", "Room Number") as null|num if(!chosenRoomNumber || !user.CanReach(src)) return if(chosenRoomNumber > SHORT_REAL_LIMIT) to_chat(user, "You have to check out the first [SHORT_REAL_LIMIT] rooms before you can go to a higher numbered one!") return if((chosenRoomNumber < 1) || (chosenRoomNumber != round(chosenRoomNumber))) to_chat(user, "That is not a valid room number!") return if(!isturf(loc)) if((loc == user) || (loc.loc == user) || (loc.loc in user.contents) || (loc in user.GetAllContents(type))) //short circuit, first three checks are cheaper and covers almost all cases (loc.loc covers hotel in box in backpack). forceMove(get_turf(user)) if(!storageTurf) //Blame subsystems for not allowing this to be in Initialize if(!GLOB.hhStorageTurf) var/datum/map_template/hilbertshotelstorage/storageTemp = new() var/datum/turf_reservation/storageReservation = SSmapping.RequestBlockReservation(3, 3) storageTemp.load(locate(storageReservation.bottom_left_coords[1], storageReservation.bottom_left_coords[2], storageReservation.bottom_left_coords[3])) GLOB.hhStorageTurf = locate(storageReservation.bottom_left_coords[1]+1, storageReservation.bottom_left_coords[2]+1, storageReservation.bottom_left_coords[3]) else storageTurf = GLOB.hhStorageTurf checked_in_ckeys |= user.ckey //if anything below runtimes, guess you're outta luck! if(tryActiveRoom(chosenRoomNumber, user)) return if(tryStoredRoom(chosenRoomNumber, user)) return sendToNewRoom(chosenRoomNumber, user) /obj/item/hilbertshotel/proc/tryActiveRoom(var/roomNumber, var/mob/user) if(activeRooms["[roomNumber]"]) var/datum/turf_reservation/roomReservation = activeRooms["[roomNumber]"] do_sparks(3, FALSE, get_turf(user)) user.forceMove(locate(roomReservation.bottom_left_coords[1] + hotelRoomTemp.landingZoneRelativeX, roomReservation.bottom_left_coords[2] + hotelRoomTemp.landingZoneRelativeY, roomReservation.bottom_left_coords[3])) return TRUE else return FALSE /obj/item/hilbertshotel/proc/tryStoredRoom(var/roomNumber, var/mob/user) if(storedRooms["[roomNumber]"]) var/datum/turf_reservation/roomReservation = SSmapping.RequestBlockReservation(hotelRoomTemp.width, hotelRoomTemp.height) hotelRoomTempEmpty.load(locate(roomReservation.bottom_left_coords[1], roomReservation.bottom_left_coords[2], roomReservation.bottom_left_coords[3])) var/turfNumber = 1 for(var/i=0, iAs the sphere breaks apart, you're suddenly ejected into the depths of space!") var/max = world.maxx-TRANSITIONEDGE var/min = 1+TRANSITIONEDGE var/list/possible_transtitons = list() for(var/AZ in SSmapping.z_list) var/datum/space_level/D = AZ if (D.linkage == CROSSLINKED) possible_transtitons += D.z_value var/_z = pick(possible_transtitons) var/_x = rand(min,max) var/_y = rand(min,max) var/turf/T = locate(_x, _y, _z) A.forceMove(T) qdel(room) if(storedRooms.len) for(var/x in storedRooms) var/list/atomList = storedRooms[x] for(var/atom/movable/A in atomList) var/max = world.maxx-TRANSITIONEDGE var/min = 1+TRANSITIONEDGE var/list/possible_transtitons = list() for(var/AZ in SSmapping.z_list) var/datum/space_level/D = AZ if (D.linkage == CROSSLINKED) possible_transtitons += D.z_value var/_z = pick(possible_transtitons) var/_x = rand(min,max) var/_y = rand(min,max) var/turf/T = locate(_x, _y, _z) A.forceMove(T) /obj/item/hilbertshotel/ghostdojo name = "Infinite Dormitories" anchored = TRUE interaction_flags_atom = INTERACT_ATOM_ATTACK_HAND /obj/item/hilbertshotel/ghostdojo/interact(mob/user) . = ..() promptAndCheckIn(user) //Template Stuff /datum/map_template/hilbertshotel name = "Hilbert's Hotel Room" mappath = '_maps/templates/hilbertshotel.dmm' var/landingZoneRelativeX = 2 var/landingZoneRelativeY = 8 /datum/map_template/hilbertshotel/empty name = "Empty Hilbert's Hotel Room" mappath = '_maps/templates/hilbertshotelempty.dmm' /datum/map_template/hilbertshotel/lore name = "Doctor Hilbert's Deathbed" mappath = '_maps/templates/hilbertshotellore.dmm' /datum/map_template/hilbertshotelstorage name = "Hilbert's Hotel Storage" mappath = '_maps/templates/hilbertshotelstorage.dmm' //Turfs and Areas /turf/closed/indestructible/hotelwall name = "hotel wall" desc = "A wall designed to protect the security of the hotel's guests." icon_state = "hotelwall" canSmoothWith = list(/turf/closed/indestructible/hotelwall) explosion_block = INFINITY /turf/open/indestructible/hotelwood desc = "Stylish dark wood with extra reinforcement. Secured firmly to the floor to prevent tampering." icon_state = "wood" footstep = FOOTSTEP_WOOD tiled_dirt = FALSE /turf/open/indestructible/hoteltile desc = "Smooth tile with extra reinforcement. Secured firmly to the floor to prevent tampering." icon_state = "showroomfloor" footstep = FOOTSTEP_FLOOR tiled_dirt = FALSE /turf/open/space/bluespace name = "\proper bluespace hyperzone" icon_state = "bluespace" baseturfs = /turf/open/space/bluespace flags_1 = NOJAUNT_1 explosion_block = INFINITY var/obj/item/hilbertshotel/parentSphere /turf/open/space/bluespace/Entered(atom/movable/A) . = ..() A.forceMove(get_turf(parentSphere)) /turf/closed/indestructible/hoteldoor name = "Hotel Door" icon_state = "hoteldoor" explosion_block = INFINITY var/obj/item/hilbertshotel/parentSphere /turf/closed/indestructible/hoteldoor/proc/promptExit(mob/living/user) if(!isliving(user)) return if(!user.mind) return if(!parentSphere) to_chat(user, "The door seems to be malfunctioning and refuses to operate!") return if(alert(user, "Hilbert's Hotel would like to remind you that while we will do everything we can to protect the belongings you leave behind, we make no guarantees of their safety while you're gone, especially that of the health of any living creatures. With that in mind, are you ready to leave?", "Exit", "Leave", "Stay") == "Leave") if(!user.canmove || (get_dist(get_turf(src), get_turf(user)) > 1)) //no teleporting around if they're dead or moved away during the prompt. return user.forceMove(get_turf(parentSphere)) do_sparks(3, FALSE, get_turf(user)) /turf/closed/indestructible/hoteldoor/attack_ghost(mob/dead/observer/user) if(!isobserver(user) || !parentSphere) return ..() user.forceMove(get_turf(parentSphere)) //If only this could be simplified... /turf/closed/indestructible/hoteldoor/attack_tk(mob/user) return //need to be close. /turf/closed/indestructible/hoteldoor/attack_hand(mob/user) promptExit(user) /turf/closed/indestructible/hoteldoor/attack_animal(mob/user) promptExit(user) /turf/closed/indestructible/hoteldoor/attack_paw(mob/user) promptExit(user) /turf/closed/indestructible/hoteldoor/attack_hulk(mob/living/carbon/human/user, does_attack_animation) promptExit(user) /turf/closed/indestructible/hoteldoor/attack_larva(mob/user) promptExit(user) /turf/closed/indestructible/hoteldoor/attack_slime(mob/user) promptExit(user) /turf/closed/indestructible/hoteldoor/attack_robot(mob/user) if(get_dist(get_turf(src), get_turf(user)) <= 1) promptExit(user) /turf/closed/indestructible/hoteldoor/AltClick(mob/user) . = ..() if(get_dist(get_turf(src), get_turf(user)) <= 1) to_chat(user, "You peak through the door's bluespace peephole...") user.reset_perspective(parentSphere) user.set_machine(src) var/datum/action/peepholeCancel/PHC = new user.overlay_fullscreen("remote_view", /obj/screen/fullscreen/impaired, 1) PHC.Grant(user) return TRUE /turf/closed/indestructible/hoteldoor/check_eye(mob/user) if(get_dist(get_turf(src), get_turf(user)) >= 2) user.unset_machine() for(var/datum/action/peepholeCancel/PHC in user.actions) PHC.Trigger() /datum/action/peepholeCancel name = "Cancel View" desc = "Stop looking through the bluespace peephole." button_icon_state = "cancel_peephole" /datum/action/peepholeCancel/Trigger() . = ..() to_chat(owner, "You move away from the peephole.") owner.reset_perspective() owner.clear_fullscreen("remote_view", 0) qdel(src) /area/hilbertshotel name = "Hilbert's Hotel Room" icon_state = "hilbertshotel" requires_power = FALSE has_gravity = TRUE noteleport = TRUE hidden = TRUE unique = FALSE dynamic_lighting = DYNAMIC_LIGHTING_FORCED ambientsounds = list('sound/ambience/servicebell.ogg') var/roomnumber = 0 var/obj/item/hilbertshotel/parentSphere var/datum/turf_reservation/reservation var/turf/storageTurf /area/hilbertshotel/Entered(atom/movable/AM) . = ..() if(istype(AM, /obj/item/hilbertshotel)) relocate(AM) var/list/obj/item/hilbertshotel/hotels = AM.GetAllContents(/obj/item/hilbertshotel) for(var/obj/item/hilbertshotel/H in hotels) if(parentSphere == H) relocate(H) /area/hilbertshotel/proc/relocate(obj/item/hilbertshotel/H) if(prob(0.135685)) //Because screw you qdel(H) return var/turf/targetturf = find_safe_turf() if(!targetturf) if(GLOB.blobstart.len > 0) targetturf = get_turf(pick(GLOB.blobstart)) else CRASH("Unable to find a blobstart landmark") var/turf/T = get_turf(H) var/area/A = T.loc log_game("[H] entered itself. Moving it to [loc_name(targetturf)].") message_admins("[H] entered itself. Moving it to [ADMIN_VERBOSEJMP(targetturf)].") for(var/mob/M in A) to_chat(M, "[H] almost implodes in upon itself, but quickly rebounds, shooting off into a random point in space!") H.forceMove(targetturf) /area/hilbertshotel/Exited(atom/movable/AM) . = ..() if(ismob(AM)) var/mob/M = AM parentSphere?.checked_in_ckeys -= M.ckey if(M.mind) var/stillPopulated = FALSE var/list/currentLivingMobs = GetAllContents(/mob/living) //Got to catch anyone hiding in anything for(var/mob/living/L in currentLivingMobs) //Check to see if theres any sentient mobs left. if(L.mind) stillPopulated = TRUE break if(!stillPopulated) storeRoom() /area/hilbertshotel/proc/storeRoom() var/roomSize = (reservation.top_right_coords[1]-reservation.bottom_left_coords[1]+1)*(reservation.top_right_coords[2]-reservation.bottom_left_coords[2]+1) var/storage[roomSize] var/turfNumber = 1 var/obj/item/abstracthotelstorage/storageObj = new(storageTurf) storageObj.roomNumber = roomnumber storageObj.parentSphere = parentSphere storageObj.name = "Room [roomnumber] Storage" for(var/i=0, i