So, how do I do that? Give a node a condition that makes it only be considered valid, if at least one child's condition is true. We have something similar for a particular conversation's START-node (DialogueManager.ConversationHasValidEntry(title)). I understand why it doesn't feel right to have this kind of condition, because then if this node has a Script-entry that sets some of the variables used in the conditions of the children, those Script-entries won't be executed during the check, and thus the checks become more and more erroneous the deeper you go, especially into quests which change their states a lot.
A 1-layer deep check, though, is very useful and easy to maintain, so can I do this kind of Condition somehow?
I've been looking into the Lua-functions, but I don't see any hint of having access to the current node or its children. Making a C# function also sounds like a great idea, until you realize you can only send simple datatypes. Do I have to make a custom C# function which I send the node-ID to and somehow look up its conversation and find its children or what?
Or should I do this by overriding the ShowResponseButtons() and do the ignoring there? Seems like a weird place to put that concern. I'd much rather that I could put it as a Condition.
This is again to try to combat the need for a massive Condition on a root-menu response-node called "Quests", to only make it show (be valid) if there are quests available (children/links with valid conditions).
Only show response-button, if at least one child's condition is true
Re: Only show response-button, if at least one child's condition is true
Hi,
You can assign a function to DialogueManager.isDialogueEntryValid, which is a delegate that lets you perform additional checks on a dialogue entry beyond simply checking its Conditions field. Example:
You can assign a function to DialogueManager.isDialogueEntryValid, which is a delegate that lets you perform additional checks on a dialogue entry beyond simply checking its Conditions field. Example:
Code: Select all
DialogueManager.isDialogueEntryValid = IsChildTrue;
...
bool IsChildTrue(DialogueEntry entry)
{
foreach (var link in entry.outgoingLinks)
{
var child = DialogueManager.masterDatabase.GetDialogueEntry(link);
if (Lua.IsTrue(child.conditionsString)) return true;
}
return false; // No child is true, so return false.
}
Re: Only show response-button, if at least one child's condition is true
That's brilliant! Wow! I thought I had you there for a second
Re: Only show response-button, if at least one child's condition is true
Actually, this also enables me to do the deeper check I was talking about in the other thread, where I wanted it to keep going through the tree as long as it only hits group-nodes, so I can have a more elaborate net of nodes handling the conditions for each dialogue in the quest. This is so I can control directly through conditions which quests to generate response-buttons for, and these conditions depend on several variables spread over the "unassigned"-, "active" and "success"-nodes, which together determine whether the quest currently has a dialogue available, meaning it is available and its requirements are met or it's currently active and the objectives are or aren't available, and things like that. This way I would only generate response-buttons for the quests which currently will have a dialogue to show the player.
Re: Only show response-button, if at least one child's condition is true
But this solution will affect the entire system and not just the specific nodes I want it to use it on. I could maybe check for a keyword, INVALIDIFNOVALIDCHILD, in the Title-field or Description-field of the node or something. And then make another one for skipping groups, as well.
Re: Only show response-button, if at least one child's condition is true
You could also define a custom field (e.g., "Invalid If No Valid Child") and check if it's true. If so, run the child condition check. When you're writing your conversation, set the custom field true on applicable nodes. This might be a little tidier than embedding information in the title or description.