Thursday, November 13, 2014

Easy NPC and DeMythifying the NPC Bug

NPCs are a powerful way to grab the attention of visitors to your sims and an excellent tool for engaging and guiding them through a region. At Nara's Nook we use them to greet, to entertain, and to introduce visitors to our novels. They can be so lifelike and enchanting that you might think they are powerfully complicated to create. When I first started creating them, that was true.

But as I demonstrated at the OSCC conference, and in this tiny video clip, it's now possible to create an NPC with a mouse-click and position it in less than a minute. Simply dress in the way you want the NPC to look and click the ball.  The Script will copy your appearance and rez an NPC that looks like you. You can drag the ball around to position the character as you'd like. Click the ball to derezz or rez the character. 

Right click the ball and you see this demo version contains three things: script, appearance card (titled "My Dancer") and an animation. You can add animations to this and when the character rezzes it will cycle through the animation in the contents. You can delete the animation provided in the ball but it must contain at least one animation to work.

This is character creation at its simplest. It's easy enough for the newest of our newbies to do. It requires no knowledge of scripting or animating. It uses little in the way of system resources. 

This worked beautifully for us until, around the end of September, a change in an Opensim update caused trouble. We call it the NPC bug. I want to emphasize, this bug is not isolated to this script. We have duplicated it in every NPC generation method we use. Fred Beckhusen, who generates more NPCs than I do, discovered the bug first in his regions and he does not use the same scripts we use at Nook grid. So lets bury the myth here that any particular generation script is the source of the NPC bug.

1. What is the NPC bug?

It is a change in the newest development releases of OpenSimulator that will cause all scripts running in a region to die when an NPC wearing scripts is deleted. It does not happen every single time but happens enough that it is a headache.

2. What versions of OpenSim is this a problem for?

I first ran into after some patches were uploaded for 8.0.1 around end of September. If your version is prior to that, you should not see this bug.

3. Is there a way to avoid triggering the NPC bug?

Yes. We had some 34 NPC characters in our build for the OpenSim conference--all generated by a variety of means and some requiring scripts to fulfill their purpose. After the bug appeared we had to go back and remake every NPC to insure they did not trigger the bug and crash us at the conference. Read on and I will walk you through the kinds of NPC and how to avoid the bug with each.

If  it is a simple NPC created with a  poseball as I demonstrate in the video, follow this procedure before clicking the poseball to save your appearance.

1. Detach any HUD or AO you have on your viewer interface--recording appearance with those on will result in an NPC that triggers the bug.

2. Remove any facelight, club lights, etc. Lights are the biggest source of NPC crash.

3. It's easy to forget that many attachments might have hidden scripts. Jewelry, shoes, hair should be script free. Inspect all attachments for scripts.

4. When you are script free, it is safe to click your poseball and record your appearance.

Some NPC, like the fire dancer , require a scripted item. In this case the rotating texture in the animation could be deleted after the object was rezzed and retain the animated behavior. We used that as the work around for the lizard band too. The lizards were attached to a scripted rotating disc and set up to rez when someone was near and disappear when no one was close. We couldn't figure out why they triggered the bug when they disappeared because they had no scripts. Deleting the script from the disc they were attached to eliminated the issues and once the rotation is part of the object parameters there is no need to keep the rotation script anyway. The trick with having certain NPC only rez if someone is close is how we managed to cram 34 NPCs into a build and still alow enough resources for the sim to handle visitors. For large groups of characters like the lizard band and the NPC dolls that gave clues in Free the Hero, it was crucial that they only re when needed.

There are some characters, like Shannan Albright's dragon shifter, that can't function without their scripts. Those are the ones you have to set to be on all the time. In that way the NPC is only deleted when the region is shutting down.

If you make a mistake and generate an NPC that triggers the bug it's not the end of the world. Delete the object that rezzes the NPC and restart the region. All should be well again.

That should get you started creating characters in your builds while avoiding the NPC bug. Don't let the bug scare you away from the chance to experience all the wonderful fun adding interactive characters to your builds can bring.

You can find the original NPC poseball in a gift box beside the landing area at You can find a version with the capability to sense and rez for nearby avatars in Paradise region. That one is a green poseball set to copy. Set float radius in that script to a non zero number to enable sensing.

If you'd like to see our the Geeked-Out Fairytales NPC exhibit we built for the conference, you'll find a duplicate of that build loaded at
My thanks to Mata Hari who wrote the script we use in the original poseball and to Fred Beckhusen who added to it to create the sensor version. You will find a more advanced and powerful NPC Controller and instructions on how to use that here at Fred's website.