How do I Get my NPC to Accept Certain Objects?

I’m designing a game. It’s my first time, and I’m not very well-educated on inform 7. I have an NPC who I want to accept an object. I’ve hit a road block here. No matter what I type, my NPC is still uninterested in things offered to her. Does anyone know how to fix this?

(I’m writing my game on Playfic.)

2 Likes

By default inform blocks the pc giving an object to an npc. If you want to get rid of this rule, include this line:

The block giving rule is not listed in the check giving it to rules.

If this is all you do, it will mean that the player can give anything to an npc, who will take it, and then never give it back, so it will probably require a little more coding to get the exact results you want! You can read more in the Inform recipe book, 7.4.

3 Likes

The way to determine this is by testing the game in the IDE - type ACTIONS. Then the game will spell out what is being tried, whether it succeeded or not, and if it failed what rule interrupted so you know the name of the rule you have to alter - per Caleb’s suggestion above.

I think you could also selectively block the rule using something like

The block giving rule does nothing when the noun is the friendship bread and the person asked is the Baker.

That way you don’t have to account for the player handing multiple things to multiple characters if you’d rather not. The only thing you’d want to ensure is that the standard block-refusal message doesn’t inadvertently dissuade the player from trying the action you want with the correct NPC if they try giving the item to other people and see the default message - usually a hint that they can’t do that anywhere in the game.

3 Likes

I usually use the method Hanon described, but just to round out the possible ways to override the standard rule, another method is to substitute a new check rule – this also allows you to print a custom refusal message easily:

To sniff is a verb.
This is the baking friendship rule:
	if the noun is the friendship bread, continue the action;
	say "[The second noun] [sniffs] in disdain, 'What would I do with that?'" instead.
The baking friendship rule substitutes for the block giving rule when the second noun is the Baker.

You can also combine both techniques:

To sniff is a verb.
This is the baking friendship rule:
	say "[The second noun] [sniffs] in disdain, 'What would I do with that?'" instead.
The baking friendship rule substitutes for the block giving rule when the second noun is the Baker.
The baking friendship rule does nothing if the noun is the friendship bread.
1 Like

Thank you!!!