Cutscene change room and character not working

Started by Alen101, Sun 01/11/2015 06:37:03

Previous topic - Next topic

Alen101

Im trying to make a little cutscene when the player enter a room, but the cutscene ocurs in other room with other character.
example: guy1 enters room,
camera goes to other room and guy 2 talks for a little , then back to guy 1 who is the player.

The same as maniac mansion first cutscene, player enters house then dr fred apears in his lab and talks for a little then goes back to dave

Its too caotic and costy to make another room for each cutscene and
it give me error if i use this: cBern.SetAsPlayer(); to change the camera to the guy 2 place. It say that the player is not in the room, but of course this happens because obviously in my case second player must not be in the same room where guy1 is entering.
Hope i was clear enough.


What i am doing wrong?

2)i have 3 players too as in maniac, then how can i came back to the rigth player after the dr fred talk.
Beacause i cant say player.SetAsPlayer

thanks for any help!

AnasAbdin

#1
You can always let the current player character change to the desired room for the cut scene at y = -1 or any negative number.
(e.g.. player.ChangeRoom(roomNumber, player.X, player.Y * -1) assuming the original player's Y is positive...)

in the cut scene room, use the After Fade In:

if ( player.Y < 0 )
{
//cut scene commands...

//if you want to end the cut scene by sending the player back to their previous room:
player.ChangeRoom(player.PreviousRoom, player.X, player.Y * -1);
}

for the second question, I think something like this would work:

cCharacterName.SetAsPlayer();

Alen101

thanks but it doesnt work ;( heres my code:

function room_FirstLoad()
{
if ( player.y < 0 )
{
StartCutscene(eSkipESCOnly);
cBern.Say("blablabla.");
player.ChangeRoom(player.PreviousRoom, 603, 126);

So the player change the room but from then , nothing happens.
I get stucked in the second room watching the other character but wont go back to the first room neither the character talks there.

AnasAbdin

Quote from: AnasAbdin on Sun 01/11/2015 06:53:12
in the cut scene room, use the After Fade In:

use:
function room_AfterFadeIn()
{

}

Alen101

but then, wont it will repeat every time i enter that room?

AnasAbdin

Not if you use a specific condition:
In my example, it will repeat every time the player enters the room at a Y < 0.. you can use any condition you like

Quote from: AnasAbdin on Sun 01/11/2015 06:53:12
if ( player.Y < 0 )
{
//cut scene commands...

//if you want to end the cut scene by sending the player back to their previous room:
player.ChangeRoom(player.PreviousRoom, player.X, player.Y * -1);
}

Vincent

#6
I think there's a lots of ways to to that.
If you want that happen only one time you can try to do something like with :

Booleans
Code: ags

bool First_time; // global boolean set to true
function room_AfterFadeIn()
{
  if (First_time) // <---- First time for the cutscene, true
  {
    if ( player.Y < 0 )
    {
     First_time = false; //<----- so it will happen just one time
     //cut scene commands...
     //if you want to end the cut scene by sending the player back to their previous room:
     player.ChangeRoom(player.PreviousRoom, player.X, player.Y * -1);
    }
  }
}


Or you could check this also by a nice function :

Code: ags

function room_AfterFadeIn()
{
  if (Game.DoOnceOnly("First_cutscene")) // 
  {
    if ( player.Y < 0 )
    {
     //cut scene commands...
     //if you want to end the cut scene by sending the player back to their previous room:
     player.ChangeRoom(player.PreviousRoom, player.X, player.Y * -1);
    }
  }
}



:EDIT: Quote from the manual
Be Very careful with where you place the corresponding EndCutscene command. The script must pass through EndCutscene in its normal run in order for the skipping to work - otherwhise, when the player presses ESC the game could appear to hang.

Khris

room_FirstLoad is exactly what's needed here; I'm not sure how all those alternatives are going to fix the original problem.

Alen101, from what you describe it sounds like the function doesn't run at all; did you actually link it to the event in the room's event panel?
Or did you simply type "function room_FirstLoad()" yourself?

Alen101

#8
No i linked it because i have read in the forums that if you just type the stuff yourself it doesnt work.

I still cant figure this out and nothing is working, it looks like is not calling the function as Khris sayed but everything seems ok.

Alen101

#9
So ive tryed all you had told me but nothing seems to work, here is my last attempt:

Code: ags
function room_AfterFadeIn()
{

if (Game.DoOnceOnly("player.PreviousRoom == 10")) //when player enters room 11 from room 10 is the only way to see the cutscene.
{
StartCutscene(eSkipESCOnly);
cBern.SetAsPlayer(); //here ive tryed to change the player so the cutscene takes place in the room with bern, ive been playing with character alex untill this moment
//so the player change works but it doesnt
player.Say("Mmm im hungry.");// no one speech this line 
cAlex.SetAsPlayer(); // here ive tried to return to the character alex, the one i was playing first but it dont return 
//EndCutscene();
}

}

AnasAbdin

I don't know why you're making this a big deal  ???

If the room is already meant to be visited in the gameplay before that particular cutscene then I'd simply use a condition in the "After Fade In"

Code: ags

function room_AfterFadeIn()
{
  //make a condition that works only for this particular cutscene, I'm using cEgo.y < 0
  if ( cEgo.y < 0 )
  {
    // cutscene begin
    //   ...
    //  ...
    //cutscene end
    //if you want the cutscene to end by returning to the same room of the current
    //character before the scene began then simply use ChangeRoom..
  }

  //AfterFadeIn contents unrelated to the cutscene

}

Snarky

#11
There are a couple of problems here.

First, this is wrong:

Quote from: Alen101 on Mon 02/11/2015 04:09:11
Code: ags
if (Game.DoOnceOnly("player.PreviousRoom == 10")) //when player enters room 11 from room 10 is the only way to see the cutscene.


Or at least, it's not doing what you probably think it's doing. The string within Game.DoOnceOnly() is not evaluated, it's just an arbitrary label, so this is exactly the same as if (Game.DoOnceOnly("only the first time this function is called")).

What you probably want is:

Code: ags

  if(player.PreviousRoom == 10)
  {
    if(Game.DoOnceOnly("first time entered from room 10"))
    {
      // Do stuff...
    }
  }


The other problem is that when you set a different character as player, that changes the room. But as explained in the manual, that doesn't happen until the end of the script. I'm not entirely sure how the flow works in this case, but apparently the effect is that the room script is interrupted, so the rest of the stuff never happens.

What you need to do is to just do the character change in this script, and move the other commands to a script in the room where cBern is, which gets launched when the room loads (probably that room's room_AfterFadeIn()). If that's a room that can be visited other times as well, you'll have to put another check to make sure it only runs that time. For example, if the player is always cAlex for the rest of the game, you could do:

Code: ags
function room_AfterFadeIn() // In the room where cBern is
{
  if(player == cBern) // Here's the test
  {
    cBern.Say("Mmm im hungry.");
    cAlex.SetAsPlayer();
  }
}


Perhaps a safer way is to set a global variable before you change the room, and test that. Let's say we've defined a boolean called hungryCutscene:

Code: ags
// Room where cAlex is
function room_AfterFadeIn()
{
  if(!hungryCutscene)  // Normal case, we're not coming back from the cBern "I'm hungry" cutscene 
  {
    // Check if we should play the cutscene, in two steps
    if(player.PreviousRoom == 10)
    {
      if(Game.DoOnceOnly("first time entered from room 10"))
      {
        // OK, play the cutscene
        StartCutscene(eSkipESCOnly);
        hungryCutscene = true;
        cBern.SetAsPlayer();  // This loads the room cBern is in, to play the cutscene
      }
    }
    // If you need other special cases, put them here
  }
  else // this means (hungryCutscene == true)
  {
    hungryCutscene = false;  // Oops! Gotta do this or stuff will go wrong next time you enter
    EndCutscene();
  }
}


Code: ags

// Room where cBern is
function room_AfterFadeIn()
{
  if(hungryCutscene) // Here's the test
  {
    cBern.Say("Mmm im hungry.");
    cAlex.SetAsPlayer();
  }
}

Monsieur OUXX

#12
Snarky got it right.

Let's leave aside the small issue with "DoOnceOnly".

Your core issue is that there are instructions that you should avoid using in cutscenes because they are executed after the script, i.e. after the cutscene. You should just remember "this instruction does not mix well with cutscenes". Changing the player character is one of those "toxic" instructions in cutscenes.

So, then, how to fix that? Here again you need one core idea: It is that you should chop your cutscene into several scripts, each of them happening in the right room at the right time, with a way for each of those scripts to pick up where the previous script ended, so that the cutscene appears as one long cutscene. That's what's explained in detail with room_AfterFadeIn and all those conditions scripting.

It took me a long time to understand that: cutscenes that span across several rooms with player-character swapping are to dealt with carefully.

Spoiler

Also, off-topic:
Code: ags

    cBern.SetAsPlayer();  //Feel the Bern!

[close]
 

Khris

How about for now, let's put a Display("after fadein"); inside the function, and nothing else. As soon as that shows up like it's supposed to, we can tackle the rest.
Also, I'm not sure what calling StartCutscene() without also ending it does; it might lead to some unexpected results though and is not recommended.

Snarky

Khris, the function is running fine. It just gets interrupted by the implicit ChangeRoom() in the SetAsPlayer() call.

Alen101

Thank you guys!
I fixed the main problem thanks to all the advices.
Snarky was rigth, the problem was that the  cBern.SetAsPlayer(); change the room then all the other parts of the script wont run.
But all the advices help me so thank you all

SMF spam blocked by CleanTalk