I’ve got a real doozy of a pickle here if you need a puzzle to work on.
I have a dialogue box. It looks like this:
![image|690x446](upload://2i5mQjLyJF9vyUHKaLpKKiSpRZh.png
When you interact with an NPC, the game pauses, this becomes visible, etc. The grid on the left fills up with the topics that are available to discuss with the NPC. When you click on one, the box on the right displays their dialogue about that topic.
Here is the first part of the graph of this dialogue box that kicks in when you click a topic:
Clicking on the button in the topic widgets that get created fires an event dispatcher, which calls that red event node, which in turn passes along the topic of the button you clicked. Meanwhile, there is a map variable where the keys are names and the values are structs. We use the topic passed from the button to look up a struct, then we break the struct.
One of the variables we get out of this struct is a boolean that tells us whether the topic is related to a quest or not. We run that into a branch node.
Non-quest-related dialogue is handled simply. Another of the variables held in this struct that I mentioned is another map. The keys in this map are again names, and the values are again structs. Confused yet? Good.
The keys in this map represent the stage the quest is at. Non-quest related topics are just at stage 00, so when we plug it into a Find node, we don’t need to grab anything, we just hardcode it to 00, then it grabs the struct, breaks the struct, and gives us the dialogue text associated with the topic.
If, however, the topic was quest related, we bind an event to a dispatcher called On Quest Objective Inspected (this really does happen first, don’t let the positions of the nodes deceive you). Then we call a different event dispatcher, On Quest Dialogue Clicked, which is declared in a different actor, our Quest Actor.
The above is the scripting for the parent class, but each individual quest will have its own Quest Actor with custom scripting to represent the events that drive the quest forward.
The below shows a simple fetch quest Quest Actor.
At QuestStage 00, the NPC tells you he needs a test item. Then the QuestStage advances to 01, and he gives you a similar but slightly more abrasive dialogue.
After that, if you click this dialogue topic and you have a test item in your inventory, he says thanks. If you speak to him about it subsequently, he says thanks again.
This is all handled by a name variable inside that second tier struct called AdvanceQuestTo.
Here’s an example of what the whole complex of maps and structs and stuff looks like in the outliner:
What I’m trying to do with this one is make a quest-related dialogue option that doesn’t actually go anywhere but is dynamic, so that when you click on it a second time, they give you a different response (hence the Stage 01 dialogue “advancing” itself to Stage 01 again).
But back to the dialogue box’s event graph.
As far as I can tell, we’re still grabbing the AdvanceQuestTo and TopicText variables and plugging them into the Set Text node that comes off the True branch of the Branch node that is determined by whether the dialogue is quest related or not.
However, in practice, clicking on the topic text of an NPC with a default Quest Actor results in nothing happening with that big righthand box of the dialogue box. Which is to say that it seems to be pulling a null variable.
I’ve traced the execution flow with a breakpoint and stepping into the code, and all of the nodes are getting hit in the right order. Unfortunately, it appears that you can’t see the value of variables coming out of structs in debug mode, so I have to put a PrintString on it and get the AdvanceQuestTo value, which comes back as “None.”
Any ideas on why that is?