Jibble

Author Topic: MODULE: BACKGROUND SPEECH (with animation&sound!) v1.1.0 (for AGS 3.2+)  (Read 8096 times)

Snarky

  • Global Moderator
  • Private Insultant
    • I can help with proof reading
    • I can help with translating
That's literally all there is to it.

If anyone's looking to implement this, that's not quite true. You have to actually store the overlay in the array (or the animation will never end), and null it out when you stop the animation (or the character will afterwards refuse to perform any other animations, including walking). This should do it:

Code: Adventure Game Studio
  1. // Script.ash
  2.  
  3. import Overlay* SayInBackground(this Character*, String text);
  4.  
  5. // Script.asc
  6.  
  7. Overlay *backgroundSpeech[]; // pointer to any character's background speech overlay
  8.  
  9. function game_start()
  10. {
  11.   backgroundSpeech = new Overlay[Game.CharacterCount]; // initialize array of pointers
  12. }
  13.  
  14. function repeatedly_execute()
  15. {
  16.   int i = 0;
  17.   while (i < Game.CharacterCount) // iterate all pointers checking for ended background speech
  18.   {
  19.     if ((backgroundSpeech[i] != null) && (!backgroundSpeech[i].Valid))
  20.     {
  21.       character[i].UnlockView(); // unlock character from speech view when done talking
  22.       backgroundSpeech[i] = null;
  23.     }
  24.     i++;
  25.   }
  26. }
  27.  
  28. Overlay* SayInBackground(this Character*, String text)
  29. {
  30.   Overlay *o = this.SayBackground(text);
  31.   if ((o != null) && (this.SpeechView > 0))
  32.   {
  33.     backgroundSpeech[this.ID] = o;
  34.     this.LockView(this.SpeechView);
  35.     this.Animate(this.Loop, this.AnimationSpeed, eRepeat, eNoBlock, eForwards);
  36.   }
  37. }