Animation in another room

Started by , Sun 05/11/2006 22:21:42

Previous topic - Next topic

Jazz

Hi everybody,

I'm working on this game, where an action in one room can have an effect in another.

What I've done is I've created an (invisible) player Observer  in the room where the effect takes place. When the (visible) playing character activates the trigger, I switch to the Observer, and play the animation using a function-call from the "Player enters Room (after fade-in)" script.

Now this works fine and dandy.

After the animations are done, I want to switch back to the original player.  However, the "character[original].SetAsPlayer();" makes the game hang, probably because I call it before the end of the "Enters Room (after fade-in)"-script has finished.

Is there a safe place where I can call "SetAsPlayer()" *before* control is released to the (human) player, am I going about this the wrong way, or what?

Any help greatly appreciated,

thanks, Jazz.

Rui 'Trovatore' Pires

Consider not using a different character instead. Consider keeping your player character's XY coordinates and his view/frame/loop in ints, then changing his room and appearance for the duration of the cutscene and have him do what you want (or at least just put him in that room, invisible) and then just bring him back to the playable room.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

SSH

Try making a room repeatedly_execute and call the function in there
12

Jazz

Thanks Rui and SSH for your input. Trying out both your suggestions, I found out the cause of hanging the game was a queuing of NewRoom Calls.

Apparently (this was not clear to me, so I hope another newbie reading this may find it helpful) it is possible to divide an animation over multiple rooms. Beware however, that when changing rooms during an animation sequence:

1. stop the script in the current room,
2. add a (continuation of the) script to the next room.
     what worked for me was using a GlobalInt indicating an animation is running, and
     checking for this in the routine "Player enters Room (after fade-in)"
3. You can move NPCs (characters that are currently not SetAsPlayer) around at
     will. However, if you change the room of the active character, that's where your
     (partial) script ends!
4. DON'T use SetAsPlayer on a character that's not in the current room. This will
     choke the game when encountered during the "Player Enters Room(...any...)"
     (There is an implicit ChangeRoom there. This was the cause of my misery...)
     Instead, ChangeRoom the active character to the room where the desired
     character resides (end of partial script), pick up the animation sequence in that
     room, and use SetAsPlayer() there.

So, if you want to do an animation-sequence in 3 rooms (A, B and C) and then switch back to the original room (A), your animation script is divided in 4 (!) parts,
and altogether could look similar to this:

// I use an invisible dummy character Y.
// Others move a (made fully transparent) main character around.
// You should do what you like

For Room A:
========
function StartAnim()
{
  // This is the start, EGO is active character

  ... // do whatever

  // Get Y in the Room (option)
  Character[Y].ChangeRoom(A);
  character[Y].SetAsPlayer();
  SetGlobalInt(X,1);
  character[Y].ChangeRoom(B);
  // Nothing beyond this point...
}

function FinishAnim()
{
  // This is the end

  ... // Do whatever, some final activities

SetGlobalInt(X,0); // <-- Don't forget this one !
//Switch back to main character
character[EGO].SetAsPlayer();

// Regular play resumes from here
}

//This is the code for the "Player Enters Room (after fadein)" routine in Room A
{
if(GetGlobalInt(X) == 1)
   FinishAnim();
}

For Room B:
========
function ContAnim()
{
  // This is the first continuation, Y is active character

  ... // do whatever

  // Done, move on...
  character[Y].ChangeRoom(C);
  // Nothing beyond this point...
}

//This is the code for the "Player Enters Room (after fadein)" routine in Room B
{
if(GetGlobalInt(X) == 1)
   ContAnim();
}

For Room C:
========
function ContAnim()
{
  // This is the second continuation, Y is active character

  ... // do whatever

  // Done, move on...
  character[Y].ChangeRoom(A);
  // Nothing beyond this point...
}

//This is the code for the "Player Enters Room (after fadein)" routine in Room C
{
if(GetGlobalInt(X) == 1)
   ContAnim();
}

I know, this might be stating the obvious for the more experienced AGS-sers, but I had to find out the hard way. So I hope this helps.

Also in the documentation of AGS there is reference to the StartCutscene() and
EndCutscene() functions. I've tried these, but I haven't got a clue as to what their
effect is. Animation works just as fine without them, so I tossed them out of my
scripts.
If anyone wants to elaborate on their use and effects, please do reply to this thread.

Regards, Jazz

Pumaman

Start/EndCutscene are for creating skippable cutscenes. Using them means that the player can press ESC (or whatever) to skip the script up until the EndCutscene command.

Jazz

To make this clear, where would one put Start/EndCutscene() in the Room A, B, C example?

At the beginning of StartAnim() and the end of EndAnim(),
at the beginning and end of each of the StartAnim(), ContAnim() and FinishAnim() functions,
or somewhere else?

Thanks, Jazz

Pumaman

Assuming that you have one continuous cutscene that runs through rooms A, B and C then you'd put a single StartCutscene at the point in Room A where the non-interactive bit starts, and an EndCutscene in Room C just before control is returned to the player.

SMF spam blocked by CleanTalk