Moria's NPC Object

What's this?

I have found it useful to have a physical object on PernWorld that I can store basic information about the NPCs I regularly use. First, it gives me a puppet for using said NPC when my character is elsewhere. Second, I have coded my object to let me change NPC info in a quick and easy manner. So, here's that code. Everyone is free to use it. There are both step-by-step instructions on how to format the object, and a copy & paste general outline for the object if you want to just make it and play with it later.

All commands that players can use on the NPC object are prefaced with cmd in the attribute name. This makes it easier to keep track of what actual commands are when reviewing the object.

Be aware that several sections of code have content that you will have to change before applying the code to your object. These are marked with a double asterisk on both sides of what needs to be replaced. Usually, this will be a DBref# or a name. I.E. **DBref#**.


Step by Step Instructions

1) Create your NPC object and set the flags on the object.

@create NPC=10
@set npc=!halt
@set npc=commands
@set npc=puppet
@set npc=safe
@set npc=monitor

Safe reduces the risks of accidentally destroying the object.
Commands allows the object to respond to commands.
Puppet allows the object to listen and relay what it hears back to you
Monitor allows the object to make changes in itself based on the commands you provide it.

2) Program the help command.

&CMD_HELP npc=$+npchelp:@pemit %#=%rThe following commands may be used on the NPC object:%r+npclist +npcinfo <npcname> +change <npcname>%r+change can only be used by the object owner. The other commands may be used by any player.%r%rTo add an NPC to this object, set the following attributes, using the name of the NPC in the place of <name> in the attribute name:%rdesc_<name> should hold the desc of the NPC.%r I.E. &desc_npc npc=This is an NPC object!%rinfo_<name> should hold the personality and background info for the NPC.%r I.E. &info_npc npc=This is the generic profile for this object!%rhome_<name> should hold the DBref# for the home of the NPC in question, so you can teleport them 'home'.%r I.E. &home_npc npc=#1 (if Mother_Pern owned the object).%r%rAny time an NPC is added, the NPClist attribute should be updated to include all NPC names so the +npclist command remains accurate.%r

This brief help file serves as a reminder for the owner as to what attributes they need to set, and an explanation of function for other players.

3) Set the @desc. You will need to be sure you have the DBref# of the object when you enter this.

@Desc npc=[u(**DBref#**/call_desc)]%rOOC: I'm a mutable NPC puppet owned by **Your Name**. To see a list of NPCs loaded on this puppet, please type '+npclist'. For more information on any of these NPCs, please type '+npcinfo <name>'. Please send **Your Name** an @mail if there are any problems with this puppet.

What this does is allows you to change the part of the desc that shows the individual NPC's desc each time you use the +change command (we'll get there in a minute) while still leaving a very clear note that this is both a puppet and an NPC object, and who the owner is.

4) Set up the +change command.

&CMD_CHANGE npc=$+change *:@name me=%0;&call_desc me=[u(**DBref#**/desc_%0)];@link me=[u(**DBref#**/home_%0)]

You use this command by typing +change <npcname> without the brackets. Right now, it doesn't do anything, because we haven't programmed the attributes this would reference. So please please please don't use it yet. You'll bork the code. >.>

5) Program the default NPC attributes: DESC_NPC, INFO_NPC and HOME_NPC.

&DESC_NPC npc=There's nothing to see here, move along...
&HOME_NPC npc=**Your DBref#!**
&INFO_NPC npc=Personality: I'm an NPC object designed by Moria!  Isn't it sweet of her to share code like this? ;)

Don't do anything else yet, we'll play with this shortly, promise!

6) Program another NPC into the object (you can either create your own, or use this test content).

&DESC_TEST npc=Testing, Testing, 1-2-3!
&HOME_TEST npc=**Your DBref#**
&INFO_TEST npc=Personality: Test details for a test NPC!

If you choose to program an actual NPC, replace **Your DBref#** with the dbref# of whatever home location you want. If you still want the NPC to link to you, use your DBref#. :)

7) Create the NPClist and NPCinfo commands and set the NPC list.

&CMD_NPCINFO npc=$+npcinfo *:@pemit %N=The following info is stored about %0:%rDesc: [u(**DBref#**/desc_%0)]%r[u(**DBref#**/info_%0)]
&CMD_NPCLIST npc=$+npclist:@pemit %N=The following NPCs are on file:%r[u(**DBref#**/npclist)]
&NPCLIST npc=NPC Test

8) Now, test it! If you used real NPC info instead of Test, you will get your real NPC info instead of Test. :)
+npclist should get this answer:

The following NPCs are on file:
NPC Test

+npcinfo NPC should get this answer:
The following info is stored about NPC:
Desc: There's nothing to see here, move along...
Personality: I'm an NPC object designed by Moria!  Isn't it sweet of her to share code like this? ;)

And the all important +change Test should result in the following when you look at the object:

Test(#**DBref**Mps$)
Testing, Testing, 1-2-3!
OOC: I'm a mutable NPC puppet owned by **Your Name**. To see a list of NPCs loaded on this puppet, please type '+npclist'. For more information on any of these NPCs, please type '+npcinfo <name>'. Please send **Your Name** an @mail if there are any problems with this puppet.

And if you +change NPC

npc(#**Dbref**Mps$)
There's nothing to see here, move along...
OOC: I'm a mutable NPC puppet owned by **Your Name**. To see a list of NPCs loaded on this puppet, please type '+npclist'. For more information on any of these NPCs, please type '+npcinfo <name>'. Please send **Your Name** an @mail if there are any problems with this puppet.

I think that's it. To add NPCs to the object, just set a &desc_<name>, &info_<name> and &home_<name>. There is no known limit to the number of NPCs the object can hold, but I would recommend not going crazy with it. :)

If you have any questions, feel free to contact me (Moria) in game, or send me an email at moc.liamg|dlrownrep.anairom#moc.liamg|dlrownrep.anairom.

Have fun!


Mass code!

Warning: you will have to edit some lines of text in order to have a working model. Anything with double asterisks around it (**Your Name** for example) must be updated before use to avoid it totally not working.

@create NPC=10
@set npc=!halt
@set npc=commands
@set npc=puppet
@set npc=safe
@set npc=monitor
&CMD_HELP npc=$+npchelp:@pemit %#=%rThe following commands may be used on the NPC object:%r+npclist +npcinfo <npcname> +change <npcname>%r+change can only be used by the object owner. The other commands may be used by any player.%r%rTo add an NPC to this object, set the following attributes, using the name of the NPC in the place of <name> in the attribute name:%rdesc_<name> should hold the desc of the NPC.%r I.E. &desc_npc npc=This is an NPC object!%rinfo_<name> should hold the personality and background info for the NPC.%r I.E. &info_npc npc=This is the generic profile for this object!%rhome_<name> should hold the DBref# for the home of the NPC in question, so you can teleport them 'home'.%r I.E. &home_npc npc=#1 (if Mother_Pern owned the object).%r%rAny time an NPC is added, the NPClist attribute should be updated to include all NPC names so the +npclist command remains accurate.%r
@Desc npc=[u(**DBref#**/call_desc)]%rOOC: I'm a mutable NPC puppet owned by Bilana. To see a list of NPCs loaded on this puppet, please type '+npclist'. For more information on any of these NPCs, please type '+npcinfo <name>'. Please send Bilana an @mail if there are any problems with this puppet.
&CMD_CHANGE npc=$+change *:@name me=%0;&call_desc me=[u(**DBref#**/desc_%0)];@link me=[u(**Dbref#**/home_%0)]
&DESC_NPC npc=There's nothing to see here, move along...
&HOME_NPC npc=#10656
&INFO_NPC npc=Personality: I'm an NPC object designed by Moria!  Isn't it sweet of her to share code like this? ;)
&DESC_TEST npc=Testing, Testing, 1-2-3!
&HOME_TEST npc=#10656
&INFO_TEST npc=Personality: Test details for a test NPC!
&CMD_NPCINFO npc=$+npcinfo *:@pemit %N=The following info is stored about %0:%rDesc: [u(**DBref#**/desc_%0)]%r[u(**DBref#**/info_%0)]
&CMD_NPCLIST npc=$+npclist:@pemit %N=The following NPCs are on file:%r[u(**DBref#**/npclist)]
&NPCLIST npc=NPC Test

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License