intfiction.org

The Interactive Fiction Community Forum
It is currently Sun May 19, 2013 8:11 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Taking things from NPCs
PostPosted: Mon Dec 27, 2010 4:23 pm 
Offline

Joined: Mon Dec 27, 2010 4:17 pm
Posts: 2
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).


Top
 Profile Send private message  
 
PostPosted: Mon Dec 27, 2010 8:13 pm 
Offline
User avatar

Joined: Sat Dec 22, 2007 6:00 pm
Posts: 355
Location: Western Australia
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;
    }
;


Allowing the player to steal anything from an NPC is also simple. Override "checkTakeFromInventory", but leave it blank, like so:
Code:
    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;
        }
    }

_________________
Emily Boegheim


Top
 Profile Send private message  
 
PostPosted: Mon Dec 27, 2010 10:27 pm 
Offline

Joined: Mon Dec 27, 2010 4:17 pm
Posts: 2
Thank you so much for such a helpful response! That was perfect!


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group