Page 1 of 2
How do I make a locked conversation choice that you can see but can't choose?
Posted: Thu Jun 27, 2019 10:52 pm
by AoF
I'd like to make some very specific conversation choices "locked" until you gain enough stats, but I'd like the player to be able to see that option exists before they have the stats, so they have a sense of what dialogue choices will be in the future. This will be a response menu, if that matters. I have plenty of other response choices that I want to hide, so I'll need a solution that only works for certain choices and not by default. Thanks!
Re: How do I make a locked conversation choice that you can see but can't choose?
Posted: Thu Jun 27, 2019 11:05 pm
by Tony Li
Hi,
This post has an example package. You can use the code in it as-is. Briefly:
1. Tick the Dialogue Manager's
Input Settings > Include Invalid Entries. Invalid (locked) entries will appear as response buttons, but the buttons will not be interactable. You can optionally set an
[em#] Tag for Invalid Responses to format them differently.
2. Add conditions to your locked entries. For example, if the player must be at least level 5, set the node's
Conditions field to something like:
3. Add a custom Boolean field named "Show Invalid". Set it true for locked entries that should be visible even if their conditions aren't met yet.
Re: How do I make a locked conversation choice that you can see but can't choose?
Posted: Thu Jun 27, 2019 11:11 pm
by AoF
Tony Li wrote: ↑Thu Jun 27, 2019 11:05 pm
3. Add a custom Boolean field named "Show Invalid". Set it true for locked entries that should be visible even if their conditions aren't met yet.
Can you elaborate on this part? I know how to add a custom field, but where would I check for its value, what would I write if it's true/false, and where would I put that code?
Thanks!
Re: How do I make a locked conversation choice that you can see but can't choose?
Posted: Thu Jun 27, 2019 11:18 pm
by Tony Li
Hi,
You don't need to change its value except at design time -- i.e., when you're writing your dialogue. The script in the package that I linked above checks it for you. If "Show Invalid" is true, it tells the response menu to show it even if its conditions are false. If "Show Invalid" is false, it won't appear in the menu if its conditions are false.
You can also change it at runtime if you want, but you probably won't need to do that. To change it at runtime, set the corresponding Lua field. The post I linked above has an example.
Re: How do I make a locked conversation choice that you can see but can't choose?
Posted: Thu Jun 27, 2019 11:29 pm
by AoF
Oh sorry, I hadn't looked at the script yet, I didn't know it already used this field. Thanks again.
Re: How do I make a locked conversation choice that you can see but can't choose?
Posted: Thu Jun 27, 2019 11:38 pm
by Tony Li
No worries! If you have any questions about using it, just let me know. If you play the example scene and then pick it apart, it should be pretty clear.
Re: How do I make a locked conversation choice that you can see but can't choose?
Posted: Sun Jul 07, 2019 7:34 pm
by AoF
I got this working, but I have a complex situation I don't know how to handle in it. Here's my node:
You should only be able to ask, "Do you know anything about that girl in the alley?" if you've met that girl in the alley. I don't think it makes sense to show this node before you've met her. On the other hand, I want this node to drain energy when you choose it, and if you don't have enough energy, this node should be invalid.
In other words, the conditions that are currently in the node should show the node if they pass. But, I want to add a condition that says, "totalEnergy > 0", and if that one fails, I want the node to be invalid.
I already have this "ShowEnergyCostInResponseMenu" class that I'm using. I'm wondering if there's a way in there to dynamically change the node's "Show Invalid" value? Here's how it looks:
Code: Select all
using PixelCrushers.DialogueSystem;
using UnityEngine;
public class ShowEnergyCostInResponseMenu : MonoBehaviour
{
private static UnityEngine.Events.UnityAction subtractEnergyCall = () => TotalEnergy.SubtractEnergy();
public void OnConversationResponseMenu(Response[] responses)
{
foreach (var response in responses)
{
var cost = Field.LookupInt(response.destinationEntry.fields, "energyCost");
if (cost > 0)
{
response.formattedText.text = TextSprites.energy + response.formattedText.text;
response.destinationEntry.onExecute.RemoveListener(subtractEnergyCall);
response.destinationEntry.onExecute.AddListener(subtractEnergyCall);
}
}
}
}
The problem is, it should only set "Show Invalid" to true if all the other conditions are met and energy == 0. I'm not sure how to check if all conditions are met. I'm also not sure if changing the field in here (if even possible), would be used, because I remember reading something about how you need to do changes like that two nodes in advance.
Re: How do I make a locked conversation choice that you can see but can't choose?
Posted: Sun Jul 07, 2019 8:30 pm
by AoF
I tried putting this in that if statement:
Code: Select all
if (response.enabled)
{
Debug.LogError("setting field to invalid");
Field.SetValue(response.destinationEntry.fields, "Show Invalid", true);
}
It permanently changed the value in the database (something I don't want). Is there a way to make this change runtime only?
Update: Figured out how to not save the value here:
viewtopic.php?t=1271#p6769
The only thing I haven't figured out is to append "you should have enough energy," to the conditions at runtime.
Re: How do I make a locked conversation choice that you can see but can't choose?
Posted: Sun Jul 07, 2019 8:48 pm
by AoF
Yeah, I don't think this can work unless there's an extremely complicated solution. Once you click on this node and the quest ends, I'd want to change the "Show Invalid" back to false so you can no longer see the option. Relating "valid" to "visible" seems to make things more complex in my case. I think what I'd want is a new field called "Valid" that's a string with a script. It can be evaluated, just like Conditionals. That way, the node could be visible/hidden independent of whether it's valid/invalid.
Re: How do I make a locked conversation choice that you can see but can't choose?
Posted: Sun Jul 07, 2019 9:04 pm
by AoF
By the way, I *think* line 55 has a bug in it. It shows this: var luaResult = Lua.Run("return Dialog[" + response.destinationEntry.id + "].Show_Invalid");
Shouldn't that "Show_Invalid" be using the variable instead? If I understand this correctly, you couldn't evaluate at runtime if you changed the name of your variable.