MODULE: BACKGROUND SPEECH (with animation&sound!) v1.1.0 (for AGS 3.2+)

Started by Electroshokker, Sat 11/10/2008 10:19:51

Previous topic - Next topic

Electroshokker

While the more experienced scripters amongst you probably have this all figured out, I reckon the rest of you would have major difficulties getting a character to say something in the background, while animating a speech view and playing a voice clip.

If so, this module is just for you, then!

You'll never want to use the old Character.SayBackground again!  ;D

Module:  Background Speech
Version: 1.1.0 (updated by And-Or)

Download it here!
Mediafire link

Works with AGS 3.2!

What it does

- Plays background speech with text, sound & animation.
- Supports multiple characters

What it doesn't

Lip sync. No can do.

----------------------------

character.SayInBackground(String message, AudioClip* clip, int view, AudioPriority priority=eAudioPriorityNormal);
Similarly as in the previous version, prints the message in "talking style", plays clip and animates the view. The difference is that you can do it for several characters at the same time (as many, as many overlays and channels there are). Also, if you don't want to play the voice, you can pass null as clip. And if you don't want to change the animation, you can pass 0 as view.
The displayed text disappears after a time that depends on the game speed and the length of the text. You can also make the character stop speaking earlier, using StopSayInBackground.

character.StopSayInBackground();
Stops speaking in background (audio and animation).

character.BackgroundTalkActive();
This will tell you if the character is currently speaking in background.

Makeout Patrol


Dualnames

I'd say this would have been darm good, if it wasn't already done. Don't know if its improved though ;D. If you check SSH's and Scorpiorus background speech module it offers the same thing.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

monkey0506

Actually SSH's (coughandminecough) background speech modules allow for queued background speech with animation. So it's actually a bit different. Don't know if it's forward-compatible with AGS, I don't know how he scripted it (coughminesnotcough).

abstauber

I'm currently using SSHs and apparently your version :) - though I had to change 3 or 5 lines, but not a big deal.  The only real drawback is that it uses global INTs to trigger stuff out of a conversation.
And because it still works, I've been to lazy to implement a replacement.

But still thanks for sharing. If yours can trigger events out of a converstion, I might try.


Helme

Hi!

I'm using your script, but there is one problem. Sometimes the animation keeps on repeating without a break. So you see the chararcters speaking animation without speaking.

Electroshokker

Quote from: Helme on Sun 14/06/2009 16:54:54
Sorry for bothering you again , but since I use your Character.SayInBackground-command, there are new bugs.
1) Sometimes the animation does not stop.
2) Far worse: there are moments in the game, in which you change the charakter. Sometimes, when you change the character, the new character can't move. I hoped to solve the problem by unlocking the view of the char before changing, but it doesnt seem to work.

I would be very happy for some advice

Cheers
Helme

As I'm working on the ags linux port atm, I unfortunately don't have the time to check this. I am aware that there are certain bugs in this module. I'll try to fix these at a later point in time, but if any of you feel the need to improve the module already, be my guest.

Helme

KrisMuc solved my problem.

If you add the following to the module-code, the bug is gone.

// in rep_ex

 if (player.ID == charid) {    // oder if (player == character[charid])
   speaking = false;
   character[charid].UnlockView();
   charid = -1;
 }

Electroshokker

Updated to v1.0.1, new version works only for AGS 3.2 (uses new-style audio scripting)

If you want the old version for use in older AGS versions, you can get it here

Enjoy!

And-or

Hi,
Long-time reader, first time writer. I am just starting my adventure with AGS and wrote my first simple game to learn how to do it.
And one of the first obstacles I stopped at was this background talk problem (no audio, no animation). I found the Electroshokker's module, but I I could not use it since I needed more than one character to be speaking at the same time. So, I rewrote it to match my requirements. If anyone's interested, here it is:

http://www.megaupload.com/?d=54P764QV

Note that the above version was only tested with AGS 3.2.1.111

The functions are as follows:

character.SayInBackground(String message, AudioClip* clip, int view, AudioPriority priority=eAudioPriorityNormal);
Similarly as in the previous version, prints the message in "talking style", plays clip and animates the view. The difference is that you can do it for several characters at the same time (as many, as many overlays and channels there are). Also, if you don't want to play the voice, you can pass null as clip. And if you don't want to change the animation, you can pass 0 as view.
The displayed text disappears after a time that depends on the game speed and the length of the text. You can also make the character stop speaking earlier, using StopSayInBackground.

character.StopSayInBackground();
Stops speaking in background (audio and animation).


character.BackgroundTalkActive();
This will tell you if the character is currently speaking in background.


Hope someone will find this useful :)

And-or

David Ostman

And-or was kind enough to mail me his version (as MegaUpload is gone), and gave me permission to upload it and link to it here, in case anyone needs it:

http://www.mediafire.com/?sf3el98nssz734e

Note: He mentions, "although it might not be exactly the same version as I might have made some improvements".

Bandersnatch

Sorry to drag this topic up after such a long time but I'm finding a problem - the text display is off the right of the screen! Any ideas about that?

pixg

I have a problem importing this, it might be a noob thing (sorry if it is) but it seems when importing scripts in AGS it looks for a .scm file, it cant actually see the .ash or .acs files.

monkey0506

That's because Electroshokker is a lazy jerk. :P

ASH and ASC files are just plain-text files. You can open them in Notepad. Then create a new script in your game, and copy the ASH file into your script's ASH, and the ASC file into your script's ASC. For your own convenience you could then right-click on that script and export it for easier importing into other projects.

Armageddon

Sorry to dig this up again but I'm having problems. It says.

Failed to save room room1.crm; details below
BackgroundSpeech.ash(38): Error (line 38): PE03: Parse error at 'AudioClip'

Because of this line.

import function SayInBackground(this Character*,  String message, AudioClip *clip, AudioPriority priority=eAudioPriorityNormal)

???

Dualnames

Laters be late.

Regardless, I believe that occurs because the module demands that you set the setting on the General Settings regarding the use of the older or new sound system to new.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)


Armageddon

I could really use having this fixed for OROW, just noticed I forgot to post this too.


monkey0506

Well if you follow your own code, you're passing null for the AudioClip:

Code: ags
cDriver.SayInBackground(..., null, ...);


And then in the module code, the first line is:

Code: ags
channel = clip.Play(priority);


Obviously if clip is null then you're not going to be able to call clip.Play. This is a problem due to poor coding of the module. You can correct this particular instance by changing the first line to this:

Code: ags
if (clip != null) channel = clip.Play(priority);
else channel = null;


You're likely to encounter several other similar/related issues when dealing with code released by this particular author. And while modularizing it is all well and good, if you're not even doing a talkie game, I'll just point out that background speech with animation is effectively the same as:

Code: ags
// Script.ash

import Overlay* SayInBackground(this Character*, String text);

// Script.asc

Overlay *backgroundSpeech[]; // pointer to any character's background speech overlay

function game_start()
{
  backgroundSpeech = new Overlay[Game.CharacterCount]; // initialize array of pointers
}

function repeatedly_execute()
{
  int i = 0;
  while (i < Game.CharacterCount) // iterate all pointers checking for ended background speech
  {
    if ((backgroundSpeech[i] != null) && (!backgroundSpeech[i].Valid)) character[i].UnlockView(); // unlock character from speech view when done talking
    i++;
  }
}

Overlay* SayInBackground(this Character*, String text)
{
  Overlay *o = this.SayBackground(text);
  if ((o != null) && (this.SpeechView > 0))
  {
    this.LockView(this.SpeechView);
    this.Animate(this.Loop, this.AnimationSpeed, eRepeat, eNoBlock, eForwards);
  }
}


That's literally all there is to it.

SMF spam blocked by CleanTalk