Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: selmiak on Thu 03/11/2011 22:56:53

Title: skipping cutscene takes ages
Post by: selmiak on Thu 03/11/2011 22:56:53
I have

StartCutscene(eSkipESCOnly);

lots of walking and talking and animation
2 rather fast while loops
some wait() commands

EndCutscene();


and it takes ages to skip this. like 9-10s nothing happens. The screen stays frozen and accepts no input and so on.
commenting out the while loops didn't change anything. What causes a skippable cutscene take so long?

Title: Re: skipping cutscene takes ages
Post by: Khris on Thu 03/11/2011 23:23:52
Could you post the actual code?
Title: Re: skipping cutscene takes ages
Post by: selmiak on Fri 04/11/2011 00:31:56

  StartCutscene(eSkipESCOnly);
   
  player.SetWalkSpeed(25, 6); 
  cEgo.Walk(170, 110, eBlock, eWalkableAreas);
  player.SetWalkSpeed(5, 5);
  Wait(200);
  oSunshine.Transparency=75;
  Wait(35);
  oSunshine.Graphic=10;
  oSunshine.Transparency=50;
  Wait(35);
  oSunshine.Graphic=12;
  oSunshine.Transparency=25;
  Wait(35);
  oSunshine.Graphic=13;
  oSunshine.Transparency=0;
  //PlayMusic(2);
  Wait(10);
  oSunshine.SetView(3);
  oSunshine.Animate(1, 4, eRepeat, eNoBlock);
 
  oCloud.SetView(3);
  oCloud.Animate(2, 0, eRepeat, eNoBlock);

  Wait(80);
  oWolke1.SetView(3); /
  oWolke1.Animate(9, 1, eRepeat, eNoBlock);
  Wait(40);
  PlaySound(6);//Sound motor -----------------
  Wait(260); 

  oPlane.Move( 20, 120, 2, eNoBlock,  eAnywhere);
  Wait(100);
 
  oWolke2.SetView(3);
  oWolke2.Animate(10, 1, eRepeat, eNoBlock);
 
  Wait(60);
  StopMusic();
 
  // GESPRÃ,,CH
  cCaptain.Say("Good morning James.");
  cCaptain.Say("I hope you had a good night.");
  cEgo.Say("Morning Captain.");
  cEgo.Say("Oh!");
  cEgo.Say("What a night!");

...more talking
 
    oHud.Visible=true;
    oHud.Transparency=hudfade;
    while(hudfade>-1)
     {
      oHud.Transparency=hudfade;
      hudfade-=7;
      Wait(1);
     }
    oHud.SetView(3);
    oHud.Animate(17, 4, eOnce, eBlock);
   
  cCaptain.Say("This is the island.");   
...even more talking
 
    oHud.Animate(18, 4, eOnce, eBlock);
   
  cCaptain.Say("It is completely hollow.");
...some more talking
 
    oHud.Animate(19, 4, eOnce, eBlock);
   
...and more talking lines
  cEgo.Say("...");
 
    hudfade=0;
    while(hudfade<101)
     {
      oHud.Transparency=hudfade;
      hudfade+=10;
      Wait(1);
     }
     
...more talkie
   oPlane.Animate(11, 3, eOnce , eBlock);
   oPlane.Animate(12, 3, eRepeat, eNoBlock);
   oArnie.Visible=true;
   oArnie.Animate(14, 3, eOnce, eNoBlock);

...and some more talking
 
    oJump.Visible=true;
    oArnie.Visible=false;
    oJump.Animate(15, 3, eOnce, eNoBlock);
 

  oPlane.Animate(13, 3, eOnce , eBlock);
  oPlane.Animate(8, 3, eRepeat, eNoBlock);
  oPlane.Move( 320, 120, 2, eNoBlock,  eAnywhere);
  Wait(60);
     moved=true;
    EndCutscene();


where there is ...talking there is just cEgo and cCaptain saying stuff and I skipped it to make the post smaller and not spoil too much ;)
Title: Re: skipping cutscene takes ages
Post by: Arjunaz78 on Fri 04/11/2011 09:42:21
It's seems you have a Blocking code..but i'm not sure what it is..maybe the "Wait();" code that cause this..

correct me if i'm wrong..
Title: Re: skipping cutscene takes ages
Post by: Khris on Fri 04/11/2011 11:07:56
Cutscenes are more or less made exclusively of blocking code, aren't they...?

selmiak:
You have probably tried this already but I'd narrow down the problem by commenting out most of the code, then putting part after part back in and see which lines cause the wait.
Title: Re: skipping cutscene takes ages
Post by: selmiak on Fri 04/11/2011 19:53:48
seems like the huge cEgo.Say and cCaptain.Say portions are responsible for the lag. What do I do now to make the cutscene easily skippable? Putting the talking paragraphs into extra functions is no solution, I tried that already ;)
Title: Re: skipping cutscene takes ages
Post by: Khris on Fri 04/11/2011 20:35:51
Afaik, internally, skipping a cutscene is achieved my processing each command differently. Character.Say commands for instance should be basically skipped entirely (as opposed to say a blocking move, where the character is "warped" to the target coordinates instead of walking there so skipping doesn't screw up the game state).

If for some reason a Character.Say in skipping mode still causes a short wait, many of them could cause a considerable lag. This is beginning to sound like a bug, it's just weird that nobody else has noticed it yet.

If you're sure it's the Say lines, I'd post this in the engine thread so the people maintaining the new build are alerted to this.
Title: Re: skipping cutscene takes ages
Post by: selmiak on Thu 02/02/2012 14:32:47
okay, I had some time to tinker with it again and found out it must be animation + speech combined.
If I either comment out the lots of text and have animations or if I have no animations started at all but leave the text in, skipping is pretty fast. If both are in it's really takes ages to skip.
So now the question is... how do I stop animations in a rooms script on esc?
Title: Re: skipping cutscene takes ages
Post by: selmiak on Sat 04/02/2012 21:04:10
I tried checking for keypress in repeatedly execute and this didn't work there, so I added a global bool that is set to true if esc is pressed while in that room and while the cutscene to skip is playing, but this also didn't work.
help!
Title: Re: skipping cutscene takes ages
Post by: selmiak on Sun 05/02/2012 14:48:16
haha, I nailed it down to one animation. So if you are reading this and have the same problem... make sure your animation doesn't have more than ~60 frames. Mine had 96 frames at first and this caused the lag. Cutting it down to 50 made it go smoother.
Title: Re: skipping cutscene takes ages
Post by: Ryan Timothy B on Wed 15/02/2012 02:06:12
Quote from: Khris on Fri 04/11/2011 20:35:51
If for some reason a Character.Say in skipping mode still causes a short wait, many of them could cause a considerable lag. This is beginning to sound like a bug, it's just weird that nobody else has noticed it yet.
I realize this post is a little old but I had to respond. It's not exactly a bug, it's actually doing what it should do. If the Say command blocks the game for 5 seconds to show you the text but was within a skipped cutscene, the engine will run 5 seconds worth of repeatedly execute always calls plus any character, object animations.

The only real way around it is to check before the Say command.


if (!Game.SkippingCutscene) player.Say("Line1 Blah blah blah");
if (!Game.SkippingCutscene) player.Say("Line2 Blah blah");


It seems redundant to duplicate that code, but AGS is doing exactly what it should be doing. Since during the Say command you may have code in Repeatedly Execute Always that does something if the character is on a specific frame.