Author Topic: DisplaySpeechBackground queued talking  (Read 15244 times)

Scorpiorus

  • 100101101010b
    • Scorpiorus worked on one or more games that won an AGS Award!
    •  
    • Scorpiorus worked on one or more games that was nominated for an AGS Award!
Re: DisplaySpeechBackground queued talking
« Reply #20 on: 13 Sep 2005, 01:15 »
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.

:)
« Last Edit: 24 Dec 2005, 19:35 by strazer »

Lazarus

  • I'm going as fast as I can!
Re: DisplaySpeechBackground queued talking
« Reply #21 on: 19 Sep 2005, 10:02 »
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

  • 100101101010b
    • Scorpiorus worked on one or more games that won an AGS Award!
    •  
    • Scorpiorus worked on one or more games that was nominated for an AGS Award!
Re: DisplaySpeechBackground queued talking
« Reply #22 on: 20 Sep 2005, 00:52 »
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.

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.



Quote
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?

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.
« Last Edit: 20 Sep 2005, 00:55 by Scorpiorus »

Lazarus

  • I'm going as fast as I can!
Re: DisplaySpeechBackground queued talking
« Reply #23 on: 20 Sep 2005, 10:14 »
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

  • 100101101010b
    • Scorpiorus worked on one or more games that won an AGS Award!
    •  
    • Scorpiorus worked on one or more games that was nominated for an AGS Award!
Re: DisplaySpeechBackground queued talking
« Reply #24 on: 20 Sep 2005, 13:39 »
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).

Quote
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.

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

Quote
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

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

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
Re: DisplaySpeechBackground queued talking
« Reply #25 on: 20 Sep 2005, 14:59 »
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

Scorpiorus

  • 100101101010b
    • Scorpiorus worked on one or more games that won an AGS Award!
    •  
    • Scorpiorus worked on one or more games that was nominated for an AGS Award!
Re: DisplaySpeechBackground queued talking
« Reply #26 on: 20 Sep 2005, 15:42 »
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

    • Vel worked on one or more games that won an AGS Award!
    •  
    • Vel worked on one or more games that was nominated for an AGS Award!
Re: DisplaySpeechBackground queued talking
« Reply #27 on: 24 Sep 2005, 09:44 »
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'

  • Mittens Viscount
  • bob
    • Privateer Puddin' worked on one or more games that won an AGS Award!
    •  
    • Privateer Puddin' worked on one or more games that was nominated for an AGS Award!
Re: DisplaySpeechBackground queued talking
« Reply #28 on: 24 Sep 2005, 18:14 »
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

  • 100101101010b
    • Scorpiorus worked on one or more games that won an AGS Award!
    •  
    • Scorpiorus worked on one or more games that was nominated for an AGS Award!
Re: DisplaySpeechBackground queued talking
« Reply #29 on: 28 Sep 2005, 22:00 »
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

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
MODULE: DisplaySpeechBackground queued talking
« Reply #30 on: 27 Nov 2005, 21:14 »
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...
« Last Edit: 28 Feb 2006, 12:28 by SSH »

Re: DisplaySpeechBackground queued talking
« Reply #31 on: 01 Dec 2005, 17:09 »
"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

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
Re: DisplaySpeechBackground queued talking
« Reply #32 on: 01 Dec 2005, 17:19 »
Did you export the functions and import them in the script header?

Re: DisplaySpeechBackground queued talking
« Reply #33 on: 01 Dec 2005, 17:24 »
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);
« Last Edit: 24 Dec 2005, 19:51 by strazer »

SSH

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
Re: DisplaySpeechBackground queued talking
« Reply #34 on: 01 Dec 2005, 20:27 »
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

Re: DisplaySpeechBackground queued talking
« Reply #35 on: 01 Dec 2005, 22:59 »
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

  • SEND PIZZA.
    • Best Innovation Award Winner 2017, for his work to help AGS games reach the widest possible audience - through popular distribution platforms (Steam, Galaxy) as well as other operating systems (Android, Linux)
    • monkey0506 worked on one or more games that won an AGS Award!
    •  
    • monkey0506 worked on one or more games that was nominated for an AGS Award!
Re: DisplaySpeechBackground queued talking
« Reply #36 on: 02 Dec 2005, 02:43 »
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
« Last Edit: 24 Dec 2005, 19:48 by strazer »