ORK integration

Announcements, support questions, and discussion for Quest Machine.
dlevel
Posts: 135
Joined: Wed Nov 16, 2016 6:17 pm

Re: ORK integration

Post by dlevel »

Tested it and UI has plenty of room, so I think I found the issue, when the player has the same quest 2 times is where things getting messy because the completed one and the ongoing one (with the same name because they are the exact same kill quest) are both marked as Active quests so I guess that might confuse the UI? So when the player tried to return the quest he presses the on going one and he can't return the previous one.

I suggest splitting them to Active, Available and Completed (as in Active-Completed that waits to be returned) in the UI so it doesn't mixes up.


also a question, can I run some code on complete/start of a generated quest?
User avatar
Tony Li
Posts: 20734
Joined: Thu Jul 18, 2013 1:27 pm

Re: ORK integration

Post by Tony Li »

Hi,
dlevel wrote: Thu Sep 03, 2020 3:15 am...I think I found the issue, when the player has the same quest 2 times is where things getting messy because the completed one and the ongoing one (with the same name because they are the exact same kill quest) are both marked as Active quests so I guess that might confuse the UI?
I don't think so. Every generated quest gets a unique internal ID such as "Kill 3 Orcs fe2ba065-a2ca-4b8c-a1a0-d6c3dfe6a1d1".

Did you have a chance to reproduce the issue in the editor with the Debug checkbox ticked? If so, what was the value of Y (versus what you expected it to be)?
dlevel wrote: Thu Sep 03, 2020 3:15 amalso a question, can I run some code on complete/start of a generated quest?
You're starting the generation manually, so you should be able to run some code before calling GenerateQuest().

To run some code immediately after a quest has been generated, hook into the generatedQuest event:

Code: Select all

GetComponent<QuestGeneratorEntity>().generatedQuest += OnGeneratedQuest;

void OnGeneratedQuest(Quest quest)
{
    Debug.Log("Generated a quest titled " + quest.title);
}
dlevel
Posts: 135
Joined: Wed Nov 16, 2016 6:17 pm

Re: ORK integration

Post by dlevel »

Sorry I wasn't specific enough, I need to run code after the generated quest is accepted, and after completed (counter 100% filled). I haven't been able to try to reproduce in editor since having some other critical stuff, I have disabled the return to complete for now
User avatar
Tony Li
Posts: 20734
Joined: Thu Jul 18, 2013 1:27 pm

Re: ORK integration

Post by Tony Li »

Hi,

Listen for the "Quest State Changed" message.

Quest State Changed
Sent when a quest state or quest node state changes.
- Parameter: Quest ID.
- Argument 0: [StringField] Quest node ID, or blank for main quest state.
- Argument 1: [QuestState] / [QuestNodeState] New state.

Code: Select all

using UnityEngine;
using PixelCrushers;
using PixelCrushers.QuestMachine;

public class TestQuestMessages : MonoBehaviour, IMessageHandler
{
    void OnEnable()
    {
        MessageSystem.AddListener(this, QuestMachineMessages.QuestStateChangedMessage, string.Empty);
    }
    void OnDisable()
    {
        MessageSystem.RemoveListener(this);
    }

    public void OnMessage(MessageArgs messageArgs)
    {
        if (messageArgs.values[0] == null) // If value 0 is null, this refer to main quest, not node.
        {
            var questState = (QuestState)(messageArgs.values[1]);
            Debug.Log("Quest " + messageArgs.parameter + " change to state: " + questState);
        }
    }
}
Whenever you want to look into the generated quest return issue, just let me know.
dlevel
Posts: 135
Joined: Wed Nov 16, 2016 6:17 pm

Re: ORK integration

Post by dlevel »

something interesting happened when I tried this script to keep track of the states of the quests.

When I accepted a quest these errors popped up, and quest changed to disabled, but the quest was active normally in-game and the counter worked fine.

https://ibb.co/jv1P8XN

errors:

Message System exception sending 'Quest State Changed'/'Kill 6 Arpas b1136da7-9cdc-4bf4-917b-bcef79775b97' to Quest Machine (PixelCrushers.QuestMachine.QuestListener): Specified cast is not valid.
UnityEngine.Debug:LogError(Object)
PixelCrushers.MessageSystem:SendMessageWithTarget(Object, Object, String, String, Object[]) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Message System/MessageSystem.cs:342)
PixelCrushers.MessageSystem:SendMessage(Object, String, StringField, Object[]) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Message System/MessageSystem.cs:438)
PixelCrushers.QuestMachine.QuestMachineMessages:QuestNodeStateChanged(Object, StringField, StringField, QuestNodeState) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Utility/QuestMachineMessages.cs:165)
PixelCrushers.QuestMachine.QuestNode:SetState(QuestNodeState, Boolean) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest Node/QuestNode.cs:428)
PixelCrushers.QuestMachine.Quest:SetState(QuestState, Boolean) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest.cs:886)
PixelCrushers.QuestMachine.QuestGiver:GiveQuestToQuester(Quest, QuestParticipantTextInfo, QuestListContainer) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestGiver.cs:791)
PixelCrushers.QuestMachine.QuestGiver:OnAcceptQuest(Quest) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestGiver.cs:694)
PixelCrushers.QuestMachine.UnityUIQuestDialogueUI:AcceptQuest() (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest UIs/Unity UI/Unity UI Quest Dialogue UI/UnityUIQuestDialogueUI.cs:219)
UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
ORKFramework.Behaviours.ORKInputModule:ProcessMousePress(MouseButtonEventData)
ORKFramework.Behaviours.ORKInputModule:ProcessMouseEvent(Int32)
ORKFramework.Behaviours.ORKInputModule:ProcessMouseEvent()
ORKFramework.Behaviours.ORKInputModule:Process()
UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2019.4.8f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)



Message System exception sending 'Quest State Changed'/'Kill 6 Arpas b1136da7-9cdc-4bf4-917b-bcef79775b97' to Quest Machine (PixelCrushers.QuestMachine.QuestListener): Specified cast is not valid.
UnityEngine.Debug:LogError(Object)
PixelCrushers.MessageSystem:SendMessageWithTarget(Object, Object, String, String, Object[]) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Message System/MessageSystem.cs:342)
PixelCrushers.MessageSystem:SendMessage(Object, String, StringField, Object[]) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Message System/MessageSystem.cs:438)
PixelCrushers.QuestMachine.QuestMachineMessages:QuestNodeStateChanged(Object, StringField, StringField, QuestNodeState) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Utility/QuestMachineMessages.cs:165)
PixelCrushers.QuestMachine.QuestNode:SetState(QuestNodeState, Boolean) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest Node/QuestNode.cs:428)
PixelCrushers.QuestMachine.QuestNode:SetState(QuestNodeState, Boolean) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest Node/QuestNode.cs:445)
PixelCrushers.QuestMachine.Quest:SetState(QuestState, Boolean) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest.cs:886)
PixelCrushers.QuestMachine.QuestGiver:GiveQuestToQuester(Quest, QuestParticipantTextInfo, QuestListContainer) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestGiver.cs:791)
PixelCrushers.QuestMachine.QuestGiver:OnAcceptQuest(Quest) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestGiver.cs:694)
PixelCrushers.QuestMachine.UnityUIQuestDialogueUI:AcceptQuest() (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest UIs/Unity UI/Unity UI Quest Dialogue UI/UnityUIQuestDialogueUI.cs:219)
UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
ORKFramework.Behaviours.ORKInputModule:ProcessMousePress(MouseButtonEventData)
ORKFramework.Behaviours.ORKInputModule:ProcessMouseEvent(Int32)
ORKFramework.Behaviours.ORKInputModule:ProcessMouseEvent()
ORKFramework.Behaviours.ORKInputModule:Process()
UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2019.4.8f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)



Message System exception sending 'Quest State Changed'/'Kill 6 Arpas b1136da7-9cdc-4bf4-917b-bcef79775b97' to Quest Machine (PixelCrushers.QuestMachine.QuestListener): Specified cast is not valid.
UnityEngine.Debug:LogError(Object)
PixelCrushers.MessageSystem:SendMessageWithTarget(Object, Object, String, String, Object[]) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Message System/MessageSystem.cs:342)
PixelCrushers.MessageSystem:SendMessage(Object, String, StringField, Object[]) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Message System/MessageSystem.cs:438)
PixelCrushers.QuestMachine.QuestMachineMessages:QuestNodeStateChanged(Object, StringField, StringField, QuestNodeState) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Utility/QuestMachineMessages.cs:165)
PixelCrushers.QuestMachine.QuestNode:SetState(QuestNodeState, Boolean) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest Node/QuestNode.cs:428)
PixelCrushers.QuestMachine.QuestNode:SetState(QuestNodeState, Boolean) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest Node/QuestNode.cs:445)
PixelCrushers.QuestMachine.Quest:SetState(QuestState, Boolean) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest.cs:886)
PixelCrushers.QuestMachine.QuestGiver:GiveQuestToQuester(Quest, QuestParticipantTextInfo, QuestListContainer) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestGiver.cs:791)
PixelCrushers.QuestMachine.QuestGiver:OnAcceptQuest(Quest) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestGiver.cs:694)
PixelCrushers.QuestMachine.UnityUIQuestDialogueUI:AcceptQuest() (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest UIs/Unity UI/Unity UI Quest Dialogue UI/UnityUIQuestDialogueUI.cs:219)
UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
ORKFramework.Behaviours.ORKInputModule:ProcessMousePress(MouseButtonEventData)
ORKFramework.Behaviours.ORKInputModule:ProcessMouseEvent(Int32)
ORKFramework.Behaviours.ORKInputModule:ProcessMouseEvent()
ORKFramework.Behaviours.ORKInputModule:Process()
UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2019.4.8f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)
User avatar
Tony Li
Posts: 20734
Joined: Thu Jul 18, 2013 1:27 pm

Re: ORK integration

Post by Tony Li »

I typed the script directly into my previous reply, and there were a couple of errors. I just updated it above.

Keep in mind that every quest can have two instances: one in the quest giver's list and, when the player accepts the quest, another in the player's list. When the player accepts a quest, you'll see four messages:

1. A disabled instance is copied to the player's journal.
2. This instance is set to WaitingToStart.
3. Then it's set to Active.
4. Finally, the quest giver's original instance is disabled and removed.
dlevel
Posts: 135
Joined: Wed Nov 16, 2016 6:17 pm

Re: ORK integration

Post by dlevel »

The errors are gone and the script works fine.


So I started reproducing the other issue again, what I did is:

1) Quests generated, I accepted them, saved.
2) loaded game, quests generated again with other ID and are at WaitingToStart
3) the previous quests are in Active Quests list as they should.
4) the WaitingToStart quests not showing as available in the quest generator


https://ibb.co/VmXc4Cj
User avatar
Tony Li
Posts: 20734
Joined: Thu Jul 18, 2013 1:27 pm

Re: ORK integration

Post by Tony Li »

If the player already has a generated quest to do the same action on the same type of target (e.g., Kill + Skeleton), the quest giver will not offer new generated versions of the same type of quest. Instead, it will only show the active one. When the player completes it, the quest giver will be able to offer the second generated quest of that type.

However, if the player has an active Kill + Skeleton quest and the quest giver has generated a different type of quest (e.g., Kill + Spider), then it will show both -- one as active, another as offerable.

If this isn't the behavior you're seeing, please tick the Quest Machine GameObject's Debug Settings > Debug checkbox. Then reproduce the issue in the editor's play mode. Look for a line like this:

Quest Machine: DailyQuestsBoard.StartDialogue: #offerable=X #active=Y #completed=Z

What are the values of X, Y, and Z?
dlevel
Posts: 135
Joined: Wed Nov 16, 2016 6:17 pm

Re: ORK integration

Post by dlevel »

So updated to the latest version today (1.2.11), and went back to check the state of quests. I have this issue that the quests are generated, and if the player doesn't pick them all up and saves/loads, the quests he didn't picked before loading are not available to choose them, but the ongoing quests are there. Quest progress etc. are saved fine as well.

here is a vid:



and setting of the quest generator/giver:

https://ibb.co/3FKtKKm

I use empty save key since gameonbject's name is unique across scenes.


also a big issue that happened after I updated to the 1.2.10 (before I upgrade to 1.2.11 today), all players received all rewards again! like if they had finished 20 quests the past month, they got all 20 rewards again after they loaded their game. I have no need to return to quest giver, so they receive their reward when they finish the quest automatically.

Can you identify why that happened so we know it will not happen again? Maybe the feature that removes the old quests from journal?
User avatar
Tony Li
Posts: 20734
Joined: Thu Jul 18, 2013 1:27 pm

Re: ORK integration

Post by Tony Li »

Hi,
dlevel wrote: Tue Oct 13, 2020 7:49 amSo updated to the latest version today (1.2.11), and went back to check the state of quests. I have this issue that the quests are generated, and if the player doesn't pick them all up and saves/loads, the quests he didn't picked before loading are not available to choose them, but the ongoing quests are there.
Please remind me what kicks off the generation of the quests for that job board.

Try setting the Save Key just in case there's another GameObject hiding somewhere with the same name.

I just tested the following in Quest Machine's basic demo scene:
  • Played the scene and allowed the Knight to generate a quest on start. Did not pick up the quest.
  • Saved the game.
  • Stopped. UNticked the Knight's Generate Quest On Start checkbox to guarantee that it won't create a new quest.
  • Player and loaded the game. The Knight was reloaded with the quest that it originally generated.
dlevel wrote: Tue Oct 13, 2020 7:49 amalso a big issue that happened after I updated to the 1.2.10 (before I upgrade to 1.2.11 today), all players received all rewards again! like if they had finished 20 quests the past month, they got all 20 rewards again after they loaded their game. I have no need to return to quest giver, so they receive their reward when they finish the quest automatically.
When you generate a quest, how are rewards set up?

In regular quest generation, reward actions are added to the quest's Successful state's Actions list. The Actions list is only run once, when the quest normally progresses into the Successful state. It is not run when loading a saved game where the quest is already in the Successful state.
Post Reply