A small mod that makes citizens in a village or city run indoors during a dragon or vampire attack.
This was born out of frustration at seeing the citizens all trying to be a hero and rushing headlong to their doom attacking dragons and vampires. Instead, the citizens will run to safety like smart people should when faced with the horrors of giant flying fire breathing lizards (or bloodthirsty undead). NPCs who live in the attack location who own a home there will retreat to it. If the attack location has an inn, NPCs who don't live there will flee to the inn, along with any NPCs who live outdoors. If no inn is present the game picks a random interior from the surrounding area and those NPCs will flee there instead.
This should work for any NPCs added by mods as well, up to a limit of 150 in the area. After that, they're on their own. The NPCs chosen are first come, first serve by the game engine.
Guards, members of The Companions, Vigilants of Stendarr, and the player's followers/teammates will not run, they will stand and fight. Farm animals will not run either, because they're stupid. That includes your horse.
Spawned dragons are detected via animation events, which should allow for completely reliable detection even if the dragon never lands on something.
Hand placed dragons are detected when their combat state changes* as well as when they land on any available perch objects in the area.
Vampires will be detected when the events that spawn them begin running.
* [Only after they land on the ground]
Requires the Unofficial Skyrim Special Edition Patch to be installed first!