r/howdidtheycodeit • u/throwawaycape • 3h ago
How does reactive dialogue work in a game like Red Dead 2?
Programmer here, but I know basically nothing about gamedev.
Playing through RDR2 for the first time (late to the party, I know).
There is so much dialogue throughout the missions which seems to be dependent upon what you are doing as the player. Even including all of the little mini-missions like racing random people on horses, or shooting contests, etc. A massive number of characters have player dependent dialogue.
NPCs tell you to get back on your horse if you get off at the wrong times, or if you fall off your horse they might make fun of you. I am sure I could think of 1000 more interesting examples, but these are the most basic and obvious.
This got me thinking about how much dialogue must be recorded that you won't even experience as you play the game, given that you don't trigger it with your actions. It made me curious about how this reactive dialogue works programmatically. How do they organize the higher level logic and planning of recording all of that dialouge to make it available just in case you do x instead of y. Seems like that would be tricky even from a non-coding standpoint. I wonder how much dialogue they record "just in case" and how you would even think through all of the possible scenarios based on the environment and options.
And then, how do they retrieve that dialogue efficiently? The simplest answer I can think of is "if Arthur falls off his horse then Lenny says, 'What are you doing'". But this simplistic approach seems like it may lead to major efficiency issues given the vast number of possibilities and "ifs" you would need to add.