The following is a sample script taken from my forthcoming game, Juniper Crescent – The Sapphire Claw. This includes all the logic which controls the dialogue choices and responses as well as some function calls – to animate characters, for instance. The game is being developed using the Wintermute Engine and tool set, so the script format is the one that this tool set uses.
Talk to the Skull global SkullVar;
global BlinkyVar;
global Coconut;
global InvisibleVar;
var Blinky = Scene.GetNode(“blinky”);
var Skull = Scene.GetNode(“skull”);
var Pole = Scene.GetNode(“pole”);
var Scout = actor;
////////////////////////////////////////////////////////////////////////////////
on “Talk”
{
GoToObject();
Game.Interactive = false;
// greetings if(!SkullVar.Talked)
{
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“Hello, skull.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“Hello, cat. It’s so good to meet you.”);
// set the flag, so that we know we’ve already talked to him SkullVar.Talked = true;
}
153
else {
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“Hi, it’s me again.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“Hello. I’m glad you came back to talk some more.”);
}
if(InvisibleVar == true) {
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“You can see me?”);
Skull.Talk(“Yes, of course I can.”);
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“But I’m invisible.”);
Skull.Talk(“Not to me, you’re not.”);
}
// and let the dialogue choices begin SkullTalk1();
// restore interactivity Game.Interactive = true;
}
////////////////////////////////////////////////////////////////////////////////
on “LookAt”
{
Scout.GoToObject(this);
Game.Interactive = false;
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“This is a sorry-looking skull.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“Don’t be so rude. You can hurt a person’s feelings saying things like that.”);
if(!SkullVar.Talked) {
APPENDICES
154
Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“Good grief, a talking skull!”);
// set the flag, so that we know we’ve already talked to him SkullVar.Talked = true;
}
Game.Interactive = true;
}
////////////////////////////////////////////////////////////////////////////////
on “Take”
{
Scout.GoToObject(this);
Game.Interactive = false;
if(!SkullVar.Moved) {
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“Excuse me a moment.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“Hey, just what do you think you’re doing?”);
Skull.SkipTo(440, 450);
Pole.Interactive = true;
SkullVar.Moved = true;
} else {
Scout.Talk(“No need to move it again.”);
}
Game.Interactive = true;
}
////////////////////////////////////////////////////////////////////////////////
on “Cards”
{
Scout.GoToObject(this);
Game.Interactive = false;
SAMPLE SCRIPT 155
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“Would you like to play a game of cards.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“And just how do you expect me to hold my cards?”);
Game.Interactive = true;
}
////////////////////////////////////////////////////////////////////////////////
on “Coconut”
{
Game.SelectedItem = “null”;
Scout.GoToObject(this);
Game.Interactive = false;
Scout.Talk(“Hey, Coconut. Come over here, will you?”);
Coconut.Talk(“Okay...”);
Coconut.GoTo(551, 565);
Coconut.Talk(“What do you want?”);
Scout.Talk(“Have you ever seen a talking skull before?”);
Coconut.Talk(“No...”);
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“Hey, skull, say something cool.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“I’m not a trained parrot, you know.”);
Coconut.Talk(“Hey, that’s neat.”);
Game.Interactive = true;
}
////////////////////////////////////////////////////////////////////////////////
on “LeftClick”
{
Scout.GoToObject(this);
}
APPENDICES
156
//FUNCTIONS
////////////////////////////////////////////////////////////////////////////////
function GoToObject() {
Scout.GoTo(300, 600);
Scout.TurnTo(DI_DOWNRIGHT);
}
////////////////////////////////////////////////////////////////////////////////
function SkullTalk1() {
var Responses;
var Selected;
var Loop = true;
while(Loop) {
// prepare the choices
Responses[0] = “Talking skull”;
Responses[1] = “Name”;
Responses[2] = “Pole”;
Responses[3] = “Skull Rock”;
Responses[10] = “Exit”;
// fill the response box
if(!SkullVar.Talking) Game.AddResponse(0, Responses[0]);
if((!SkullVar.Name)||((BlinkyVar.Nigel)&&(!SkullVar.Nigel))) Game.AddResponse(1, Responses[1]);
if(!SkullVar.Pole) Game.AddResponse(2, Responses[2]);
if(!SkullVar.SkullRock) Game.AddResponse(3, Responses[3]);
Game.AddResponse(10, Responses[10]);
// let the player choose one Selected = Game.GetResponse();
SAMPLE SCRIPT 157
// now let the conversation develop depending on the selected sentence if(Selected==0) //Talking Skull
{
if(!SkullVar.Moved)
Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“I never expected you to talk.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“Why not? You seem to be doing remarkably well for a pussy-cat.”);
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“But you’re just a skull.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“So, you’ve got something against skulls have you?”);
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“No, I...”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“It’s always the same - prejudice just follows me around.”);
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“Really?”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“Well, not that I actually go anywhere...”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“I blame Ray Harryhausen for stereotyping the whole subject of skeletons.”);
SkullVar.Talking = true;
}
else if(Selected==1) //Name {
if (!SkullVar.Name) {
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.
sprite”);
Scout.Talk(“What’s your name?”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“I’m not in the habit of giving my name out to just anyone, you know.”);
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.
sprite”);
APPENDICES
158
Scout.Talk(“It’s something embarrassing, isn’t it?”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“Not at all! It’s, er... Cutthroat Jake! Yes.”);
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.
sprite”);
Scout.Talk(“You just made that up.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“No I didn’t!”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“You can call me Jake if you like.”);
SkullVar.Name = true;
Skull.Caption = “Jake”;
}
if ((BlinkyVar.Nigel)&&(!SkullVar.Nigel)) {
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.
sprite”);
Scout.Talk(“That mouse over there...”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“I hate that mouse. Do you have any idea what he did to me?”);
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.
sprite”);
Scout.Talk(“I...”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“He had the audacity to build a nest in my eye socket.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“I was only able to drive him out by whistling for six hours straight.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“Do you realise how difficult that is when you don’t have any lips...?”);
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.
sprite”);
Scout.Talk(“The mouse told me your real name is Nigel.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“Well...”);
SAMPLE SCRIPT 159
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.
sprite”);
Scout.Talk(“What sort of a name is Nigel for a skull?”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“I know, I know...”);
SkullVar.Nigel = true;
Skull.Caption = “Nigel”;
} }
else if(Selected==2) //Pole {
if(SkullVar.Moved) {
Scout.Talk(“Why were you stuck on that pole?”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“I was placed there as a warning to intruders.”);
} else {
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.
sprite”);
Scout.Talk(“Why are you stuck on that pole?”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“I’ve been placed here as a warning to intruders.”);
}
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup. sprite”);
Scout.Talk(“Intruders?”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“People like yourself, who come here looking for the treas-ure hidden in Skull Rock.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“Oops! Forget I ever said that.”);
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.
sprite”);
Scout.Talk(“Not very good at your job are you?”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“You call this a job? It’s certainly not one I would have chosen myself, if I’d had any say in the matter.”);
APPENDICES
160
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“It’s not as if I can just walk away and get another job.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“When a skull doesn’t even have the rest of his skeleton with him, career options are severely limited.”);
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“Talk a lot, don’t you?”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“It’s the sheer and utter boredom – I haven’t had a decent conversation in forty three years.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“Listen, you won’t tell anyone that I mentioned the treasure, will you?”);
SkullVar.Pole = true;
}
else if(Selected==3) //Skull Rock {
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“What can you tell me about Skull Rock?”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“Not very much, I’m afraid. I’ve never even seen it.”);
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“Why, because you don’t have any eyes?”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“No, I can see you just fine.”);
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“Weird, that...”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“Ever since I was placed here I’ve been facing in the same direction.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“And the local monkeys are really awful – telling me how beautiful the view is and how wonderful the sun looks as it sets over the sea.”);
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“Now, don’t get upset.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
SAMPLE SCRIPT 161
Skull.Talk(“I’d weep if I had any tear ducts...”);
SkullVar.SkullRock = true;
// go to the second branch of dialogue //SkullTalk2();
}
else if(Selected==10) //Exit {
if(!SkullVar.Moved) Scout.ForceTalkAnim(“actors\scout\rr\talkup.sprite”);
Scout.Talk(“I’ll be seeing you.”);
Skull.ForceTalkAnim(“sprites\Skull\talk.sprite”);
Skull.Talk(“Okay, bye. Don’t forget to come back soon.”);
Loop = false; // we want to end the dialogue }
} }
APPENDICES
162