Give item to player after certain topic is discussed

Following on from my conversation I posted about previously, I thought I would implement a similar topic/response structure to another NPC. This time, the NPC is holding a key, and only after a certain topic has been discussed does the NPC give the player the key. Just to complicate things, I only want to give the player the key on certain subjects, but have the ability to discuss additional subjects.

I started with something like this:

The Manager is a man in the clubhouse. The manager carries a key.

Table of The Manager's Conversations
topic	response
"key" or "the key"	"'Here is the key'"
"boat" or "the boat"	"'Here is the key."

Instead of asking the Manager about something when the Manager is carrying the key:
	if the topic understood is a topic listed in the Table of Manager's Conversations:
		move the key to the player;
		say "[response entry][paragraph break]";		
	otherwise:
		say "Dunno mate";
		
Understand "talk to [someone] about [text]" as asking it about.

I also tried:

Instead of asking the manager about something:
	if the topic understood is a topic listed in the Table of The Manager's Conversations:
		say "[response entry][paragraph break]";
		if the topic understood matches "key";
		move the key to the player.
	otherwise:
		say "Dunno mate";

And I even tried to add an if statement to the response, something like:

"[if player does not have key]'Here is the key'"[move key to player][end if]

Any help gratefully received, thank you.

Don’t worry, I’m going with this and ignoring the irrelevant topics:

The Manager is a man in the clubhouse. The manager carries a key.
Understand "manager" as the manager.

Table of The Manager's Conversations
topic	response
"key" or "the key"	"'Here is the key'"
"boat" or "the boat"	"'Here is the key."

Instead of asking the manager about something:
	if the topic understood is a topic listed in the Table of The Manager's Conversations:
		say "[response entry][paragraph break]";
		move the key to the player;
	otherwise:
		say "Dunno mate";
		
Understand "talk to [someone] about [text]" as asking it about.

Since it’s a table, you can add extra columns:

Table of The Manager's Conversations
topic	response	item
"key" or "the key"	"'Here is the key.'"	key
"boat" or "the boat"	"'Here is the key.'"	key
"cheese"	"'I don't like cheese.'"	nothing

Instead of asking the Manager about a topic listed in the Table of the Manager's Conversations:
	say "[response entry][paragraph break]";
	if the item entry is not nothing:
		move the item entry to the player;
	
Instead of asking the Manager about something:
	say "'Dunno mate.'";

Of course in this example you can ask for the key multiple times. In a real game you’d want to check whether Manager still has it.

If you want various topics to cause different actions, it gets more complicated, but we can start with this.

4 Likes

Hi @zarf - I wasn’t aware you could give the item via the table. That’s a useful feature, thanks for pointing that out.