DisplaySpeechBackground queued talking

Started by Scorpiorus, Sat 21/02/2004 16:43:26

Previous topic - Next topic

Scorpiorus

#20
I thought about converting this into a module but then somehow hesitated whether its functionality is enough to be a stand-alone script module. Think I just add multiple conversations feature (and possibly something else) and then make a module out of it.

:)

Lazarus

Thanks for the reply
and looking at my last post I didn't explain it very well

I had copied exactly as you had written and was using the background talking in the room function :

function repeatedly_execute() {
Ã,  Ã,  if (qIsTalking()==0) {Ã,  Ã, 
Ã,  Ã,  Ã,  Ã, qDisplaySpeech(EGO, "blah blah");
Ã,  Ã,  Ã,  Ã, qDisplaySpeech(EGO, Delay(20));
Ã,  Ã,  Ã,  Ã, qDisplaySpeech(EGO, "more blah");
Ã,  Ã,  Ã,  Ã, qDisplaySpeech(EGO, Delay(70));Ã,  Ã, 
Ã,  Ã,  }
}

And when the player left the room the background talking was continuing in the next room, and it was here that I was placing the "qStopSpeech()" to counteract it.

At the moment I seemed to have fixed the problem.


Now I have acouple of questions the first is that when I have a NPC character talking in the background and I then remove him to replace the character with another different NPC there seems to be a delay before the first background talking stops, is there away to stop the background talking instantly?
At the moment I'm using

if (character[EGO].room == 34) {
Ã,  if (qIsTalking()==0) {Ã,  Ã, 
Ã,  Ã,  Ã,  Ã, qDisplaySpeech(EGO, "blah blah");
Ã,  Ã,  Ã,  Ã, qDisplaySpeech(EGO, Delay(20));
Ã,  Ã,  Ã,  Ã, qDisplaySpeech(EGO, "more blah");
Ã,  Ã,  Ã,  Ã, qDisplaySpeech(EGO, Delay(70));Ã,  Ã, 
Ã,  Ã,  }
}
else if (character[ROGER].room == 34) {
Ã,  Ã,  if (qIsTalking()==0) {
Ã,  Ã,  Ã,  Ã, qDisplaySpeech(EGO, "blah blah");
Ã,  Ã,  Ã,  Ã, qDisplaySpeech(EGO, Delay(20));
Ã,  Ã,  Ã,  Ã, qDisplaySpeech(EGO, "more blah");
Ã,  Ã,  Ã,  Ã, qDisplaySpeech(EGO, Delay(70));
Ã,  Ã, }
}

else { qStopSpeech();Ã,  }


The secound question is how did you workout the sizes for
#define BUFFER_SIZE 300
#define AGS_STRING_LENGTH 200
and what effect would there be increasing these values?

Thanks Lazarus


*Currently using AGS Editor 2.70 (Build 2.70.601)*

Scorpiorus

#22
Quote from: Lazarus on Mon 19/09/2005 10:02:51I had copied exactly as you had written and was using the background talking in the room function :

function repeatedly_execute() {
Ã,  Ã,  if (qIsTalking()==0) {Ã,  Ã, 
Ã,  Ã,  Ã,  Ã, qDisplaySpeech(EGO, "blah blah");
Ã,  Ã,  Ã,  Ã, qDisplaySpeech(EGO, Delay(20));
Ã,  Ã,  Ã,  Ã, qDisplaySpeech(EGO, "more blah");
Ã,  Ã,  Ã,  Ã, qDisplaySpeech(EGO, Delay(70));Ã,  Ã, 
Ã,  Ã,  }
}

And when the player left the room the background talking was continuing in the next room, and it was here that I was placing the "qStopSpeech()" to counteract it.

Ok, first let's sort out the qStopSpeech() problem because it's related to the other question. If I understand you correctly the above code is placed in the *room* repeatedly execute interaction event, right? I ask because you typed "function repeatedly_execute()" what usually is the name of global repeatedly execute which should be placed in the main global script file.
Also, I assume EGO is an NPC and not a player character.

The fact qStopSpeech() does its job when you put it within room's repeatedly execute means the function itself works properly. I guess there is a problem with on_event part, let's see...

Could you modify you main global script on_event function like this:

function on_event(int event, int data) {

   // ...
   // ...
   // some other code may be here
   // ...
   // ...


   // move the following lines at the very
   // end of on_event function:
   //
   if (event == LEAVE_ROOM) {
      Display("qIsTalking1 = %d", qIsTalking());
      qStopSpeech();
      Display("qIsTalking2 = %d", qIsTalking());
   }

}

Now, the background talking is started in the first room that causes the trouble (ie. backgroung talking does not stop when you leave it) and just before the player leaves the room you should see two displays:

qIsTalking1 = SOME NUMBER
qIsTalking2 = SOME NUMBER

So tell me please what there numbers are, for qIsTalking1 and qIsTalking2 respectively.
And let me know if it doesn't display anything at all.



Quotehow did you workout the sizes for
#define BUFFER_SIZE 300
#define AGS_STRING_LENGTH 200
and what effect would there be increasing these values?

AGS_STRING_LENGTH is the maximum length of an AGS string, you should not change it because it can cause serious problems with some versions of AGS, apart from that it won't change anything (for instance, if you increased the value it would just take more system memory and nothing else).

BUFFER_SIZE specifies the size of the buffer to store queued speech messages, it determines how many qDisplaySpeech calls you can have in one go, ie:

if (qIsTalking()==0) {Ã,  Ã, 
Ã,  qDisplaySpeech();
Ã,  qDisplaySpeech();
Ã,  qDisplaySpeech();
Ã,  qDisplaySpeech();Ã,  Ã, 
Ã,  ....
Ã,  ....
Ã,  etc but not more than BUFFER_SIZE in total
}

You can increase it which would take up more memory but I believe 300 is more than enough. ;)


p.s. So post those qIsTalking1, qIsTalking2 numbers so that we could resolve the original problem and I could then post a working example for the "changing characters" question.

Lazarus

Yes you are right in both accounts I was showing where I had placed the "if (qIsTalking()==0) { " in the room script as I wanted the background talking to loop. And the background talking is between two NPC talking to each other and not the player.

I started in say room 1 where the two NPC characters are talking to each other and I got when leaving room 1:
qIsTalking1 =0
qIsTalking2 =0

now I'm in room 2 where the background talking has carried forward this however doesn't happen ever time but more times than not. When I leave room 2 to go back to room 1 I get
qIsTalking1 =1
qIsTalking2 =0
this doesn't happen every time as I also got
qIsTalking1 =0
qIsTalking2 =0
when leaving room 2.


I asked about buffers and string length as I'm playing around with the background talking to continue while the player interacts with objects etc.. because at the moment when a player interacts with something the background talking pauses. The problem I've got is the background talking doesn't follow on from each other in order eg..
1,2,3,4,5
it seems to display lines randomly eg.. 1,4,6,3
and increasing the buffer size almost sorts it out if thats any help

thanks
*Currently using AGS Editor 2.70 (Build 2.70.601)*

Scorpiorus

Quote from: Lazarus on Tue 20/09/2005 10:14:26
I started in say room 1 where the two NPC characters are talking to each other and I got when leaving room 1:
qIsTalking1 =0
qIsTalking2 =0

That is what I have been suspecting! Here, qIsTalking1 returns incorrect value because with the background speech going on it should return 1. That's clear now why qStopSpeech doesn't remove background talking -- it checks qIsTalking internally and since it's 0 qStopSpeech doesn't even try disabling what's already off (as it thinks).

Quotenow I'm in room 2 where the background talking has carried forward this however doesn't happen ever time but more times than not. When I leave room 2 to go back to room 1 I get
qIsTalking1 =1
qIsTalking2 =0
this doesn't happen every time as I also got
qIsTalking1 =0
qIsTalking2 =0
when leaving room 2.

This makes it clear that sometimes qIsTalking works but some other times it doesn't.

QuoteI asked about buffers and string length as I'm playing around with the background talking to continue while the player interacts with objects etc.. because at the moment when a player interacts with something the background talking pauses. The problem I've got is the background talking doesn't follow on from each other in order eg..
1,2,3,4,5

Ah, did you put DisplaySpeechQ_RE(); inside the repeatedly_execute_always function by any chance? :)

You see, DisplaySpeechQ_RE(); is the main run-time routine that handles and updates background talking each game loop but it has to be placed within the main global repeatedly_execute function.
I see that you probably tried to make it work with blocking interactions but unfortunetely DisplaySpeechQ_RE() won't work correctly inside rep_ex_always because the last one is called at the end of a game script loop unlike normal repeatedly_execute that's invoked at the beginning instead.
Getting messages out of order is probably also caused by the very same issue -- if qIsTalking wrongly returns 0 from time to time qDisplaySpeech(...); is getting added to the buffer which eventually overflaws (ie more than 300 messages). Since it's a circular buffer it starts to overwrite the most outdated messages those you have at the beginning. I now see that I should have made it to report an error instead, because although the method I used should generally work fine, it also can go wrong if there is a logic mistake in the script such as putting qDisplaySpeech() in rep_exec without any sort of qIsTalking checks. Surely, qIsTalking in its turn must report the correct state then.

I'll see if I can make it work with repeatedly_execute_always but that would possibly require to change some of the framework code.


As for your first question concerning the characters change you can take a look at the demo game I just uploaded:

http://www.geocities.com/scorpiorus82/bgtalk_v10.zip requires AGS 2.7 (right click save as or copy&paste into the address bar)

See whether moving DisplaySpeechQ_RE() back to rep_exec solves the problem and if the code in the test game does what you are after.

Otherwise just let me know if something is wrong. ;)

ps. By the way what AGS version do you have, 2.7? I'm going to sort out that timing problem with DisplaySpeechQ_RE and also update it to use object-oriented scripting and script module support. Those two require AGS v2.7 or higher of course.

SSH

Quote from: Scorpiorus on Tue 20/09/2005 13:39:14
ps. By the way what AGS version do you have, 2.7? I'm going to sort out that timing problem with DisplaySpeechQ_RE and also update it to use object-oriented scripting and script module support. Those two require AGS v2.7 or higher of course.

Since script modules can have their own repeatedly_execute, you don't need to bother fixing that timing thing: the user never need know about that _RE function at all!  ;D
12

Scorpiorus

Hehe, it was going to be a simple one... but then Lazarus' having mentioned a possibility to have it going during blocking incited me to make it optionally work that way. I thus still need to re-code it a bit.

But yeah, module feature rocks -- "put that part here before this but after that" is no more!1 :)

Vel

I have a questoin:
Will
qDisplaySpeech(EGO, "hi there MAN!");
qDisplaySpeech(MAN, "hey Roger");
qDisplaySpeech(EGO, Delay(50));
qDisplaySpeech(MAN, "blah blah");
SetGlobalInt(11,1);

Set the 11th global int to 1 after the player has seen the last message of the conversation or not?

Privateer Puddin'

No, it wont do it at the end because the qDisplaySpeech aren't blocking (how it performed when i have done things after it)

Scorpiorus

You can have:

at the top of the script:
bool bConversationStarted = false;

start talking:
qDisplaySpeech(EGO, "hi there MAN!");
qDisplaySpeech(MAN, "hey Roger");
qDisplaySpeech(EGO, Delay(50));
qDisplaySpeech(MAN, "blah blah");
bConversationStarted = true;

repeatedly execute:

if (bConversationStarted && qIsTalking()==0)
{
   SetGlobalInt(11,1);
   bConversationStarted = false;
}

SSH

#30
I have made a module for this. I tried to get hold of Scorp to check if it was OK to release, but he's not been around for a whuile, so I'll keep this low-key a release until I hear from him. Anyway, you can

download SSH's module here (Requires AGS 2.71!)
Mirror

and it is nearly backwards compatible with the existing code. I changed the Delay directive to qDelay, so as not to clash with other module that might use such a common word. I also added qSetGlobalInt and qAddScore directives that work in the same way as Delay. Finally, I added the ability to use subtitles along with the speech, for whatever someone might want that for...
12

ManicMatt

"Undefined token qdisplayspeech"

Nope, that can't be right! I put that big code in the top part of the global script like it asked, and put this following excerpt in the repeatingly executed room script file:

qDisplaySpeech(TRA, "hi there MAN!");
qDisplaySpeech(TRA, "hey Roger");
qDisplaySpeech(TRA, Delay(50));
qDisplaySpeech(TRA, "blah blah");

Not working... so I add above it:

qDisplaySpeech(int CharID, string message);

but don't know what to do with that...

(Should I be asking this in another thread?)

SSH

Did you export the functions and import them in the script header?
12

ManicMatt

#33
I deleted the int charID bit after realising what it represents, and pasted the import definitions into the script header.

Now it says it doesn't know what this is:

return IsOverlayValid(cur_overlay);

SSH

If you're using the original script with v2.7 or later, you'll need to make sure the  "Enforce object based scripting" setting on the General setting page of the editor is OFF
12

ManicMatt

Ah! Yes, it['s not complaining, and the game runs...

however...

my character isn't saying anything!

I think I'm supposed to put this in my script, but the engine doesn't understand it.

DisplaySpeechQ_RE();

(Thanks for helping me out btw!)

monkey0506

#36
I've also started modulificating this, but it's still pretty preliminary (no sounds or speech views yet).  But I can say that I got a module typed up that successfully ran a small conversation to in the background in a queued order (with some help from Scorporious's code ;D).  I'm trying to work out the animations, and then I'll work on the sounds.

Edit:

Script module released: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23806

SMF spam blocked by CleanTalk