Forum rules - please read before posting.

Overriding speech text in game

Is it possible to override the text a character should speak in game?

I'm trying something like this but the displayText property is read-only.

EventManager.OnStartSpeech += (AC.Char speakingCharacter, string speechText, int lineID) =>
{
    Speech speech = KickStarter.dialog.GetLatestSpeech();
    speech.displayText = "My new text...";
};

Any other way to accomplish this?

Thanks!

Comments

  • You can modify the Speech class's SpeechLog variable:

    speech.log.fullText = "My new text...";
    

    However, the Speech class is added to Dialog after the event is called. I'll see about adding an alternative event that provides the Speech instance as a parameter, so you can simply use:

    EventManager.OnStartSpeech += (Speech speech) =>
    {
        speech.displayText = "My new text...";
    };
    
  • Man that would be great!
  • I see that there is now an EventManager.OnStartSpeech_Alt available. Not sure it that is ment for this but there is no way to set the displayText there.

    Preferably one would be able to update the LineID so that both the text and any speech associated with it would updated at the same time.

    A feature like this would be great as it would enable more dynamic scenarios such as switching out all spoken text depending on for example a global variable.

    Thanks!

  • edited April 2019

    The "_Alt" speech events are what I was referring to in my last post. The suffix is necessary to differentiate them from the existing events.

    Modifying displayText is still prevented to avoid further issues, but you can still change both the text and the ID by modifying the log:

    EventManager.OnStartSpeech += (Speech speech) =>
    {
        speech.log.fullText = "My new text...";
        speech.log.lineID = 123;
    };
    
  • That's cool.. Sadly though, the timeout for how long the speech should be active isn't updated to match the new lineID/fullText.

  • If you're looking to modify your Speech class instance so much that it'd affect the line ID, the text, and the duration of it, it's better to just script your own instance of it. See the Manual's "Speech scripting" chapter for more.

  • Oh, but the timing is the last thing man :)

    But sure, I guess I can trig another one instead, but it would have to replace/cancel out the current one. Is it possible to cancel the speech that is about to be shown and show my own instead? The challenge is to do it whenever a speech would "naturally" occur, which is why I loved the idea of using your new event.

    Thanks!
  • You can use this to terminate an active Speech class:

    AC.KickStarter.dialog.KillDialog (mySpeech);
    

    Placed in the OnStartSpeech_Alt event would give you access to the Speech class.

  • EventManager.OnStartSpeech_Alt += (speech) =>
    {
    KickStarter.dialog.KillDialog(speech);
    };

    ...results in the following message: "Cannot kill dialog '...' because it is not in the speech list."

    Are you sure it wouldn't be easier to update the timeout on the current speechas that would guarantee that the "new" speech would behave exactly the same way as the "old" one in terms of being skippable etc?

  • Use a co-routine to wait until the end of the current frame before killing it.

  • edited April 2019

    I tried it and the result is that the previous speech text has already started to show before it's being killed so it looks very choppy.

  • I think you'll need to start at the beginning and explain in the broader sense what exactly it is you're trying to accomplish, and why.

  • edited April 2019

    Sure, here's the scenario :)

    Before the player (a caveman) has learned to speak English (through completing a puzzle), I want all his speech actions to be replaced with jibberish. I can do this either by checking a global variable in the interaction for all hotspots and all conversations (hundreds of places), or do this once using the OnStartSpeech_Alt event.

    I have it working perfectly with OnStartSpeech_Alt except for the timing of the speech.

  • Could you share an example? Does any of the text (jibberish and regular) ever feature tokens e.g. [wait]? Please also share a shot of your Speech Manager's speech settings.

  • The regular text will probably features tokens later, the gibberish will not.

    Here's a screenshot of my speech manager:
    https://1drv.ms/u/s!Amz_vh8OYDX3u4d-1ijJXiUGcmLdng

    If it's really hard to let us override the timeout, I guess a workaround on my side could be that I check the length of the current text in script and substitutes it with a jibberish version of more or less equal length.

  • Replacing regular text with jibberish does sound like the better approach, but tokens will still be respected. I shall look into it.

    Another approach would be to rely on a separate language for the jibberish, and change languages based on the global variable. Though, this'd only really be feasible if you had no other translations.

  • Ah, translations will probably come into the picture later in this project.

    Optimally the timeout wouldn't be set by me but by AC based on the length of the updated text (or, if a speech sound is assigned, that length of the clip). So it would work exactly the same as with any other text.

    Thanks for looking into it!
  • PMing you a test script now.

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.