Yeah, it would be possible, but it may be tough to tweak it to work exactly as you intend. Spawning an NPC or 2 if no others are near shouldn't be too hard if you just do an NPC List search and check a set distance around the player to see if any NPCs are already within that range.
You will also need to consider stuff like NPCs spawning inside walls. If you are picky (like me), you would need to also make sure NPCs don't spawn facing a wall or in an awkward looking position. You can do a FindGroundZ() and CheckLoS() from the player to make sure the NPCs aren't spawned inside of a wall, but they may still be spawned close enough to a wall that they look like they are partially in it. You can also set the heading of the NPC to face toward the player so they aren't at a bad heading, but it might look a bit odd having all NPCs spawn facing the character.
I have some scripts I recently created to spawn an entire dungeon and it works pretty well. I made some plugins that can move the NPCs away from walls and also make them face away from walls as well. It isn't perfect yet, but it looks decent enough. I may submit the scripts here sometime after I get them tweaked enough. They are a bit complex though and are pretty resource intensive so I wouldn't really recommend them for regular use. I mostly created them for development purposes so I could do something like spawn an entire LDoN zone and save the spawns to the DB after for permanent use. Then with a little cleanup (mostly #spawnfix and pathing) we could have a fully spawned zone from scratch with minimal effort and time.
|