I need help to make an NPC take the player to another room

Fragen zu "Adventure Game Studio"? Hier rein!
Antworten
Rubacant
Verpackungs-Wegwerfer
Verpackungs-Wegwerfer
Beiträge: 76
Registriert: 14.03.2006, 21:45

I need help to make an NPC take the player to another room

Beitrag von Rubacant »

I need help to make an NPC take the player to another room Like in Maniac mansion


I want ed or edna or other char-NPC to run at the player and you can run away and then the NPC grabs him and take him to the dungen


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); // this kinda worked but you cant move when she runs at you


}

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

Please help
Rubacant
Verpackungs-Wegwerfer
Verpackungs-Wegwerfer
Beiträge: 76
Registriert: 14.03.2006, 21:45

Re: I need help to make an NPC take the player to another ro

Beitrag von Rubacant »

// ============================= cutscene functions ===========================================
// this section after SetPlayer

function BeginCutscene (int actor){
}

function FinishCutscene (int CutsceneEnded){
}

function IsCutscene () {
}

function ToDungeon (int charid) { // this to
}

function EdPutsHamsterIntoCage () {
}

function BeamEdBackIntoHisRoom (int ignoreRoom14){
}

function SendEdBackIntoHisRoom (){ // this
}

function BeamEdnaBackIntoHerRoom (int ignoreRoom14){
}

function SendEdnaBackIntoHerRoom (){ // and this
}
Zuletzt geändert von Rubacant am 29.11.2006, 07:41, insgesamt 2-mal geändert.
Rubacant
Verpackungs-Wegwerfer
Verpackungs-Wegwerfer
Beiträge: 76
Registriert: 14.03.2006, 21:45

Re: I need help to make an NPC take the player to another ro

Beitrag von Rubacant »

I found this in the MM Global script what do i need to do to make this work. so a NPC can grab you and take you to dungen


// ============================= hunter ===========================================
// this section after cutscene functions
int hunter_char = NO_CHAR;
// two-dimeanional hunting
#define STEPS_UNTIL_DIR 10
int steps = STEPS_UNTIL_DIR;
int lastx = -1;
int lasty = -1;
// give player time to act
#define COUNTDOWN_OFF -1
#define COUNTDOWN_START 400
#define COUNTDOWN_STOPPED -2
int countdown = COUNTDOWN_OFF;
int hunter_area = -1;

function StartHunting (int hunter){
hunter_char = hunter;
lastx = -1;
lasty = -1;
countdown = COUNTDOWN_OFF;
// switch player disabled
// avo- SetGlobalInt (291, 1); // avo veraltet
}

function StartCountdown (){
// give player some time to think and react
// but player can't move
SetGlobalInt (2, 0);
hunter_area = GetWalkableAreaAt (character [GetPlayerCharacter ()].x - GetViewportX (), character [GetPlayerCharacter ()].y - GetViewportY ());
RemoveWalkableArea (hunter_area);
countdown = COUNTDOWN_START;
}

function StopHunting (){
hunter_char = NO_CHAR;
// player may move
if (hunter_area >= 0)
{
RestoreWalkableArea (hunter_area);
hunter_area = -1;
}
SetGlobalInt (2, 1);
// switch player enabled
// avo- SetGlobalInt (291, 0); // avo veraltet
}

function IsHunting (){
int result = hunter_char != NO_CHAR;
if (result)
{
// stop hunting when chars are in different rooms
if (character [hunter_char].room != character [GetPlayerCharacter ()].room)
{
StopHunting ();
result = hunter_char != NO_CHAR;
}
}
return result;
}

function HunterSucceeded (){
int hunter = hunter_char;
}

function TimeToActIsOver (){
int hunter = hunter_char;
}

function DoHunting (){
int caught = 0;
int charid = GetPlayerCharacter ();
int px = character [charid].x;
int py = character [charid].y;
// check distance
int dx = px - character [hunter_char].x;
int dy = py - character [hunter_char].y;
if ((dx * dx + dy * dy) <= 500)
{
caught = 1;
HunterSucceeded ();
}
else if (steps <= 0)
{
if ((px != lastx) || (py != lasty))
{
// correct HUNTER's direction
MoveCharacter (hunter_char, px, py);
lastx = px;
lasty = py;
}
steps = STEPS_UNTIL_DIR;
}
else steps--;
return caught;
}

function RepExec_Hunting (){
int caught = 0;
if (IsHunting ())
{
if (countdown == COUNTDOWN_OFF) caught = DoHunting ();
else if (countdown == 0)
{
countdown = COUNTDOWN_OFF;
TimeToActIsOver ();
}
else if (countdown > 0) countdown--;
}
return caught;
}




#sectionstart on_event // DO NOT EDIT OR REMOVE THIS LINE
function on_event (int event, int data){

if (event == LEAVE_ROOM) qStopSpeech();

if (event == RESTORE_GAME)
{
AdjustLanguage ();
CallRoomScript (GAME_RESTORED);
}
if ((event == ENTER_ROOM) || (event == RESTORE_GAME))
{
MoveToWalkableArea (GetPlayerCharacter ());
}
if (event == LEAVE_ROOM)
{
if ((hunter_char == ED) && (character [ED].room != 19))
{
// ED goes back into his room
SendEdBackIntoHisRoom ();
}
else if ((character [EDNA].room != 17) && (character [EDNA].room == data))
{
// EDNA goes back into her room
SendEdnaBackIntoHerRoom ();
}
}
}
#sectionend on_event // DO NOT EDIT OR REMOVE THIS LINE
Benutzeravatar
Sinitrena
Tastatursteuerer
Tastatursteuerer
Beiträge: 678
Registriert: 08.05.2004, 01:01
Wohnort: Frankfurt
Kontaktdaten:

Beitrag von Sinitrena »

First of all: You allready had a thread with this question, there's no reason to start a new one.


All right, I'll try to look at this code.
if ((player.x < cEdna.x && cEdna.Loop == 1) || (player.x > cEdna.x && cEdna.Loop == 2))
{



}
There doesn't seem to happen anything after this if statement, either you forgot it, or you wanted to that the following part of the script happens when this stament is true or you just didn't post it.
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.
When you put a FollowCharacter, the character will follow even when you change the room. You have to write: cEdna.FollowCharacter(null) somewhere to stop this.
//cEdna.Say("What some food HON"); // how do i make her say this once when she see you
I get it that you want her to say this only the very first time she sees a player character. Am I right? You would need an int to do this (or a global veriable, whatever you prefer). You define the int at the beginning of the global script:
int edna;
and use an if statement to look whether she already said it:
if (edna==0) {
cEdna.Say("What some food HON");
edna=1;
}
//cEdna.Walk(player.x, player.y,eBlock); // this kinda worked but you cant move when she runs at you
Of course you can't move, that's what eBlock means, that you don't have any control as the player.
The solution would be to use cEdna.FollowCharacter(player, 0,0), I think (I never needed it and I didn't test it)
Quote from the AGS manuel:
As a special case, setting DIST=0 and EAGERNESS=0 makes CHARID behave as if it is chasing CHARTOFOLLOW - it will try and get there as quickly as possible. Setting EAGERNESS=0 also tells the character not to stop when they reach CHARTOFOLLOW, but instead to randomly wander around the character - useful perhaps for a very energetic dog or something.
You might need to script a bit more then just this line, though.
I tryed the leave room stop following thing but that didnt work
I have no idea why this doesn't work, mainly because I always use scripts and never the interaction editor. I could guess that you probably set it to the wrong character.
http://www.sinitrena.de.vu Meine Spiele: "A very special dog", "A magic stone", "James Bond - Who wants to live again?", "Lonely Night", "Death of an Angel", "The Witch, the Wizard and the Blue Cup", "Emerald Eyes"
Rubacant
Verpackungs-Wegwerfer
Verpackungs-Wegwerfer
Beiträge: 76
Registriert: 14.03.2006, 21:45

Thank you but

Beitrag von Rubacant »

Im useing the code in script for Room: Repeatedly execute

dosnt work any where else


She still says it over and over again

int edna;

if (edna==0)
{
cEdna.Say("What some food HON");
edna=1;
}


whats weird about the cEdna.FollowCharacter(player, 0,0); code is
when you come back to the room and she not there but she comes back anyway but she dont chase you to other rooms. She come back even if she in a differnt room.


even if you do the cEdna.FollowCharacter(null) when leave room

Im puzzled with this


whats the stuff about hunter that was in the global script





Is this right

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

int edna;

if (edna==0)
{
cEdna.Say("What some food HON");
edna=1;
}

cEdna.FollowCharacter(player, 0,0);

}
Rubacant
Verpackungs-Wegwerfer
Verpackungs-Wegwerfer
Beiträge: 76
Registriert: 14.03.2006, 21:45

Oh NO

Beitrag von Rubacant »

I forgot my Rooms will have 2 backgrounds. 1 for each side of the room.

Is there a way to do a int (or a global veriable to stated that she will follow the player in thous two rooms and no where else.

Or say if player is in room5 stop following or 6

I use Regions to send the player to the other side of the room.

Cuz i need Npc to chases them to the other side and back and if you leave the room from a door following stops

like this say your in a ball room room3 and 4 are ball room she will chase you back and forth there but if you go to room 2 and 5 she stops following you
Benutzeravatar
Sinitrena
Tastatursteuerer
Tastatursteuerer
Beiträge: 678
Registriert: 08.05.2004, 01:01
Wohnort: Frankfurt
Kontaktdaten:

Beitrag von Sinitrena »

Im useing the code in script for Room: Repeatedly execute

dosnt work any where else
You should defenitly not put youre whole code in repeatedly execute. I hope you didn't try this.

Put "int edna; " at the very beginning of your room script, NOT in any function (and remember this for all future ints and Strings you might use some time.
if (edna==0)
{
cEdna.Say("What some food HON");
edna=1;
}
This part should be wherever you need it. It might be possible to put it in rep ex, but I would rather write this in "player enters room after fade in". You'll probably need some adittional ints, depending on what should happen in this room. The reason to put it in player enters room is, that it will happen as soon as the player enters the screen and not when he has done anything in the room, and it should not happen reapeatedly either.
whats weird about the cEdna.FollowCharacter(player, 0,0); code is
when you come back to the room and she not there but she comes back anyway but she dont chase you to other rooms. She come back even if she in a differnt room.
I'm not sure if I understand what you want to say. When she isn't following, she doesn't change room without a line like cEdna.ChangeRoom (7) somewhere. You should look at your script for a line like this and remove it (when you can remove it without stopping something else from working, then you might need another int)
Is this right

if (cEdna.x > GetViewportX() && cEdna.x < GetViewportX()+system.viewport_width)
Actually, I have no idea what you want to do with this line, sorry. Could you explain this a bit more?
I forgot my Rooms will have 2 backgrounds. 1 for each side of the room.

Is there a way to do a int (or a global veriable to stated that she will follow the player in thous two rooms and no where else.

Or say if player is in room5 stop following or 6

I use Regions to send the player to the other side of the room.

Cuz i need Npc to chases them to the other side and back and if you leave the room from a door following stops
When you send the player to a different room you have different parts in your script (like player walks onto region 1, player walks onto region 2, etc). You don't need to write anything additional in those parts where you send the player to the other side of the room. Just put cEdna.FollowCharacter(null) in every part of the script where she should stop following
http://www.sinitrena.de.vu Meine Spiele: "A very special dog", "A magic stone", "James Bond - Who wants to live again?", "Lonely Night", "Death of an Angel", "The Witch, the Wizard and the Blue Cup", "Emerald Eyes"
Rubacant
Verpackungs-Wegwerfer
Verpackungs-Wegwerfer
Beiträge: 76
Registriert: 14.03.2006, 21:45

I got it i think

Beitrag von Rubacant »

First thnk you for the help


I think i got the script working right here it is


//Main room script

int edna;

int ednafollow;




// script for Room: Player enters room (before fadein)

// this part of the code is use if the leave the room and come back in she still follows you


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

if (cEdna.x > GetViewportX() && cEdna.x < GetViewportX()+system.viewport_width) // this so she only follows you when she sees you

cEdna.FollowCharacter(player, 1,80);

}


// script for Room: Repeatedly execute




if(player.Room == cEdna.Room) // All Chars // if ednas in the room
{

object[4].Visible = true;
cEdna.FaceCharacter(player);
character[EDNA].BlockingWidth = 15;
character[EDNA].BlockingHeight = 15;


if (cEdna.x > GetViewportX() && cEdna.x < GetViewportX()+system.viewport_width) // only when she see you
{

if (edna==0)
{
cEdna.Say("What some food HON");
edna=1;
PlaySound(5);
}
object[4].Visible = false;


if (ednafollow==0) // this will make follow you only when she is in the room and olny once so she dont come back over and over
{
ednafollow=1;
cEdna.FollowCharacter(player, 1,80);
}

}

}


// GRAB CODE



if (character[SYD].IsCollidingWithChar(cEdna) == 1)

{

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

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

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

character[EDNA].FollowCharacter(null);

}



//All so do character[EDNA].FollowCharacter(null); when player leaves room or not if you want her to chase you down
Benutzeravatar
Sinitrena
Tastatursteuerer
Tastatursteuerer
Beiträge: 678
Registriert: 08.05.2004, 01:01
Wohnort: Frankfurt
Kontaktdaten:

Beitrag von Sinitrena »

I think i got the script working
That's great. So you don't need any more help with this script?
http://www.sinitrena.de.vu Meine Spiele: "A very special dog", "A magic stone", "James Bond - Who wants to live again?", "Lonely Night", "Death of an Angel", "The Witch, the Wizard and the Blue Cup", "Emerald Eyes"
Rubacant
Verpackungs-Wegwerfer
Verpackungs-Wegwerfer
Beiträge: 76
Registriert: 14.03.2006, 21:45

:)

Beitrag von Rubacant »

Thank you for all the help

I works good for now i dont know what bugs that will popup later. I hope not.

I havent started to make the game yet just trying to learn the codeing and how to do stuff making test games.



My first Maniac Mansion game will be called

Maniacs Mansion Terror of the Tablet
Anonymous1

Beitrag von Anonymous1 »

What is the story about this game?

And please: It is "Maniac Mansion" and not "Maniacs Mansion"!
Rubacant
Verpackungs-Wegwerfer
Verpackungs-Wegwerfer
Beiträge: 76
Registriert: 14.03.2006, 21:45

Beitrag von Rubacant »

You will find out why its called MANIACS MANSION

The story its about a very old Tablet that Ted found in egypt 25 years ago and gave to Drfred before he died

The base of the plot is kinda the same Dr Fred Kidnamps Sandy.
But Sandy has soming DrFred Wants but its a Lot deeper then that.


Plus there could be other things going on in the game to. All so depending what chars you pick and how you play the game.

Plus this game is going to a lot harder then Classic Maniac Mansion
A real mind bender
Anonymous1

Beitrag von Anonymous1 »

Rubacant hat geschrieben:You will find out why its called MANIACS MANSION

The story its about a very old Tablet that Ted found in egypt 25 years ago and gave to Drfred before he died

The base of the plot is kinda the same Dr Fred Kidnamps Sandy.
But Sandy has soming DrFred Wants but its a Lot deeper then that.


Plus there could be other things going on in the game to. All so depending what chars you pick and how you play the game.

Plus this game is going to a lot harder then Classic Maniac Mansion
A real mind bender
Well, I won't play your game, that's for sure. I only wanted to know, if you have a story for your game, because the other users want to know it also (or maybe not?!?). And I must say that this isn't really an original idea from you. You only use the same storyline like Maniac Mansion, but you changed it a little bit. So I'm still sceptical about your project, because I'm a little bit scared about your knowledge with AGS. And that you want to make a big project is a little be terrifiying.

I wish you good luck with your project. But don't really think that you will find many new friends through your game, as long you ask TOO MUCH questions about the script function of AGS.
Zuletzt geändert von Anonymous1 am 03.12.2006, 10:45, insgesamt 1-mal geändert.
Rubacant
Verpackungs-Wegwerfer
Verpackungs-Wegwerfer
Beiträge: 76
Registriert: 14.03.2006, 21:45

Beitrag von Rubacant »

Well, I don't will play your game, that's for sure ????

Do you mean

I will not play your game for sure?

OR

I will play your game?



????????????????
Benutzeravatar
KhrisMUC
Adventure-Gott
Adventure-Gott
Beiträge: 4674
Registriert: 14.03.2005, 00:55
Wohnort: München

Beitrag von KhrisMUC »

Mulle won't play it, based on the rest of his post.

I'm not too fond of the game, either. Please do us and yourself a favor and don't brag about how cool and mind-bending the game will be.

It's way better to surprise everyone with a cool game out of the blue than to continuously point out how great it's going to be and then deliver mediocre stuff with "first game" written all over it.

It's like you've just discovered that you like walking around mountains and now tell everybody that you'll climb Mt. Everest faster than Reinhold Messner.
Use gopher repellent on funny little man
Antworten