Other user's assetsAll the assets in this file belong to the author, or are from free-to-use modder's resources
Upload permissionYou can upload this file to other sites but you must credit me as the creator of the file
Modification permissionYou are allowed to modify my files and release bug fixes or improve on the features so long as you credit me as the original creator
Conversion permissionYou can convert this file to work with other games as long as you credit me as the creator of the file
Asset use permissionYou are allowed to use the assets in this file without permission as long as you credit me
Asset use permission in mods/files that are being soldYou are not allowed to use assets from this file in any mods/files that are being sold, for money, on Steam Workshop or other platforms
Asset use permission in mods/files that earn donation pointsYou are not allowed to earn Donation Points for your mods if they use my assets
Author notes
This author has not provided any additional notes regarding file permissions
File credits
This author has not credited anyone else in this file
Donation Points system
Please log in to find out whether this mod is receiving Donation Points
Changelogs
Version 2.0.Test
Redesigned the logic to make the mod run vastly faster, which allows for a more straightforward handling of NPCs.
Skyrim's quest-alias logic now handles sorting the NPCs into "eligible" or "ineligible" to be sent home, rather than papyrus. This not only runs much faster, but allows all NPCs to be processed simultaneously.
Each NPC no longer needs to wait their turn, so a slower but more accurate system is used to determine if they should be teleported home or not. The script will check twice to see if the NPC's position is changing, and if so, moves them to their package start location. This means that NPCs who are holding position as part of their quest scripting will always be ignored. False positives of NPCs who are simply wandering around the cell will still happen, but should continue without issue, as they did in version 1.0.
All filters for package templates have been removed.
All filters for location keywords have been removed except for "Clearable" locations, to prevent the script from running when waiting or sleeping in places where most AIs should be hostile to the player..
The bards still won't shush. With the new system it's quite easy to pick the bard out from the inn crowd and run a different script on them, but so far nothing makes them simply stop playing without using "recycle actor", and that seems risky. Thoughts are welcome.
Test version 2 includes the script needed for the mod to actually work. Everyone who downloaded the last test have a mod that does nothing! (Thank you, Babixbabix for being the one to tell me.)
Test version 2 will process potential followers, but not current followers. No data yet on how it handles the extra-extra style followers.
Test version 2 raises the limit on NPCs processed to 50.
Test version 2 adds a third pass on the script to check for movement.
Mods that add an unreasonable number of NPCs to smaller cells will still cause a problem. If there's so many NPCs on the cell that they can't begin to move to the door after three seconds, you're going to have a bad time.
Version 1.1.1
I forgot to add back in the checks to see if an NPC was dead or hostile to the player. Oops! Thanks, Holt59.
The filter to see if the cell was clearable or not was on the open menu event, but not the close menu event, which meant that if the cell was clearable, the script would always run. Yikes.
In fact, I've decided to limit the script to only run in locations with the keyword identifying them as an Inn. While this cuts down the places this mod will work to only a few dozen cells, I feel like letting it run wild across all of Tamriel is going to cause too many unexpected cases of things breaking.
Version 1.1
Closing Time now works on Waiting! Thanks, Sthaagg!
There is now a three hour minimum on the sleep or wait duration, to keep the script from running if only one or two hours have passed.
FormLists have been exchanged for Arrays, which run faster. Thanks again, Sthaagg!
Now that the quest runs on menu events rather than sleep events, the script has been moved from a magic effect to a quest alias.
The queuing will now begin after the sleep or wait has ended, rather than at the beginning. This is to avoid the NPCs in the cell radically changing while the queue is being made, leaving the final array a mess. While this means it will take the entire process longer to complete, it will be more accurate.
An AI Package Template white-list has been created, to allow only NPCs who are doing basic packages to be moved by the script. This list includes things like sandbox, eat, sleep, travel, and so forth. I expect to tweak this list based on feedback!
A limit of 50 NPCs has been placed on the script. However, that's still overkill. If there's more than 10 NPCs in the cell, the script will take a very long time to finish. That includes disabled NPCs, so mods like Interesting NPCs who store many NPCs hidden in taverns until they're ready to use will still slow the script down.
States are used in the script to make spamming the script not break everything. If you begin to sleep or wait again before the script has had time to process, the new events will be ignored. However, this doesn't mean the results will be correct. Only the NPCs who were in the cell at the time of the first wait/sleep will be moved.
The mod has been made future-proof by a new maintenance quest/script. Thanks for going out of your way to help me set that up, Thanks, Sthaagg! It all came together with your help.
Version 1.0.2
The Go Home script will now abort before queuing if the player is in a location with the "LocTypeClearable" keyword. This should cover most cells which are hostile by default. Let me know if you think if any other useful exceptions.
More exclusions have been added to the queuing. NPCs who are dead or have their AI disabled will be ignored. References who can't be cast as an actor will be ignored. (This should cut down on errors in the Papyrus log.)
More verbose and clear logging has been added to the trace-enabled script, to make it easier for players to read the script and report issues.
Version 1.0.1
NPCs of race Mannequin (or Manakin according to Bethesda) will be ignored.
The logic was tweaked a bit. I had my int which was running the list updated a little late, so the first entry of the queue wasn't being processed.
Tweaked the debug messages, since looking at them is a thing I am asking people to do, e.g. replaced more instance of "NPC" with the name of the character.
NPCs who have no package start location will be sent back exactly where they were found, rather than sent back to their editor location. I still haven't been able to reproduce any case of an NPC not having a package start location, so I am going to rely on feedback from people who were running into this case to tell me if it worked or not!
Version 1.0
Initial Release
You've just had a restful night at the inn. You wake up and discover that everyone's been partying at the bar all night, and are now all stampeding towards the exit door, causing a traffic jam that takes ten minutes to clear up. It doesn't have to be this way.
This mod runs invisibly in the background. Whenever you sleep, it takes stock of all of the NPCs around you, so that when you wake up, they're all be where they'd actually be at that hour. Your mornings may now actually be peaceful. This will always be true when sleeping or waiting in any inn.
Spoiler:
Show
The mod's script uses an SKSE function to find all NPCs in the cell with you at the time you've gone to bed and assign them to a list. When you wake up, the list is read, and each NPC is moved to where their current AI package wants them to be.
That said, here's some notes:
Technically, the NPC is moved twice. First they're sent to a holding cell. This is done because most AI packages begin with a travel sequence, which always have the start location at the NPC themselves. The holding cell ensures that the start location is not the Inn.
Next, the NPC evaluates their AI package. The travel sequence begins.
Finally, they're moved to their AI package start position. The travel sequence began in an unloaded cell, so it's skipped, and the NPC is moved directly to the location where their package wants them to be, depending on the time of day.
A failsafe double checks to make sure they're not still in the holding cell. If they are, they're moved to their default position, and the game system takes over. In all of my tests, this has never happened.
The script only puts the NPC where they want to be. So if the Innkeeper is standing next to your bed when you go to sleep, they'll still be there when you wake up.
Current followers are ignored by the script. They'd just be put right back where they were, so it's a waste if processing time.
If there's a very large number of NPCs in the Inn, which is certainly possible in a normal modded game, and you're using a mod which makes sleep happen much faster, you may see some NPCs being teleported after you wake up. The script has to move each NPC one at a time, so it may not be through with everyone by the time you're out of bed!
SKSE is required. The archive contains a single ESP-FE plugin and BSA archive. The plugin contains only new records and a few simple scripts.
This should work with all Inns, all beds, all ways you can sleep, and with all NPCs.
If you're using Engine Fixes (and you should be!) setting the sleep speed down to 10% is ok, but if you have a huge number of NPCs in the Inn, you'll probably be awake before the script finishes queuing them into the list, so you'll be able to see them all poof to the holding cell one by one. For more modest NPC counts (10 - 20) setting it to 30% sleep speed should be fine.
Mods like AI Overhaul and Immersive Citizens are supported and encouraged. It will make it more likely that the NPC has a place go go in the morning, leading to a quieter Inn when you wake up.
That said, mods that add a very large number of NPCs to the Inns at night, like Skyrim Belongs to the Nords, will take a very long time to process, so even without Engine Fixes it's likely that the script is still queuing up the NPCs after you've woken up, so you'll be able to see them poof away one by one. That's not immersive!
What if the NPC is lost forever? They won't be. Even if I teleported them to the holding cell and left them there, their AI package would still take over and eventually they'd move back to where they want to be. The only case where they'd be stuck is if they have no AI Package at all, and if that's true they're not a finished NPC. However, the script checks to see if they're still in there, and moves them to where they were just standing a second ago, so everyone's safe.
I originally had the idea for this mod some time in 2018. After making Tidy Up, many pointed out that Clean Up worked on the entire cell at once. I didn't want to make Tidy Up work that way, but after looking at how Clean Up used SKSE to scan the cell for references of a specific type and then run a function on each, I realized that I should try to use that new knowledge to achieve my old wish. So, thanks IronDusk33!
Sthaagg was a huge help in leveling up this mod to version 1.1. Thank you so much!