Abandon State
Abandon State
Hey Tony,
What's the best way to change the default state that Abandon Quest goes to for a specific quest? I've looked around, tried a few things but I'm guessing that like usual it's easier than I'm making it.
Thanks
What's the best way to change the default state that Abandon Quest goes to for a specific quest? I've looked around, tried a few things but I'm guessing that like usual it's easier than I'm making it.
Thanks
Re: Abandon State
OnQuestStateChange() will work, as in that post. If you want to make it general-purpose, you could add a field named, say, "Abandoned State", to the Quests template whose type is Quest State, and set its default value (e.g., abandoned). If you want a specific quest to go to the unassigned state when abandoned, you could change the field's value for that quest.
Then your OnQuestStateChange() might look like this:
Alternatively, you could assign a delegate to QuestLog.SetQuestStateOverride.
Then your OnQuestStateChange() might look like this:
Code: Select all
void OnQuestStateChange(string quest)
{
if (QuestLog.CurrentQuestState(quest) == "abandoned")
{
var desiredState = DialogueLua.GetQuestField(quest, "Abandoned State").asString;
if (desiredState != "abandoned")
{
QuestLog.SetQuestState(quest, desiredState);
}
}
}
Re: Abandon State
I did something similar
I did basically the same earlier but I used GetQuestState instead and it caused a hang and I was getting byte reallocation messages. But what I just posted is almost instant. Does that look like it'll be ok? Just want to make sure I'm not causing any kind of leak, which is what looked like was happening before.
Code: Select all
public void OnQuestStateChange(string questName)
{
if(questName == "wells/10goblins")
{
if(QuestLog.CurrentQuestState(questName) == "abandoned" || QuestLog.CurrentQuestState(questName) == "unassigned")
{
QuestLog.SetQuestState(questName, "ready");
}
}
}
Re: Abandon State
I'd like it to be more portable so I don't have to write the quest name for each one as there are only going to be a few NPCs that need this.
Re: Abandon State
NVM those reallocation messages are still going crazy and I commented out the stuff I just did and it's still happening. Now I don't know why it is doing it.
Re: Abandon State
restarting Unity seemed to fix it for some reason
Re: Abandon State
So, it looks like that if the code I posted above looks like it won't cause any issues I'm good to go.
Re: Abandon State
That code above looks fine.
Re: Abandon State
Awesome, thank you, once again.