Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Allawayjh on Thu 08/12/2016 01:03:26

Title: Ways to Pause Timers?
Post by: Allawayjh on Thu 08/12/2016 01:03:26
Hello all!

I'm working on a game where I want to give the player a number of tasks, and depending on what order they do it in, get different responses back to them. I want them to receive feedback view background dialogue. EX: the Prince says he needs his hat taken,shortly after Lady M says she needs a cigarette. If you do Lady M's task first, you hear a snippet of the conversation she's having, and afterward the prince makes some sort of snarky comment, seen as a background text display.

After talking with Gilbert, he thought timers would be the best and easiest way to do this sort of thing. After a little collaboration, this is the code currently in the game.

The problem is when the dialogue plays after you do someone's favor, the timer continues to run. Is there a way to pause the timer after a dialogue starts, and then restart it when the timer is over?

Jen

Code (ags) Select


int line;
int timer;
bool princeWasHelped = false;

function BGSay(this Character *,  String what)
{
 
  timer=100;
  this.SayBackground(what);
}

function room_FirstLoad()
{
  dStartTimer.Start();


}



function room_RepExec()
{
    if (IsTimerExpired(1)) {
    if (line==0)
    {
      cPrinceG.BGSay("Take my hat?");
     
      Wait (10);
     
      cPriest.BGSay("Hang my cloak, please.");
     
      Wait (10);
     
      cLadyM.BGSay("A smoke, Daphne?");
     
   
    }
    if (line==1)
    {
      if (princeWasHelped == true) {
        cPrinceG.BGSay("Shall we enter the parlor now?");
      }
     
      if (princeWasHelped == false) {
       
       
      cPrinceG.BGSay("My hat, valet. Now.");
     
      }
    }
    if (line==2)
    {
      cPrinceG.BGSay("Utterly horrible service");
      //time=50;
    }
   SetTimer(1, timer);
   
   if (line<=17) line++;
   
   
   
   
  }
}



function oHat_Interact()
{
oHat.SetPosition(60, 660);
princeWasHelped = true;
dprinceWasHelped.Start();
}