Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: HandsFree on Mon 27/08/2012 15:13:28

Title: Voice acting without Say function
Post by: HandsFree on Mon 27/08/2012 15:13:28
In my last game I used a gui label for all text output. That way I had all text nicely displayed in the same gui. That worked fine for me and I would like to do the same thing in a next game.
But what if I decide to add voice acting? Is it possible to add voiceacting when there's no dialog and no .say commands?

Instead of cEgo.Say("&10 Hi! How are you?");
Can I do something like lblText.Text = "&10 Hi! How are you?";?
Title: Re: Voice acting without Say function
Post by: Khris on Mon 27/08/2012 15:29:02
The SayAt command should work with voice speech and allows you to position the text anywhere you want.
You could write an extender function like this:
Code (ags) Select
function MySay(this Character*, String text) {
  this.SayAt(10, 190, 300, text);
}

If the text is obscured by the GUI, use a non-clickable character to display the GUI background.

If that doesn't work, another thing I can think of is this:
Code (ags) Select
function MySay(this Character*, String text) {
  int fs = text.IndexOf(" ");
  String just_text = text.Substring(fs, (text.Length - (fs+1)));
  String just_voice = text.Substring(0, fs);
  lblText.Text = just_text;
  this.Say(just_voice);
  lblText.Text = "";
}

The latter should work provided that a command like player.Say("&10"); will work.

I'm just guessing here, I've never really used voice speech.
Title: Re: Voice acting without Say function
Post by: HandsFree on Mon 27/08/2012 15:52:49
So for the first example, do I need to create a character to say things?
The function call would be like this?
text = "&10 Hi! How are you?";
MySay(cNarrator,text);?
Title: Re: Voice acting without Say function
Post by: Khris on Mon 27/08/2012 16:34:08
No, the beauty of extender functions is that you can call them just like a built-in command.
So in both cases, calling it would look like this:
Code (ags) Select
  cNarrator.MySay("&10 Hi! How are you?");
Title: Re: Voice acting without Say function
Post by: HandsFree on Tue 28/08/2012 01:12:15
I get MySay is not a public member of character...
I put the function in the global script and the call in a room script. I tried import function MySay(Character, String); And variations.
What am I doing wrong?
Title: Re: Voice acting without Say function
Post by: Khris on Tue 28/08/2012 11:01:31
This is the import line you need to put in Globalscript.ash:

Code (ags) Select
import function MySay(this Character*, String text);

If you've done everything correctly and type "player.", the auto-complete window should list MySay, with the icon featuring a small arrow.
Title: Re: Voice acting without Say function
Post by: HandsFree on Tue 28/08/2012 12:13:11
Cool, both versions work now. I prefer the second because it gives me more control over how the text is displayed.
However I was hoping the say command wouldn't give the wait cursor because there's no text in it, but it still does. That's ok if there's a speech file, but I wanted to decide on including speech later. And when there's no speech I don't like the wait cursor.

It looks I'll just have to do the normal display in a label and when it's certain there will be voiceacting rework the speech parts to use this character.MySay method.
thanks
Title: Re: Voice acting without Say function
Post by: Khris on Tue 28/08/2012 13:40:35
You should under no circumstances use something other than the MySay way, now that is has been established as what you'd use if there's going to be a voiced version.

It's much less hassle (none at all) to change the MySay function for now, as opposed to replacing countless Display commands later. It's the very next best thing to changing the internal Say command (which isn't possible).

Say is a blocking function, and if there's no text but voice, the game is paused until the line is skipped or the sample has played to the end.
All you need to do is change the MySay function for now:
Code (ags) Select
function MySay(this Character*, String text) {
  // int fs = text.IndexOf(" ");
  // String just_text = text.Substring(fs, (text.Length - (fs+1)));
  // String just_voice = text.Substring(0, fs);
  lblText.Text = text;
  // this.Say(just_voice);
  WaitMouseKey(400);  // ten seconds, keypress, mouse click
  lblText.Text = "";
}