Hello Everyone!
I have some code where characters talk in the background. Nothing fancy really, just have this setup:
void Cut1(){
Character *c;
String m;
if(Cut1Stage == 0){ m = "Some stuff"; c = cChar1;}
else if(Cut1Stage == 1){ m = "Some Other stuff"; c = cChar2;}
else if(Cut1Stage == 2){ m = "Even more!"; c = cChar1;}
//etc etc.
Cut1Stage ++;
c.SayBackground(m);
Cut1Timer = (m.Length/Game.TextReadingSpeed + 1) * GetGameSpeed();
}
//Then in rep_exec_always():
function repeatedly_execute_always(){
if(Cut1On && Cut1Timer > 0) Cut1Timer --; //if one is still talking, count down
else if(Cut1On && Cut1Timer <= 0) Cut1(); //else get to the next bit
}
It all works fine left on it's own. The problem is when the player character says something (player.Say("blah")) it cuts off the character talking in the background (as in, they're speech completely disappears). Is there an option to change that, or is it supposed to be like that? Or (most likely) am I doing something wrong?
Thanks in advanced!
Why not have player SayBackgound which is non blocking, whereas Say is blocking.
Hello Slasher
Thank-you very much :) using SayBackground() and an enforced wait did the trick. I was worried that the functionality of Say() would be lost, i.e. the fact that it is blocking, and simultaneously having the ability to skip through the speech, but WaitMouseKey() did the trick.
if anyone is interested, the code is:
//somewhere, then imported
void Comment(this Character*, String m){
this.SayBackground(m);
WaitMouseKey((m.Length/Game.TextReadingSpeed + 1) * GetGameSpeed()); //so wait time can be skipped
this.SayBackground(""); //so that if wait time is skipped, the character stops talking
}
//elswhere
player.Comment("Woohoo!");
Thanks again!
It should be noted that some functionality of Say() is indeed lost, namely the talking animation.
Say() shouldn't just cut off active SayBackground() calls though; this almost sounds like a bug. I can't imagine it's intended or that there's a good reason for this behavior, at least I can't think of one right now.
Also, there's a much cleaner way of removing background speech:
void Comment(this Character*, String m){
Overlay* bgs = this.SayBackground(m);
WaitMouseKey((m.Length/Game.TextReadingSpeed + 1) * GetGameSpeed()); //so wait time can be skipped
if (bgs != null && bgs.Valid) bgs.Remove();
}
Hello Khris!
Ahh, I keep forgetting it's an Overlay, thanks! As for the lack of using a speaking view, hopefully forcing a repeated animation will work. As I don't have any speech animations to date, I tested this out very rudimentary, but it seemed to work:
void Comment(this Character*, String m){
Overlay* bgs = this.SayBackground(m);
this.LockView(this.NormalView + 1); //The talking view is always 1 above the normal view
this.Animate(this.Loop, 5, eRepeat, eNoBlock, eForwards);
WaitMouseKey((m.Length/Game.TextReadingSpeed + 1) * GetGameSpeed()); //so wait time can be skipped
if (bgs != null && bgs.Valid) bgs.Remove();
this.UnlockView();
}
Thanks again! :)
You're welcome :)
Btw, you can also use
this.LockView(this.SpeechView);