Dynamic NPC Dialogue
Sometimes you can do amazing things when you start digging through legacy code.
One of the best ways to make upgrades to gameplay is by using existing systems to make it happen! In Solar Purge, players have the opportunity to visit a space station hub world in between campaign missions. Here they can check their gear, read up on lore in the codex, play procedural challenge runs, and become immersed in the universe of the game by talking with the various NPCs.
The Unreal Engine already makes it reasonably easy to update things like character dialogue from the level blueprint, and plans were already in place to use this to change major NPC dialogue from mission to mission.
Some of my very first feedback from some other people on the team was how my dialogue was just a little bit too helpful; after all, the player characters have been hurtled halfway across the supercluster and the NPCs on the station don’t know these people (and aliens, and autonomous AIs in robot bodies). This got me to thinking, “wouldn’t it add another layer of suspension of disbelief if these NPCs could react differently to different player characters?”
And I found a way to do this looking through the legacy code:
Before I joined the team at Hitscan Games there were a lot of backend systems already in place. Originally, there had been plans for vendors to interact with player characters semi-regularly, and there had to be a way to handle cases where players didn’t have enough money on hand, or hadn’t completed some quest. The NPC Base Blueprint therefore had a section called “Failed Dialogue.”
This looked promising!
After a quick confirmation with the project lead that this wasn’t being used anywhere else, the solution started to take shape. Since we were already able to run a check on which player character any given player was using, then it should just be a matter of running that check on dialogue start and then branching on a pass or a fail for that check.
In the universe of Solar Purge, humanity has been under the bootheel of an alien space empire called the Aesrena for longer than many of the human characters have been alive, so there is a fair degree of background resentment. While there will certainly be plenty to read in the game’s codex, I believe that game dialogue should be used not to infodump but to make the game world feel lived in. Here we can take a look at two different NPCs to see how they each react to various human vs non-human playable characters:
One of the game’s four player classes is a renegade Aesrenan Assassin. When first arriving on the space station hub level after completing the game’s tutorial, the player gets a chance to interact with dozens of NPCs. After meeting a few more helpful characters in the corridors, they arrive in the command center. Here we get a chance to do a lot of worldbuilding while the player gets their bearings.
By filling in the main and “failed” Dialogue fields, I’m able to set up alternate paths to activate via a “Requirements Met” Blueprint component attached to the BP_NPC_Base Blueprint.
Next we set that component up to check when the NPC would change paths (the “ID” field), and run a conditional check on the Assassin base class. If any other player class interacts, she’ll stay on her main dialogue tree. If the player is using the Assassin however, we move to the alternate path from the beginning!
Here are the results during gameplay:
With unique reactions both the world and the NPCs in it feel a lot more alive!
Let’s take a look at a second example:
This one is a little more complex.
Two of the player classes are human (Engineer and Stryker), while the Assassin and Juggernaut characters aren’t. On meeting an NPC in the Archives section of the station, we run a check on whether we are on the first line of dialogue (ID == 0), then on whether the player has selected the Engineer or if not that then Stryker. If any other class interacts, they’ll experience the alternate dialogue path.
Here are the results for the human Engineer and Stryker classes:
Here we see the Assassin and Juggernaut classes’ interactions:
And now we’ve created NPCs who can react differently to different players and on different play sessions! As a result each one feels a little bit more alive than it might otherwise. By layering these characters throughout the hub world and a few early campaign missions each playthrough will not only take a on a slightly different flavor, but also more fully immerse players in the universe of Solar Purge!
Expanding interactivity by hijacking legacy code isn’t something that’s always going to work, but when it does it can multiply your options with just a minor Blueprint Component! This is just one example of the kinds of things I do at Hitscan Games to add that immersive touch and keep players coming back for another session!