Custom Speech Command problem

Started by Blackthorne, 27 Aug 2021, 17:21

« previous - next »

Blackthorne

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: ags
function TopBar60(this Character*, String WrittenText)
{
  Game.NormalFont = eFontSpeech;
  DisplayTopBar(60, this.SpeechColor, 16, this.Name, WrittenText);
  Game.NormalFont = eFontNormal;
}


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

Code: ags
cRoberto.TopBar60("I'm saying this here sentence.");


as opposed to always having to type

Code: ags
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

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: ags


    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?
The fediverse needs great indie game developers! Find me there!

Crimson Wizard

#2
Quote from: DeadSuperHero on 14 Sep 2021, 12:59
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: ags

function TopBar(this Character*, String WrittenText)
{
  int voice_num = 0;
  if (WrittenText.Chars[0] == '&')
  {
     int real_text_at = WrittenText.IndexOf(" ");
     voice_num = WrittenText.Substring(0, real_text_at).AsInt;
     WrittenText = WrittenText.Substring(real_text_at + 1, WrittenText.Length - real_text_at);
  }

  Game.NormalFont = eFontSpeech;
  AudioChannel *chan;
  if (voice_num > 0)
    chan = Game.PlayVoiceClip(this, voice_num);
  DisplayTopBar(40, this.SpeechColor, 16, this.Name, WrittenText); 
  Game.NormalFont = eFontNormal;
  if (chan != null)
    chan.Stop();
}


SMF spam blocked by CleanTalk