Quest states
Quest states
Hi,
I'm sorry I have so many questions. I'm just trying to get everything setup so I can focus on writing more quests.
Anyway, am I able to add a completely new quest state? I've read some other posts and it looks like you're not really adding a new state, it's just putting a different name on an old state. I need a whole new state that will show up in all the other controls. I looked at the QuestState.CS and I don't want to add to it and screw it up if it is limited or something.
What I'm needing to do is say NPC with exclamation over head means quest is Unassigned, NPC grey Question mark means quest is active, yellow question mark means (NOT SUCCESSFUL but you did what he wanted.) then when you turn in the item is becomes successful and there is no indicator or there could be a new exclamation if he has another quest.
If I can assign a new state in the QuestState I'd like to do that so I can use it thoughout.
So basically, I need a state that says quest has been completed but not yet turned in.
Because if I use success for the last state then it goes to the completed section of the log. I don't want it out of the log until they've turned it in and gotten their reward.
Thanks
I'm sorry I have so many questions. I'm just trying to get everything setup so I can focus on writing more quests.
Anyway, am I able to add a completely new quest state? I've read some other posts and it looks like you're not really adding a new state, it's just putting a different name on an old state. I need a whole new state that will show up in all the other controls. I looked at the QuestState.CS and I don't want to add to it and screw it up if it is limited or something.
What I'm needing to do is say NPC with exclamation over head means quest is Unassigned, NPC grey Question mark means quest is active, yellow question mark means (NOT SUCCESSFUL but you did what he wanted.) then when you turn in the item is becomes successful and there is no indicator or there could be a new exclamation if he has another quest.
If I can assign a new state in the QuestState I'd like to do that so I can use it thoughout.
So basically, I need a state that says quest has been completed but not yet turned in.
Because if I use success for the last state then it goes to the completed section of the log. I don't want it out of the log until they've turned it in and gotten their reward.
Thanks
Re: Quest states
You can assign replacement functions (delegates) without directly modifying the source code. Otherwise when you import a Dialogue System update you'll lose your changes.
Internally, the Dialogue System stores its data in Lua. Each quest's state is a string. For example:
For this example, to keep it short let's use the word "preempted" for the state "NOT SUCCESSFUL but you did what he wanted". This is valid in Lua:
or, using the SetQuestState() function:
Or, in C# code:
To get the value in C# code:
In some inspectors, you'll need to manually enter:
instead of using quest state dropdowns because those dropdowns offer a "preempted" option.
In some places you'll want the Dialogue System will treat "preempted" the same as "unassigned". In other places, such as overhead indicators, you'll override the default behavior to recognize that it's different from "unassigned". Assign a delegate to QuestLog.StringToState to tell it to treat "preempted" the same as "unassigned" by default:
Now the Dialogue System will handle "preempted" like unassigned everywhere except where you override that behavior, which is what we'll do next.
From your description, I think the only place where you want to handle "preempted" differently is overhead indicators. To do this, write a replacement for QuestStateListener.cs. Update the class name, and replace these two lines:
with this:
The rest should work as-is. Let's say you name your replacement CustomQuestStateListener. Just add this script to your NPC instead of QuestStateListener.
Internally, the Dialogue System stores its data in Lua. Each quest's state is a string. For example:
Code: Select all
Quest["chazpea/yellowskull"].State = "unassigned"
Code: Select all
Quest["chazpea/yellowskull"].State = "preempted"
Code: Select all
SetQuestState("chazpea/yellowskull", "preempted")
Code: Select all
QuestLog.SetQuestState("chazpea/yellowskull", "preempted");
Code: Select all
string state = QuestLog.CurrentQuestState("chazpea/yellowskull");
Code: Select all
SetQuestState("chazpea/yellowskull", "preempted")
In some places you'll want the Dialogue System will treat "preempted" the same as "unassigned". In other places, such as overhead indicators, you'll override the default behavior to recognize that it's different from "unassigned". Assign a delegate to QuestLog.StringToState to tell it to treat "preempted" the same as "unassigned" by default:
Code: Select all
QuestLog.StringToState = CustomStringToState;
public static QuestState CustomStringToState(string s)
{
// Treat "preempted" the same as "unassigned":
if (s == "preempted") return QuestState.Unassigned;
else return QuestLog.DefaultStringToState(s);
}
From your description, I think the only place where you want to handle "preempted" differently is overhead indicators. To do this, write a replacement for QuestStateListener.cs. Update the class name, and replace these two lines:
Code: Select all
public QuestState questState;
Code: Select all
public string questState;
Re: Quest states
Are you talking about the main QuestStateListener or the Wrapper? Because I'm getting all kinds of errors if I change that line from the full script.
And the quest states are drop downs with no option to write in a custom state.
And the quest states are drop downs with no option to write in a custom state.
Re: Quest states
It looks like a lot of the errors are because it expects the class to be called QuestStateListener not CustomQuestStateListener.
The errors:
The errors:
Re: Quest states
OK, I inherited from QuestStateListener and all the errors are gone except for the second image.
the bold underlined part is the error. I see you're getting the questState var above. Should I change that or the bold code?
It's obviously an error because it's trying to compare a string with a state enum.
Code: Select all
public void UpdateIndicator()
{
// Check quest state:
var questState = QuestLog.GetQuestState(questName);
for (int i = 0; i < questStateIndicatorLevels.Length; i++)
{
var questStateIndicatorLevel = questStateIndicatorLevels[i];
[b][u] if (questState == questStateIndicatorLevel.questState && questStateIndicatorLevel.condition.IsTrue(null))
{[/u][/b]
if (DialogueDebug.logInfo) Debug.Log("Dialogue System: " + name + ": Quest '" + questName + "' changed to state " + questState + ".", this);
if (questStateIndicator != null) questStateIndicator.SetIndicatorLevel(this, questStateIndicatorLevel.indicatorLevel);
questStateIndicatorLevel.onEnterState.Invoke();
}
}
It's obviously an error because it's trying to compare a string with a state enum.
Last edited by nivlekius on Sun Mar 17, 2019 12:49 pm, edited 1 time in total.
Re: Quest states
Sorry for the delay. I'm out of the office for a couple of hours but I'll be back soon and will reply with an answer then.
Re: Quest states
No worries man, It's Sunday. Do what you gotta do. I'm just doing my thing here and writing as things come up. I'm not trying to blow anything up. I'm just sort of brainstorming and posting as I go.
Re: Quest states
Okay, I'm back! Here's an example scene (exported in 2018.2):
CustomQuestStateExample_2019-03-17.unitypackage
I also included an updated QuestStateListener.cs script that will be in version 2.1.3. Methods are now virtual, which makes it simpler to write the subclass. Egbert is on the left, Chazpea is on the right.
In CustomQuestStateListener, you'll see that the quest state dropdowns have been replaced by text fields so you can type in new quest states such as "preempted".
CustomQuestStateExample_2019-03-17.unitypackage
I also included an updated QuestStateListener.cs script that will be in version 2.1.3. Methods are now virtual, which makes it simpler to write the subclass. Egbert is on the left, Chazpea is on the right.
In CustomQuestStateListener, you'll see that the quest state dropdowns have been replaced by text fields so you can type in new quest states such as "preempted".
Re: Quest states
That's great thank you! I've been sitting here trying this and that to hook into QuestStateListener and it just wasn't happening.
So, do I keep the CustomQuestState on the manager?
So, do I keep the CustomQuestState on the manager?
Re: Quest states
nvm got my answer from the scene