Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Follow me Script
#4
Code:
// :CATEGORY:OpenSim NPC
// :NAME: NPC_Follower.lsl
// :AUTHOR:Ferd Frederix
// :REV:1.0
// :WORLD:OpenSim
// :DESCRIPTION:
//  This is a NPC follower.
// License: http://creativecommons.org/licenses/by-nc
// :CODE:  
    
// tunables
float max_distance = 70; //distance for sensoring a real avatar
string fName = "Max";
string lName = "Muster";

float gTimer;
// stuff
integer iWaitCounter = 60;
integer channel; // dialog channel
integer listener; // holds the listener handle;
key npc;    // npc key
integer npc_on = FALSE;
vector Dest;
string lastAnim;
  
Play(string anima)
{
    if (anima == lastAnim)
        return;
  
    if (anima == "Stehen9" && llFrand(5) < 1)
    {
        anima = "Redeanimation";  
        gTimer = llFrand(5) + 4;
    }
    else
    {
        gTimer = llFrand(5) + 1;
    }
    
    osNpcPlayAnimation(npc,anima);
    osNpcStopAnimation(npc,lastAnim);
    lastAnim = anima;
}

Sound()
{
    if (llFrand(2) > 0.5)
        return;
        
    integer n = llGetInventoryNumber(INVENTORY_SOUND);
    integer n2 = llCeil(llFrand(n));

    string name = llGetInventoryName(INVENTORY_SOUND,n2);
    llTriggerSound(name,1.0);
}


walk_to_master(vector myPos)
{
    vector myVector = <randBetween(-2,2),randBetween(-2,2),myPos.z> ;
    myPos.z = 0;

    iWaitCounter = 60;
    Play("gehenauswaehlen");
    osNpcMoveToTarget(npc, myPos + myVector, OS_NPC_NO_FLY );
    llSetTimerEvent(0.5);
    Sound();
}

float randBetween(float min, float max)
{
    return llFrand(max - min) + min ;
}
dialog(key avi)
{
    channel = llCeil(llFrand(5000) + 5000);
    listener = llListen(channel,"","","");
    llDialog(avi, "Choose:",["Start","Entfernen","Aussehen"],channel);
}
Start()
{
    vector npcPos = llGetPos() + <1.0,1.0,1.0>;
    npc = osNpcCreate(fName,lName, npcPos, "Aussehen");
    llSetObjectDesc(npc);
    npc_on = TRUE;
    llSensor("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI);  
}

default
{
    
    state_entry()
    {
        llSay(0,"NPC Bereit");
        gTimer = llFrand(2) + 1;
        osNpcRemove(llGetObjectDesc());

    }
    
    changed (integer what)
    {
        if (what & CHANGED_REGION_START)
        {
            if (npc_on)
            {
                Start();
            }
        }
    }
    
    on_rez(integer p)
    {
        llResetScript();
    }
    
    touch_start(integer x)
    {
        //if (llDetectedKey(0) == llGetOwner())  {
            dialog(llDetectedKey(0));
        //}
    }
    
    listen(integer channel, string name, key id, string msg) {
        llListenRemove (listener);
        if (msg == "Start")
        {
            if( !npc_on ) {
               Start();
            } else {
                llOwnerSay("Bereits gestartet!");
            }
        } else if (msg == "Entfernen")  {
            npc_on = FALSE;
            osNpcRemove(llGetObjectDesc());
            llSetTimerEvent(0);
        } else if (msg ==  "Aussehen") {
            osAgentSaveAppearance(llGetOwner(), "Aussehen");
            llOwnerSay("Aussehen wurde gespeichert!");
        }
    
    }

    sensor(integer num)
    {
        Dest = llDetectedPos( 0 );
        walk_to_master(Dest);
    }
    
    no_sensor()
    {
         Play("Redeanimation");
         llSleep(10);
         llSensor("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI);
    }
  
    timer()
    {
        vector pos;
        if (--iWaitCounter)  {
          
            list Poses = llGetObjectDetails(npc,[OBJECT_POS]);
            pos = llList2Vector(Poses, 0);
            
            if (llVecDist(pos, Dest ) > 4) {
                return;
            }
        }
        
        if (llFrand(5) < 0.5) {
             if (llVecDist(pos, Dest ) <1) {
                Play("Victory");
                llTriggerSound("kitten4",1.0);
                llSleep(1.5);
            } else {
                Play("Redeanimation");
                llTriggerSound("kitten3",1.0);
                llSleep(1.5);
            }
            
            
        }
        
        Play("Stehen9");

        llSleep(gTimer);
        llSetTimerEvent(0);
        llSensor("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI);
        
    }
}
[Bild: attachment.php?aid=2586]


[-] The following 2 users say Thank You to Manfred Aabye for this post:
  • Anachron, Pius Noel
Zitieren


Nachrichten in diesem Thema
Follow me Script - von brenner23 - 25.11.2018, 19:16
RE: Follow me Script - von Pius Noel - 26.11.2018, 11:48
RE: Follow me Script - von brenner23 - 26.11.2018, 14:27
RE: Follow me Script - von Manfred Aabye - 29.11.2018, 23:05

Möglicherweise verwandte Themen...
Thema Verfasser Antworten Ansichten Letzter Beitrag
  HG Teleporting Script funktioniert nicht mehr Pharcide 15 5.221 13.07.2018, 19:09
Letzter Beitrag: Anachron
  Vector Script Kater 12 1.626 21.06.2018, 21:14
Letzter Beitrag: Kater
  Suche Script Gruppe Titoss 3 848 29.05.2018, 07:06
Letzter Beitrag: GamaTotchi Yoshikawa
  Suche Tür Script LadyContessa Barbosa 6 2.560 14.12.2017, 15:41
Letzter Beitrag: LadyContessa Barbosa
  Script: Objekt rezzen auf Befehl georgm76 4 2.624 27.08.2017, 03:46
Letzter Beitrag: Manfred Aabye

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste