I’m working on a fairly bog-standard RPG, and I’m trying to work out a really robust workflow to position NPCs throughout the world and dynamically change their spawn location and dialogue in response to player activities or progression of the main quest/world state. This is mostly thinking out loud, but I’d really appreciate some feedback if there are obvious flaws to the architecture I’ve built.
Right now I’m accomplishing this by building a giant dict containing every NPC in the game accessible by enum key, and giving the NPC itself keys for its default spawn location and default dialogue. Temporary changes to either, like a quest moving someone across the world or changing their dialogue to read “I don’t have time to talk, darn it, I need those peanuts you promised me!”, are stored as a <NPC key, dialogue/spawn override> pair in the actual quest node that causes these changes. More permanent changes, like moving around in response to the main quest, are achieved by using scripting commands to manually change an NPC’s default keys.
With this all set up, every time a level is loaded in or someone is spoken to, the game iterates through every quest looking for override spawn/dialogue keys. If it finds some, it sorts them by priority and returns the highest-priority override, and if it finds nothing it spawns them at their default location, or plays the default dialogue.
All in all this feels like a fairly robust design, since linking behavior to individual quests/quest nodes means that debugging unwanted behavior is as simple as checking that NPC’s overrides, and because it simplifies my workflow as a content creator by focusing everything on the quest editor, instead of forcing me to juggle multiple tables and scripting injectors across different parts of the game. That having been said, I am literally pulling this entire setup out of thin air, and there are no formal patterns or architectural standards I’m building towards; is there anything about this that’s likely to bite me in the rear end as complexity scales, or is this a fairly okay way to approach a complex problem?