Page 1 of 1

Fiddling with NPC for the first time

Posted: Wed Mar 03, 2021 11:28 pm
by Baroun Tardis
Scripted a lot in SL, feeling my way around in OS

Ran the OS demo script for create a clone. It works fine so long as the position is below <256,256,z> . Above that, the NPC says it creates, and the key seems legit, and I can use a different script to kill it ... but it rez's at <163,83,21.5>
Attempts to do an osNpcMoveTo or MoveToTarget result in it walking like it's stuck on something.
My little workshop is up around <470,250,22> so I'd really like it to come to me rather than going to it, and I'd like to be able to put it where I want it.

Is there some bug with NPCs and variregions that it gets confused at >256 positions?
It's not even getting there, but hanging up before that.
It does keep trying to get to the destination - the osNpcGetPos changes as it tries to walk through something that's not there.

Is there a better way to do this?
I saw something about animated meshes... is there a sample script for that I can dissect?

Re: Fiddling with NPC for the first time

Posted: Thu Mar 04, 2021 12:29 am
by Ilan Tochner
Hi Baroun,

Which OSSL functions are called by this script? Can you paste this demo script here please?

Re: Fiddling with NPC for the first time

Posted: Thu Mar 04, 2021 10:16 am
by Graham Mills
I've done a little with NPCs on Kitely megaworlds and had them patrol above 256, 256, z.

https://twitter.com/vrsimility/status/1 ... 0207108100

There's a basic animesh script at the end of this thread

viewtopic.php?t=5398

with further comments here

viewtopic.php?t=5437

Re: Fiddling with NPC for the first time

Posted: Thu Mar 04, 2021 2:51 pm
by Joelle Tardis
Scripts used - -

//
// osNpcCreate Script Exemple
// Author: djphil
//

key npc;

default
{
state_entry()
{
llSay(PUBLIC_CHANNEL, "Touch to see osNpcCreate usage.");
}

touch_start(integer number)
{
key toucher = llDetectedKey(0);
vector npcPos = llGetPos() + <1.0, 0.0, 1.0>;
osAgentSaveAppearance(toucher, "appearance");
npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance");
llOwnerSay((string)npc+" created at "+(string)npcPos);
state hasNPC;
}
}

state hasNPC
{
state_entry()
{
llSetTimerEvent(5.0);
}

timer()
{
llSetTimerEvent(0.0);
osNpcSay(npc, "Hello world!");
}

touch_start(integer number)
{
osNpcSay(npc, "Goodbye!");
llSetTimerEvent(0.0);
osNpcRemove(npc);
npc = NULL_KEY;
state default;
}
}

==================


default
{
state_entry()
{
key npc = "f9c5b295-4c75-4f80-a6fa-88301ee24055";
osNpcSay(npc,"Hello!");
osNpcMoveToTarget(npc,<160,200,23>,OS_NPC_FLY);
llSay(0,(string)osNpcGetPos(npc));
}
}

Re: Fiddling with NPC for the first time

Posted: Thu Mar 04, 2021 3:04 pm
by Ilan Tochner
You can try replacing llGetPos with osNpcGetPos.

Re: Fiddling with NPC for the first time

Posted: Thu Mar 04, 2021 4:05 pm
by Graham Mills
My quick hack to circulate the NPC between five locations, probably rather laggy at scale.

Code: Select all

list posList =[<1062.40210, 808.17059, 21.35000>,
                <868.92542, 826.17444, 21.35000>,
                <877.43176, 882.00000, 21.35000>,
                <886.46490, 924.84503, 21.35000>,
                <1075.18933, 897.45819, 21.35000>];
vector target;
integer p;
key npc;

default
{

    touch_start(integer n)
    {
        p = 0;
        vector npcPos = llGetPos() + <0.0, 0.0, 1.0>;
        npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance1"); 
        target = llList2Vector(posList, p);
        llSetTimerEvent(2.0);
        osNpcMoveToTarget(npc, target, OS_NPC_NO_FLY);
    }
 
    timer()
    {
        if (llVecDist(osNpcGetPos(npc), target) < 3.0)
        {
            if (p == 4)
            {
                p = 0;
            }
            else
            {
                p++;
            }
            target = llList2Vector(posList, p);
            osNpcMoveToTarget(npc, target, OS_NPC_NO_FLY);
        }
    }
}

Re: Fiddling with NPC for the first time

Posted: Wed Mar 10, 2021 12:39 am
by Krull Kitty
I had no idea NPC's could fiddle. :shock:

Re: Fiddling with NPC for the first time

Posted: Wed Mar 10, 2021 2:10 am
by Snoots Dwagon
Krull Kitty wrote: Wed Mar 10, 2021 12:39 am I had no idea NPC's could fiddle. :shock:

You kidding? That's all they do. :mrgreen: