CompletedQuest not working

Hi. First of all thank you for another brilliant course :slight_smile:

I’ve got a little bit of confusion on the last part trying to use the bool logic. I havet an issue when trying to use the CompletedQuest predicate. I’ve looked at github to make sure I didn’t miss anything.

Basically I get stuck at the first node of my dialogue and it throws the attached null reference exception error. Any ideas on why it’s coming up?


The tricky part about this one is that there are actually multiple possible null references on line 109…
It could be that there is no 0th parameter
It could be that there is no Quest by the name in parameters[0]
And it could be that the quest hasn’t been accepted yet…
This may require a little null checking on your part…

case "CompletedQuest":
     if(parameters[0]==null) return false;
     Quest questToTest = Quest.GetByName(parameters[0]);
     if(questToTest==null) return false;
     if(!HasQuest(questToTest) return false; 
     return GetQuestStatus(questToTest).IsComplete();

Sometimes checks like these seem tedious, and they are, but they’re often neccessary, and at this level in the course, we’re not always good at reminding you of these checks.

Thank you Brian - That makes perfect sense. I’ll be a little braver next time! I must admit just toward the end of the course things started going quite alot above my head so I went into autopilot and hoped some of it would sink in. Come along way doing these courses though so thank you and the team very much

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms