Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Radiant on Mon 17/08/2015 23:08:57

Title: Very slow cutscene skip
Post by: Radiant on Mon 17/08/2015 23:08:57
I have a rather odd issue. In the following block of code, pressing ESC during the cutscene will cause the game to hang for about twenty seconds (as if there were some really expensive/slow calculations being done), before continuing normally. I see no reason why this particular cutscene would take more than a fraction of a second to "fast forward", other cutscenes (in the same room, even) are skipped lightning-fast as normally. Perhaps somebody else has seen this before?

Code (ags) Select
     
        StartCutscene (eSkipESCOrRightButton);
        Speech.SkipStyle = eSkipKeyMouseTime;
        DisplaySpeech (FROTZ, "&101 Well done!");
        DisplaySpeech (FROTZ, "&105 As you've probably seen, you can interact with things by clicking on them. You can look, take things, talk to people, and so forth.");
        DisplaySpeech (FROTZ, "&106 You can walk around by clicking on the floor. If you want, you can use the right mouse button to quickly walk anywhere.");
        DisplaySpeech (FROTZ, "&107 Finally, you can click on yourself to bring up the menu. This shows your inventory and lets you save or quit the game.");
        DisplaySpeech (FROTZ, "&108 More importantly, now that you have your wand, you can cast spells by clicking on yourself and selecting one.");
        DisplaySpeech (FROTZ, "&109 Exactly.");
        EndCutscene   ();
      Speech.SkipStyle = eSkipKeyMouse;
Title: Re: Very slow cutscene skip
Post by: Crimson Wizard on Mon 17/08/2015 23:17:29
Hmmm, I vaguely remember someone talking about such thing. Maybe AGS calculates cutscene time based on speech file length?
Title: Re: Very slow cutscene skip
Post by: Radiant on Mon 17/08/2015 23:43:13
Perhaps, but I tried removing the VOX file and get the same result.
Title: Re: Very slow cutscene skip
Post by: Monsieur OUXX on Mon 24/08/2015 13:16:16
Maybe it's the AGS engine that's responsible for this, but my guts tell me it's a custom script in your repeatedly_execute_always (so it still gets exectued when you press Esc, but does not reflect on-screen, as you know how AGS works). My instinct tells me that this custom script probably works perfectly everywhere else, because you're not in the conditions that trigger the bad behaviour, but I imagine that for this particular dialog, your character is in the one and only situation that makes some script loop too much.

Do you have custom scripts in your game? Try putting your character in a different situation: different coordinates, different room, make a different character say this very dialog, etc.
Title: Re: Very slow cutscene skip
Post by: StillInThe90s on Mon 24/08/2015 17:37:53
Are you using a particle generator? I had very similar cutscene skip lag with WeatherModule or SnowRainPS module. Don't remember which one.
Title: Re: Very slow cutscene skip
Post by: Dualnames on Tue 25/08/2015 04:45:07
Lol, u guys are noobs.

Code (AGS) Select


StartCutscene (eSkipESCOrRightButton);
        Speech.SkipStyle = eSkipKeyMouseTime;
        if (!Game.SkippingCutscene)DisplaySpeech (FROTZ, "&101 Well done!");
        if (!Game.SkippingCutscene)DisplaySpeech (FROTZ, "&105 As you've probably seen, you can interact with things by clicking on them. You can look, take things, talk to people, and so forth.");
        if (!Game.SkippingCutscene)DisplaySpeech (FROTZ, "&106 You can walk around by clicking on the floor. If you want, you can use the right mouse button to quickly walk anywhere.");
        if (!Game.SkippingCutscene)DisplaySpeech (FROTZ, "&107 Finally, you can click on yourself to bring up the menu. This shows your inventory and lets you save or quit the game.");
        if (!Game.SkippingCutscene)DisplaySpeech (FROTZ, "&108 More importantly, now that you have your wand, you can cast spells by clicking on yourself and selecting one.");
        if (!Game.SkippingCutscene)DisplaySpeech (FROTZ, "&109 Exactly.");
        EndCutscene   ();
      Speech.SkipStyle = eSkipKeyMouse;

Title: Re: Very slow cutscene skip
Post by: Crimson Wizard on Tue 25/08/2015 09:28:21
Code (ags) Select

void DisplaySpeechEx(int character, String text)
{
    if (!Game.SkippingCutscene)
        DisplaySpeech(character, text);
}




I would rather find out why the engine does not skip it though. Because it should.
Title: Re: Very slow cutscene skip
Post by: Radiant on Sat 29/08/2015 21:43:00
Quote from: Monsieur OUXX on Mon 24/08/2015 13:16:16
Maybe it's the AGS engine that's responsible for this, but my guts tell me it's a custom script in your repeatedly_execute_always
It turns out you are correct; the culprit is a bunch of Rawdraw code in the rep_ex_al function. Thanks for the tip!

Well, so it was a scripting error. However, perhaps this should be something that logs warnings? E.g. any rawdraw command in rep_ex_al during a skipping cutscene may be cause for a logfile warn.
Title: Re: Very slow cutscene skip
Post by: Crimson Wizard on Sun 30/08/2015 01:34:51
Quote from: Radiant on Sat 29/08/2015 21:43:00
Well, so it was a scripting error. However, perhaps this should be something that logs warnings? E.g. any rawdraw command in rep_ex_al during a skipping cutscene may be cause for a logfile warn.
I am wondering if it should run in case of skipping cutscene. This seems to be a flaw in cutscene concept to me.
Title: Re: Very slow cutscene skip
Post by: Snarky on Sun 30/08/2015 09:00:47
I believe the problem is that you can't just automatically skip the rawdraw commands, because there's no way for AGS to know that those drawings don't persist outside of the cutscene, so you might end up with an inconsistent state. The intention is that the state of the game at the end of the cutscene should be the same whether or not you skipped through it, and that means that every state-changing action has to be executed.
Title: Re: Very slow cutscene skip
Post by: Crimson Wizard on Sun 30/08/2015 12:31:16
Right, I see, that makes sense now.
I guess it will be useful to make a warning to the log for all commands that take significant time to perform. And not only in always_rep_exec, because these may appear inside other functions too.
Title: Re: Very slow cutscene skip
Post by: Radiant on Tue 01/09/2015 20:16:12
Yes, but if it occurs in other functions, the programmer has most likely planned for it; whereas if it occurs in r_e_a he may not be aware. R_e_as are hard to trace.
Title: Re: Very slow cutscene skip
Post by: Crimson Wizard on Wed 02/09/2015 13:48:59
I feel very uneasy to rely on such speculations, as whether it is likely that programmer planned something or not. Inexperienced scripter may forget to put a long loop inside "not IsSkippingCutscene" check in a normal event function too.
I think it is generally a mistake to perform time-consuming operations inside skippable cutscene, because that could lead to doing more actions than required, instead of setting game to final state after EndCutscene. These warnings, if added, they could notify game author about this.


Spoiler

E: TBH, this made me think that cutscenes are done incorrectly in AGS. Executing same script when skipping it opens a door for all kinds of synchronization issues. Would not it better if the game script acted similar to try/catch structure? Like (pseudolanguage)
Code (ags) Select

cutscene
{
    // do cutscene
}
catch_skipped
{
    // do what happens if cutscene was skipped at any moment
}


Although that would be problematic to do something like that in AGS, where cutscene can start in one room script and end in another.
[close]
Title: Re: Very slow cutscene skip
Post by: Radiant on Wed 02/09/2015 18:03:39
Quote from: Crimson Wizard on Wed 02/09/2015 13:48:59
I feel very uneasy to rely on such speculations, as whether it is likely that programmer planned something or not. Inexperienced scripter may forget to put a long loop inside "not IsSkippingCutscene" check in a normal event function too.

Fair point, but if you're going to throw a warning for every Rawdraw operation, then that will just flood the logfile with 40+ messages per second. What would help is e.g. detecting if e.g. a full second goes by without the screen being updated; perhaps similar to the infinite-loop check on while loops.