Having trouble figuring out why I can't get this variable (Warning: very convoluted blueprint)

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:

image

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?

so quest actor value in struct is giving null?

No it’s topictext and advancetoqueststage that are coming back null

Did a little more work debugging with print strings and I narrowed it down to this struct not being found. The boolean out returns “false” when it’s plugged into a print string node.

But when we look at the NPC I’m trying to talk to, we clearly see that there is a struct there. We’re getting 00 from the NPC’s QUestActor variable and using it as the lookup value in the map, so it should be returning the struct associated with 00 in the NPC’s TopicText map. There clearly is a 00 in this map and it clearly has a struct associated with it.

And when we look at the quest actor’s variables, they are set to match this dialogue’s.

image

edit: I also just ran the map into an IsNotEmpty node and it returned true. So it’s pulling the map and recognizing that the map has contents, but for some reason when we try to look up the key 00 with the value 00, it doesn’t work.

edit again: If I don’t use the QuestStage variable from the QuestActor for the input pin of the Find node but just type in 00, it returns the correct dialogue without any issue. but 00 is exactly what the QuestStage variable is.

Why isn’t this working??

Using arrays and maps inside structs can be a tricky pain. A few quick points:

-If you are changing an array inside of a struct you need a node called Set Array Element (I think thats what it’s called). That has to be triggered after you update the array with your Add node or whatever other wise the array updated doesn’t trigger.

-Look into Datatables if you haven’t already. Datatable is sort of like an array of structs. It makes working with them easier.

-Personally, when I have an actor file with a menu of variables…I don’t bother putting them inside a struct. Structs often give package errors for no reason and other annoying ■■■■ like this. If the data is in a child actor that isn’t changing at run time then I wouldn’t bother couching it in a struct if you don’t have to.

-From those images we can’t tell where the data is coming from, are you sure it’s coming from the specific child actor with that struct set up? Or the host actor? That might be why no data.