Seanachai Quote

"Do you really think there are no larger answers to the small ones we can supply? Miguel, we know there are answers for everything. Unfortunately, we know very few of them." (Alexis Paninian to Mitchell Campion following a 4 minute teleportation from Paxton, Ohio to 3XNorth, 3YEast and 150Z off the Coast of Spain, circa 5/28 & 3 weeks, OSB airdate 4/7/1959).

Friday, July 5, 2013

Sorting out the Process for the Non-Scripter - Adapting a Script - Your own NPC

Sorting out the Process for the Non-Scripter  - Adapting a Script  - Your own NPC

 Supplies for this Tutorial are at : The OHN NPC tool kit is available to copy @no cost in the
Princess Pea is there every time I show up.
Kitely, Graham Mills "Stuff" world to pick up.  It is a big yellow box, The pathmaker and the spawn script is listed here.

Introduction Comment  
I will continue to work on ways to improve my non-player character's usefulness, because its so important to storytelling and most certainly lots of fun.  I need to admit upfront, I've already spent some time on this project instead of completing my builds. Now I can get back to building.

What I've come up with is too limited for some, but its a start.  And keeping in mind how confused I grew, and how hard it was to find good tutorials, I am going to try to make mine a step by step approach with scripts attached.  For those of you who are already using NPCs, this tutorial may not be what you are looking to find.  If you've only got started with them, as I have, this tutorial could help you to see something missing in your process or mine that you can revise.   Revision, particularly in the open source/sim metaverse is a magical mess. My admission is that I'm a full permission accommodater, but I always fully credit the script or snippet together original or nearly authors.

What is a NPC?  A NPC is a non player character, sometimes called a bot.  NPCs are storybuilding devices, because they help to caption a 3D world illustration in an unique way.  Storybuilding uses for NPCs do not require 2 way conversations between the avatar and the NPC.  Storybuilding NPCs are characters who give out important information to avatars or in world characters being puppeteer-ed by humans.  NPCs add to immersion, a foremost objective of the storybuilder.


STEP 1.  Dress up in the garment or costume that you want your NPC to look like. Your new NPC box will make an exact duplicate of your avatar, including whatever is attached to you. 
  • Your NPC will not be an object that you can script.  Your NPC will listen to its origin script and notecards that you move into a box from your inventory.
  • Your NPC can be bumped about (see comment below about a security bounding box).

STEP 2. Select the build tool and create a basic box.  I like to colorize my box.  It is easier to differentiate from other boxes I may make, including sit objects.

The green NPC Maker Box and the Red Kill NPC Box

Open the Contents Tab and add the following scripts to the box.

Script: NPC OHN -This script is used to create the NPC and force it to do what you want it to do.  Photos of how this works will be shown following this list of contents.

When you first unpack (open) the OHN yellow box, you will see 2 objects to copy to inventory and an instructions notecard. You can rezz the Kill NPC box and use as is.  The scripts to make your own NPC are in the moving man.  Rezz him and copy the scripts to him into your inventory. Because the moving man's moving routine is wide you may see him leave you.  After you watch him, you can delete him.  You've saved him to inventory to bring him out again later if desired.  If you choose not to delete him (npc OHN), your clone will be accompanied by the moving man when you create your clone.  This is a nice surprise if you want to create a couple that works in tandem.  It is likely I will experiment with this process at another time  - interactive wedding cake topper maybe?  hmmmmm.
Dysfunctional family photo.
Oooooeee for a  theatrical producer?

When you put your NPC OHN script into the box with the notecard explained below, the hover text will tell you to that you need to change the actionCard notecard, before it will work properly.  This is due to the fact that the moving man's path needs to be changed to fit your world's coordinate position.  If you didn't your NPC would be created in parts unknown.  The hover text instructions use the word vector.  Vector for this purpose means the places (points) where the NPC will first be created and positions (coordinates) where the NPC will move.  You only need to do the first position change to cause the script to create the NPC.  This is easy, because its where you dropped the box.  Get the box position and you are ready to edit the actionCard.

Edit the script to your NPC name
string appearanceCard = appearance 
don't change appearance until
you've cloned yourself in the costume you choose
The only scripting you need to change to the script is the name of your NPC.  Do not change what appearance to load until you've created your NPC that looks like you. After you edit your actionCard to change the position of where your NPC is first created, you can make your clone.  

Notecards to Include and/or revise: 
Notecard 1: actionCard - is the path that the NPC will follow.  If you don't want to manually determine enter these coordinates, you can use an additional tool that follows these Process instructions.  I call the tool the NPC Pathmaker.

What goes in the NPC Maker Script
Notecard 2: NPC Objects2Rez - will rez the objects that you need to rezz for your NPC to use..  The objects that rez are small boxes that you will include in the contents.  The 3 boxes are size 2x, 2y, 2z. Color code them red. You will need to revise the positions you list for your objects to align with the path you choose for the ActionCard. 

Notecard 3: NPC Objects2Rez - will rezz the positions for the objects (by UUID).  You do not need to adapt this notecard.  The notecard will rezz the objects rezzed in the positions revised by you in the Objects2Rez card.

Notecard 3: npc_appearance  -  you will rename this card to whatever you name your NPC.  This renaming will ensure that your box does not create a differently costumed NPC from the one you created originally.  Obviously you will want to use the card long enough to know whether you've properly costumed (including attachments) your NPC.  If you want to add an attachment (magic wand for example) to your NPC you should add that attachment to your own avatar costume, before you create the NPC you expect to use.

Note: I named my new appearance notecard Pea.  It is a final decision and I did not want a new avatar with the outfit I wore after I created Pea with the npc OHH script (in the box that is now a NPC Maker Tool).

Now you have a NPC, but it doesn't say anything that related to your world or story.  So you can change what the NPC says by pasting over actionCard "talk" Or you can add in "talk".

See photo.

Changes I need to make so my NPC would fulfill her acting role



STEP 3.  If you accidentally spawn (create) more than one NPC, no worries.  I created a NPC Kill Box.   The Kill Box uses step STEP 3.  I color coded this box brown.    Later I made the box nearly transparent for future use.  The box is good to keep around in case there is glitch (a good name for an NPC = Glitch).  A kill script tool box is included with the OHN kit too.  It is already scripted and ready to use.

STEP 4.  The NPC Kill Box deletes all NPCs by touch.  You can always touch your NPC creation box to create a NPC copy after you delete all NPCs.  Be patient, and wait for a second to do this.

STEP 5. optional - add an animation that you like and name it walk, or add an animation you choose and name it whatever.  I wanted my Princess Pea to waltz a wee bit with herself.  I simply changed the name of the animation to prissy  I then went into the actionCard and changed the float animation I wasn't going to use to prissy, so that my princess could be prissy.  I left the float animation in the box, but it did not cause a problem.  I may need my NPC/actor to swim through a flood at some point.  Who knows? 

STEP 6. Now for the security part.  To keep your NPC from being pushed about (even over a cliff), you can keep her/him away from visitors by using a bounding box.  For the most part my worlds are no fly game regions (a few parcels are fly).  I only need to make a transparent hollow rectangle making it easier to get to my original NPC box.  For fly regions, it is best to build a box that completely covers the NPC (large enough to afford the walk you lay out).  Avatars will see everything they need to say, but your NPC will be spared by a force field of sorts. 

STEP 7 - Test the Mess.  This is the scary part.  When you come back into a closed region (Kitely on Demand) you should see your NPC doing whatever you decided it to do in the clothing you originally costumed yourself in prior to creating the NPC.

Optional STEP 8 - Pathmaker.  Use this tool to step off the path.  Create a 1x, 1y, 1z box.  Add the the Pathmaker script to the box.  It is now a tool.  Take the pathmaker tool. into inventory.  Then choose click it and use it as a HUD.  Follow the directions quoted Directly from Furious Typer 

Drop this script in a prim, wear it on your HUD. Start walking! Just click it every time you want your NPC to move to that spot. So click at point A go a ways, click point B, then C, etc. Then it will path along those points.

Currently this is written so you can keep on clicking then type in '/12 anything' and it will create the notecard 'Path1'. Just copy that into inventory and go on to the next step.

Pictures are wonderful for illustrating how a problem is resolved through the use of tools.  Ruby quotes Alice (Lewis Carroll) wherever she goes or teaches.  Since 3D worlds are proof in the pudding, I hope that the photos included with this tutorial make it easier to see how the scripts and notecards explained are useful. 

Credits to all those individuals, particulary OHN and  who created the carefully planned scripts for this short tutorial.  It is my sincere plea that someone will come along and share some more about NPCs.  Kitely is the perfect place to use them (sans the loading issue).  I suppose an always on world would be more efficient, but that will come with time, providing there is more reason to warrant the costs.   Thanks to Linda Kelly for offering up the lovely costume.  It says good-nature humor all over it.

No comments:

Post a Comment