Is there a way to have NPCs use interior doors?

My dungeon maps will be fairly large, with multiple rooms and corridors, and I'd like to add some doors. I found a thread that talks about how to set up a door event so the player can open it from either side. So far so good.

What about wandering enemies/NPCs? Is there a way to have them open a door?

Let's say your party is in a room, the door is shut, and some goblins are walking past you in the hallway outside. And let's say one of them notices the light from your torch under the door, or overhears the loud racket your party is making as it loots the room. It would be nice if I could have the goblins could walk up to the door, open it, and walk inside the room.

Is it possible to have an enemy/NPC event open a door event that is blocking its path?

Along that line, if there is a timid enemy who flees when he sees you, it would be nice if he could enter a room and close/lock the door behind him to hide. I'm assuming if the first is possible, then I could probably figure out how to do this as well.
That would require a pathfindindig script and/or a script that makes events aware of the player, i.e. they attack if they, or the player, get within a certain range.

The other thing is, events cannot start other events, at least not without scripting. I think someone wrote a script that gives you many more commands for your events, but I can't remember if that includes this option.
If the event-NPC is controlled as in a cutscene, you can make the use of the door a part of that cutscene.

If the event-NPC is on random move, then no - not by default as events can't trigger other events.

There are ways to do it if you control the event in a way that you create the "random move" yourself instead of automatically, but that would require an extremely complex event checking where to move.
You could use a script that gives you all enemy positions as variables. Set all doors to "through" and on parallel process.

Every door checks, if the coordinates of any enemy event or the player are the same as its own. If that happens, play the door animation.

As all doors are "through" it's only a matter of making them play the animation at the right time.
Hm. You guys have given me some interesting ideas to ponder. I'll have to play around with the events a bit more, and maybe see if I can locate one of those scripts...

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-way-to-have-npcs-use-interior-doors.42766/