Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Nixxon on Mon 16/11/2020 01:20:16

Title: Delayed Character Background Speech
Post by: Nixxon on Mon 16/11/2020 01:20:16
S'up Gang.

This one is probably a little 'pedestrian'.

I am wanting to have some character background speech display sporadically during a room.

More specifically, the character would speak using 3 or 4 random lines of speech without interrupting the player movement, using the 'Character.SayBackground' command I am assuming.

Ideally, the first string of speech would occur approximately 20-30 seconds after the player character resumes movement in the room.

I thought of doing something in the repeatedly execute. Not sure if that's the best option if a cleaner method is available?

Many thanks.

EDIT: Bugger, looks like I had this exact query a few moons ago and had it sorted. - https://www.adventuregamestudio.co.uk/forums/index.php?topic=52848.0

Actually, I'm still having issues displaying an animation (set character view) to show talking animation. Based on Snarky's last response in the above thread, it isn't really possible without heavy coding and better to use a Module. The most up to date BGspeech module I could find was this - https://www.adventuregamestudio.co.uk/forums/index.php?topic=48086.msg636452160#msg636452160. Unfortunately that gave me a font error in the script on compiling.

I am able to change the character view, however it does not animate. Using the animate.character function throws an error.

SEE LINE 22 -

Code (ags) Select
// room script file
int cBase_speechTimer = 0;

// A helper function to simplify the job of background speech with voice
void SayBackgroundClip(this Character*, String message, AudioClip* clip)
{
  this.SayBackground(message);
  if(clip != null)
    clip.Play();
}

function repeatedly_execute_always() {
  cBase_speechTimer++;
  if (cBase_speechTimer % 600 == 0) {
    int which = cBase_speechTimer / 600;
    if (cBase.Room != player.Room)
      return; // do nothing

    if (which == 1)
    {
      cBase.SayBackground("Unit 19, please report"); // cBase.SayBackgroundClip("&1 DIALOG 1", aPEDO7); --- existing code for speech
      cBase.ChangeView(19); // Changes view, but doesn't animate using loop
    }
    else if (which == 2)
      cBase.SayBackground("message 2"); // cBase.SayBackgroundClip("&2 DIALOG 2", aStonethrow); --- existing code for speech
    else if (which == 3)
      cBase.SayBackground("message 3"); // cBase.SayBackgroundClip("&3 DIALOG 3", aMonstereat); --- existing code for speech

    else
      cBase_speechTimer = 0; // Loop around
  }
}


Any ideas?