Talking in background

Started by Kinoko, Wed 17/03/2004 15:05:10

Previous topic - Next topic

Kinoko

Sorry if this is in the manual but for the life of me, I can't figure out how to get this done.

Basically, I have a character in the back of a room that I want to have talking, as if he's reading a speech over and over. I need this to be said in the background so it doesn't affect normal gameplay, and I need this character to stop speaking when the player talks to him. I then need him to start talking in the background again when the dialogue is over.

I tried using DisplaySpeechBackground but all the text appears at once and even then, I have the problem of repeating the "speech" over again once it's all finished. Plus, the character doesn't use the talking animation when this method is used.

Any ideas, anyone? Would the answer maybe involve creating a seperate text file with the engine accessing it and turning it into speech?

Scummbuddy

I'm not on my normal computer, but have you tried 'DisplaySpeechChar'? It may or may not be nonblocking.
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

SSH

Ummm. you asked something similar already and Scorpiorus replied with: http://www.agsforums.com/yabb/index.php?board=2;action=display;threadid=11868

which has some handy stuff for doing some of what you want. Basically with background speech it creates overlays, so you need to record which overlay was used and wait until it disappears before doing the next speech line. You also need to animate the chanracter manually. You''ll need a variable to track which speech line he's on, too, which you can set to a null value when you want to interrupt him and then  reset where your dialog completes.

12

Scummbuddy

could make his idle view a talking view
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Kinoko

I've used the code Scorpius suggested, and it works fine except that I'd like to be able to have the speech in the background start over once it has finished (it's quite a few lines of speech).

Also, the Delay line doesn't seem to have any effect on the script at all. I can't get any kind of wait or delay between lines.

Mr Flibble

#5
Sorry if this is a noob response, but did you try the interaction editor?
Put these in the "First time Character enters room"
IA means an interaction, not a script function.
1)IE Display "Your Text"
2)Script- Wait(number of gameloops);
3)IE Display"More text"

Or a simpler one, make a new dialog.
-------------------------------------
@S //This is Dialog one
Man: Blah blah
Man: ...
Man: Blah Blah
Man: ...

Then in the interactions menu,
Talk to character = Stop Dialog(1)
RunDialog(2)
RunDialog(1)
--------------------------------------

Not sure if either would work. Just a suggestion.

Ah! There is no emoticon for what I'm feeling!

Kinoko

That's fine for a normal conversation but not talking in the background.

Akumayo

Let's say that the man reading the speech is called MAN.  Okay, here is what you do

In the rooms repetedly execute:

DisplaySpeech(MAN,"Bla bla bla what a boring speech");

That should work, if not, mabye insert a Wait(x); after it, the wait time should equal how long the speech is(only do that if the speech on the screen flashes)

Luck
"Power is not a means - it is an end."

Kinoko

Again, that solves the repeat problem, but it's not talking in background. I need all this to be non-blocking.

Scorpiorus' script works like a charm so I'm happy with that except for those two problems; wait and repeating the whole thing.

orangeblotofdoom

Quote from: Kinoko on Mon 22/03/2004 13:38:33
Again, that solves the repeat problem, but it's not talking in background. I need all this to be non-blocking.

Scorpiorus' script works like a charm so I'm happy with that except for those two problems; wait and repeating the whole thing.
Apologies for bringing an old[ish] thread up again.

I'm having the same problem as the above (I think)... Need non-blocking background speech, can't figure out how to make a non-blocking delay between the lines.
Basically, I'm trying to do this:
(ovrly is an integer.)

ovrly=DisplaySpeechBackground(blah);
NonexistentWaitFunction(40);
RemoveOverlay(ovrly);
ovrly=DisplaySpeechBackground(blah);
//repeat until finished.

Looked on the tutorial pages, searched the forum. Can't find anything I can use. Any help would be appreciated.

Thanks...

strazer

#10
a-v-o posted the basics for the following in the german ags forum:

Top of script:
--------------

int pause=0;
int speakline=1;

(Room's) repeatedly_execute:
----------------------------

if (pause > 0)
   pause--;
else {
   if (speakline == 1) {
      DisplaySpeechBackground(MAN,"Hello!"); // Display dialogue line in background...
      pause = 2*GetGamespeed(); // ...then set pause for x number of game loops (here: 2 seconds)
   }
   else if (speakline == 2) {
      DisplaySpeechBackground(WOMAN,"Hi!");
      pause = 3*GetGamespeed();
   }
   else if (speakline == 3) {
      DisplaySpeechBackground(MAN,"Goodbye!");
      // End of conversation
   }
   else {
      speakline = 0; // Repeat above conversation...
      pause = 3*GetGamespeed(); // ...after this delay
   }
   speakline++; // Display next dialogue line next time
}


Should work, but I haven't tested it yet.

orangeblotofdoom

Thanks much. Works perfectly.
Since I have long lines of speech, it overwrote the previous line before it had finished. And I wanted the lines to go by pretty quickly, so I didn't want to set the "3*GetGameSpeed();" to anything above 3.
Just put in ov=DisplaySpeechBackground(blah) and RemoveOverlay(ov) in the next else if's first line.
Like so:

Code: ags

if (pause > 0)
   pause--;
else {
     if (speakline == 1) {
      ov=DisplaySpeechBackground(EGO, "The Loooorrrd Goooooood sayethed to all ye who liveth in iniquity..."); 
      pause = 3*GetGameSpeed(); 
    
   } else if (speakline == 2) {
   RemoveOverlay(ov);
         ov=DisplaySpeechBackground(EGO, "Thou shalt surely burneth in the firey depths of hades for eternity");

          pause = 3*GetGameSpeed();

   }
//etc.


Appreciate it, strazer (and a-v-o, or whoever wrote it...).


Scorpiorus

QuoteScorpiorus' script works like a charm so I'm happy with that except for those two problems; wait and repeating the whole thing.
I've corrected the mistake I made so it should work now. Thanks for finding it :) http://www.agsforums.com/yabb/index.php?board=10;action=display;threadid=11868

~Cheers

fransaskois

Thanks guys, this was very helpful.

One thing, however... In my game, after you talk to the NPC who's doing this background talking, he dissapears from the room.  

I set up an int that would change after dialogue 1 was completed (simonsint), and tried to tell AGS to only do the background speech thing if this integer was at 0, the original, pre-dialogue setting.
Here's what I have.

------------------------------dialog script file-----------------------------
@S  // dialog startup entry point
return
@1  // option 1
NPC: "Mister...I... I..."
run-script 2
new-room 10 // Room 10 is a black screen which, after a second or two
                     // brings you back to the room you were just in.


-------------------script header----------------
int pause=0;        //   There int's are for the background speech
int speakline=1;  //     thing described above.

int simonscounter;  // this i made, and could be the source of my woes ;)

-------------------global script------------------  

function dialog_request (int value){
 
   if (value == 2)
   AnimateCharacter (NPC, 1, 6, 0);  // NPC animation
   while (character[NPC].animating) Wait (2);
   simonscounter = 1;

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

----------------------Room Interactions, Repeatedly Execute-----------------
if (simonscounter == 0)
{
if (pause > 0)
...   //carbon-copy of the solution given above, these are my background                        ...   // speech lines, etc.
}
// then i added this.  As you can see in my global script, simonscounter
// is set to 1 when the dialogue is finished.
if (simonscounter == 1)
       {
   pause = -1;
   }
}


---------
This is what I want to happen:
-Player enters room1 , NPC starts background speech
-Player talks to NPC.
-Once their dialogue is done, NPC does his animation game goes to room 2 (black screen), then returns to room 1.
-NPC is gone, room is silent.

BUT this is what happens:
-Player enters room1, NPC starts background speech.
-Player talks to NPC.
-Once their dialogue is done, NPC does his animation then game goes to room 2 (black screen), then returns to room 1.
-NPC is gone, but "ghost" background speech is still going.

Anyways, that's that.  I hope you can make sense of what's going on.

thanks guys
"My computer is narcoleptic."

strazer

#14
Hi!

Ok, first of all, add these braces or you will get in trouble later:

function dialog_request (int value){

 if (value == 2)
 {
   AnimateCharacter (NPC, 1, 6, 0); // NPC animation
   while (character[NPC].animating) Wait (2);
   simonscounter = 1;
 }

}

Now, about your problem.
If you declare simonscounter in the SCRIPT HEADER, a SEPERATE variable is declared for the global script and for every room. So if you change the one in the global dialog_request function, it has no effect on the one in the room, ie it stays 0 and background speech goes on.

What you need to do is declare simonsint in the global script, export it, then import it into the script header or the room script.
This way both global and local script refer to the same variable.

SMF spam blocked by CleanTalk