OK, probably because of my inability to grasp the full concept of the "while" code, I'm having some trouble with this. In the last part of my cutscene, I want to have a character say something while another is animating. Would it help if I put the animation (which is actually a series of animations) in a function? I'm sure it has something to do with DisplaySpeechBackground, but I'm not exactly sure what. It's three seperate messages, so should I put waits in between? Won't that pause the animations? Help!
Haven't you tried putting it as is:
somewhere in the cutscene:
....
....
SetCharacterView(MAN, ...);
AnimateCharacter(MAN, .........);
DisplaySpeech(HERO, "blah blah blah");
....
....
Animation is played without problems then.
~Cheers
What I meant is that since I have three messages to display, and his animation is actually a series of smaller animations, how can I make it that he doesn't pause in the middle of one of his animations so he can finish talking? That's the problem I'm having right now.
Edited to expand: The first two work as you wrote, but I already figured that part out. His third message, though, is long while ironically the animation I'm having the other character do is relatively short. Sure, I can use DisplaySpeechBackground, but then how do I get the character to look like he's talking?
try the next:
SetCharacterView(MAN, character[MAN].talkview + 1); // get his talking view
AnimateCharacter (MAN, character[MAN].loop, speed, repeat); //start talking anim
DisplaySpeechBackground(MAN, "blah blah blah"); //display speech
Huzzah, well on my way, thanks for the help :)
But how do I make him stop?
The character thats animating?
From the manual.
The REPEAT parameter sets whether the animation will continuously repeat the cycling through the frames. If REPEAT is zero, the animation will start from the first frame of LOOP, and go through each frame in turn until the last frame, where it will stop. If REPEAT is 1, when the last frame is reached, it will go back to the first frame and start over again with the animation.
I think he wants to stop the character just when he finishes to talk. :P
well there are two ways:
1. Put a ReleaseCharacterView() somewhere in the script directly so that it stops the animation. You have to guess/calculate the moment when it is most suitable.
But that is not a general solution as if you'll adjust the length of speech text (speech display time) you have to tweak the moment when ReleaseCharacterView() is called. Can be tricky.
2. Another possibility (I'd do it that way) to set up a global while loop (maybe you have one already :P) to handle all background things such as a time moment or isDisplaySpeechValid etc...
Example:
StartCutScene()
int overlay1=-1; //a text overlay for the char number 1
int timer = 0; // cutscene timer
int exit = 0; // when 1 quit the the global while loop
while (timer < 1000 && exit == 0) { //the main while loop
//first DisplaySpeechBackgroundAnimationChecks:
if (IsOverlayValid(overlay1)==0 && overlay1!=-1) {
ReleaseCharacterView(MAN); //stop talking anim
overlay1 = -1; //ensure do not enter here until another DisplaySpeechBackground is done
}
// animation at 0 loops of time
if (timer == 0) { SetCharacterView.... AnimateCharacter(....);}
// animation at 100 loops of time
if (timer == 100) AnimateCharacter(....);
// speech at 200 loops of time
if (timer == 200) {
SetCharacterView(MAN, ...);
AnimateCharacter(MAN, .........);
overlay1 = DisplaySpeech(HERO, "blah blah blah"); //get an overlay id to check it each while loop!
}
Wait(1); //update engine
timer++; //process the next tick
}
int skipped = EndCutscene();
Although I haven't tested the code it should work this way. :P
~Cheers
Though this code does stop his talking animation, it causes two new problems-
1. the text inexplicably warps at one point
2. there's a loooooong pause before action starts again.
Maybe I'm doing it wrong? I just copied yours in and replaced the blanks with my characters. Garr, sorry, this whole scripting thing is a bit hard for someone whose hardest scripting language to date was HTML, but the end product is looking great.
Quote1. the text inexplicably warps at one point
Each character has to have his own overlay variable:
int overlay1=-1; //a text overlay for the char number 1
int overlay2=-1; //a text overlay for the char number 2
int overlay3=-1; //a text overlay for the char number 3
in while:
if (IsOverlayValid(overlay1)==0 && overlay1!=-1) {
ReleaseCharacterView(CHAR1); //stop talking anim
overlay1 = -1; //ensure do not enter here until another DisplaySpeechBackground is done
}
if (IsOverlayValid(overlay2)==0 && overlay2!=-1) {
ReleaseCharacterView(CHAR2); //stop talking anim
overlay2 = -1; //ensure do not enter here until another DisplaySpeechBackground is done
}
if (IsOverlayValid(overlay3)==0 && overlay3!=-1) {
ReleaseCharacterView(CHAR3); //stop talking anim
overlay3 = -1; //ensure do not enter here until another DisplaySpeechBackground is done
}
Quote2. there's a loooooong pause before action starts again.
You need to adjust the values, the timer variable is compared to.
while (timer <
1000 &&....
...
if (timer ==
0)
if (timer ==
100)
if (timer ==
200)
Because now the cutscene is event based altering these values would reflect when each hapenning begins. All the values are measured in game loops, so you probably may need to display a FPS counter with the Debug(4,1) command.
If it still doesnt work you could probably post your code for me to look at. :P
~Cheers
OK, after a pretty hectic weekend I was finally able to sit down and try some changes to the script. Now the pause is minimal and easily changed, but the text still warps and I can't understand why. I havea feeling I'm missing something really obvious here :-\ Here's my script-
AnimateCharacter (REILY, 0, 3, 1);
DisplaySpeechBackground (REILY, "...or the fact that he had to get his headphones custom made to fit over his afro.");
StartCutscene(1);
int overlay1=-1; //a text overlay for the char number 1
int timer = 0; // cutscene timer
int exit = 0; // when 1 quit the the global while loop
while (timer < 187 && exit == 0) { //the main while loop
//first DisplaySpeechBackgroundAnimationChecks:
if (IsOverlayValid(overlay1)==0 && overlay1!=-1) {
ReleaseCharacterView(REILY); //stop talking anim
overlay1 = -1; //ensure do not enter here until another DisplaySpeechBackground is done
}
// animation at 0 loops of time
if (timer == 0) { SetCharacterView (AFRO, 2); AnimateCharacter(AFRO, 12, 21, 0);}
// animation at 83 loops of time
if (timer == 83) AnimateCharacter(AFRO, 13, 4, 0);
// speech at 135 loops of time
if (timer == 135) {
SetCharacterView(AFRO, 2);
AnimateCharacter(AFRO, 14, 4, 0);
overlay1 = DisplaySpeech(REILY, "...or the fact that he had to get his headphones custom made to fit over his afro.");
IsOverlayValid (1); //get an overlay id to check it each while loop!
}
Wait(1); //update engine
timer++; //process the next tick
}
//the next three lines would be better to place within a while loop (on timer==0). Also I think it would be a good idea to comment these lines, adjust the rest of the script and see how it works
AnimateCharacter (REILY, 0, 3, 1);
overlay1=DisplaySpeechBackground (REILY, "...or the fact that he had to get his headphones custom made to fit over his afro.");
StartCutscene(1);
int overlay1=-1; //a text overlay for the char number 1
int timer = 0; // cutscene timer
int exit = 0; // when 1 quit the the global while loop
while (timer < 187 && exit == 0) { //the main while loop
//first DisplaySpeechBackgroundAnimationChecks:
if (IsOverlayValid(overlay1)==0 && overlay1!=-1) {
ReleaseCharacterView(REILY); //stop talking anim
overlay1 = -1; //ensure do not enter here until another DisplaySpeechBackground is done
}
// animation at 0 loops of time
if (timer == 0) { SetCharacterView (AFRO, 2); AnimateCharacter(AFRO, 12, 21, 0);}
// animation at 83 loops of time
if (timer == 83) AnimateCharacter(AFRO, 13, 4, 0);
// speech at 135 loops of time
if (timer == 135) {
SetCharacterView(AFRO, 2);
AnimateCharacter(AFRO, 14, 4, 0);
//opps forgot the ...Background postfix
overlay1 = DisplaySpeechBackground(REILY, "...or the fact that he had to get his headphones custom made to fit over his afro.");
IsOverlayValid (1); //that one does nothing
}
Wait(1); //update engine
timer++; //process the next tick
}
Hey, thanks a lot, it finally works :)