Problems when programming a cutscene

Started by Jakerpot, Tue 17/02/2009 23:08:02

Previous topic - Next topic

Jakerpot

Hi, i developed a code, but it doesn`t work! (Ooooo!!!) When cCliche should walk, he doesn`t, the viewport is released and he disappear! Someone can search my error/s and tell me please? I`m stuck in this error for one week, and can`t figure wth is it...

Code: ags


function room_RepExec()
{
cCliche.Transparency = 100;
if (IsTimerExpired(8)){
  cCharacter.Say("Oh no! he is comming!");
  SetViewport(600, 112);
  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);
  SetBackgroundFrame(2);
  Wait(80);
  cCliche.Transparency = 0;
  SetBackgroundFrame(2);
  cCliche.Say("Ha! Now i will take this intruder and teach him a lesson!");
  cCliche.Move(629, 152);
  Wait(40);
  cCliche.Move(627, 173);
  cCliche.FaceLocation(527, 188);
  int PlayerX = cCharacter.x;
  int PlayerY = cCharacter.y;
    cCliche.Walk(PlayerX, PlayerY);
  ReleaseViewport();
}
if (SecSystem == false){
  SetBackgroundFrame(0);
}
else {
  SetBackgroundFrame(1);
  oMetalBar1.Visible = true;
  oMetalBar2.Visible = true;
  oMetalBar3.Visible = true;
  oDoorLeft.Visible = true;
  oDoorRight.Visible = true;
}
}
function hHotspot1_Interact()
{
int RandomInteract=Random(2);
if (RandomInteract==0){
  dRandomInteract1.Start();
}
if (RandomInteract==1){ 
  dRandomInteract2.Start();
}
else {
  dRandomInteract3.Start();
}
}




Trent R

#1
Have you tried using breakpoints or Display catches to find out where it doesn't work? What color depth is your game? Do any of the sprites used for cCliche have an alpha channel?

I started to write a long post, then I realized that this is your rep_exec script. You can't put walk under repeatedly_execute because it will try to make the character move there every singe frame, and end up not moving at all. Also, you can't put Wait() commands in there either (I don't think so at least).

Put your script in another function, then call it once.

~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Matti

#2
Of course you can put it in the rep-ex, but it must not be called repeatedly. There's the if-statement with the timer and there should be no problem with it.

Didn't go through the whole code so I can't help you right now.

Trent R

#3
I stand corrected. In that case, I'll ask again, have you tried using breakpoints or Display checks to see where your script stops working?

~Trent
PS-I missed the Timer code due to strange tabbing. The following code is exactly the same, but with cleaner tabbing.
Code: ags

function room_RepExec()
{
  cCliche.Transparency = 100;
  if (IsTimerExpired(8)){
    cCharacter.Say("Oh no! he is comming!");
    SetViewport(600, 112);
    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);
    SetBackgroundFrame(2);
    Wait(80);
    cCliche.Transparency = 0;
    SetBackgroundFrame(2);
    cCliche.Say("Ha! Now i will take this intruder and teach him a lesson!");
    cCliche.Move(629, 152);
    Wait(40);
    cCliche.Move(627, 173);
    cCliche.FaceLocation(527, 188);
    int PlayerX = cCharacter.x;
    int PlayerY = cCharacter.y;
    cCliche.Walk(PlayerX, PlayerY);
    ReleaseViewport();
  }
  if (SecSystem == false){
    SetBackgroundFrame(0);
  }
  else {
    SetBackgroundFrame(1);
    oMetalBar1.Visible = true;
    oMetalBar2.Visible = true;
    oMetalBar3.Visible = true;
    oDoorLeft.Visible = true;
    oDoorRight.Visible = true;
  }
}


function hHotspot1_Interact()
{
  int RandomInteract=Random(2);
  if (RandomInteract==0){
    dRandomInteract1.Start();
  }
  if (RandomInteract==1){ 
    dRandomInteract2.Start();
  }
  else {
    dRandomInteract3.Start();
  }
}
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Makeout Patrol

You're setting cCliche's transparency to 100 (making him invisible) once every game loop. I assume that should be in the 'if' statement. If that doesn't work, do what Trent R is saying with the Display checks.

Jakerpot

Ok, thank you all  :D i will do what you are saying thanks!!!



Khris

The .Walk and .FaceLocation calls are probably supposed to have eBlock added to them. Plus you're using .Move instead of .Walk twice, which'll move the character without displaying their walk-cycle.

Code: ags
    ...
    cCliche.Say("Ha! Now i will take this intruder and teach him a lesson!");
    cCliche.Move(629, 152, eBlock);
    Wait(40);
    cCliche.Move(627, 173, eBlock);
    cCliche.FaceLocation(527, 188, eBlock);
    int PlayerX = cCharacter.x;
    int PlayerY = cCharacter.y;
    cCliche.Walk(PlayerX, PlayerY, eBlock);
    ReleaseViewport();
    ...


Is cCharacter the player character? If so, you can use cCliche.Walk(player.x, player.y, eBlock); instead of the three lines above ReleaseViewport();.

Jakerpot

khris, i used .move because i will create an animation, because he will walk on a edge, so i used move... you meani don't have to use the int's? LOL of course i don't! I'm soooo stupid, i do the things the hardest way... Thanks btw!



Khris

No problem :)

Could you modify the first post and add [solved] the topic if the issue is resolved?

SMF spam blocked by CleanTalk