Taking things from NPCs

Greetings all!

I’m a fledgling programmer with a novice question:

When I try to take things from the NPC, I get the message “The NPC won’t let you have that.”

How do I change this message? I’d like to at least customize it to say something like: The NPC scowls at you. “Stop trying to steal my stuff!”

Also, how would one change the code so that things can be freely taken from an NPC (say, if I were a pickpocket).

Whether or not you can take something from an NPC is controlled by the NPC’s “checkTakeFromInventory” method. It behaves pretty much like an ordinary check method. If you want to stop the player from taking something from the NPC, print a failure message and then stop the action with “exit”. Otherwise, just ignore the action.

Changing the failure message is simple. Just print your failure message and then use the “exit” command to stop the action, like so:

[code]+ bob: Person
‘Bob’
‘Bob’
"Bob looks around suspiciously. "
// etc.

checkTakeFromInventory (actor, obj)
{
    "Bob scowls at you. <q>Stop trying to steal my stuff!</q> ";
    exit;
}

;[/code]

Allowing the player to steal anything from an NPC is also simple. Override “checkTakeFromInventory”, but leave it blank, like so:

    checkTakeFromInventory (actor, obj) { }

If you want to allow some things to be stolen, but not others, just block the ones you don’t want stolen. For instance:

[code] checkTakeFromInventory (actor, obj)
{
if (obj == pants)
{
"You can hardly steal Bob’s pants while he’s wearing them. ";
exit;
}

    if (!actor.canPickPockets) {
        "Bob scowls at you. <q>Stop trying to steal my stuff!</q> ";
        exit;
    }
}

[/code]

Thank you so much for such a helpful response! That was perfect!