Change font size
It is currently Sat Dec 15, 2018 12:57 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 4   [ 34 posts ]
Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: Pointing your nose..
PostPosted: Sun Aug 28, 2011 12:00 pm 
Furious Typer
User avatar

Joined: Mon Aug 10, 2009 11:53 pm
Posts: 258
EDIT: This post and script are completely outdated. There hasn't been a need to artificially force the rotation of an NPC to 'forward' in some time now. Would be a good idea to take this one off the list! :D

Take care all!
- Hap

_________________
Sorry, I was just thinking upon the immortal words of Socrates who said ... "I drank what?? ... "
- Real Genius


Last edited by Haplo Voss on Tue Sep 30, 2014 9:08 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: Pointing your nose..
PostPosted: Mon Aug 29, 2011 7:43 am 
Furious Typer
User avatar

Joined: Mon Aug 10, 2009 11:53 pm
Posts: 258
I went ahead and snagged a decent VPS again for now until I can afford a snappy dedicated. I will attach a region to the grid later tonight and set out a watchdog NPC so u can see the effects I'm talking about as well.

Thanks all
- Hap

_________________
Sorry, I was just thinking upon the immortal words of Socrates who said ... "I drank what?? ... "
- Real Genius


Top
 Profile  
 
 Post subject: Re: Pointing your nose..
PostPosted: Mon Aug 29, 2011 12:47 pm 

Joined: Wed Aug 17, 2011 2:51 am
Posts: 45
Interesting script... I will try to examine it tomorrow when I hopefully have some time..
Thanks for sharing the script!


Top
 Profile  
 
 Post subject: Re: Pointing your nose..
PostPosted: Mon Aug 29, 2011 2:40 pm 
Furious Typer
User avatar

Joined: Mon Aug 10, 2009 11:53 pm
Posts: 258
Void Pipe {L_WROTE}:
Interesting script... I will try to examine it tomorrow when I hopefully have some time..
Thanks for sharing the script!


No problem and much appreciated. My uh... 'dirty' scripting there in the sensor is a bit messy due to the repeated attempts to get it to do what I want so it may take some deciphering, and I'm sure with some cleanup it could be made much tighter with less overhead.

I'll throw in some more commenting here after while as well so some of the more unconventional declarations make a lick of sense.

Thanks,
- Hap

_________________
Sorry, I was just thinking upon the immortal words of Socrates who said ... "I drank what?? ... "
- Real Genius


Top
 Profile  
 
 Post subject: Re: Pointing your nose..
PostPosted: Mon Aug 29, 2011 9:41 pm 
Furious Typer
User avatar

Joined: Mon Aug 10, 2009 11:53 pm
Posts: 258
OK New Region:

Haplhazard 9999,9970 (notice the 'l' - it's intentional, don't forget it)

Nothin but an empty cottage a couple of trees and a couple of mysterious glowie things you can click on.

Oh and an NPC that chases you around most of the region. :D

Take care,
- Hap

_________________
Sorry, I was just thinking upon the immortal words of Socrates who said ... "I drank what?? ... "
- Real Genius


Top
 Profile  
 
 Post subject: Re: Pointing your nose..
PostPosted: Tue Aug 30, 2011 6:12 am 
Furious Typer
User avatar

Joined: Fri Aug 19, 2011 7:10 pm
Posts: 236
Location: UK
I like this script, thanks for sharing.

I modified it a little: I've included a standing animation so my bot doesn't just stand there rigid while waiting and, since I have a couple of other bots on the sim, I've set it to ignore those (I use a regular naming convention for them, so it's easy enough to filter out).

Next step, weld a chatbot script to it :)

_________________
50's sim based at Rumbled on OSGrid
happily running on Debian Linux on a VPS since June 10 2013


Top
 Profile  
 
 Post subject: Re: Pointing your nose..
PostPosted: Tue Aug 30, 2011 8:13 am 

Joined: Wed Aug 17, 2011 2:51 am
Posts: 45
Roken, please post your modified script here as well... ;o)


Top
 Profile  
 
 Post subject: Re: Pointing your nose..
PostPosted: Tue Aug 30, 2011 11:33 am 
OSG Elite
User avatar

Joined: Thu Dec 11, 2008 7:51 am
Posts: 392
Location: England UK
Nice script Haplo :-)

I did try it yesterday and see the issue you are having. I tried changing the osNpcSetRot part (taken from a follower prim) but that still failed. Unfortunatly my scripting skills at rotation suck big time so I gave up.

Not sure if you ahve seen this on the Open Simulator wiki:
{L_QUOTE}:
Set the rotation of the avatar. Only setting the rotation in the Z plane in Euler rotation will have any meaningful effect (turning the avatar to point in one direction or another). Setting X or Y Euler values will result in the avatar rotating in an undefined manner.
I did try to break down the quaternion (into x,y,z,s) and set x & y at 0, but that just ended up with the NPC not pointing in any direction at all :(

It would be real nice to have this script working properly.

_________________
"Nothing lasts forever; It's scientific"
~David Byrne (Talking Heads)


Top
 Profile  
 
 Post subject: Re: Pointing your nose..
PostPosted: Tue Aug 30, 2011 12:32 pm 
Furious Typer
User avatar

Joined: Mon Aug 10, 2009 11:53 pm
Posts: 258
Hey Adelle,

I know - I thought it interesting that using the Z axis as one would think... did not work unless you were on I believe the +128, +128 quarter of the sim, however using the Y axis makes it work perfectly except for when you come to a halt.

Too bad there's no llLookAt or llRot2Fwd that I can stick into a variable. lol


Also for you people wanting to make sure your NPCs are animated while they sit/stand idle - Throw a simple AO in a ball, throw a series of standing anims with it, wear it, then create NPC. Done. No extra load in the main script. Remember that anything you wear - so will your NPC.. including scripts. Most of them actually work on the NPC just as well as you. Probably not as sim - friendly but something to keep in mind for all sorts of purposes ... *cough* dance stoofs *cough* :)

NOTE: On the simpler AO scripts anyway - it appears that one of the few limitations are detecting avatar states of a NPC. i.e. NPCs wearing an AO will not use the walking animation when they begin a moveto command, nor a flying animation when the fly to a target.
I assume this is probably due to the fact that the movement system is being somewhat bypassed more like a vehicle, even though in the end it is pumping movement to the scene. However whatever is in the standard idle process runs fine. Standing loops, dance loops, Death by HUD, what have you.

If you drop by my region you'll notice my doppleganger has standing anims. It's because I forgot to take off my AO first. lol

Take care all,
- Hap

_________________
Sorry, I was just thinking upon the immortal words of Socrates who said ... "I drank what?? ... "
- Real Genius


Top
 Profile  
 
 Post subject: Re: Pointing your nose..
PostPosted: Tue Aug 30, 2011 7:34 pm 
Furious Typer
User avatar

Joined: Fri Aug 19, 2011 7:10 pm
Posts: 236
Location: UK
OK, here's my (slightly modified) version of the script. I may seek to add to it. As I mentioned, welding a chat bot script to it may be a nice idea.

If anyone uses this script note that some important lines are commented out (which you will need to uncomment and amend on first run). Specifically, the SaveAppearance lines (you have the option to clone yourself or someone else). See the line "key cagent " if you clone someone else. They MUST be present on the sim for this to work. Please don't clone people without their permission.

After you run the script to create your first NPC, you can safely comment out the osAgentSaveAppearance and/or osOwnerSaveAppearance lines since you already have the notecard with the appearance. Remember to remove teh NPC before amending the script - otherwise you'll need to use the emergency recovery line.

{L_CODE}:
key npc;
vector curPos;
vector vecTo_targ;
vector nPos;
integer destX;
integer destY;
integer target_x;
string animw = "walkf2";               //These are the names of the walking and standing anims that the NPC should use.
string anims = "FemaleSway";
// key cagent = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx" //I prefer to use an alt set up to look like I want - enter the UUID of the avatar that you want to use (see below)

default
{
    state_entry()
    {
        llListen(11,"",NULL_KEY,""); // Uhm. Yeah
    }
   
    touch_start(integer num)
    {
        llOwnerSay("\n\nNPC Block:\nType /10 (command) to control your NPC.\ncreate - spawn NPC\nremove - despawn NPC\nreload - reload NPC appearance\nstart - start NPC watchdog\nstop - stop and remove the NPC watchdog");
        // What? Nifty little instruction toucher. Every little script needs one *pat pat*.
    }   

    listen(integer channel, string name, key id, string msg)
    {
        if (msg != "")
        //npc = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; This is an emergency recovery line in case the script crashes leaving the NPC behind, enter the NPC UUID and uncomment the line to allow you to remove the NPC cleanly.
        {
            if (msg == "create"){
                //osAgentSaveAppearance(cagent,"appearance");    // Grab the agent apparance that you want to use. After first run, remove the NPC then comment this line (you already have the notecard, so point reinventing the wheel)
               //osOwnerSaveAppearance("appearance"); //Alternatively, uncomment this line to clone yourself
                destX = (integer) llFrand (65)-30;      // Creates random X coord around center
                destY = (integer) llFrand (65)-30;      // Creates random Y coord around center
                npc = osNpcCreate ("My", "Bot", llGetPos()+<destX, destY, 0>, "appearance"); //Change the name here. If you want to use other Bot detection, see below re naming
               
            }
            else if (msg == "start"){
                osSetSpeed(npc, 1);
                osAvatarPlayAnimation(npc,anims);
                llSensorRepeat("","",AGENT,92.0,PI*2,0.8); // Kick off the watchdog   
               
            }
            else if (msg == "stop"){
                osNpcRemove(npc);
                llResetScript();                           // Stop all processes. Kill all NPCs.
            }
            else if (msg == "remove"){
                osNpcRemove(npc);                          // Kill the NPC
            }
            else if (msg == "reload"){
                osNpcLoadAppearance(npc, "appearance");    // Load appearance notecard in prim
            }
            else {
                llOwnerSay("Nope");                        // Unknown command basket
            }
        }
    }
   
    sensor (integer _det) // -----------> Watchdog Rotation and Movement Sensor <---------------
    {
        integer x;
        for (x = _det - 1; x >= 0; x--) {                                // Grab incoming avatars
            if (llDetectedKey(x) != npc && llDetectedKey(x) != "" && llGetSubString(llGetDisplayName(llDetectedKey(x)),-3,-1) != "Bot") //The third test tests against my own naming convention for NPCs of Firstname Bot. This will match and ignore any AV with the surname "Bot"
                {
                target_x = x;
                vecTo_targ = llList2Vector(llDetectedPos(target_x),0);   // Grab vector to target
                nPos = osNpcGetPos(npc);       
                }
        }
       
        if (vecTo_targ.x > 5){                       // Backup check. Make sure target is not at edge of sim or out of range.                                             
            if (llFabs(vecTo_targ.x - nPos.x) > 5 || llFabs(vecTo_targ.y - nPos.y) > 5){          // If NPC is farther than 5m away... ok let's do it
                osAvatarStopAnimation(npc,anims); //Stop the standing anim and
                osAvatarPlayAnimation(npc,animw); //Start the walk anim                                           
                osNpcSetRot(npc, llRotBetween(<0,-1,0>,llVecNorm(vecTo_targ - osNpcGetPos(npc)))); // Face target position
                osNpcMoveToTarget(npc, vecTo_targ, OS_NPC_NO_FLY); 
                               
            }
            else {
                osAvatarStopAnimation(npc,animw);
                llSleep(1); //I found that I didn't need rotation correction, but you need this delay to prevent sliding at the end of the walk
                osAvatarPlayAnimation(npc,anims);
                  }
           }
    }                   // ------------> End of Watchdog Movement Block <------------------------
}

_________________
50's sim based at Rumbled on OSGrid
happily running on Debian Linux on a VPS since June 10 2013


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 4   [ 34 posts ]
Go to page 1, 2, 3, 4  Next


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net