Preventing taking things from others


In Inform7, you by default can’t items worn by or held by other people off of them with a rejection message saying that the item belongs to the NPC. In Dialog by default neither the player nor the NPC has any problem with clothes and other items being taken away. This makes sense in some cases (taking someone’s coat to hang it up maybe?), but there are lots of situations where the player would know not to take the item or the NPC would object to the taking of the item.

Here is my first try at teaching the player some propriety:

(prevent [take $object])
    ($object is #wornby $someone)
    ~(current player $someone)
    (The $someone) is wearing (that $object) (name $object)!

(prevent [take $object])
    ($object is $heldby $someone)
    ~(current player $someone)
    (The $someone) is holding (that $object) (name $object)!

I’m not sure how to code exceptions to these rules though, for example taking someone’s coat.

1 Like

Another thing related to clothes and NPCs; while you can take clothes worn by someone, there is no opposite action for clothing someone. “Put clothes on NPC”, the natural choice, responds with “You can’t put things on the NPC”, I think because the NPC is not a supporter.

1 Like

I agree, that’s an oversight on my part. Will fix in the next library version.

To override something like your proposed rules, you could negate the prevent-rule in a specific case:

~(prevent [take *])
        (* is #wornby #client)

You’ll want to review the default library code to see if you’re unintentionally overriding some other check, but in this situation everything looks fine.

Another option is to rewrite the action into something else, and modify those action-handling rules in turn:

(instead of [take $Obj])
        ($Obj is #wornby $Wearer)
        (current player $Player)
        ~($Player = $Wearer)
        (try [tell $Wearer to give $Obj to $Player])

Oh, I like the redirection from taking to asking. Thank you!