Question About QuestCondition
Posted: Thu Jun 03, 2021 6:02 am
Hi!
I require some help with the QuestConditon.
What I was trying to achieve, is to have a custom QuestCondition which in StartChecking() would check if the condition is already true, and if it is, then calls SetTrue().
For example, I want to create a condition that checks if the player has a magic Wand. Let's imagine that the player had found the wand before. Then when the Quest starts, the condition has to check if ht player already has the Wand. How would you go about that?
I am using this custom QuestCondition as an AutoStartCondition.
The problem with my approach is that it causes a StackOverflow error in this bit of the code:
Since the condition returns true, the Quest becomes active. Then in BecomeOfferable it checks if it is not equal to WaitingToStart (which it is not) thus sets it to WaitingToStart, which calls SetState() and consequently SetStartChecking(true).
Please let me know if the above explanation is clear.
I require some help with the QuestConditon.
What I was trying to achieve, is to have a custom QuestCondition which in StartChecking() would check if the condition is already true, and if it is, then calls SetTrue().
Code: Select all
public override void StartChecking(System.Action trueAction)
{
base.StartChecking(trueAction);
//if (AlreadyTrue())
//{
// SetTrue();
// return;
//}
Subscribe();
}
I am using this custom QuestCondition as an AutoStartCondition.
The problem with my approach is that it causes a StackOverflow error in this bit of the code:
Code: Select all
public void BecomeOfferable()
{
try
{
QuestState state = GetState();
Debug.Log(state);
if (GetState() != QuestState.WaitingToStart)
SetState(QuestState.WaitingToStart);
questOfferable(this);
SetQuestIndicatorState(questGiverID, QuestIndicatorState.Offer);
}
catch (Exception e) // Don't let exceptions in user-added events break our code.
{
if (Debug.isDebugBuild) Debug.LogException(e);
}
}
Please let me know if the above explanation is clear.