Trapping words to NPCs

Hello everyone!

As the year begins anew, so too does my ever-optimistic attempt at coding I7. I seem to have a knack for disregarding basic solutions and problems and heading unerringly for the most complex and arcane stuff. This, I fear, is no different.

I was playing around with a scene in which an NPC would react to orders, but would be insulted if you used a particular name or title for the character. I want to create an extra step within the Understand process that not only translates but flags; in effect, almost another pronoun which carries a connotation of its own (addressing your boss as “shithead” as opposed to “milord”, for instance).

Basically, the issue is to make a variant of the Cave Troll example, in which an error-producing command is halted, analyzed, and then regexped into a new command, which finally is fed back into the parser. Cave Troll or simpler variants suffice to trap all of this kind of parser errors. Unfortunately, there seems to be a host of errors that are not amenable to such solution, and which do in fact finish executing before the rules are even called.

For instance, take this code:

The Lounge is a room. The Study is north of the Lounge.

John Armitage Wakinshaw IIIrd is a man in the Lounge.
A persuasion rule for asking someone to try doing something: persuasion succeeds.

Test me with "actions / Jack, go north / John, go north"

As I understand it, the reason this occurs before we can affect it is because the library file Language.i6t performs its magic before the parser proper, and (for some reason I can’t fathom) isolates these operations within a place where I7 can’t easily reach.

I know that, if need be, we can do an “every turn” sort of chunking effect which would match every command beginning with "[certain words], ". It feel like more than a little overkill to do it for every single command, however, especially since I don’t want it to trigger if we actually do have a character named “Madame” or “Mylady.”

I’ve poked around rec.arts.int-fiction in search of an answer, but there’s not much there. All I found was the Cherubim example, which doesn’t seem to work as advertised. Any takers?

I think it’s easier if you have the insulting names parse as usual and then just check if the player has used those words.

[code]The Lounge is a room. The Study is north of the Lounge.

John Armitage Wakinshaw III is a man in the Lounge.
Understand “wankingshaft” as John Armitage Wakingshaw III.

Insulting command is a truth state that varies.

Before reading a command:
change insulting command to false.

A persuasion rule:
if the player’s command includes “wankingshaft”:
change insulting command to true;
persuasion succeeds.

Before John Armitage trying doing something when the insulting command is true:
say “‘It’s Wakingshaw! Wakingshaw!’ he cries.”;
[stop the action. <-- if you don’t want the NPC to try the action when insulted]

Test me with “wankingshaft, look / John, go north”[/code]

Nitku gave a good answer that works well. I know you’re always wanting to generalize, however, so I played around with your question for a few minutes and came up with this:

:smiling_imp: Warning: Juvenile Antics Ahead

[code]The testarea is a room.
The western testarea is west of the testarea.

A man called John Battista is in the testarea. Understand “buttfeasta” or “john buttfeasta” as john. The description of john is “It’s John Battista. He’s kind of a jerk, and people often remind him of this by calling him ‘John Buttfeasta.’”.

A person has some text called hated-nickname. The hated-nickname of john is “buttfeasta”.

Persuasion rule for asking someone to try doing anything:
if the player’s command matches the text “[hated-nickname of the person asked]”:
say “[The person asked] glares at you.”;
persuasion fails;
otherwise:
persuasion succeeds.

Test me with “x john / battista, w / w / buttfeasta, e”.[/code]
In the above case, an insulted person has a very short memory and doesn’t stay angry. If you want them to continue being angry after you insult them, something like this would be in order:

[code]The testarea is a room.
The western testarea is west of the testarea.

A man called John Battista is in the testarea. Understand “buttfeasta” or “john buttfeasta” as john. The description of john is “It’s John Battista. He’s kind of a jerk, and people often remind him of this by calling him ‘John Buttfeasta.’”.

A person has some text called hated-nickname. The hated-nickname of john is “buttfeasta”.

A person can be upset. A person is usually not upset.

Apologizing is an action applying to one visible thing. Understand “apologize to [something]” as apologizing.

Check apologizing:
unless the noun is a person:
say “Do sunsets make you cry, too?” instead;
otherwise:
if the noun is the player:
say “You have issues.” instead;
unless the noun is upset:
say “‘You don’t have anything to apologize for, [italic type]do you[roman type]?’ says [the noun].” instead.

Carry out apologizing:
now the noun is not upset.

Report apologizing:
if the player’s command matches the text “[hated-nickname of the noun]”:
say “You bite your tongue and politely say ‘[noun], I apologize.’”;
say “‘I accept your apology,’ says [the noun].”.

Persuasion rule for asking someone to try doing anything:
if the person asked is upset:
say “‘Get away from me, you vermin,’ scowls [the person asked].”;
persuasion fails;
otherwise if the player’s command matches the text “[hated-nickname of the person asked]”:
say “[The person asked] glares at you.”;
now the person asked is upset;
persuasion fails;
otherwise:
persuasion succeeds.

test me with “john, w / w / buttfeasta, e / g / apologize to buttfeasta / battista, e”
[/code]