Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: iamlowlikeyou on Sat 22/01/2011 09:40:04

Title: PauseGame while in dialog, without skipping speech line [SOLVED]
Post by: iamlowlikeyou on Sat 22/01/2011 09:40:04
I'm trying to make a PauseGame function like in the classic Lucas games, which means it should pause on key press - also during dialog and cutscenes, but without skipping anything - simply halting the game until the key is pressed again, no matter what is going on...

And by the way, isn't it possible to allow only speech skip when pressing a specific key (fx Esc), and not just any key?

EDIT: and by the way#2; if I set it so that player cannot skip speech lines by keyboard, it doesn't react on the pause key until dialog is finished...
Title: Re: PauseGame while in dialog, without skipping speech line
Post by: Ryan Timothy B on Sat 22/01/2011 23:49:08
I wrote this half a year ago. I had it so that the moment you tap Space, it'll pause the game. Then the moment you release Space while it's paused, it'll unpause. I didn't like it unpausing the moment you pressed the space bar, which is why I had it unpause after you released it.

You'll have to put this in the global script in the repeatedly execute always function.

bool spaceIsHeldToPause, spaceIsHeldToUnpause;

function repeatedly_execute_always()
{
    if (IsKeyPressed(eKeySpace) && !IsGamePaused())
    {
      SetSkipSpeech(2);
      PauseGame();
      spaceIsHeldToPause=true;
    }
    else if (spaceIsHeldToPause && !IsKeyPressed(eKeySpace)) spaceIsHeldToPause=false;
    else if (!spaceIsHeldToPause && IsKeyPressed(eKeySpace) && IsGamePaused()) spaceIsHeldToUnpause=true;
    else if (spaceIsHeldToUnpause && !IsKeyPressed(eKeySpace) && IsGamePaused())
    {
      SetSkipSpeech(0);
      UnPauseGame();
      spaceIsHeldToUnpause=false;
    }
}


This will pause during speech or any cutscene.
I believe the SetSkipSpeech was used to prevent the pressing of Space to skip the speech. There was also a glitch that once the game was paused during dialog, it would continue through the lines of text if you clicked the mouse. Not sure if CJ had corrected that or not since I wrote this.
Title: Re: PauseGame while in dialog, without skipping speech line
Post by: iamlowlikeyou on Sun 23/01/2011 10:51:19
Thank you!
I will try to implement this in my game.
The mouse button glitch will be no problem, as I have totally disabled the mouse in this game :)