Forum rules - please read before posting.

Conversation with no dialogue options remaining

I have hundreds of conversations that have multiple dialogue option each. These dialogue options are disabled by default once they have been chosen.

I want to have a pop-up that says "All questions have been asked" when the player triggers a conversation that's had all of its dialoge options exhausted. How would I go about doing this?

Comments

  • The Converation script's AllOptionsBeenChosen function can be used to determine this.

    This can be run when a Conversation begins via the OnStartConversation event, and then made to run an ActionList that displays a Menu popup.

    Example script, attached to the Conversation:

    using UnityEngine;
    using AC;
    
    public class ExhaustedConversationCheck : MonoBehaviour
    {
    
        public ActionListAsset actionList;
    
        void OnEnable () { EventManager.OnStartConversation += OnStartConversation; }
        void OnDisable () { EventManager.OnStartConversation -= OnStartConversation; }
    
        void OnStartConversation (Conversation conversation)
        {
            if (conversation.gameObject == gameObject)
            {
                if (conversation.AllOptionsBeenChosen (true))
                {
                    // All options chosen
                    actionList.Interact ();
                }
            }
        }
    
    }
    
  • Perfect, thank you so much, Chris!

  • Actually, I think the GetCount() function may be better as sometimes some options are disabled rather than being exhausted - that's my fault for explaining it wrong!

    So basically it would check if any visible options are showing and if not it would then run an actionlist.

    Do you know a demo script for that at all please, Chris?

  • The GetNumEnabledOptions function - in place of AllOptionsBeenChosen - will check that.

  • How would I write this in the code?

  • Replace:

    if (conversation.AllOptionsBeenChosen (true))
    

    with:

    if (conversation.GetNumEnabledOptions () == 0)
    
  • edited April 21

    I've been trying to solve this same problem in my project but with a Cutscene instead of an ActionList, but after the last option is chosen the Cutscene doesn't get played. The setup I have is a Cutscene that starts the Conversation with this script attached:

    public class PlayCutsceneOnExhausted : MonoBehaviour
    {
        public Cutscene cutscene;
    
        void OnEnable() { EventManager.OnStartConversation += OnStartConversation; }
        void OnDisable() { EventManager.OnStartConversation -= OnStartConversation; }
    
        void OnStartConversation(Conversation conversation)
        {
            Debug.Log("OnStartConversation");
            if (conversation.gameObject == gameObject)
            {
                Debug.Log("Conversation started " + conversation.GetNumEnabledOptions());
                if (conversation.GetNumEnabledOptions() == 0)
                {
                    // All options chosen
                    Debug.Log("Conversation options have been all chosen");
                    cutscene.Interact();
                }
            }
        }
    
    }
    

    In the console window I see Conversation Started 2 when starting the conversation, then Conversation Started 1 after clicking one option and progressing through the tree, but it never gets to 0. Here's a screenshot of the Conversation object: https://imgur.com/a/gsYMH2e

    my unity version is 2022.3.62f3 and AC 1.85.5

  • Welcome to the community, @allisoninezlee.

    Do the Conversation's ActionLists hide each option, such that no options are shown in the Conversation menu? I'm wondering if GetNumEnabledOptions is returning the correct value, or if there's a mismatch somehow.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.