How do i make an NPC take the player to another room

Started by Dred Rubacant, Sun 26/11/2006 02:46:42

Previous topic - Next topic

Dred Rubacant

How do i make the edsions take the player to the dungen or to other locations???


I have no idea how to script this please help
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Ashen

You're going to have to be a bit more specific than that.
Basically, it sounds like it would be a cutscene, and you'd code it like any cutscene - move the Characters (Character.Walk, Character.Animate), have them say things (Character.Say, Display), and eventually move the player to the 'Dungeon' room (Character.ChangeRoom). Read the manual to figure out exactly which commands you want, and how to use them.

As for how you'd trigger this - it depends on how you want it to happen. The most obvious way would be to check if the player is in the same room as one of the Edisons (Character.Room property) and run the code then. For those who don't quite remember Maniac Mansion (or haven't played it, even), please clarify when you'd want this to happen.
I know what you're thinking ... Don't think that.

Dred Rubacant

I want ed  or edna or other char-NPC  to run at the player and grab him  and take him to the dungen
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Ashen

Quote
move the Characters (Character.Walk, Character.Animate), have them say things (Character.Say, Display), and eventually move the player to the 'Dungeon' room (Character.ChangeRoom). Read the manual to figure out exactly which commands you want, and how to use them.

It's really not that hard, honestly.
The bit that needs clarifying is WHEN they'll run at the player - are they in a room the player walks into, do they appear in the room the player is in, do they move randomly, or in a set pattern.... That'll be the more complicated part to code so that's the part you need to give details on. (Or at least know the details yourself and try to work it out from there.) The rest is just a case of reading the manual and figuring out the commands to use (the one's mentioed in that quote are a start, and probably Character.Animate too).
I know what you're thinking ... Don't think that.

Dred Rubacant

Where would i code this  in globle script

I want it as soon has the npc see's you it will chase you and when it grabs you it takes you to the dungen.

and when the npc grabs you. you cant move


can you give me a example please to get me started 
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

R4L

If this is your game, then why are so many people making it for you?   :P

Have you even tried doing this? You just seemed to ask for code, yet you don't know where to put it.

Dred Rubacant

There not making it for  me i just need help  I just need a example OK
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

MalleTheRedPhoenix

Ashen GAVE you an example! What you 're expecting for? That the others should make YOUR game or what?!?

No wounder, why some people don't like you. You don't care for their meanings and make fun about them.

This is one good reason, why I won't help you in such cases. And I don't believe that you really want to make a game anyway.

If you can't work with AGS, then let it be!

Ashen

Here's a VERY basic example:
Code: ags

  // in repeatedly_execute
  if(player.Room == cEd.Room) {
    cEd.FaceCharacter(player);
    cEd.Walk(player.x, player.y,eBlock);
    cEd.Say("Gotcha!");
    player.ChangeRoom(10, 100, 110);
  }

Assumes you have a Character called cEd, and that the dungeon is room 10. change these (and the coordinates) to match your game.

Mulle was a little harsh, but he and R4L have a point - you should at least be trying for yourself before posting, even if it doesn't work. You'll learn more that way than just copy-pasting code, and then you won't have to wait on the forum for answers.


You're also STILL not really answering the questions people (mostly ME, I admit) ask you.
Quote from: You
I want it as soon has the npc see's you it will chase you and when it grabs you it takes you to the dungen.

and when the npc grabs you. you cant move

That bit was fairly clear anyway but:
Quote from: Me
The bit that needs clarifying is WHEN they'll run at the player - are they in a room the player walks into, do they appear in the room the player is in, do they move randomly, or in a set pattern....

I've also made the thread title a little more generic, for anyone searching.
I know what you're thinking ... Don't think that.

Da_Elf

my guess is that the NPC will be walking either a set path or walking a random path but will rush after to Player when he/she is actually facing the player.

Dred Rubacant

Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Ashen

You're welcome, but I'm not actually sure how much use that code is. It's just the quickest, most basic method I could think of. It doesn't allow, for example, for cEd being off-screen when he / the player enters the room (most of your backgrounds look to be scrolling), or facing away from the player at the time. As soon as they're in the same room together the player is caught, and there's nothing they can do about it - which seems like it'd be very annoying, and like something you'd want to avoid. I just wanted to show you that it's really not that complicated - you should take a crack at it yourself.

The other questions (which you still haven't commented on - I'd guess Da_Elf is right, but you never know) are things you'll need to consider too - how you want NPCs (the Edisons) to move around the house. I can only think that that will be much more complicated than a simple 'Move Character, Change Room' interaction and you'll be back asking for help with that. Which isn't a problem - provided you can be clear about what you actually want and make some effort yourself. The Charactrer Control module mght be of use, when you get to that. Oh, and another thing to note: What version of AGS are you using? In another thread I think you said you changed to 2.7 for compatability with a resource pack - are you still using that?
I know what you're thinking ... Don't think that.

Dred Rubacant

Im going to you 2.7 for the game  and the script work. is there away when you see that char in view then it chases you


if(player.Room == cEdna.Room) {


   cEdna.FaceCharacter(player);
    cEdna.FollowCharacter(player);   // Tryed adding this

    cEdna.Walk(player.x, player.y,eBlock);
   
       cEdna.Say("Gotcha!");

    player.ChangeRoom(10, 100, 110);
}

Is there any way to atvite when you see the other char
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Ashen

What did you add the FollowCharacter command for?
It could be used to make the NPC move to a given number of pixels (10 by the default values) from the player's location, if you could make the movement blocking (so the player can't just run away) and make it start immediately (the default value of 97 for eagerness means she'll probably wait a while before chasing him - which would look wrong).
But then you wouldn't need the blocking Walk command - So what where you trying to do with it? 

The way I would do it is: check if the NPC is on the visible screen, then check if they're facing the player, then run the interaction.

The 'visible' part of a scrolling room is between GetViewportX() and GetViewportX() + system.viewport_width horizontally and GetViewportY() and GetViewportY() + system.viewport_height (System.ViewportWidth/Height in V2.72). I think all your rooms are horizontal scrolling only, right? So you only need the first bit.

You can tell if the NPC is facing the character by checking their Loop and the player's X coordinate.
(player.x < cEdna.x && cEdna.Loop == 1) means player is to the LEFT of the NPC, and the NPC is facing the correct way.
(player.x > cEdna.x && cEdna.Loop == 2) means player is to the RIGHT of the NPC, and the NPC is facing the correct way.


There might be an easier way, but that's off the top of my head.
I know what you're thinking ... Don't think that.

Dred Rubacant

Sorry dont understand what you mean about  how to use the

(player.x < cEdna.x && cEdna.Loop == 1)
(player.x > cEdna.x && cEdna.Loop == 2)


and  check if the NPC is on the visible screen :( ??? :'(
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Ashen

Have you tried?

They're just extra conditions like if (player.Room == cEdna.Room) - albeit a little more complicated.

Code: ags

if ((player.x < cEdna.x && cEdna.Loop == 1) || (player.x > cEdna.x && cEdna.Loop == 2)) {

Would tell you if Edna is facing the player.

Similarly comparing cEdna.x with the bounds of the visible screen (GetViewportX()and GetViewportX() + system.viewport_width) will tell you if she's on screen:
Code: ags

if (cEdna.x > GetViewportX() && cEdna.x < GetViewportX()+system.viewport_width)

And the same to check cEdna.y against the vertical bounds (GetViewportY() and GetViewportY() + system.viewport_height) IF your rooms scroll vertically.

The you can just nest the Room, on-screen and facing check conditions inside each other (pseudocode):
Code: ags

if (room) {
  if (on-screen) {
    if (facing) {
      DoStuff();
    }
  }
}


You could run them into one condition, but that would be quite unwieldy, given the length of some of the conditions:
Code: ags

if ((room) && (on-screen) && (facing)) {
  DoStuff();
}
I know what you're thinking ... Don't think that.

Dred Rubacant

#16
Ok i kinda got it to work but there a problem



heres the code



if(player.Room == cEdna.Room)  // All Chars
{

cEdna.FaceCharacter(player);

}
if ((player.x < cEdna.x && cEdna.Loop == 1) || (player.x > cEdna.x && cEdna.Loop == 2))
{



}
if (cEdna.x > GetViewportX() && cEdna.x < GetViewportX()+system.viewport_width)
{

  cEdna.FollowCharacter(cSyd, 4, 10);   //  this works she runs at you  but every time you go in the room she comes back how do i stop this.
   
//cEdna.Say("What some food HON");  // how do i make her say this once when she see you

//cEdna.Walk(player.x, player.y,eBlock);
 



   if (character[SYD].IsCollidingWithChar(cEdna) == 1)   // This works great
   
{

cEdna.Say("Gotcha!");
PlayMusic (11);

cEdna.Say("What are you doing in my house!");

   player.ChangeRoom(10, 462, 131);
   cEdna.ChangeRoom(10, 504, 127);


}


I tryed the leave room stop following thing but that didnt work
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Dred Rubacant

Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

SMF spam blocked by CleanTalk