Jibble

Author Topic: Custom Speech Command problem  (Read 197 times)

Blackthorne

  • Infamous Quests
    • Blackthorne worked on one or more games that won an AGS Award!
    •  
    • Blackthorne worked on one or more games that was nominated for an AGS Award!
Custom Speech Command problem
« on: 27 Aug 2021, 17:21 »
In one of our games, we wrote a simple custom speech command for NPCs without dialogue portraits using the DisplayTopBar command.  It looks like this

Code: Adventure Game Studio
  1. function TopBar60(this Character*, String WrittenText)
  2. {
  3.   Game.NormalFont = eFontSpeech;
  4.   DisplayTopBar(60, this.SpeechColor, 16, this.Name, WrittenText);
  5.   Game.NormalFont = eFontNormal;
  6. }

Which works nicely, because you can just call the character name, and what they say easily

Code: Adventure Game Studio
  1. cRoberto.TopBar60("I'm saying this here sentence.");

as opposed to always having to type

Code: Adventure Game Studio
  1. DisplayTopBar(60, 15,16, "Roberto", "I'm saying this here sentence.");

It uses the color set in the character properties for the display window color, etc.  Nice.  Only problem is now I'm trying to add voices.... annnnddd, there's really no way to numbers these or use speechcenter.  I'm kind of stumped here. 

Any ideas?


-----------------------------------
"Enjoy Every Sandwich" - Warren Zevon

http://www.infamous-quests.com

DeadSuperHero

  • There's no sense crying over spilled tears.
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with scripting
Re: Custom Speech Command problem
« Reply #1 on: 14 Sep 2021, 12:59 »
Thought about this for a few minutes. I don't know if it's possible to invoke speech playback without an actual say command.

Here's a really hacky idea, though: could you pipe the WrittenText to a secondary Say command that's referenced off-screen? It's a really dirty idea, but it might work.

So like...

Code: [Select]

    function TopBar60(this Character*, Int LineNum, String WrittenText)
    {
      Game.NormalFont = eFontSpeech;
      DisplayTopBar(60, this.SpeechColor, 16, this.Name, WrittenText);
      this.SayAt(999, 999, 0, "&%n %s", LineNum, WrittenText);
      Game.NormalFont = eFontNormal;
    }


It's hacky and gross, and probably slightly incorrect (been a while since I hacked around with this stuff), but with some tweaking it might be possible to get something out of it?
Check out my game: Life is a Party!

The fediverse needs great indie game developers! Find me there!

Re: Custom Speech Command problem
« Reply #2 on: 14 Sep 2021, 13:07 »
It's hacky and gross, and probably slightly incorrect

It's actually how this is done most of the time (more or less).


I replied elsewhere, since 3.5.0 it's also possible to play voice directly:
https://www.adventuregamestudio.co.uk/forums/index.php?topic=59428.msg636639305#msg636639305

The function which splits text into voice number and an actual text: such function may be used as a replacement in Dialogs, as it's only parameter is String.
Code: Adventure Game Studio
  1. function TopBar(this Character*, String WrittenText)
  2. {
  3.   int voice_num = 0;
  4.   if (WrittenText.Chars[0] == '&')
  5.  {
  6.      int real_text_at = WrittenText.IndexOf(" ");
  7.      voice_num = WrittenText.Substring(0, real_text_at).AsInt;
  8.      WrittenText = WrittenText.Substring(real_text_at + 1, WrittenText.Length - real_text_at);
  9.   }
  10.  
  11.   Game.NormalFont = eFontSpeech;
  12.   AudioChannel *chan;
  13.   if (voice_num > 0)
  14.     chan = Game.PlayVoiceClip(this, voice_num);
  15.   DisplayTopBar(40, this.SpeechColor, 16, this.Name, WrittenText);  
  16.   Game.NormalFont = eFontNormal;
  17.   if (chan != null)
  18.     chan.Stop();
  19. }
  20.  
« Last Edit: 14 Sep 2021, 13:31 by Crimson Wizard »