Very slow cutscene skip

Started by Radiant, Mon 17/08/2015 23:08:57

Previous topic - Next topic

Radiant

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
      
        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;

Crimson Wizard

Hmmm, I vaguely remember someone talking about such thing. Maybe AGS calculates cutscene time based on speech file length?

Radiant

Perhaps, but I tried removing the VOX file and get the same result.

Monsieur OUXX

#3
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.
 

StillInThe90s

Are you using a particle generator? I had very similar cutscene skip lag with WeatherModule or SnowRainPS module. Don't remember which one.

Dualnames

Lol, u guys are noobs.

Code: AGS


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;

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Crimson Wizard

#6
Code: ags

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.

Radiant

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.

Crimson Wizard

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.

Snarky

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.

Crimson Wizard

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.

Radiant

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.

Crimson Wizard

#12
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

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]

Radiant

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.

SMF spam blocked by CleanTalk