iliveisl

 

awesome and free NPC script to get you started

14 comments

a few weeks ago i had the privilege to meet Ohn Lang – a passionate and talented OpenSim scripter and creator who happens to like NPCs. NPC scripting is something that intimidates me (lol, sit scripts scare me!) but have so many practical and fun applications

Ohn Lang will be adding NPCs to Hax Nuit which will bring it to life and truly complete it. in her quest to do so, she has created a pretty amazing script that is free to use and very nicely configured

in her words:

Just wanted to let you know, I finished that action NPC script we were talking about in the comments on your blog. I made a copy/modify/transfer package. The default configured behavior is being demonstrated by the NPC on the ohn freebies world, in the SW corner of the region. The package is set out, bright yellow box. People just need a kitely account to go in and grab it.

http://www.kitely.com/virtual-world/Ohn-Lang/ohn-freebies

The NPC walks, talks, pauses, sits, stands, and animates based on an action configuration card. Automatically re-rezzes on region restart. The default appearance uses Linda Kellie’s Adam skin, Farmboy outfit, and Rugged AO (so he walks studly-like, LOL). The NPC controller can also be configured to rez objects anywhere in the region and these objects can be sat on by the NPC when instructed to do so through the action configuration card. Out of the package, it rezzes, places, and uses three such objects.

This script will be the foundation for the Hax Nuit NPCs. I designed it (hopefully) to be easily extendable and customizable.

I tried to name things in a friendly way. And the code is actually kinda simple :D. The script is long, but that’s because I like clean formatting and whitespace. There are a some global variables, then a few functions (none of them too long or complicated).

Then the default state: starting stuff from fresh, configured objects in inventory rez, NPC gets created, and immediately after it transitions to the NPCidle state. This is the new quasi-default state once the NPC is first created. Each different type of action (moving, talking, animation, etc.) is associated with a different state (such as NPCtalk or NPCgoto). As the NPC cycles through the configured actions, the script will transition to the state for that action type, do the action, then transition right back to the idle state once finished. The idle state is where the script decides what to do next, and consequently which state should be transitioned to.

The action states have very little code in them, so I think they should be easier than average to follow. Because each action is associated with its own state, this makes it easy to extend. Just create a new state for the new action type using the template I provided in the instructions card, add support for the action command and state in the idle state (I provided a template for that too), and boom, script extended. :D

dang, that NPC does more than i do! thank you Ohn for reaching out to say hello, sharing your awesome work, and being a wonderful new friend  =)

maria-large

Maria, the gynoid from the 1927 film Metropolis

Twitter Tumblr Digg Reddit Stumbleupon Delicious Facebook Plusone Pinterest Linkedin Tumblr Posterous Snailmail

written by Ener Hax

January 24th, 2013 at 9:07 pm

posted in freebies,OpenSim

tagged with ,

14 comments to 'awesome and free NPC script to get you started'

subscribe to comments with RSS or trackBack to 'awesome and free NPC script to get you started'.

  1. Awww MAN!!!!! I’d love it but . not worth starting a whole nuther account for just one script. I been thinking about making bots too. Ah well, thanks anyway :-(

    Crystal Brewton

    24 Jan 13 at 11:23 pm

  2. You can login with a Twitter name, Crystal.

    I got the same question from someone else on our G+ group.

    Yes, I plug it on the Opensim Virtual community group here…

    https://plus.google.com/communities/116284417302234467612

    Then I visited Kitely to get the scripts and there I met someone else who had just read the group post!

    Gaga

    25 Jan 13 at 12:10 am

  3. hi Crystal, i’d say you should grab your avatar name at least, for the future

    i also hate (loathe) setting up new accounts but reserving your avatar name may be important to you (it was important for Ener Hax)

    that said, i love Kitely, it is a perfect place for us now and once hypergrid is installed, it may be a very good place to have your “all grid” avatar based from (like creating your account on OSgrid)

    dang Gaga, i really think you are doing an amazing job developing Google Plus as an information repository – it seems to be an ideal choice =) *claps for Gaga*

    Ener Hax

    25 Jan 13 at 9:53 am

  4. Ohn was the 1 that show me how to do my npc’s on Osg regions (we have more then 200 in there but only if any knows wich prim to touch and all xxx, lol)
    If i was back on OSG id love to try that new 1, as it seems amazing.
    2 bad Sl is all i do now;)

    ZZ Bottom

    25 Jan 13 at 9:54 am

  5. Ohn,
    Finally the dim light of how to script NPC has begun to shine. I believe this is the best explanation on how to make the NPC’s work.
    Hooray!
    Thanks again

    mrjoyce

    25 Jan 13 at 12:05 pm

  6. I’m glad someone finally coded some decent scripts for the NPC funness- that everyone can use (the NPCS are a hoot!). My npcs were always very specific to whatever sim they were made for, and as my code evolved with my toy-needs – I even went more off the deep end when I started playing with tying their functions to a php driven AIML bot script hosted on my server (so their ability to fit anywhere else became impossible).
    I need to play with OpenSim more, and complete that aiml fun though. I’ve sort of been on a hiatus from OpenSim (playing with other goodies). Congrats on the new NPCs for your Hax Nuit. I’ll come see it if Kitely ever allows Hyper Grid visitors.

    Araxie

    25 Jan 13 at 12:31 pm

  7. so ZZ, you say you have 200 NPCs in one region?!? o_O

    so they don’t lag the region much or how does it affect performance? (i dunno nothing about them – but am thinking about a zombie apocalypse as a scenario for Hax Nuit – how fun would that be? i’d make a second copy of Hax Nuit though, one for the awesome story line Ohn is developing and one for total zombie mayhem) =D

    mrjoyce,, please show me the light switch when you get it figured out! i’m sitting in the dark under a prim! =p

    Araxie is the one who got me fired up about NPCs with stories of NPC faeries running around! i look forward to meeting you in-world – HG will be available at Kitely sometime in the future (i would guess this year) =)

    Ener Hax

    25 Jan 13 at 2:03 pm

  8. :D lots of visits to my world!

    I hope the scripts live up to everyone’s expectations. Let me know if you run into any major issues with the existing functions. I think I will try to change the moving function so that it doesn’t rely on llSleep. If/when I do that, I’ll post an update to the ohn freebies world.

    @Ener – I think zombies and would be fun, maybe in the underground tunnels. They can be all part of the world. I could make zombies wander around in the tunnels, and maybe follow people. If they catch them, maybe immobilize them for a bit, lol.

    Ohn Lang

    25 Jan 13 at 9:50 pm

  9. Can this script be used to set up a greeter bot at my house?

    Azulmarino

    26 Jan 13 at 7:51 pm

  10. You could customize it to do that. It does have a talk function. You would need to customize the script to detect and track visitors, so that you don’t spam them :)

    I have a second NPC bot on the ohn freebies world that is designed specifically to be a greeter. It’s actually the first one I put out in that world. She’s the pretty one just off the path heading north, about center of the region. There are instructions to change her look as well.

    That one works with a hollow cylinder prim that uses llVolumeDetect() to recognize avatars that enter the cylinder. The assumption is that the NPC and cylinder prim are placed at the location where visitors teleport in.

    The cylinder tracks who has visited before. Upon entering the cylinder, the cylinder script checks a notecard to see if the avatar has ever visited before, and if not, it instructs the NPC to welcome them for the first time, and invite them to join a group. If the avatar has visited in the past, but not since the region restarted, the cylinder instructs the NPC to welcome them back. If the avatar enters the cylinder area a second and subsequent times after being welcomed back, nothing is done.

    If you wanted an NPC that was both a greeter and could also do the things supported in my new action NPC script (perhaps to serve also as a tour guide?), you could take both sets of scripts, and add the functionality from the greeter NPC script to the action NPC script, and go from there. the new action NPC script is much better written I think.

    Ohn Lang

    27 Jan 13 at 3:04 pm

  11. Well, as i did them, if you click on some prims it will rezz from 3 up to 10 (the max npc i put to rezz at once).
    Note that i have more then 200 but on 4 sims (zztt zztt1 zztt2 zztt3) and if i remenber i have to click on like 30 prims to rezz all of them and have them in world at same time..
    All them use lots of prims (Sex parts, prim feet, nails and clothes, some i did use mroe then 300 prims like a sword:)
    Me and my Loved one, never had any problems with all them rezzed but 1, if you tlp out of the region when you come back you will not be able to listen to sounds that are created via scripts (and we did a lot of those, from sea waves ro the sound of wind and rusty doors and so on!)
    I had a lot of a fight with several Osg developers in March, trying to figure why having more then 5 npc rezed would kill the sounds after a tlp out of the region and come back!
    As im using the latest osg dev release, far away from the 1 i used when i created them, i don’t even know if the problem still remains.
    Also note that i have most of npc just rezzing and using poseballs, so simple scipts.
    The ones that use a script to walk on a specif path, will stress more my computer, but i only made 2 of those!
    This latest script seems that can be much more stresfull then just rezzing and making a npc us a animation on a poseball!
    But to end, my regions can have them all rezzed and handles at least 2 users roaming around!

    ZZ Bottom

    29 Jan 13 at 5:21 am

  12. Nice work, thank you for it.
    How do i know in the npc_appearance notecard
    for what the uuid is, e.g. the skin, shape and AO.

    Kind Regards
    Karl

    Ken

    29 Jan 13 at 9:04 am

  13. Hi Karl (Ken?),

    The npc_appearance card probably shouldn’t be edited directly, at least I didn’t intend it to be.

    To change how the npc will look, delete the npc_appearance card from the prim.

    Then dress in the skin, shape, clothes, attachments that you want your NPC to have.

    Then click the prim to create the NPC.

    Easy as that :D

    The script creates the appearance card automatically.

    I haven’t edited the card manually myself.

    If I did need to and I needed to change the UUID of something (I use Firestorm), I would go into my inventory, right-click the item, and choose “Copy Asset UUID” and then paste the UUID where it belonged in the notecard.

    I’m not sure what the steps would be in other viewers, but I am guessing it is something similar to that.

    Ohn Lang

    31 Jan 13 at 2:26 am

  14. these are great tips Ohn – should be placed online somewhere as a central resource – could even simply be something the the Sim-on-a-Stick blog page linked on the right with just a collection of your comments

    lemme think about a meaningful way to archive your awesome tips =)

    Ener Hax

    1 Feb 13 at 3:19 am

leave a reply - add your thoughts

you can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>