Multiple Characters in room when interacting with things [SOLVED]

Started by DarkMasterOz, Sun 13/08/2006 15:09:48

Previous topic - Next topic

DarkMasterOz

Sorry i can't think of how to describe my problem in short for the topic title, I've got 5 characters:
* Character 1: Baz
* Character 2: Brian
* Character 3: Bob
* Character 4: Barry
* Character 5: Billy
and I want to make it so if a character is in a room with any one of the other characters and looks at something like an item or a hotspot, that other character will interact as well. Like this for example:

1) Bob looks at a window and says "It's a window"
2) If Baz is in the room with him, Baz will say "yes you're right"
3) If Brian is in the room with him he'll say "correct, that is a window" etc...
also
if any of the other characters interacts with an object, Bob will join in too.

I know how to make all 5 interact with each other by using this inside a "runscript" for example:

if (player == cBaz) { cBaz.Say("I don't know how to work it."); }
if (player == cBrian) { cBrian.Say("I've tried, it still doesn't work.");
cBob.Say("Well make it work"); }
if (player == cBob) { cBob.Say("If I did that, i'd kill everyone."); }
if (player == cBarry) { cBarry.Say("I am unable to comply."); }
if (player == cBilly) { cBilly.Say("You do it Bob.");
cBob.Say("No");
cBilly.Say("Brian?.");
cBrian.Say("No too.");
cBilly.Say("Barry?.");
cBarry.Say("I can't do that Dave.");
cBilly.Say("Baz?.");
cBaz.Say("Yeh I don't think so.");
cBilly.Say("Don't blame me if you beam into a brick wall covered with poo.");
cBob.Say("We bloody well will bottom gag, now do your stuff.");   }


But that will make them talk even if they arent in the room

If somebody can help me solve this, i've got one more problem which i cant seem to find answer to on forums or manual properly. After that i'm pretty much set.

GarageGothic

something like:
Code: ags
if (player.Room == cBrian.Room) cBrian.Say("I'm in the same room as you dumbass!");

should do the trick.

DarkMasterOz

#2
Thanks that worked, But is there anyway to tweak it so that if the player is Baz only certain people will talk, while if the player was Bob, other certain people will speak. At the moment i've done this:

if (player == cBaz) { cBaz.Say("Is that a dog?."); }
if (player.Room == cBrian.Room) cBrian.Say("Yes, yes it is.");
if (player.Room == cBob.Room) cBob.Say("Wow you're clever arent you wonderboy.");
if (player == cBrian) { cBrian.Say("That's a dog."); }
if (player.Room == cBob.Room) cBob.Say("Correct.");
if (player == cBob) { cBob.Say("That is one big evil dog."); }
if (player.Room == cBilly.Room) cBilly.Say("How do you know it's evil?.");


But when Baz talks to the dog, it'll do this:
Baz: "Is that a dog?."
Brain: "Yes, yes it is."
Bob: "Wow you're clever arent you wonderboy."
Bob: "Correct."
Billy: "How do you know it's evil?."


anyway to make it stop at <Bob: "Wow you're clever arent you wonderboy."> and when another person looks interacts with the object/hotspot/character it'll say the rest?



can i add another question to this it's similar in away.
I've got my characters interacting with each other, an example from Talk runscript for my Baz character:

Ã,  Ã,  // script for Character 6 (Baz): Talk to character
if (player == cBaz) { cBaz.Say("I'll talk to myself later, busy thinking at moment!."); }
if (player == cBrian) { cBrian.Say("Yo Baz.");
cBaz.Say("Yo Bad Boy B."); }
if (player == cBob) { cBob.Say("How ya doing sparky?.");
cBaz.Say("Fine, Great, couldn't be better.");
cBob.Say("..Ok."); }
if (player == cBarry) { cBarry.Say("Any luck Baz?.");
cBaz.Say("Not quite yet.");
cBaz.Say("Keep us up-to-date.");
cBaz.Say("Will do."); }
if (player == cBilly) { cBilly.Say("Now then numpty.");
cBaz.Say("What?.");
cBilly.Say("What you upto?.");
cBaz.Say("Adventuring, doing Adventure type things.");
cBilly.Say("Just like me.");
cBaz.Say("Yup, just like you, you man of wisdom you.");
cBilly.Say("Quite true."); }Ã, 


But i want them to say different stuff each time and leave the old lines of talking behind when they progress with new information, mainly when i've collected an item or spoken to somebody and got some information for plot. Any ideas?

Khris

After an if-clause, you can either run a single command (in this case, no {}s are needed) or you can run a bunch of commands, grouped by {}.

So addressing your first question:

if (player == cBaz) { 
Ã,  cBaz.Say("Is that a dog?.");
Ã,  if (player.Room == cBrian.Room) cBrian.Say("Yes, yes it is.");
Ã,  if (player.Room == cBob.Room) cBob.Say("Wow you're clever arent you wonderboy.");
}
if (player == cBrian) {
Ã,  cBrian.Say("That's a dog."); }
Ã,  if (player.Room == cBob.Room) cBob.Say("Correct.");
}
if (player == cBob) {
Ã,  cBob.Say("That is one big evil dog.");
Ã,  if (player.Room == cBilly.Room) cBilly.Say("How do you know it's evil?.");
}
The second question is mainly about using variables.
You could use a global int, increment it after a dialog and check it's value.

Like this:
if (GetGlobalInt(1)==0) {
Ã,  // first dialog
Ã,  SetGlobalInt(1,1);
}
else if (GetGlobalInt(1)==1) {
Ã,  // second dialog
Ã,  SetGlobalInt(1,2);
}
else if (GetGlobalInt(1)==2) {
Ã,  // third dialog
Ã,  SetGlobalInt(1,3);
}
...

The elses are very important here, if they were left out, all dialogs would run after another!

DarkMasterOz

Thanks the first bit works fine, sorry i've been away so i couldn't say thank you.
I'm not sure how to do this bit though, where do i put it and what do i need to change:

if (GetGlobalInt(1)==0) {
Ã,  // first dialog
Ã,  SetGlobalInt(1,1);
}
else if (GetGlobalInt(1)==1) {
Ã,  // second dialog
Ã,  SetGlobalInt(1,2);
}
else if (GetGlobalInt(1)==2) {
Ã,  // third dialog
Ã,  SetGlobalInt(1,3);
}


Do i make new dialogs like "dialog 39, dialog 40, dialog 41"
and add the speech there or can i add speech in the runscript which i use for my playerable characters when they interact with each other?

Khris

You'd put it in the same place as before.
Whether you use AGS's dialogs or just cBob.Say() commands doesn't matter, both should work fine with this code, just put them right where the // xth dialog line is.
Like this:

if (GetGlobalInt(1)==0) {

Ã,  // first dialog
Ã,  if (player == cBaz) {
Ã,  Ã,  cBaz.Say("Is that a dog?.");
Ã,  Ã,  if (player.Room == cBrian.Room) cBrian.Say("Yes, yes it is.");
Ã,  Ã,  if (player.Room == cBob.Room) cBob.Say("Wow you're clever arent you wonderboy.");
Ã,  }
Ã,  ... // and so on
Ã,  
Ã,  SetGlobalInt(1,1);
}
else if (GetGlobalInt(1)==1) {

Ã,  // second dialog
Ã,  if (player == cBaz) {
Ã,  Ã,  cBaz.Say("Hey, that's a dog.");
Ã,  Ã,  if (player.Room == cBrian.Room) cBrian.Say("Yes, we KNOW that.");
Ã,  Ã,  if (player.Room == cBob.Room) cBob.Say("You are repeating yourself.");
Ã,  }

Ã,  SetGlobalInt(1,2);

}
else if (GetGlobalInt(1)==2) {

Ã,  // third dialog
Ã,  if (player == cBaz) {
Ã,  Ã,  cBaz.Say("Hehehe, that dog sure looks funny.");
Ã,  Ã,  if (player.Room == cBrian.Room) cBrian.Say("Right.");
Ã,  Ã,  if (player.Room == cBob.Room) cBob.Say("Shut up, Baz.");
Ã,  }

Ã,  // no SetGlobalInt(1,3); here, since there's no fourth version

}


DarkMasterOz

Cheers, i've got it working now 1 last question, how can i make it so that if i pickup an object, look at an object, talk to a non playerable character etc... it does that dialog change thing when i talk to my playeble characters.

Example "Baz" reads a book which is a hotspot, its part of the plot and leaves a clue.
How can i make that trigger the next dialog so when my players talk they talk about and keep talking about it until i solve the clue and get another one which activates the next lot of dialog.

Khris

Keep a list of events and corresponding GlobalInts, and everytime something ought to trigger the next dialog, use SetGlobalInt(x, GetGlobalInt(x)+1); where x is the GlobalInts number.

SMF spam blocked by CleanTalk