Forum rules - please read before posting.

Conversation Structure: Exit conversation when all options are exhausted?

Hello AC users - I'm trying to use AC's conversation system to get the following effects:

  • The player enters a conversation, and they have (for example) 3 options
  • As an option is chosen, that option is removed from the selection (via the Dialogue: Toggle action)
  • When the last option is chosen, it plays and then an exit sequence that ends the conversation immediately proceeds from it

I've been using the "autoplay lone option" feature, but this requires there to be a "Thanks, that's all for now" or equivalent option always present in the list - so the player can choose it straight away without seeing all the other options.

What I'd like is the ability to toggle that last option on when the player selects the last of the available lines - it would then "auto play lone option" and segue out of the convo when the last dialogue sequence plays. I'm struggling to see a convenient way to track when all the options have been chosen ... am I missing something, or is this behaviour not really possible with the basic actions?

If anyone has any experience of similar setups, I'd love to hear your wisdom!

Cheers,

Martyn

Comments

  • So, the exit sequence isn't a part of the Conversation itself - just a series of Actions that run when there are no options left?

    In that case, you can hook into the OnEndConversation event to run a new Cutscene.

    For example, attached to a Conversation:

    using UnityEngine;
    using AC;
    
    public class FinishConversation : MonoBehaviour
    {
    
        public Cutscene cutscene;
    
        void OnEnable () { EventManager.OnEndConversation += OnEndConversation; }
        void OnDisable () { EventManager.OnEndConversation -= OnEndConversation; }
    
        void OnEndConversation (Conversation conversation)
        {
            if (conversation == GetComponent <Conversation>())
            {
                cutscene.Interact ();
            }
        }
    
    }
    
  • Thanks for that Chris - as ever, I'm having ... mixed results ... implementing it on my side :-)

    What I'm finding that with a character who has a number of conversation options, all enabled at the start, that gradually get whittled down by toggle off and toggle off forever, the autoplay lone option works and then the sign-off cutscene plays. All good!

    However ... a number of character have conversation options that are enabled after a variable check in the action list that initiates the conversation, and, whether enabled or not when the conversation runs, the signoff cutscene doesn't play, leaving the player hanging. Is it possible that onEndConversation doesn't fire if there are "unused" conversation options that are disabled?

  • Shouldn't be the case - the event should trigger regardless of the state of the options.

    How are you ending the Conversation, and what's your AC version? The more details you can share, the more accurately I can recreate the issue.

  • AC Version is 1.71.8 (happy to level it up if need be) and conversations are being ended via autoplay lone option after all the other ones are temporarily or permanently toggled off.

  • Are you overriding options in your "Dialogue: Start conversation" Action? In what order are you enabling options vs starting the conversation in the problematic Conversation.

    There's more detail hidden here than I think we're going to get through posting like this. If you can PM me a simple test scene with a pair of Conversations - one that works, one that doesn't - that'd be best.

    You shouldn't need to provide any character graphics or prefabs - just Cutscenes that can be manually run to initiate them should be enough. From that, you can create a .unitypackage file of the scene and the FinishConversation script.

    Let me know your Unity version, also.

  • edited January 2021

    My situation is similar. I want one thing to happen when the player chooses the leave conversation option, and another thing to happen when they have chosen all dialogue options.

    I checked the 'auto-play lone option' which will play the leave conversation option. This then checks my AC global boolean to determine which thing should happen.

    I set the boolean in the AC Conversation script when it does the auto-play in line 163:

        if (numPresent == 1 && autoPlay)
            {
                foreach (ButtonDialog _option in options)
                {
                    if (_option.CanShow ())
                    {
                // Add Stats for completing all conversation options.
                        GlobalVariables.SetBooleanValue(120, true);
                        RunOption (_option);
    
    
                        return;
                    }
                }
    

    I'm not sure if this is the best way of doing it, but it works.

  • In the event that a dialogue option is auto-played, the OnStartConversation event is still triggered. You can hook into that to update the variable via a custom script:

    using UnityEngine;
    using AC;
    
    public class SetVariableOnConversationAutoplay : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnStartConversation += OnStartConversation; }
        private void OnDisable () { EventManager.OnStartConversation -= OnStartConversation; }
    
        private void OnStartConversation (Conversation conversation)
        {
            if (conversation == GetComponent <Conversation>() &&
                conversation.autoPlay &&
                conversation.GetNumEnabledOptions () == 1)
            {
                GlobalVariables.SetBooleanValue (120, true);
            }
        }
    
    }
    
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.