<< Previous

Next >>

indy_logo.gif (3362 bytes)

Step 4 (bis): interpersonal skills

Using the previous model, conversations can be funny but not really interactive. One of the major features of Lucas' adventures was the ability to explore a set of answers when talking to other characters in the game.

tutorial_4b.gif (34083 bytes)

tutorial_4c.gif (7987 bytes)This is easy to achieve too.

Suppose you want a conversation plan like the one in the figure, with 2 stages and several choices at each stage, where a specific "good" choice leads to the following stage. This can be implemented as follows.


ROOM main
{
	IMAGE { "gr/street_2.gif" }
	WALK { "gr/street_2_bm.gif" }

	ITEM Indy
	{
		ANIMATION
		{
			// --- standby images ---
			0  0  "gr/indy_d.gif"  1 // Looking South
			0  1  "gr/indy_r.gif"  1 // Looking West
			0  2  "gr/indy_u.gif"  1 // Looking North
			0  3  "gr/indy_l.gif"  1 // Looking East
			// --- walking animation ---
			1  0  "gr/indy_wd.gif" 4 // Looking South
			1  1  "gr/indy_wr.gif" 6 // Looking West
			1  2  "gr/indy_wu.gif" 4 // Looking North
			1  3  "gr/indy_wl.gif" 6 // Looking East
			// --- talking animation ---
			2  0  "gr/indy_td.gif" 7 // Looking South
			2  1  "gr/indy_tr.gif" 4 // Looking West
			2  2  "gr/indy_tu.gif" 1 // Looking North
			2  3  "gr/indy_tl.gif" 4 // Looking East
		}
		POSITION { 140 140 0 }
	}

	ITEM sophia
	{
		ANIMATION
		{
			// --- standby images ---
			0  1  "gr/sophia_r.gif"  1 // Looking West
			0  3  "gr/sophia_l.gif"  1 // Looking East
			// --- walking animation ---
			1  1  "gr/sophia_r.gif"  1 // Looking West
			1  3  "gr/sophia_l.gif"  1 // Looking East
			// --- talking animation ---
			2  1  "gr/sophia_tr.gif" 4 // Looking West
			2  3  "gr/sophia_tl.gif" 4 // Looking East
		}
		INK { 3 }	// Sophia's speech will be pink  :)
		POSITION { 250 143 0 }
		ITEM medallion
		{
			ICON { "gr/medalion.gif" }
		}
		INTEGER
		{
			f	// Position within the conversation flow will be kept here.
			r	// User selection will be kept here.
			q	// Exit flag.
		}
		COMMAND talk sophia
		{
			MOVE indy 210 142 0	// Move to her left.
			WAIT indy
			TURN indy sophia	// Look at her.
			TURN sophia indy	// Look at him.

			/* Stage #1 within the conversation */
			WHILE { EQ f 0 }
			{
				CLRANSWER			// Clear the conversation panel.
				ADDANSWER "Sophia!"	 1	// Add this to the panel, with ID=1
				ADDANSWER "Who are you?" 2	// Add this to the panel, with ID=2
				WAITANSWER r			// Wait for user selection and put result in variable "r"

				IF { EQ r 1 }
				{
					// User chose answer with ID = 1
					WAITSAY indy "Sophia! \n I missed you so much since Atlantis!"
					WAITSAY sophia "You? \n But you almost let me die there!"
					ADD f 1		// Move onto the next stage of the conversation.
				}
				IF { EQ r 2 }
				{
					// User chose answer with ID = 2
					WAITSAY indy "Who are you?"
					WAITSAY sophia "Doctor Jones! \n I can't believe you don't remember me!"
					// This acts as a fake branch (leads the player to nowhere)
				}
			}

			/* Stage #2 within the conversation */
			LET q 0		// Clear the exit flag.
			WHILE { EQ f 1  AND  EQ q 0 }
			{
				CLRANSWER			// Clear the conversation panel.
				ADDANSWER "I need you"	1	// Add this to panel, with ID=1
				ADDANSWER "Bye for now" 2	// Add this to panel, with ID=2
				WAITANSWER r			// Wait for user and put result in "r"

				IF { EQ r 1 }
				{
					// User chose answer with ID = 1
					WAITSAY indy "I need you. Give me another chance."
					WAITSAY sophia "Mmmmm... \n Take this, it might help you."
					GIVE indy medallion	// Bingo!
					SOUND "snd/medal.au"
					ADD f 1		// The conversation is over.
				}
				IF { EQ r 2 }
				{
					// User chose answer with ID = 2
					WAITSAY indy "Bye for now"
					LET q 1		// Signal to exit this conversation
				}
			}
		}
	}
}

COMMAND look *
{
	SAY indy "Nothing special"
}
COMMAND * *
{
	SAY indy "I can't do that"
}
COMMAND * * *
{
	SAY indy "I can't do this"
}

Using an intenal scheme similar to the previous one, this example sets up a real conversation where the player can select an answer from a set of possible answers.

Only 3 instructions are needed to manage the conversation panel. First, the panel has to be cleared with CLRANSWER. Then, each possible answer is added to the panel using ADDANSWER with a custom ID integer value to recognize it later. Finally, the player selection is fetch with WAITANSWER and placed in an integer variable.

At each stage of the conversation, there's one "correct" choice that will allow to go on to the next stage. Also, in stage #2 the player has the option to leave, and come back later to finish the conversation.
The tree of questions&answers can be as sophisticated as needed. The complexity of the conversation comes from the program flow, and a smart use of integer variables.

To make the script shorter, the WAITSAY instruction was used to replace the SAY+WAIT sequence of the previous listing. Also, notice that the newline character "\n" is recognised by the SAY and WAITSAY instructions to avoid writing several WAITSAY lines one after another.

<< Previous

Next >>

Back to the main page

1