| 7.14. Obedient Characters |
Other characters can perform all the same activities that the player can; this does not always mean that they're willing to obey the player's instructions. By default, characters will refuse to obey commands of the form JULIA, WEST or ANTONY, TAKE THE PINCUSHION. Their objections can be overridden, however, and The Hypnotist of Blois implements a hypnotist who can make characters obedient at will.
In For Demonstration Purposes, the character is only capable of a few actions at the outset, but can be taught new ones if the player performs them first.
Often we want characters' obedience to be more selective. Just as the viewpoint character may be characterized in terms of what he will and will not do, so may others: Generation X demonstrates a character who will do what she's told, but who will comment unfavorably when the player asks for a nonsensical or repeated action, and who may eventually get fed up and leave.
Characters can be given moral objections to certain commands, as well: Virtue defines a few kinds of actions as bad, so that the character commanded will refuse to perform them.
Under Contract, more subtly, has the character object if the player's commands implicitly require any behavior he considers inappropriate: for instance, if the player commands him to put his pants in a container, he will work out that this requires the removal of the pants as a preliminary. If we want to implement a similar character, we may want to simply copy his unsuccessful attempt rule and the table of his retorts, then replace his banter with lines of our choosing.
The little example Latin Lessons allows us to make characters clever about vague commands: we can, for instance, write rules so that CLARK, EAT will have Clark sensibly pick something edible, rather than having the parser ask what we want Clark to eat.
Finally, Northstar demonstrates how we might make Inform understand commands of the form ASK JOSH TO TAKE INVENTORY or ORDER JOAN TO WEAR THE ARMOR.
See Characters Following a Script for a programmable robot who can be given whole sequences of actions to perform
Suppose we want to have a character who can dynamically learn new actions by observing the player performing them. We could do this by adding the actions to a list of things the character can do, but using a relation to express the same idea allows for tidier, easier-to-read code.
Thanks to Jesse McGrew for the initial design of this example.
"For Demonstration Purposes"
Section 1 - Procedure
Capability relates various people to various stored actions. The verb to be capable of implies the capability relation.
Persuasion rule:
let CA be the current action with no specific actor;
if the person asked is capable of CA:
persuasion succeeds;
otherwise:
say "[The person asked] look[s] confused. Maybe a demonstration would help.";
persuasion fails.
The action requester is an object that varies. The action requester variable translates into I6 as "act_requester".
To decide which stored action is the current action with no specific actor:
let old actor be the person asked;
let old requester be the action requester;
now the person asked is the player;
now the action requester is nothing;
let CA be the current action;
now the person asked is the old actor;
now the action requester is the old requester;
decide on CA.
The learning by observation rule is listed after the report stage rule in the specific action-processing rules.
Include Plurality by Emily Short.
Definition: a person is other if he is not the player.
This is the learning by observation rule:
repeat with the viewer running through other people who can see the player:
if the player is the actor and viewer is not capable of the current action:
say "[The viewer] watches your behavior with interest. Seems like [it-they] [is-are] learning.";
now the viewer is capable of the current action.
Section 2 - Scenario
The Daily Planet is a room. Clark is here. He is a man.
When play begins:
now Clark is capable of the action of taking inventory.
Test me with "Clark, inventory / Clark, x me / x me / Clark, x me".
|
|  Example Generation X A person who goes along with the player's instructions, but reluctantly, and will get annoyed after too many repetitions of the same kind of unsuccessful command. | |
| Example Virtue Defining certain kinds of behavior as inappropriate, so that other characters will refuse indignantly to do any such thing. | |
|  Example Northstar Making Inform understand ASK JOSH TO TAKE INVENTORY as JOSH, TAKE INVENTORY. This requires us to use a regular expression on the player's command, replacing some of the content. | |