Jump to content

RandomAvatar338

Resident
  • Posts

    7
  • Joined

  • Last visited

Posts posted by RandomAvatar338

  1. 3;CAN YOUDON'T YOU BELIEVE THAT I CAN*PERHAPS YOU WOULD LIKE TO BE ABLE TO*YOU WANT ME TO BE ABLE TO*2;CAN IPERAPS YOU DON'T WANT TO*DO YOU WANT TO BE ABLE TO*4;YOU ARE;YOUREWHAT MAKES YOU THINK I AM*DOES IT PLEASE YOU TO BELIEVE I AM*PERHAPS YOU WOULD LIKE TO BE*DO YOU SOMETIMES WISH YOU WERE*4;I DONTDON'T YOU REALLY*WHY DON'T YOU*DO YOU WISH TO BE ABLE TO*DOES THAT TROUBLE YOU?3;I FEELTELL ME MORE ABOUT SUCH FEELINGS.DO YOU OFTEN FEEL*DO YOU ENJOY FEELING*3;WHY DONT YOUDO YOU REALLY BELIEVE I DON'T*PERHAPS IN GOOD TIME I WILL*DO YOU WANT ME TO*2;WHY CANT IDO YOU THINK YOU SHOULD BE ABLE TO*WHY CAN'T YOU*3;ARE YOUWHY ARE YOU INTERESTED IN WHETHER OR NOT I AM*WOULD YOU PREFER IF I WERE NOT*PERHAPS IN YOUR FANTASIES I AM*3;I CANTHOW DO YOU KNOW YOU CAN'T*HAVE YOU TRIED?PERHAPS YOU CAN NOW*4;I AM;IMDID YOU COME TO ME BECAUSE YOU ARE*HOW LONG HAVE YOU BEEN*DO YOU BELIEVE IT IS NORMAL TO BE*DO YOU ENJOY BEING*3;YOUWE WERE DISCUSSING YOU-- NOT ME.OH, I*YOU'RE NOT REALLY TALKING ABOUT ME, ARE YOU?5;I WANTWHY DO YOU WANT*WHAT IF YOU NEVER GOT*I SOMETIMES ALSO WANT*WHAT WOULD IT MEAN TO YOU IF YOU GOT*SUPPOSE YOU SOON GOT*9;WHAT;HOW;WHO;WHERE;WHEN;WHYWHY DO YOU ASK?DOES THAT QUESTION INTEREST YOU?WHAT ANSWER WOULD PLEASE YOU THE MOST?WHAT DO YOU THINK?ARE SUCH QUESTIONS ON YOUR MIND OFTEN?WHAT IS IT THAT YOU REALLY WANT TO KNOW?HAVE YOU ASKED ANYONE ELSE?HAVE YOU ASKED SUCH QUESTIONS BEFORE?WHAT ELSE COMES TO MIND WHEN YOU ASK THAT?2;NAMENAMES DON'T INTEREST ME.I DON'T CARE ABOUT NAMES-- PLEASE GO ON.4;CAUSEIS THAT THE REAL REASON?DON'T ANY OTHER REASONS COME TO MIND?DOES THAT REASON EXPLAIN ANY THING ELSE?WHAT OTHER REASONS MIGHT THERE BE?4;SORRYPLEASE DON'T APOLOGIZE.APOLOGIES ARE NOT NECESSARY.WHAT FEELINGS DO YOU HAVE WHEN YOU APOLOGIZE?DON'T BE SO DEFENSIVE!4;DREAMWHAT DOES THAT DREAM SUGGEST TO YOU?DO YOU DREAM OFTEN?WHAT PERSONS APPEAR IN YOUR DREAMS?ARE YOU DISTURBED BY YOUR DREAMS?1;HELLO;HIHOW DO YOU DO--PLEASE STATE YOUR PROBLEM.5;MAYBEYOU DON'T SEEM QUITE CERTAIN.WHY THE UNCERTAIN TONE?CAN'T YOU BE MORE POSITIVE?YOU AREN'T SURE?DON'T YOU KNOW?5;NOARE YOU SAYING NO JUST TO BE NEGATIVE?YOU ARE BEING A BIT NEGATIVE.WHY NOT?ARE YOU SURE?WHY NO?2;YOURWHY ARE YOU CONCERNED ABOUT MY*WHAT ABOUT YOUR OWN*4;ALWAYSCAN YOU THINK OF A SPECIFIC EXAMPLE?WHEN?WHAT ARE YOU THINKING OF?REALLY, ALWAYS?3;THINKDO YOU REALLY THINK SO?BUT YOU ARE NOT SURE YOU*DO YOU DOUBT YOU*7;ALIKEIN WHAT WAY?WHAT RESEMBLANCE DO YOU SEE?WHAT DOES THE SIMILARITY SUGGEST TO YOU?WHAT OTHER CONNECTIONS DO YOU SEE?COULD THERE REALLY BE SOME CONNECTION?HOW?YOU SEEM QUITE POSITIVE.3;YESARE YOU SURE?I SEE.I UNDERSTAND.6;FRIENDWHY DO YOU BRING UP THE TOPIC OF FRIENDS?DO YOUR FRIENDS WORRY YOU?DO YOUR FRIENDS PICK ON YOU?ARE YOU SURE YOU HAVE ANY FRIENDS?DO YOU IMPOSE ON YOUR FRIENDS?PERHAPS YOUR LOVE FOR FRIENDS WORRIES YOU?7;COMPUTERDO COMPUTERS WORRY YOU?ARE YOU TALKING ABOUT ME IN PARTICULAR?ARE YOU FRIGHTENED BY MACHINES?WHY DO YOU MENTION COMPUTERS?WHAT DO YOU THINK MACHINES HAVE TO DO WITH YOUR PROBLEM?DON'T YOU THINK COMPUTERS CAN HELP PEOPLE?WHAT IS IT ABOUT MACHINES THAT WORRIES YOU?5;CAROH, DO YOU LIKE CARS?MY FAVORITE CAR IS A LAMBORGINI COUNTACH. WHAT IS YOUR FAVORITE CAR?MY FAVORITE CAR COMPANY IS FERRARI.  WHAT IS YOURS?DO YOU LIKE PORSCHES?DO YOU LIKE PORSCHE TURBO CARRERAS?6;NOKEYFOUNDSAY, DO YOU HAVE ANY PSYCHOLOGICAL PROBLEMS?WHAT DOES THAT SUGGEST TO YOU?I SEE.I'M NOT SURE I UNDERSTAND YOU FULLY.COME COME ELUCIDATE YOUR THOUGHTS.CAN YOU ELABORATE ON THAT?

     

  2. // rate is the how often in seconds a new random avatar is chosen

    // scan_distance is the range of the avatar sensor

    // speed is the pathfinding desired speed in meters per second

     

    float rate = 10.0;float scan_distance = 20.0; float speed = 0.5;string rez_hover_text = "";string active_hover_text = "Pursuing..."; integer random;key krandom;key target = NULL_KEY;default{    state_entry()    {        llSetText(rez_hover_text,<1.,1.,1.>,1.);        llCreateCharacter([CHARACTER_DESIRED_SPEED, speed]);        llSensorRepeat("",  NULL_KEY,AGENT_BY_LEGACY_NAME, scan_distance, PI, rate);    }        on_rez(integer start_param)    {        llDeleteCharacter();        llResetScript();    }    sensor(integer number_detected)    {                 random = llFloor(llFrand(number_detected));        krandom = llDetectedKey(random);        if(krandom != NULL_KEY)        {            llPursue(krandom, [PURSUIT_OFFSET, <0, 0.5, 0>, REQUIRE_LINE_OF_SIGHT, FALSE]);            llSetText(active_hover_text + llKey2Name(krandom), <0.2, 0.0, 0.0>, 1.0);        }    }        no_sensor()    {        // nothing detected, sit or pursue previous target if was one, even out of detection range, may by a flying avatar,        // only when reach the ground or fly very close by ground    }}

     

  3. string botid="PASTE_CHATBOT_ID_HERE"; //Go to Pandorabots.com and publish you own ALICE (or other) chatbot. Put your new Chabot ID in botid.

    /////PANDORABOTS AI CHAT SCRIPT/////
    ////       By Zetaphor        /////
    // 1) Create an account on Pandorabots.com
    // 2) Create a new bot by following the sites instructions
    // 3) Publish your bot
    // 4) Take the botID from the URL, and replace the botID already here, or just use the one provided!
    // 5) Enjoy

    string url;

    list params;
    integer brainon;
    default
    {
        state_entry()
        {
            llListen(0, "", NULL_KEY, "");
        }

        touch_start(integer total_number)
        {
            if (brainon==TRUE)
            {
                llSay(0,"AI Chatbot Disabled!");
                brainon=FALSE;
            }
            else
            {
                llSay(0,"AI Chatbot Enabled!");
                brainon=TRUE;
            }
        }
        listen(integer channel, string name, key id, string message)
        {
            if (brainon==TRUE)
            {
                string url="http://www.pandorabots.com/pandora/talk-xml?botid="+botid+"&costid="+(string)llDetectedKey(0)+"&input="+llEscapeURL(message);
                llHTTPRequest(url,params,"");
            }
        }
        http_response(key request_id, integer status, list metadata, string body)
        {
            list response=llParseString2List(body,["<that>"],["</that>"]);
            llSay(0,llList2String(response,1));
        }    
    }
     

  4. // Scripted by Lenis Pinden
    // You may use this script in your creations without any limits, as long as you mention the creator of the original script.

    // constants

    float walking_speed=1.15;
    float running_speed=3.0;

    list random_stand_animations=["smooth=1;stand_shoulder","smooth=2;stand_legs","smooth=3;stand_spine"];

    // globals

    integer npc_state; // 0 - inactive in default state, 1 - wandering, 2 - pursuing
    integer npc_action; // 0 - default state nothing, 1 - standing, 2 - walking, 3 - running
    float npc_animation; // 0.0 - default animation, 1.0 - stand, 1.x - stand randoms

    float next_action_switch_time;
    float next_animation_switch_time;

    // possibly will need to add state parameters in list or as a float part


    vector npc_path_pos;

    key npc_target=NULL_KEY;

    integer position_checker;

    string playing_animation;

    play_animation(string animation)
    {
        if (playing_animation==animation)
        return;
        
        llMessageLinked(LINK_THIS, -1, "", "read=0.01*" + animation + ".bvh");
        
        playing_animation=animation;
    }

    on_rezzing()
    {
        npc_state=0;
        npc_action=1;
        
        switch_npc_state(1);
    }

    change_property_checker(integer value)
    {
        if (value==1)
        {
            if (position_checker)
            llTargetRemove(position_checker);
            
            position_checker=llTarget(llGetPos(), 0.1);
        }
        else
        if (value==-1)
        {
            if (position_checker)
            {
                llTargetRemove(position_checker);
                position_checker=0;
            }
        }
    }

    switch_npc_state(integer state_number)
    {
        if (npc_state==state_number)
        return;
        
        if (state_number==1) // wander
        {
            npc_path_pos=ZERO_VECTOR;
            
            if (npc_target!=NULL_KEY)
            {
                npc_path_pos=llList2Vector(llGetObjectDetails(npc_target,[OBJECT_POS]),0); // if was following somebody - then wander around that person
                
                npc_target=NULL_KEY;
            }
            
            if (npc_path_pos==ZERO_VECTOR)
            npc_path_pos=llGetPos();
            
            next_action_switch_time=0; // triggers wander or stop
        }
        else
        if (state_number==2) // pursue
        {
            llUpdateCharacter
            ([
                CHARACTER_DESIRED_SPEED, running_speed
            ]);
            
            if (npc_target)
            llPursue( npc_target, [PURSUIT_GOAL_TOLERANCE, 3.0] );
            else
            llOwnerSay("AI Error, no target specified to pursue");
        }
        
        llSetTimerEvent(0.0001);
        
        npc_state=state_number;
    }

    /*
    integer npc_state; // 0 - inactive in default state, 1 - wandering, 2 - pursuing
    integer npc_action; // 0 - default state nothing, 1 - standing, 2 - walking, 3 - running
    float npc_animation; // 0.0 - default animation, 1.0 - stand, 1.x - stand randoms
    */

    switch_npc_action(integer action_number)
    {
        if (npc_action==action_number)
        return;
        
        if (action_number==1)
        {
            play_animation("smooth=2;stand_loop");
            next_animation_switch_time=llGetTime() + 1 + llFrand(6);
        }
        else
        if (action_number==2)
        {
            llUpdateCharacter
            ([
                CHARACTER_DESIRED_SPEED, walking_speed
            ]);
            
            play_animation("smooth=1;walk_loop");
        }
        else
        if (action_number==3)
        {
            llUpdateCharacter
            ([
                CHARACTER_DESIRED_SPEED, running_speed
            ]);
            
            play_animation("run_loop");
        }
        
        npc_action=action_number;
    }

    stop_moving()
    {
        llNavigateTo( llGetPos() + <0.05,0,0>*llGetRot(), [] );
    }

    default
    {
        on_rez(integer code)
        {
            on_rezzing();
        }
        
        state_entry()
        {
            llDeleteCharacter();
            
            llCreateCharacter
            ([
                CHARACTER_DESIRED_SPEED, walking_speed,
                CHARACTER_RADIUS, 0.5,
                CHARACTER_LENGTH, 1.72
            ]);
            
            on_rezzing();
            
            llSensorRepeat("","",AGENT,50.0,PI,2.0);
            
            //llGetFreeMemory() + "bytes free");
        }
        
        sensor(integer num)
        {
            if (llVecMag(llGetPos() - llDetectedPos(0)) > 10.0)
            {
                npc_target=llDetectedKey(0);
                switch_npc_state(2);
            }
            else
            {
                switch_npc_state(1);
            }
        }
        
        no_sensor()
        {
            if (npc_target!=NULL_KEY)
            {
                npc_target=NULL_KEY;
            }
            
            switch_npc_state(1);
        }
        
        not_at_target() // it could trigger after npc state is being switched, keep this in mind
        {
            //llOwnerSay("not at target");
            
            change_property_checker(-1);
            
            if (npc_state==2)
            {
                switch_npc_action(3);
            }
        }
        
        timer() // timer needs constant polling ON SOME STATES with some interval like 0.5 - 1 sec or so
        {
            float time=llGetTime();
            
            //integer total_actions=llList2Integer( [2,1], npc_state-1 );
            
            //integer new_action = ( npc_action + 1 + (integer)llFrand(total_actions-1)  ) % total_actions; // select next action, or skip some actions, but don't do the same, and loop
            
            //llOwnerSay("NPC state="+(string)npc_state+" NPC new_action="+(string)new_action);
            
            /*
            integer npc_state; // 0 - inactive in default state, 1 - wandering, 2 - pursuing
            integer npc_action; // 0 - default state nothing, 1 - standing, 2 - walking, 3 - running
            float npc_animation; // 0.0 - default animation, 1.0 - stand, 1.x - stand randoms
            */
            
            if (npc_state==1) // wandering
            {
                // add a timer over here to when to switch that thing
                
                if (time > next_action_switch_time)
                {
                    if (npc_action!=2) // switch from anything else but walk wander
                    {
                        llWanderWithin( npc_path_pos, llVecNorm(<1.,1.,1.>)*7., [] );
                        switch_npc_action(2);
                        
                        next_action_switch_time=time + 1.0 + llFrand(6); // walking time
                    }
                    else
                    {
                        stop_moving();
                        switch_npc_action(1);
                        
                        next_action_switch_time=time + 1.0 + llFrand(16); // standing time
                    }
                }
            }
            else
            if (npc_state==2) // pursuing
            {
                if (llVecMag(llGetVel())<0.05) // if reached target and stand
                {
                    change_property_checker(1);
                    
                    switch_npc_action(1);
                }
                else
                {
                    switch_npc_action(3);
                }
            }
            
            /*
            integer npc_state; // 0 - inactive in default state, 1 - wandering, 2 - pursuing
            integer npc_action; // 0 - default state nothing, 1 - standing, 2 - walking, 3 - running
            float npc_animation; // 0.0 - default animation, 1.0 - stand, 1.x - stand randoms
            */
            
            if (npc_action==1)
            {
                if (time > next_animation_switch_time)
                {
                    play_animation( llList2String(random_stand_animations,(integer)llFrand(llGetListLength(random_stand_animations))) );
                    
                    next_animation_switch_time=time + 3 + llFrand(12);
                }
            }
            
            /*
            if (npc_state==1)
            {
                //llOwnerSay("C");
                
                if (new_action==0) // stand
                {
                    llSetTimerEvent(1.0 + llFrand(3)); // how much time would character stay in that action  
                }
                else
                if (new_action==1) // walk around
                {
                    llSetTimerEvent(2.0 + llFrand(8));
                }
            }
            else
            {
                llSetTimerEvent(0.35); // velocity polling
            }
            */
            
            llSetTimerEvent(1.0);
        }
        
        link_message(integer sender, integer value, string message, key id)
        {
            integer index=llSubStringIndex(id,"=");
            
            string action=id;
            if (~index)
            action=llDeleteSubString(action,index,-1);
            
            string parameter=llDeleteSubString(id,0,index); // if index is -1 then whole thing gets deleted, and empty string returned
            
            if (action=="play_end")
            {
                if (npc_action==1)
                {
                    //if (~llListFindList(random_stand_animations,[parameter]))
                    //{
                        play_animation("smooth=2;stand_loop");
                    //}
                }
            }
        }
        
        path_update(integer type, list reserved)
        {
            if (type == 1)
            {
                //llOwnerSay("stopping");
                
                if (npc_state==2) // pursuing
                {
                    change_property_checker(1);
                    
                    switch_npc_action(1);
                }
            }
            
            //llOwnerSay((string)type);
            
            /*
            if (type == 0)
            {
                llOwnerSay("Near");
            }
            else if (type == 1)
            {
                llOwnerSay("Stopping");
            }
            else if (type == 2)
            {
                llOwnerSay("Cannot path find from current location.");//! Attempting to go to the center of the region.");
     
                //llNavigateTo(<128.0, 128.0, llGround(<128.0, 128.0, 0.0> - llGetPos())>, [FORCE_DIRECT_PATH, TRUE]);
            }
            else if (type == 3)
            {
                llOwnerSay("Goal not on navmesh!");
            }
            else if (type == 4)
            {
                llOwnerSay("Goal unreachable!");
            }
            else if (type == 5)
            {
                llOwnerSay("Target gone!");
            }
            else if (type == 6)
            {
                llOwnerSay("No place to go!");
            }
            else if (type == 7)
            {
                llOwnerSay("Hiding from pursuer...");
            }
            else if (type == 8)
            {
                llOwnerSay("Switched from hiding to running...");
            }
            else if (type == 9)
            {
                llOwnerSay("Region has no nav mesh..");
            }
            else if (type == 1000000)
            {
                llOwnerSay("Hit an unspecified failure");
            }
            else
            {
                llOwnerSay("Unknown failure");
            }
            */
        }
    }

  5. // REQUIRED TO RUN
    // 1. Requires the script on the post "Pathfinding - Useful Scripts - Prim Character Animation Script" in Content - This script controls ath other script - sending it stand, left, and right (linked messages).


    float update_rate = 1.0;
    integer stand_delay = 10;

    integer flag; // alternates left and right steps and prevents message backlog

    default
    {
       state_entry()
       {
           llSetTimerEvent(update_rate);  // gen event every arg seconds
       }
       timer()
       {
            if (llVecMag(llGetVel()) > .001)
            { //We're moving...
                if (flag++ %2 == 0)
                    llMessageLinked(LINK_SET,1,"left",""); // step L
                else
                    llMessageLinked(LINK_SET,1,"right","");   // step R
            }
            else
                if (flag++ % stand_delay == 0) //wait 10 seconds between
                     llMessageLinked(LINK_SET,1, "stand",""); // stand still
            if (flag > 86400)
                flag = 0; // reset flag to prevent overflow error
       }
    }

  6. // REQUIRED TO RUN
    // 1. Check the MONO checkbox - Open this script after you put it in your character's Content tab... and check the MONO checkbox. Very Important!
    // 2. To automatically animate the character, this script requires the control script (see next posting called Pathfinding - Useful Scripts - Animation Controller). That other script sends this script commands (stand, left, right) to perform animations.
    // KEY PARAMETERS = NONE - Just drop it in Content and Start Animating!

    // Script Name: Super_Prim_Animator_using_one_script.lsl
    //You can now animate any object, with just one script!  Setup is very simple. Just drop the script and a blank notecard into the object, click the object, and give your animation a name.  Move all the prims around, and click Record. When done, click the Animation Name, and watch it play back every move!

    // Downloaded from : http://www.free-lsl-scripts.com/cgi/freescripts.plx?ID=1519

    // This program is free software; you can redistribute it and/or modify it.
    // Additional Licenes may apply that prevent you from selling this code
    // and these licenses may require you to publish any changes you make on request.
    //
    // There are literally thousands of hours of work in these scripts. Please respect
    // the creators wishes and follow their license requirements.
    //
    // Any License information included herein must be included in any script you give out or use.
    // Licenses are included in the script or comments by the original author, in which case
    // the authors license must be followed.

    // A GNU license, if attached by the author, means the original code must be FREE.
    // Modifications can be made and products sold with the scripts in them.
    // You cannot attach a license to make this GNU License
    // more or less restrictive.  see http://www.gnu.org/copyleft/gpl.html

    // Creative Commons licenses apply to all scripts from the Second Life
    // wiki and script library and are Copyrighted by Linden Lab. See
    // http://creativecommons.org/licenses/

    // Please leave any author credits and headers intact in any script you use or publish.
    // If you don't like these restrictions, then don't use these scripts.
    //////////////////////// ORIGINAL AUTHORS CODE BEGINS ////////////////////////////////////////////
    // One Script Prim Animation

    // Original Script by: Ferd Frederix
    // No Spam version by: Gino Rascon

    integer runtime = FALSE; // set to TRUE after making the notecard
     
    string NOTECARD = "Movement";   // the notecard for this script, you can add more than 1 script and notecard, just change this line to match
    integer playchannel = 1;    // the playback channel, this is the channel you use in LinkMessages
     
            
    integer debug = FALSE;          // if set to TRUE, debug info appears


    // notecard reading
    string priorname;               // the prior animation name so we can spot differences as we read them in
    integer iIndexLines;            // lines in a card
    integer inotecardIndex = 0;     // notecard counter;
    integer move = 0;               // N movements rea from the notecard

    key kNoteCardLines;             // the key of the notecard
    key kGetIndexLines;             // the key of the current line

    //communications
    integer dialogchannel ;         // dialog boxes

    integer nPrims;                 // total number of prims
    integer PrimsCounter = 0;       // how many have checked in
    integer timercounter = 0;       // how many seconds have gone by
    integer wantname;               // flag indicating we are waiting for a name to be chatted
     

    // the list of coords
    list masterlist;        // master list of all positions
    list llastPrimList;      // storage of the last prim position we learned
    string curranimation;   // what we are playing

    integer STRIDE = 5;     // size of the master list
    integer lastSTRIDE = 4; // size of the last prim list

    integer listener;       // temp listener when we are waiting for them to give us a name

    vector InitSize;        // the initial size when the prims were recorded
    list LoadedAnims;       // animations read from the notecard added to the Menu display

    // in case of hand editing, we wupe out extra stuff at end
    string Getline(list Input, integer line)
    {
        return llStringTrim(llList2String(Input, line),STRING_TRIM);
    }

    Record()
    {
        if (llStringLength(curranimation) > 0)
        {
            integer foundmovement = 0;      // will be set if any child moved
            integer PrimCounter ;        // skip past the root prim
            for (PrimCounter =2; PrimCounter <= nPrims; PrimCounter++ )
            {
                list my_list = llGetLinkPrimitiveParams(PrimCounter,[PRIM_POSITION,PRIM_ROTATION, PRIM_SIZE ]);
                // position is always in region coordinates, even if the prim is a child or the root prim of an attachment.
                // rot is always the global rotation, even if the prim is a child or the root prim of an attachment.                 
                
                // get current prim pos, rot and size
                vector      vrealPrimPos    = llList2Vector (my_list,0) - llGetPos();   // position subtract Global Pos
                vrealPrimPos /= llGetRot();
                rotation    rrealPrimRot    = llList2Rot    (my_list,1) / llGetRot();   // rotation subtract Global Rot
                vector      vrealPrimSize   = llList2Vector (my_list,2);                 // size  
                
                // compare it to the last one we had, stride of list is a 4, and it is already sorted
                integer iindex = (PrimCounter - 2) * lastSTRIDE;    // zeroth position is PrimCounter - start, or 2
                
                // get the last thing we remembered about this prim
                float       fprimNum        = llList2Integer    (llastPrimList, iindex);    // must be 0,1,2, in order
                vector      vlastPrimPos    = llList2Vector     (llastPrimList, iindex+1);
                rotation    rlastPrimRot    = llList2Rot        (llastPrimList, iindex+2);
                vector      vlastPrimSize   = llList2Vector     (llastPrimList, iindex+3);
                    
                // if anything changed on this prim, we must record it.
                if (vlastPrimPos != vrealPrimPos ||
                    rlastPrimRot != rrealPrimRot ||
                    vlastPrimSize!= vrealPrimSize  
                )
                {                        
                    foundmovement++;
                    
                    // show owner any changes they mnade
                    if (debug)    
                    {
                        llOwnerSay("prim:" + (string) PrimCounter);
                    
                        if (vlastPrimPos != vrealPrimPos)
                            llOwnerSay("pos delta :" + (string) (vrealPrimPos - vlastPrimPos));
                            
                        if (rlastPrimRot != rrealPrimRot)
                            llOwnerSay("rot delta:" + (string) (llRot2Euler (rrealPrimRot - rlastPrimRot) * RAD_TO_DEG));                   
                            
                        if (vlastPrimSize != vrealPrimSize)
                            llOwnerSay("size delta:" + (string) (vrealPrimSize - vlastPrimSize));
                    }
                    
                    //Save them in the master list of all animations
                    masterlist += curranimation;
                    masterlist += PrimCounter;
                    masterlist += vrealPrimPos;
                    masterlist += rrealPrimRot;
                    masterlist += vrealPrimSize;
                  
                    // save them in the last movement list
                    integer saved = FALSE;
                    integer i;
                    integer imax = llGetListLength(llastPrimList);
                    // save the changes in the last prim list so we can keep our lists smaller
                    for ( i=0; i < imax; i += lastSTRIDE )
                    {
                        if (llList2Float(llastPrimList,i) == PrimCounter)
                        {
                            llastPrimList = llListReplaceList(llastPrimList,[vrealPrimPos],i+1,i+1);
                            llastPrimList = llListReplaceList(llastPrimList,[rrealPrimRot],i+2,i+2);
                            llastPrimList = llListReplaceList(llastPrimList,[vrealPrimSize],i+3,i+3);
                            if (debug) llOwnerSay("In history at position " + (string) (i/lastSTRIDE));
                            saved++;
                        }
                    }
                    
                    // never moved before?  add it then
                    if (! saved)
                    {
                        if (debug) llOwnerSay("Someone added a new prim and then clicked Record");
                        llastPrimList += PrimCounter;
                        llastPrimList += vrealPrimPos;
                        llastPrimList += rrealPrimRot;
                        llastPrimList += vrealPrimSize;
                    }    
                } // if
            } // for
            if (debug)    llOwnerSay("history:" + llDumpList2String(llastPrimList,":"));                   
            
            if (!foundmovement)
                llOwnerSay("You must move at least one child prim.");
        }         
        else
        {
            llOwnerSay("You must name your animation.");
            llOwnerSay("Type the new animation name on channel /" + (string) dialogchannel);
            wantname++;
        }
    }

    // on reset, record the base position in history so we can see changes
    Clear()
    {
        LoadedAnims = [];           // wipe out Menu
        masterlist = [];            // wipe all recordings
        llastPrimList = [];         // wipe last animations
        integer PrimCounter ;       // skip 1, which is the root prim
        integer counter = 0;
        // save all the current settings in memory
        for (PrimCounter=2; PrimCounter <= nPrims; PrimCounter++ )
        {
            list my_list = llGetLinkPrimitiveParams(PrimCounter,[PRIM_POSITION,PRIM_ROTATION, PRIM_SIZE ]);
            
            // save the local  pos and rot, since llGetLinkPrimitiveParams returns global pos and rot
            vector primpos      = llList2Vector (my_list,0) - llGetPos();
            rotation primrot    = llList2Rot    (my_list,1) / llGetRot();
            vector primsize     = llList2Vector (my_list,2) ;
            
            llastPrimList += PrimCounter;
            llastPrimList += primpos;
            llastPrimList += primrot;
            llastPrimList += primsize;
            counter++;
        }
        if(debug) llOwnerSay("Saved " + (string) counter + " prims initial position in history");
    }

    DumpBack ()
    {
        integer i;
        integer imax = llGetListLength(masterlist);
        integer howmany = imax / STRIDE ;
        llOwnerSay((string) howmany + " movements recorded - copy these and paste them into the notecard");
        
        integer flag = 0;
        for (i = 0; i < imax; i+= STRIDE)
        {
            if ( i == 0 )
                 llOwnerSay( "|start|" + (string) llGetScale());
                 
            string saniName = llList2String(masterlist,i);
            curranimation = saniName;

            float fprimNum = llList2Integer(masterlist,     i+1);
            integer iprimNum = (integer) fprimNum;
            vector  vprimPos  = llList2Vector(masterlist,   i+2);
            rotation rprimRot = llList2Rot(masterlist,      i+3) ;
            vector  vprimSize  = llList2Vector(masterlist,  i+4);

            llOwnerSay("|"+ saniName + "|" + (string) iprimNum + "|" + (string) vprimPos + "|" + (string) rprimRot + "|" + (string) vprimSize );
            flag++;
        }
        if (! flag)
            llOwnerSay("No recording was made, nothing to play back." );
    }


    rotation calcChildRot(rotation rdeltaRot)
    {
        
        if (llGetAttached())
            return rdeltaRot/llGetLocalRot();
        else
            return rdeltaRot/llGetRootRotation();
       
    }


    PlayBack (string name)
    {
        integer i;
        integer imax = llGetListLength(masterlist);

        integer linknum = 0;

        for (i = 0; i < imax; i+= STRIDE)
        {
            string saniName = llList2String(masterlist,i);
            if (saniName == name)
            {
                float fprimNum      = llList2Float(masterlist,i+1);
                vector  vPos    = llList2Vector(masterlist,i+2);
                rotation rRot = llList2Rot(masterlist,i+3) ;
                vector vprimSize    = llList2Vector(masterlist,i+4) ;
                
                vector scale = llGetScale();
                float delta =  scale.x / InitSize.x ;   // see if the root prim has grown or shrunk as a percentage      
                
                vPos *= delta;                           // add any difference in size to it positions there
                vprimSize *= delta;                      // grow the child prim, too
                
            
                // support negative prim numbers as a delay
                if (fprimNum < 0)
                {
                    if (debug) llOwnerSay("Sleeping " + (string) (fprimNum * -1));
                    llSleep((float) fprimNum * -1);
                }
                else
                {            
                    if (fprimNum > 1 )
                    {
                        // set the local pos and locat rot to the prims orientation and position
                        rRot  = calcChildRot(rRot);
            
                        list actions = [PRIM_POSITION,vPos,PRIM_ROTATION,rRot,PRIM_SIZE,vprimSize];
                        if (debug) llOwnerSay("Moving prim :" + (string) fprimNum + ":" + llDumpList2String(actions,":"));
                    
                        llSetLinkPrimitiveParamsFast((integer) fprimNum,actions);
                    }
                }
            }
        }
    }

    MakeMenu()
    {
        list amenu = ["Reset","Record","Help","Name","Notecard","Pause"] + LoadedAnims;

        llListenRemove(listener);
        listener = llListen(dialogchannel,"","","");
        
        amenu = llDeleteSubList(amenu,12,99);
        
        llDialog(llGetOwner(), "Pick a command",amenu,dialogchannel);
    }



    default
    {
        state_entry()
        {
            InitSize = llGetScale();            // save the size  when we recorded the prims
            nPrims = llGetNumberOfPrims();      // how many we are recording
            if (debug) llOwnerSay(" Total Prims = " + (string) nPrims);
            Clear();                            
            
            string notecardname = llGetInventoryName(INVENTORY_NOTECARD,0);
            
            if (llStringLength(notecardname) > 0)
            {
                kNoteCardLines = llGetNumberOfNotecardLines(NOTECARD);
                kGetIndexLines = llGetNotecardLine(NOTECARD,0);
            }
            else
            {
                llOwnerSay("If you add a notecard, you can save your animations permanently in a notecard named " + NOTECARD);
            }
            dialogchannel = (integer) (llFrand(100) +600);
            
        }

        // read notecard on bootup
        dataserver(key queryid, string data)
        {
            if (queryid == kNoteCardLines)
            {
                iIndexLines = (integer) data;
            }

            if (queryid == kGetIndexLines)
            {
                if (data != EOF)
                {
                    queryid = llGetNotecardLine(NOTECARD, inotecardIndex);
                    list lLine = (llParseString2List(data, ["|"], []));
                    
                    string junk = llList2String(lLine,0);
                    string aniname = llList2String(lLine,1);
                    string aNum = (string) Getline(lLine,2);
                    
                    // check for the prim size,and save it, the fiorst line will look like this:
                    // [18:06]  prim position 1.2: |start|<1.02306, 1.02306, 1.02306>
                    
                    if (inotecardIndex == 0 && aniname == "start")
                    {
                        InitSize = (vector) aNum;
                    }
                    else if (inotecardIndex == 0 && aniname != "start")
                    {
                        llOwnerSay("The notecard " + NOTECARD  + " is incorrect, it must begin with 'start|<x,y,z>' with the size of the original prim");
                    }
                    else
                    {
                    
                        float Num = (float) aNum;
                        
                        vector vPos = (vector) Getline(lLine,3);          // global for calcChild()
                        rotation rRot = (rotation) Getline(lLine,4);        // global for calcChild()
                        vector Size  = (vector) Getline(lLine,5);
                        
                        vector scale = llGetScale();
                        float delta =  scale.x / InitSize.x ;   // see if the root prim has grown or shrunk as a percentage      
                
                        
                        if (aniname != priorname)
                        {
                            llOwnerSay("Loading animation " + aniname);
                            priorname = aniname;
                            LoadedAnims += aniname;
                        }
        
                        if(Num != 1)        // skip root prim
                        {
                            masterlist += [aniname];
                            masterlist += [Num];
                            masterlist += [vPos];
                            masterlist += [rRot];
                            masterlist += ;
        
                            if (Num > 1)  // not the pauses
                            {
                                rRot = calcChildRot(rRot);
                                vPos *= delta;                           // add any difference in size to it positions there
                                Size *= delta;                          // grow the child prim, too
        
                                llSetLinkPrimitiveParamsFast((integer) Num,[PRIM_POSITION,vPos,PRIM_ROTATION,rRot,PRIM_SIZE,Size]);
                                move++;
                            }
                            
                        }
                    }
                    inotecardIndex++;
                    integer     InitPerCent = (integer) llRound(( (inotecardIndex+1) / (float) iIndexLines) * 100);
                    llSetText("Initialising... \n" + (string) InitPerCent + "%" , <1,1,1>, 1.0);
                    if (InitPerCent >= 100)
                        llSetText(""  , <1,1,1>, 1.0);
                    kGetIndexLines = llGetNotecardLine(NOTECARD,inotecardIndex);
                    
                }
                else
                {
                    llOwnerSay("initialized with " + (string) move + " movements");
                    llSetText(""  , <1,1,1>, 1.0);
                }
            }
        }


        touch_start(integer total_number)
        {
            if (llDetectedKey(0) == llGetOwner() && ! runtime)
            {
                MakeMenu();
            }
            
            // add any control code here
            // example:
            // llMessageLinked(LINK_SET,playchannel,"All","");  // will play Animation named "All"
            
        }

        listen( integer channel, string name, key id, string message )
        {

            if (channel == dialogchannel)
            {
                if (message == "Reset")
                {
                    Clear();
                    if (debug)    llOwnerSay("Reset = " + llDumpList2String(llastPrimList,":"));
                    MakeMenu();
                }
                else if (message =="Pause")
                {
                    masterlist += curranimation;
                    masterlist += -1;
                    masterlist += <0,0,0>;  // pos
                    masterlist += <0,0,0,1>;// rot
                    masterlist += <0,0,0>;  // size
                    MakeMenu();
                }
                else if (message == "Record")
                {
                    Record();
                    
                    MakeMenu();
                }
                else if (message == "Name")
                {
                    llOwnerSay("Type the current animation name on channel /" + (string) dialogchannel);
                    wantname++;
                    MakeMenu();
                }
                else if (message =="Menu")
                {
                    MakeMenu();
                }
                else if (message == "Notecard")
                {
                    DumpBack();
                    MakeMenu();
                }
                else if (message == "Help")
                {
                    llLoadURL(llGetOwner(),"View online help", "http://secondlife.mitsi.com/secondlife/Posts/Prim-Animator");
                }
                else if (wantname)
                {
                    curranimation = message;
                
                    LoadedAnims += message;
                    
                    MakeMenu();
                    llOwnerSay("Recording is ready for animation '" + curranimation + "'");
                    llOwnerSay("Position all child  prims, then select the Menu item 'Record', and repeat as necessary. When finished, click 'PlayBack' to play back the animation, or click the animation name.  Click 'Name' to start a new animation sequence");
                    wantname = 0;
                    PrimsCounter = 0;
                    timercounter  = 0;
                    llSetTimerEvent(1.0);
                }
                else
                {
                    if (llListFindList(LoadedAnims,[message]) != -1)
                    {
                        PlayBack(message);
                        MakeMenu();
                    }
                }
                    
                    
            }
        }

        

        link_message(integer sender_num, integer num, string message, key id)
        {
            if (num == playchannel)
            {
                if (debug) llOwnerSay("playback animation " + message);
                PlayBack(message);
            }
        }


        

    }

  7. //This is a script that contains many Pathfinding functions which can be invoked by user commands.

    //Use channel 20 to invoke Pathfinding behaviors.

    //For example: /20 follow       // Invokes the Pursue Behavior

    // For example /20 reset        // Resets the script.

    // For example /20 auto         // Selects random avatars to pursue, then switches to wander behaviors randomly on timer.


    // listen
    integer CMDCHANNEL=20;
    integer SQUEEK_CHANNEL=77665544;

    vector  WANDER_POINT = <61,195,25>;
    float   WANDER_RADIUS = 20;
    float   EVADE_TIMEOUT = 30;           // time to try to hide, until pursue again
    float   PURSUE_TIMEOUT = 30;          // time to pursue until loking for new target
    integer PURSUE_LEAVE_ALONE_COUNT = 3; // max number of timeouts to pursue one agent
    float   WANDER_FIND_TARGET_INTERVAL=10;

    list pathUpdateLegend=[0,"Near", 1,"Stopping",
      2, "Cannot path find from current location!",
      3, "Goal not on navmesh!", 4, "Goal unreachable!", 5, "Target gone!",
      6, "No place to go!", 7, "Hiding from pursuer...",  8, "Switched from hiding to running...",
      9, "Region has no nav mesh.." , 0xF4240,  "Hit an unspecified failure"];

    integer PURSUE=1;
    integer EVADE=2;
    integer WANDER=4;
    integer FIND_AGENT=8;
    integer GET_CLOSE=16;

    integer gMyState;
    key     gTargetKey;
    integer gPursueCount;

    find_target() {
        llSensor("",NULL_KEY, AGENT, 40.0, PI);
    }

    start_wander() {
        gMyState=WANDER;
        llWanderWithin(WANDER_POINT,<WANDER_RADIUS,WANDER_RADIUS,1.0>,[]);
        llSetLinkPrimitiveParamsFast(2,[ PRIM_TEXT, "Wander at" + (string)WANDER_POINT + "\nRadius  " + (string)WANDER_RADIUS,<1,1,1>,1]);
        llSetTimerEvent(WANDER_FIND_TARGET_INTERVAL);
    }

    start_pursue(key id) {
        gTargetKey = id;
        llPursue(gTargetKey,[PURSUIT_OFFSET, <1,0,0>, PURSUIT_FUZZ_FACTOR, 1.0]);
        llSetLinkPrimitiveParamsFast(2,[ PRIM_TEXT, "Pursue " + llKey2Name(id),<1,1,1>,1]);
        llSetTimerEvent(PURSUE_TIMEOUT);
        gMyState = PURSUE;
        gPursueCount=1;
    }

    start_evade(key id) {
        llEvade(id,[]);
        llSetLinkPrimitiveParamsFast(2,[ PRIM_TEXT, "Evading " + llKey2Name(id),<1,1,1>,1]);
        gMyState=EVADE;
        llSetTimerEvent(EVADE_TIMEOUT);
    }
        
    create_character() {
        llCreateCharacter([CHARACTER_DESIRED_SPEED, 3.2, CHARACTER_RADIUS, 0.2, CHARACTER_LENGTH, 0.5]);
    }

    fly_home_and_wander() {
        llDeleteCharacter();
        llSetRegionPos(WANDER_POINT);
        create_character();
        start_wander();
    }

    default
    {
        state_entry()
        {
            llListen(CMDCHANNEL,"",llGetOwner(),"");
            llListen(SQUEEK_CHANNEL,"","","");
            llDeleteCharacter();
            create_character();
            llOwnerSay("created character");
            llSetLinkPrimitiveParamsFast(2,[ PRIM_TEXT, "Ready",<1,1,1>,1]);
            WANDER_POINT = llGetPos();
        }
        
        on_rez(integer p)
        {
            llResetScript();   
        }
        
        changed( integer ch )
        {
            if (ch & CHANGED_OWNER) {
                llResetScript();
            }
        }
        
        link_message(integer sender_num, integer num, string str, key id)
        {
            // llMessageLinked(LINK_THIS,NUM,strind_data,key_data);
        }

        listen( integer channel, string name, key id, string message)
        {
            if (channel==CMDCHANNEL) {
                list    argv=llParseString2List(message,[" "],[]);
                integer argc=llGetListLength(argv);
                string  cmd=llList2String(argv,0);
                if (cmd=="go") {
                    float X=(float)llList2String(argv,1);
                    float Y=(float)llList2String(argv,2);
                    float Z=(float)llList2String(argv,3);
                    vector dest=<X,Y,Z>;
                    if (dest==<0,0,0>) {
                        llOwnerSay("Bad coords");
                    }else{
                        integer direct = FALSE;
                        if (llList2String(argv,4)=="!") {
                            direct=TRUE;
                        }
                        llNavigateTo(dest,[FORCE_DIRECT_PATH, direct]);
                        llSetLinkPrimitiveParamsFast(2,[ PRIM_TEXT, "NavigateTo " + (string)dest + "\nDIRECT: " + (string)direct,<1,1,1>,1]);
                    }
                }else if (cmd=="come") {
                    llDeleteCharacter();
                    list L=llGetObjectDetails(id,[OBJECT_POS,OBJECT_ROT]);
                    llSetRegionPos(llList2Vector(L,0) + <2,0,0>*llList2Rot(L,1));
                    create_character();
                }else if (cmd=="jump") {
                    float X=(float)llList2String(argv,1);
                    float Y=(float)llList2String(argv,2);
                    float Z=(float)llList2String(argv,3);
                    vector p=llGetPos();
                    vector d=<X,Y,Z>;
                    llSetRegionPos(p+d);
                    llOwnerSay("Jumped from " + (string)p  + " by "  + (string)<X,Y,Z> + "  to " + (string)llGetPos());
                }else if (cmd=="follow") {
                    llPursue(id,[PURSUIT_OFFSET, <1,0,0>, PURSUIT_FUZZ_FACTOR, 1.0]);
                    llSetLinkPrimitiveParamsFast(2,[ PRIM_TEXT, "Pursue " + name,<1,1,1>,1]);
                }else if (cmd=="wander") {
                    float X=(float)llList2String(argv,1);
                    if (X==0) {
                        llOwnerSay("wander X Y Z radius"); return;
                    }
                    float Y=(float)llList2String(argv,2);
                    float Z=(float)llList2String(argv,3);
                    vector dest=<X,Y,Z>;
                    float R=(float)llList2String(argv,4);
                    llWanderWithin(dest,<R,R,1.0>,[]);
                    llSetLinkPrimitiveParamsFast(2,[ PRIM_TEXT, "Wander at" + (string)dest + "\nRadius  " + (string)R,<1,1,1>,1]);
                }else if (cmd=="reset") {
                    llResetScript();
                }else if (cmd=="stop") {
                    llSetTimerEvent(0);
                    llDeleteCharacter();
                    llOwnerSay("deleted character");
                    llSetLinkPrimitiveParamsFast(2,[ PRIM_TEXT, "Stopped",<1,1,1>,1]);                
                }else if (cmd=="mini") {
                    llUpdateCharacter([CHARACTER_RADIUS, 0.125, CHARACTER_LENGTH, 0.35]);
                }else if (cmd=="normal") {
                    llUpdateCharacter([CHARACTER_RADIUS, 0.2, CHARACTER_LENGTH, 0.5]);
                }else if (cmd=="auto") {
                    find_target();
                }   
            }else if (channel==SQUEEK_CHANNEL) {
                list argv=llParseString2List(message,["|"],[]);
                string cmd=llList2String(argv,0);
                string id=(key)llList2String(argv,1);
                if (cmd=="evade") {
                    if (TRUE || gTargetKey == id) {
                        start_evade(id);
                    }
                }else if (cmd=="pursue") {
                    if (TRUE || gMyState==WANDER) {
                        start_pursue(id);
                    }
                }
            }

        }
        
        path_update( integer type, list reserved )
        {
            integer  J=llListFindList(pathUpdateLegend, [type]);
            string msg="Unknown path update type!";
            if (J>-1)  msg=llList2String(pathUpdateLegend, J+1);
            llRegionSay(SQUEEK_CHANNEL,"path_update: " + msg + "  (" + (string)type + ")");
                
            if (llListFindList([2, 3, 4],[type])>-1) {
                if (gMyState==GET_CLOSE) {
                    // failed
                    fly_home_and_wander();
                    return;
                }
                vector p=llList2Vector(llGetObjectDetails(gTargetKey,[OBJECT_POS]),0);
                list L=llGetClosestNavPoint(p,[]);
                string txt="No closest point found";
                vector t;
                if (llGetListLength(L)>0) {
                    t=llList2Vector(L,0);
                    txt="Closest navmesh at: " + (string)t + " Target at: "+ (string)p;
                    gMyState=GET_CLOSE;
                    llNavigateTo(t,[]);
                }
                llRegionSay(SQUEEK_CHANNEL, txt );
                return;
            }
            if ( (type>=0x02 && type <=0x06) || (type == PU_FAILURE_OTHER) ) {
                llOwnerSay("path_update: " + (string)type);
                fly_home_and_wander();
            }
        }
        
        touch_start(integer p) {
            if (llDetectedKey(0)==gTargetKey) {
                // panic
                start_evade(gTargetKey);
                llRegionSay(SQUEEK_CHANNEL, "evade|" + (string)gTargetKey);
            }
        }

        sensor(integer num)
        {
            if (gMyState!=PURSUE) {
                start_pursue(llDetectedKey(0));
                llRegionSay(SQUEEK_CHANNEL, "pursue|" + (string)llDetectedKey(0) + "|" + llDetectedName(0));
            }else{
                // find someone else to stalk
                llRegionSay(SQUEEK_CHANNEL,"Looking for new target...");
                integer i;
                for(i=0;i<num;i++) {
                    if (llDetectedKey(i)!=gTargetKey) {
                        start_pursue(llDetectedKey(i));
                        llRegionSay(SQUEEK_CHANNEL, "pursue|" + (string)llDetectedKey(i) + "|" + llDetectedName(i));
                        return;
                    }
                }
                if (gPursueCount > PURSUE_LEAVE_ALONE_COUNT) {
                    start_wander();
                    llRegionSay(SQUEEK_CHANNEL, "Leaving target, wandering...");
                }else{
                    llSetTimerEvent(PURSUE_TIMEOUT);
                    gPursueCount++;
                }
            }
        }
        
        no_sensor() {
            start_wander();
            llRegionSay(SQUEEK_CHANNEL, "Can't find anyone, wandering...");
        }
            
        collision_start(integer num) {
            if (llDetectedKey(0)==gTargetKey) {
                // panic
                start_evade(gTargetKey);
                llRegionSay(SQUEEK_CHANNEL, "evade|" + (string)gTargetKey);
            }
        }
            
        timer()
        {
            llSetTimerEvent(0);
            if (gMyState==EVADE) {
                find_target();
            }else if (gMyState==WANDER) {
                find_target();
            }else if (gMyState==PURSUE) {
                find_target();
            }
        }

    }

×
×
  • Create New...