[RESOLVED] Confirmation on skippable cutscene

Started by LetterAfterZ, Sat 12/01/2013 08:32:52

Previous topic - Next topic

LetterAfterZ

Hey guys,

Been banging my head against a wall for about 2 hours on this one, I'm sure it's simple enough - just can't quite get my head around the rules of the scripting quite right yet.

So, what I want to achieve is that I have a basic introduction scene with some cycling text and want any keyboard press or click to bring up a prompt "Do you want to skip this cutscene?". The problem I've faced is that my listener doesn't seem to registed while the cutscene is playing out and the inbuilt cutscene script has no (obvious) way for adding a prompt that I could see.

My code (at this moment) is this:

Code: AGS

// room script file

function room_Load()
{
  //Play room music.
  aMusic1.Play(eAudioPriorityHigh, eRepeat);

  //Hide mouse cursor for intro
  Mouse.Visible = false;
}

function myStartGame()
{
  //re-enable mouse cursor
  Mouse.Visible = true;
  
  //START GAME: go to starting game room.
  cChristianSpear.ChangeRoom(1, 60, 348);
}

function on_mouse_click(MouseButton button) {
    Display("A click!");
    //NEED TO ADD A CONFIRMATION MESSAGE HERE
    myStartGame();
  }
}


function room_AfterFadeIn()
{
  ShowTextCentered("Game Title", 2016);
  
  Wait(80);
  
  ShowTextCentered("A subtitle placeholder...");
    
  Wait(80);
  
  ShowTextCentered("This is the prologue cutscene placeholder", 7);
  
  Wait(80);
  
  ShowTextCentered("In this scene we'll see the FIRST dream sequence.", 7);
  
  Wait(80);
  
//Start the game
  myStartGame();
}


Note: Show text centered is a little custom script that creates a Textual Overlay.

Thanks for your help!

Khris

Seems there's a line missing in your code, at the start of on_mouse_click.

The thing is though, what you want isn't possible using the built-in StartCutscene() functionality.
You would have to code your own implementation.

If you want to go ahead and do this:
-call each cutscene command that takes time in an if-clause that checks whether the cutscene was skipped and perform alternative commands if it was:
Code: ags
  if (cutscene_being_skipped) {
    cEgo.x = 290; cEgo.y = 124; cEgo.Loop = 2;
  }
  else cEgo.Walk(290, 124, eBlock);

-use repeatedly_execute_always to listen for the keypress ( if (IsKeyPressed(eKeyEscape) && cutscene == eCutSceneIntro) ... )

Needlessly to say, this is a mess; unfortunately this is the only way to do it I'm aware of.

If the cutscene is confined to two rooms exclusively used for that purpose and the game will then continue in a different room, there's no need to do this, of course. Only if the game state set by the cutscene must be retained.

LetterAfterZ

Thanks for the quick reply.

The biggest problem I'm facing here, I believe, is that while the cutscene is executing it seems to prevent the listener from running any scripts on click. I've commented out the actual 'cutscene' elements of the code (the text displays and page switch, and if nothing is happening the click registers fine and the function is perfectly happy.

As the cut scene is going to be a series of title splash screens, I don't need to worry too much about WHEN the interrupt happens, it can just happily jump ahead to the final function call - just need it to actually register this.

Khris

Whenever a blocking function is executed, like a Display command, or a call to for instance player.Walk(123, 234, eBlock), nothing else will happen during that time with one exception: the function repeatedly_execute_always is still being called every frame (and thus can't contain any blocking commands itself).

Like I said in my previous post, this is where you need to handle the mouse click or key press.

LetterAfterZ

#4
Thanks for your help. I was able to find the section in the manual covering how the blocking in functions works - didn't realise there was doc on that so it helped heaps.

I ended up resolving this a different way - breaking my cutscene into functions, ditching the "wait" command and using timers instead. Another way I considered was using WaitMouseKey and using the 0/1 it returns to do something, but I wasn't really sure the best way to do this. You can see my code below:

Code: AGS

// room script file

int myIntroCounter;

function myStartGame()
{
  //re-enable mouse cursor
  Mouse.Visible = true;

  //START GAME: go to starting game room.
  cChristianSpear.ChangeRoom(1, 60, 348);
}


function room_RepExec()
{
  if (IsTimerExpired(1)) {
    //increment cutscene
    myIntroCounter++;
        
    if (myIntroCounter == 2)
    {
        ShowTextCentered("A game...");
        SetTimer(1, 80);
    }
    else if (myIntroCounter ==3)
    {
        ShowTextCentered("This is the prologue cutscene placeholder", 7);
        SetTimer(1, 80);
    }
    else
    {
        myStartGame();
    }
  }
}

function room_Load()
{
  //Play room music.
  aMusic1.Play(eAudioPriorityHigh, eRepeat);
  //Hide mouse for intro
  Mouse.Visible = false;
}

function room_AfterFadeIn()
{
  //setup frame number
  myIntroCounter = 1;
  
  //START CUTSCENE SCRIPT - rest is run in rep exec.
  ShowTextCentered("A Time Apart From Time", 2016);
  SetTimer(1, 80);
  
}

function on_mouse_click(MouseButton button) {
  if (button == eMouseLeft){
    //myClickListener = true;
    Display("A click!");
    //NEED TO ADD CONFIRMATION MESSAGE
    //myStartGame();
  }
}


One last question I did have - at the moment I'm using an int variable that I'm incrementing to track my current frame, and I'm using an if else statement to run the various parts. One thing I'd like to possibly do later is have the parts in separate variables (rather than a single running script) with a number for each function, using the incremented number to call the function - is there a way to use dynamic variables to call a function (i.e something like myIntroFrame+myIntroCounter(); (so if the counter was one 2 it would call a function named myIntroFrame2();)


For example, in Javascript I would do it like this:

Code: AGS

function foo()
{
    alert('foo');
}

var a = 'foo';
window[a]();

Khris

No, AGS doesn't support function pointers.
You can use custom function to organize things, but you have to call them by their actual name.

LetterAfterZ

Ahh that's alright. Thanks for your help!

SMF spam blocked by CleanTalk