Problems with counter Urgent!!!

Started by Jakerpot, Sun 08/03/2009 03:00:04

Previous topic - Next topic

Jakerpot

Hi everyone, i`m trying to add a counter when a character (cCliche) quit the room, it`s 2 counters, one if the player picked up the pills (object) and another if the player doesn`t. The two are the same thing, i just changed the ID from them to make them diferent to each other. here is the code:

Code: ags

function room_RepExec()
{

cCliche.Transparency = 100;

if (IsTimerExpired(8)){
  cCharacter.Say("Oh no! he is comming!");
  SetViewport(600, 112);
  SetBackgroundFrame(1);
  oMetalBar1.SetView(7, 0);
  oMetalBar1.Animate(0, 5, eOnce, eBlock, eForwards);
  oMetalBar2.SetView(7, 0);
  oMetalBar2.Animate(0, 5, eOnce, eBlock, eForwards);
  oMetalBar3.SetView(7, 0);
  oMetalBar3.Animate(0, 5, eOnce, eBlock, eForwards);
  Wait(10);
  oMat.SetView(16);
  oMat.Animate(0, 5, eOnce, eBlock, eForwards);
  SetBackgroundFrame(2);
  Wait(40);
  cCliche.Transparency = 0;
  IsClicheOnRoom = 1;
  SetBackgroundFrame(2);
  cCliche.Say("Ha! Now i will take this intruder and teach him a lesson!");
  cCliche.ChangeView(15);
  cCliche.Animate(0, 5, eOnce, eBlock, eForwards);
  cCliche.ChangeView(11);
  cCliche.Say("I need my pills!");
  ReleaseViewport();
  SetBackgroundFrame(3);
  oMat.Visible = false;
  if (IsOnHidePlace == false){
  cCharacter.ChangeRoom(26);
    }
 else if (IsOnHidePlace == true){
   cCliche.SetAsPlayer();
   cCliche.Walk(626, 185, eBlock, eAnywhere);
   cCliche.Walk(358, 186, eBlock, eAnywhere);
   if (PickUpPills == false){
     cCliche.FaceObject(oPills, eBlock);
     cCliche.Say("Oh! Here are my pills!");
     oPills.Visible = false;
     cCliche.Walk(214, 170, eBlock, eAnywhere);
     cCliche.Say("Let's see if this boy is hidden on the security system room."); 
     SetTimer(3, 400);
     cCharacter.SetAsPlayer();
     cCliche.ChangeRoom(5);
     IsClicheOnRoom = 2;
   }
     if (IsTimerExpired(3)){
       cCliche.ChangeRoom(4);
       cCliche.SetAsPlayer();
       cCliche.Say("Dammit! Where the hell is this boy?");
       cCliche.Walk(cCharacter.x, cCharacter.y, eBlock, eWalkableAreas);
       cCliche.Say("Ha! Did you think you could escape from me? Ha!");
       cCharacter.SetAsPlayer();
       cCharacter.ChangeRoom(26);
     }
  if (PickUpPills == true){
    cCliche.FaceLocation(371, 119);   
    cCliche.Say("Hey, i remember to put my pills there!");
    cCliche.Walk(214, 170, eBlock, eWalkableAreas);
     cCliche.Say("Let's see if this boy is hidden on the security system room."); 
     SetTimer(5, 400);
     cCharacter.SetAsPlayer();
     cCliche.ChangeRoom(5);
     IsClicheOnRoom = 2;
  }
     if (IsTimerExpired(5)){
       cCliche.ChangeRoom(4);
       cCliche.Say("Dammit! Where the hell is this boy?");
       cCliche.Walk(523, 181, eBlock, eWalkableAreas);
       cCliche.Say("Ha! Did you think you could escape from me? Ha!");
       cCharacter.ChangeRoom(26);
     }
 }
}
if (SecSystem == false){
  SetBackgroundFrame(0);
}
else {
  SetBackgroundFrame(1);
  oMetalBar1.Visible = true;
  oMetalBar2.Visible = true;
  oMetalBar3.Visible = true;
  oDoorLeft.Visible = true;
  oDoorRight.Visible = true;
  oMat.Visible = true;
}
}


Well, the counter 3 and 5 doesn`t work when expired, i don`t know if they are triggered too. Why they don't work? Can someone help me please?



Khris

Both IsTimerExpired(3) & (5) are checked inside IsTimerExpired(8). Is that intentional?
Keep in mind that IsTimerExpired() returns true only once, then false again.

Jakerpot

i think not   ::) i will try put the } before the isTimerExpired things... Thank you!



Dualnames

I'd love to point out that it would be easier (or at least I find it to use integer variables instead of timers).

Example:
Code: ags

int counter;
function repeatedly_execute() {
counter++;
if (counter==240) {//240loops are 6 seconds
}
}
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)

Jakerpot

no need Dualnames, but thanks btw. It worked Chris! It worked! Now i just have to make more animations to keep my game moving  :D Thank you!



SMF spam blocked by CleanTalk