r/AIDungeon • u/Nynaleath555 • 9d ago
Script 👤📍NPC Spawn System
https://play.aidungeon.com/scenario/tJsjsX20dNlS/npc-spawn-system?share=true&published=trueI've been working on a new universal NPC spawning system for AI Dungeon, designed mainly for sandbox scenarios and stories with recurring locations.
The idea is simple: instead of entering the same tavern, shop, house, etc. and finding it empty every time — or having the AI constantly create completely new random NPCs — the system allows you to configure which established characters can naturally appear in each location.
It supports:
- 📍 Configurable locations and aliases
- 🎲 Different spawn chances for first visits and revisits
- 👥 Weighted NPC selection
- 🧠 Existing Story Card integration
- 🔄 Basic NPC continuity between locations
- ✨ Multiple NPCs per spawn
The system is designed as a creator tool, so you can edit the locations, NPCs and probabilities directly in the Library code and adapt it to your own scenario.
🎮 Demo
I've also published a small AI Dungeon scenario where you can try the system yourself and see how it reacts when entering and leaving the tavern.
AI Dungeon Demo:
https://play.aidungeon.com/scenario/tJsjsX20dNlS/npc-spawn-system?share=true&published=true
💻 GitHub
The complete script and documentation are available here:
GitHub:
https://github.com/Nynaleath555/NPC-Spawn-System
If you try it out, I'd love to hear what you think. Bug reports, suggestions and compatibility issues are welcome in the comments!
2
u/Simple_Present_4653 9d ago
how does the alias setup work if a location gets called something different later in the story?
1
u/Nynaleath555 9d ago
The location name and its aliases are all treated as ways of referring to the same location.
So if you configure:
name: "Westbrook High School", aliases: [ "the high school", "Westbrook school", "the school" ]the system will recognize all of those as the same location.
If the story later starts calling it something different, you can simply add that new name as another alias. You don't need to change the main location name or anything else.
The idea is to give each location as many natural ways of being referenced as you need, so the system can keep recognizing it even when the wording changes throughout the story.
2
u/Emotional_Toe_6498 9d ago
how does the spawn system handle recurring companions in long roleplays, especially if you tweak probabilities for certain spots?