Problems using "Messages" to notify player of "New Quest" and "Completed Quest"

Announcements, support questions, and discussion for Quest Machine.
Post Reply
mroshaw
Posts: 96
Joined: Wed Jan 19, 2022 4:10 am

Problems using "Messages" to notify player of "New Quest" and "Completed Quest"

Post by mroshaw »

Hi!

I'm trying to use "Messages" to let the player know when a new quest is received, and when a quest is completed.

I have a "Notification Manager" component that has public methods that show a message on screen and plays a sound. Alongside that component, I have a "Message Events" component. It is set up to listen for two messages:
  • Sender: Any
  • Target: Any
  • Message: Notification Manager
  • Parameter: New Quest
  • Event: <Notification Manager New Quest Method>
and:
  • Sender: Any
  • Target: Any
  • Message: Notification Manager
  • Parameter: Quest Success
  • Event: <Notification Manager Quest Succeed Method>
In my Quest, I've configured as follows:

On the "Start" state, in its "Active" state, I have a Message action:
  • Sender: Quest Giver
  • Target: Any
  • Message: Notification Manager
  • Parameter: New Quest
In the "Success" state, in its "Active" state, I have a message action:
  • Sender: Quest Giver
  • Target: Any
  • Message: Notification Manager
  • Parameter: Quest Success
When I play my game, I see the following:
  • The "New Quest" event is triggered twice, when my character accepts the Quest.
  • The "Quest Success" event is not triggered at all, when my character completes the quest.
Am I using the messaging system and Quest "states" correctly?

Many thanks!
User avatar
Tony Li
Posts: 20633
Joined: Thu Jul 18, 2013 1:27 pm

Re: Problems using "Messages" to notify player of "New Quest" and "Completed Quest"

Post by Tony Li »

Hi,

First, why not use the existing QuestMachineMessages.QuestStateChangedMessage like i in the example code in How To: Respond To Quest State Changes in Script?

If you don't want to do that, temporarily tick the Quest Machine GameObject's Debug Settings > Debug and Debug Message System checkboxes. This will log a lot of info to the Console. You should be able to see when/if it sends those messages.
mroshaw
Posts: 96
Joined: Wed Jan 19, 2022 4:10 am

Re: Problems using "Messages" to notify player of "New Quest" and "Completed Quest"

Post by mroshaw »

Thanks Tony!

I moved the action from the "Active" state to the "True" state, and it's working as expected!
User avatar
Tony Li
Posts: 20633
Joined: Thu Jul 18, 2013 1:27 pm

Re: Problems using "Messages" to notify player of "New Quest" and "Completed Quest"

Post by Tony Li »

Hi,

Great! Thanks for the update.
mroshaw
Posts: 96
Joined: Wed Jan 19, 2022 4:10 am

Re: Problems using "Messages" to notify player of "New Quest" and "Completed Quest"

Post by mroshaw »

Hi Tony!

I've looked at your first suggestion, using QuestStateChangedMessage, and it is a far superior solution! So I've scrapped all my rubbish code, and implemented your recommendation. Much better, and much more flexible!

Thanks again!!
User avatar
Tony Li
Posts: 20633
Joined: Thu Jul 18, 2013 1:27 pm

Re: Problems using "Messages" to notify player of "New Quest" and "Completed Quest"

Post by Tony Li »

Glad to help!
mroshaw
Posts: 96
Joined: Wed Jan 19, 2022 4:10 am

Re: Problems using "Messages" to notify player of "New Quest" and "Completed Quest"

Post by mroshaw »

Can I be really cheeky and ask one more question, Tony?

Is there a way I can use QuestStateChangedMessage to detect a "quest has been updated" kind of event?

I'm thinking:

"You have a new quest!" - when Quest state goes to Active.
"Quest completed!" - when Quest state goes to Successful.
"Current quest updated!" - when a quest moves to a new node, except for the first node after "Start" and the "Success" node - since those will already trigger a Quest state change.

Does that make sense?
User avatar
Tony Li
Posts: 20633
Joined: Thu Jul 18, 2013 1:27 pm

Re: Problems using "Messages" to notify player of "New Quest" and "Completed Quest"

Post by Tony Li »

You can use the same QuestMachineMessages.QuestStateChangedMessage.

If messageArgs.values[0] is null, the main quest state has changed, and (QuestState)values[1] is the main quest's state.

If messageArgs.values[0] is not null, a quest node's state has changed, and (StringField)values[0] is the ID of the quest node and (QuestNodeState)values[1] is the node's new state.
mroshaw
Posts: 96
Joined: Wed Jan 19, 2022 4:10 am

Re: Problems using "Messages" to notify player of "New Quest" and "Completed Quest"

Post by mroshaw »

That's amazing, thank you!!!
Post Reply