Love/Hate + Dialog stays paused after reporting a deed twice

Announcements, support questions, and discussion for Love/Hate.
swampytable
Posts: 9
Joined: Sat Jun 27, 2020 6:07 pm

Love/Hate + Dialog stays paused after reporting a deed twice

Post by swampytable »

I am using Love/Hate and Dialog System. My dialog system is set to pause time while conversing.

My NPC has a reaction animation set up in the same way as in the Love/Hate example scene. Essentially, you can buy him a drink by talking to a bartender, that deed should trigger a happy animation.

Code: Select all

public void OnWitnessDeed(Rumor rumor)
{
	if (factionMember == null || rumor == null) return;
        if (rumor.pleasure < -0.25)
        {
            m_animator.SetTrigger("Sad");
        }
        else if (rumor.pleasure > 0.25)
        {
            m_animator.SetTrigger("Happy");
        }
}
The Happy animation is triggered to play OnWitnessDeed.
Image

I have a dialog option that triggers the deed:
Image


This works the first time I do it. The dialog option fires the deed off, and the happy animation plays. But if I repeat the process again, when I select the dialog option that fires the deed, the game remains paused.

Through some debugging, I have found that the Love/Hate GameTime is staying paused. The Dialog time system seems to be unpausing normally. All the animations and character controllers stay paused after the second attempt at firing the deed. I read the forums to find anything similar and tried the patch in the extras section, but that doesn't work as well.

Does anyone have any idea how to address this?

Thanks for any help.
User avatar
Tony Li
Posts: 22087
Joined: Thu Jul 18, 2013 1:27 pm

Re: Love/Hate + Dialog stays paused after reporting a deed twice

Post by Tony Li »

Hi,

Are you using the latest versions of Love/Hate and the Dialogue System? If you're using a version of the Dialogue System older than 2.2.6, please update to 2.2.6 or higher.
swampytable
Posts: 9
Joined: Sat Jun 27, 2020 6:07 pm

Re: Love/Hate + Dialog stays paused after reporting a deed twice

Post by swampytable »

I am using the most up to date versionof both, 2.2.7 for dialog.
User avatar
Tony Li
Posts: 22087
Joined: Thu Jul 18, 2013 1:27 pm

Re: Love/Hate + Dialog stays paused after reporting a deed twice

Post by Tony Li »

How did you configure the Dialogue System to pause during conversations?

What is the Dialogue Manager's Other Settings > Dialogue Time Mode?
swampytable
Posts: 9
Joined: Sat Jun 27, 2020 6:07 pm

Re: Love/Hate + Dialog stays paused after reporting a deed twice

Post by swampytable »

The NPC has a Dialogue System Trigger component, where I have checked the "Pause Game During Conversation" box.

Image

The "Other Settings" time scale is realtime.

Image

I suspect that the issue isn't with dialogue, but with love/hate's pausing though. I tried the following to figure out for sure.

Code: Select all

public void OnWitnessDeed(Rumor rumor)
    {
        Debug.Log("Witness deed...");
        StartCoroutine(ShowReaction(rumor));
    }

    public IEnumerator ShowReaction(Rumor rumor)
    {
        Debug.Log("Showing reaction");
        while (DialogueTime.isPaused)
        {
            Debug.Log("DIALOG PAUSED");
            yield return null;
        }

        while (GameTime_PixelCrushers.isPaused)
        {
            Debug.Log("LOVEHATE PAUSED");
            yield return null;
        }

        if (factionMember == null || rumor == null) yield return null;
        else if (rumor.pleasure > 0.25)
        {
            m_animator.SetTrigger("Happy");
        }
    }
    
This will first get stuck in a loop if dialogue time is paused, and if it breaks that loop it will try the same on the love/hate system pause. The output is a loop of the love/hate loop above. That makes me think that dialogue is unpausing correctly, but love/hate isn't somehow maybe.

I've tried to manually force unpausing both systems with like DialogueTime.isPaused = true or time.timeScale = 1 and things, but it doens't have any effect and I am still stuck in the love/hate pause loop here.

I appreciate your help!
User avatar
Tony Li
Posts: 22087
Joined: Thu Jul 18, 2013 1:27 pm

Re: Love/Hate + Dialog stays paused after reporting a deed twice

Post by Tony Li »

Hi,

What is "GameTime_PixelCrushers.isPaused"?

I think I'd need to see a full script or example to know what's going on.

However, if you simply want to show a reaction when the conversation is done, there are a couple of easier ways:

1. You can wait for DialogueManager.isConversationActive to be false:

Code: Select all

while (DialogueManager.isConversationActive) // In a coroutine
{
    yield return null;
}
2. Or you can use an event:

Code: Select all

if (DialogueManager.isConversationActive) // No coroutine needed
{
    DialogueManager.instance.conversationEnded += ShowReaction;
}
else
{
    ShowReaction();
}

void ShowReaction()
{
    DialogueManager.instance.conversationEnded -= ShowReaction;
    m_animator.SetTrigger("Happy");
}
Those are just examples. They don't include all the logic your actual script might use.
swampytable
Posts: 9
Joined: Sat Jun 27, 2020 6:07 pm

Re: Love/Hate + Dialog stays paused after reporting a deed twice

Post by swampytable »

Thanks for the reply. I've been able to get it functioning, but I had to control the times manually in the event. This is how it works for anyone who might see this later.

The GameTime_PixelCrushers is just the Love/Hate GameTime class, I just changed it in my code because I already have a GameTime class and wanted to distinguish them. Essentially, at the end of a conversation I have to reset all the pauses or it gets stuck in a frozen time state. Here's the code.

Code: Select all

    public void queueBuyDrink(Transform target)
    {
        if (DialogueManager.isConversationActive)
        {
            DialogueManager.instance.conversationEnded += buyDrink;
        }
        else
        {
            buyDrink(target);
        }
    }
    
    void buyDrink(Transform target)
    {
        Time.timeScale = 1;
        GameTime_PixelCrushers.isPaused = false;
        GameTime_PixelCrushers.time = 1;
        DialogueTime.isPaused = false;
        DialogueTime.time = 1;

        DialogueManager.instance.conversationEnded -= buyDrink;
        GameObject.Find("player").GetComponent<DeedReporter>().ReportDeed("BoughtDrink", factionMember);
        m_animator.SetTrigger("Happy");
    }
User avatar
Tony Li
Posts: 22087
Joined: Thu Jul 18, 2013 1:27 pm

Re: Love/Hate + Dialog stays paused after reporting a deed twice

Post by Tony Li »

Sounds good, and thanks for sharing the code. If you run into any issues with it or want to re-investigate the original approach, just let me know.

BTW, you can disambiguate the GameTime class by referring to it as PixelCrushers.GameTime. That way you don't have to change any Love/Hate scripts.
swampytable
Posts: 9
Joined: Sat Jun 27, 2020 6:07 pm

Re: Love/Hate + Dialog stays paused after reporting a deed twice

Post by swampytable »

Hi,

Yeah, I would actually be interested in it working this way:
  • Use a lua command in the dialog entry to fire a deed. (i.e: ReportDeed("Player", "Fedora Joe", "BoughtDrink") in the conditions field).
  • The target responding to the deed has a class that implements IWitnessDeedEventHandler and an OnWitnessEvent(rumor) class.
  • At the end of, or during the conversation, the OnWitnessEvent is fired to run whatever action is needed by the game.
I think this way would feel like an integrated dialogue + love/hate, whereas now I'm effectively getting this result, but the way to do it feels a bit roundabout and wasn't something I could have arrived at using the existing documentation. Maybe at the very least if this is the proper way to do it there could be a section in the documentation covering this sort of scenario.

Thanks for all your help, love these packages!
User avatar
Tony Li
Posts: 22087
Joined: Thu Jul 18, 2013 1:27 pm

Re: Love/Hate + Dialog stays paused after reporting a deed twice

Post by Tony Li »

Would you please recap what about that doesn't work in your project? ReportDeed() (and any IWitnessDeedEventHandlers) will take effect when called, not when the conversation ends. But apart from that, it should work without anything extra.
Post Reply