updated bees for Inworldz
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
</Script>
|
||||
<Script name="Collision test.lsl" guid="9a7e990c-7f43-400f-b2a7-2e0311162d5a">
|
||||
</Script>
|
||||
<Script name="Listener for things that appear and disappear.lsl" guid="4ec868f0-b792-4fb1-bb0c-ef5747d20327">
|
||||
</Script>
|
||||
<Script name="Stop Processing.lsl" guid="1a220cc3-3120-4997-9d06-01f721ccda97">
|
||||
</Script>
|
||||
<Script name="Touch to Go.lsl" guid="1f188bfb-241f-410b-b29c-e81b8df22358">
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// :DESCRIPTION:
|
||||
// All in one NPC recorder player set of debug functions. Add these ONLY if you are compileing in LSLEditor.
|
||||
// :CODE:
|
||||
// IMPORTANT NOTE
|
||||
// IMPORTANT NOTE
|
||||
// DELETE ALL these lines out for Opensim, leave uncommented for testing in LSLEditor
|
||||
|
||||
integer OS_NPC_CREATOR_OWNED = 1;
|
||||
@@ -26,110 +26,110 @@ integer OS_NPC_FLY = 7;
|
||||
|
||||
|
||||
integer osIsNpc(key id){
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
osNpcStand(key npc) {
|
||||
llOwnerSay("Standing");
|
||||
llOwnerSay("Standing");
|
||||
}
|
||||
vector osNpcGetPos(key id) {
|
||||
vector vDestPos;
|
||||
vDestPos.x += llFrand(1.0); // some randomness for debugging
|
||||
llOwnerSay("Reached " + (string) vDestPos);
|
||||
return vDestPos;
|
||||
vector vDestPos;
|
||||
vDestPos.x += llFrand(1.0); // some randomness for debugging
|
||||
llOwnerSay("Reached " + (string) vDestPos);
|
||||
return vDestPos;
|
||||
}
|
||||
osNpcMoveToTarget(key npc, vector target, integer options){
|
||||
llSay(0,"Moving to " + (string) target);
|
||||
llSay(0,"Moving to " + (string) target);
|
||||
}
|
||||
key osNpcCreate(string firstname, string lastname, vector position, string cloneFrom, integer options) {
|
||||
llSay(0,"Creating NPC " + firstname + " " + lastname + " at " + (string) position);
|
||||
return (key) "12345000-0000-0000-0000-0000000000002";
|
||||
llSay(0,"Creating NPC " + firstname + " " + lastname + " at " + (string) position);
|
||||
return (key) "12345000-0000-0000-0000-0000000000002";
|
||||
}
|
||||
osNpcLoadAppearance(key npc, string notecard) {
|
||||
llSay(0,"Load notecard " + notecard);
|
||||
llSay(0,"Load notecard " + notecard);
|
||||
}
|
||||
osNpcPlayAnimation(key npc, string animation) {
|
||||
llSay(0,"Playing animation " + animation);
|
||||
llSay(0,"Playing animation " + animation);
|
||||
}
|
||||
osNpcStopAnimation(key npc, string animation) {
|
||||
llSay(0,"Stopped animation " + animation);
|
||||
llSay(0,"Stopped animation " + animation);
|
||||
}
|
||||
osNpcSay(key npc, integer iChannel, string message) {
|
||||
llSay(0,"Saying " + message);
|
||||
llSay(0,"Saying " + message);
|
||||
}
|
||||
osNpcWhisper(key npc, integer iChannel, string message) {
|
||||
llSay(0,"Whispering " + message);
|
||||
llSay(0,"Whispering " + message);
|
||||
}
|
||||
osNpcShout(key npc, integer iChannel, string message) {
|
||||
llSay(0,"Shouting " + message);
|
||||
llSay(0,"Shouting " + message);
|
||||
}
|
||||
osNpcSit(key npc, key target, integer options) {
|
||||
llSay(0,"Sat on " +target);
|
||||
llSay(0,"Sat on " +target);
|
||||
}
|
||||
osNpcSetRot(key npc, rotation rot) {
|
||||
llSay(0,"Set rotation of NPC to " + (string) rot);
|
||||
llSay(0,"Set rotation of NPC to " + (string) rot);
|
||||
}
|
||||
osOwnerSaveAppearance(string notecard) {
|
||||
llSay(0,"Created Notecard " + notecard);
|
||||
llSay(0,"Created Notecard " + notecard);
|
||||
}
|
||||
osAgentSaveAppearance(key avatar, string notecard) {
|
||||
llSay(0,"Created Notecard " + notecard);
|
||||
llSay(0,"Created Notecard " + notecard);
|
||||
}
|
||||
osNpcRemove (key target) {
|
||||
llSay(0,"NPC removed");
|
||||
llSay(0,"NPC removed");
|
||||
}
|
||||
list osGetAvatarList () {
|
||||
list lStuff = [(key) "12345000-0000-0000-0000-0000000000002", <1,2,3>, "Digit Gorilla"];
|
||||
return lStuff;
|
||||
list lStuff = [(key) "12345000-0000-0000-0000-0000000000002", <1,2,3>, "Digit Gorilla"];
|
||||
return lStuff;
|
||||
}
|
||||
osMakeNotecard(string notecardName, string contents) {
|
||||
llOwnerSay("Make Notecard " + notecardName + "Contents:" + (string) contents);
|
||||
llOwnerSay("Make Notecard " + notecardName + "Contents:" + (string) contents);
|
||||
}
|
||||
string osGetNotecard(string name) {
|
||||
// sample notecard for testing
|
||||
string str = "@spawn=Digit Gorilla|<645, 128, 25>\n"
|
||||
+ "@walk=<645, 120, 25>\n"
|
||||
+ "REPEAT\n"
|
||||
+ "@cmd=0|Hello on channel 0\n"
|
||||
+ "@wander=3|5\n"
|
||||
+ "@say=say , walking is so tiresome...\n"
|
||||
+ "@whisper=whisper, walking is so tiresome...\n"
|
||||
+ "@shout=shout, walking is so tiresome...\n"
|
||||
+ "@goto=REPEAT\n"
|
||||
+ "@goto=NEXT\n"
|
||||
+ "@say=i will never say this...\n"
|
||||
+ "NEXT\n"
|
||||
+ "@sound=somesound\n"
|
||||
+ "@randsound\n"
|
||||
+ "@pause=5\n"
|
||||
+ "@rotate=90\n"
|
||||
+ "@wander=3|1\n"
|
||||
+ "@say=Uff, I'm done...\n"
|
||||
+ "@delete\n";
|
||||
return str;
|
||||
// sample notecard for testing
|
||||
string str = "@spawn=Digit Gorilla|<645, 128, 25>\n"
|
||||
+ "@walk=<645, 120, 25>\n"
|
||||
+ "REPEAT\n"
|
||||
+ "@cmd=0|Hello on channel 0\n"
|
||||
+ "@wander=3|5\n"
|
||||
+ "@say=say , walking is so tiresome...\n"
|
||||
+ "@whisper=whisper, walking is so tiresome...\n"
|
||||
+ "@shout=shout, walking is so tiresome...\n"
|
||||
+ "@goto=REPEAT\n"
|
||||
+ "@goto=NEXT\n"
|
||||
+ "@say=i will never say this...\n"
|
||||
+ "NEXT\n"
|
||||
+ "@sound=somesound\n"
|
||||
+ "@randsound\n"
|
||||
+ "@pause=5\n"
|
||||
+ "@rotate=90\n"
|
||||
+ "@wander=3|1\n"
|
||||
+ "@say=Uff, I'm done...\n"
|
||||
+ "@delete\n";
|
||||
return str;
|
||||
}
|
||||
|
||||
osAvatarPlayAnimation(key npc, string animation){
|
||||
llSay(0,"playing " + animation);
|
||||
llSay(0,"playing " + animation);
|
||||
}
|
||||
|
||||
osAvatarStopAnimation(key npc, string animation){
|
||||
llSay(0,"Stopping " + animation);
|
||||
llSay(0,"Stopping " + animation);
|
||||
}
|
||||
|
||||
osForceOtherSit(key AvatarKey, key UUID) {
|
||||
llSay(0,"Sitting");
|
||||
llSay(0,"Sitting");
|
||||
}
|
||||
|
||||
|
||||
osSetSpeed(key NPC, float speed) {
|
||||
llSay(0,"Speed set to " + (string) speed);
|
||||
llSay(0,"Speed set to " + (string) speed);
|
||||
}
|
||||
|
||||
osNpcTouch(key NPC, key thing, integer where) {;}
|
||||
|
||||
osForceAttachToOtherAvatarFromInventory(key npc, string inventory, integer point) {
|
||||
llSay(0,"attach " + inventory + " to " + (string) point);
|
||||
llSay(0,"attach " + inventory + " to " + (string) point);
|
||||
}
|
||||
|
||||
osTeleportAgent( key avi, string name, vector dest, vector lookat) {;}
|
||||
@@ -137,4 +137,4 @@ osTeleportAgent( key avi, string name, vector dest, vector lookat) {;}
|
||||
// END commented code for OpenSim vs Editor environments
|
||||
//*******************************************************************//
|
||||
// comment this out, is only here for testing in LSLEditor.
|
||||
default {}
|
||||
default {}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,6 @@
|
||||
// :AUTHOR:Ferd Frederix
|
||||
// :KEYWORDS:
|
||||
// :CREATED:2015-07-17 13:15:19
|
||||
// :EDITED:2015-07-17 12:15:19
|
||||
// :ID:27
|
||||
// :NUM:1807
|
||||
// :REV:1
|
||||
@@ -15,13 +14,13 @@
|
||||
|
||||
default
|
||||
{
|
||||
state_entry() {
|
||||
llSetText("Type commands in chat to control the NPC, such as '@say=Hello'",<1,1,1>,1.0);
|
||||
llListen(0,"","","");
|
||||
}
|
||||
state_entry() {
|
||||
llSetText("Type commands in chat to control the NPC, such as '@say=Hello'",<1,1,1>,1.0);
|
||||
llListen(0,"","","");
|
||||
}
|
||||
|
||||
listen(integer channel, string name, key id, string message)
|
||||
{
|
||||
llMessageLinked(LINK_ROOT,0, message,"");
|
||||
}
|
||||
listen(integer channel, string name, key id, string message)
|
||||
{
|
||||
llMessageLinked(LINK_ROOT,0, message,"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
// :AUTHOR:Ferd Frederix
|
||||
// :KEYWORDS:
|
||||
// :CREATED:2015-07-17 13:15:49
|
||||
// :EDITED:2015-09-23 12:06:52
|
||||
// :ID:27
|
||||
// :NUM:1808
|
||||
// :REV:3
|
||||
@@ -15,33 +14,33 @@
|
||||
// rev 3: added on_rez() and STATUS_PHANTOM to state_entry - otherwise reset on Linux boxes did no collide any more.
|
||||
default
|
||||
{
|
||||
state_entry()
|
||||
{
|
||||
llSetStatus(STATUS_PHANTOM,FALSE);
|
||||
llVolumeDetect(FALSE);
|
||||
llSleep(0.1);
|
||||
llVolumeDetect(TRUE);
|
||||
}
|
||||
|
||||
collision_start(integer n) {
|
||||
llMessageLinked(LINK_SET,0, "@animate=someanimation|10","");
|
||||
llSetTimerEvent(5);
|
||||
}
|
||||
timer()
|
||||
{
|
||||
llMessageLinked(LINK_SET,0, "@animate=Stand|1","");
|
||||
llSetTimerEvent(0);
|
||||
}
|
||||
|
||||
changed(integer what)
|
||||
{
|
||||
if (what & CHANGED_REGION_START)
|
||||
{
|
||||
llResetScript();
|
||||
}
|
||||
}
|
||||
on_rez(integer p)
|
||||
{
|
||||
llResetScript();
|
||||
}
|
||||
state_entry()
|
||||
{
|
||||
llSetStatus(STATUS_PHANTOM,FALSE);
|
||||
llVolumeDetect(FALSE);
|
||||
llSleep(0.1);
|
||||
llVolumeDetect(TRUE);
|
||||
}
|
||||
|
||||
collision_start(integer n) {
|
||||
llMessageLinked(LINK_SET,0, "@animate=someanimation|10","");
|
||||
llSetTimerEvent(5);
|
||||
}
|
||||
timer()
|
||||
{
|
||||
llMessageLinked(LINK_SET,0, "@animate=Stand|1","");
|
||||
llSetTimerEvent(0);
|
||||
}
|
||||
|
||||
changed(integer what)
|
||||
{
|
||||
if (what & CHANGED_REGION_START)
|
||||
{
|
||||
llResetScript();
|
||||
}
|
||||
}
|
||||
on_rez(integer p)
|
||||
{
|
||||
llResetScript();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
// :AUTHOR:Ferd Frederix
|
||||
// :KEYWORDS:
|
||||
// :CREATED:2015-07-17 13:16:10
|
||||
// :EDITED:2015-07-17 12:16:10
|
||||
// :ID:27
|
||||
// :NUM:1809
|
||||
// :REV:1
|
||||
@@ -15,12 +14,12 @@
|
||||
|
||||
default
|
||||
{
|
||||
state_entry() {
|
||||
llSetText("Click to make the NPC stop processing commands",<1,1,1>,1.0);
|
||||
}
|
||||
state_entry() {
|
||||
llSetText("Click to make the NPC stop processing commands",<1,1,1>,1.0);
|
||||
}
|
||||
|
||||
touch_start(integer total_number)
|
||||
{
|
||||
llMessageLinked(LINK_ROOT,0, "@stop","");
|
||||
}
|
||||
touch_start(integer total_number)
|
||||
{
|
||||
llMessageLinked(LINK_ROOT,0, "@stop","");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,23 +4,22 @@
|
||||
// :AUTHOR:Ferd Frederix
|
||||
// :KEYWORDS:
|
||||
// :CREATED:2015-07-17 13:16:51
|
||||
// :EDITED:2015-07-17 12:16:51
|
||||
// :ID:27
|
||||
// :NUM:1811
|
||||
// :REV:1
|
||||
// :WORLD:Second Life
|
||||
// :WORLD:Opensim
|
||||
// :DESCRIPTION:
|
||||
// Sample touch to trigger a NPC script
|
||||
// :CODE:
|
||||
|
||||
default
|
||||
{
|
||||
state_entry() {
|
||||
llSetText("Click to make the NPC say hello",<1,1,1>,1.0);
|
||||
}
|
||||
state_entry() {
|
||||
llSetText("Click to make the NPC say hello",<1,1,1>,1.0);
|
||||
}
|
||||
|
||||
touch_start(integer total_number)
|
||||
{
|
||||
llMessageLinked(LINK_ROOT, 0, "@say=Hello there, " + llDetectedName(0), "");
|
||||
}
|
||||
touch_start(integer total_number)
|
||||
{
|
||||
llMessageLinked(LINK_ROOT, 0, "@say=Hello there, " + llDetectedName(0), "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,23 +4,22 @@
|
||||
// :AUTHOR:Ferd Frederix
|
||||
// :KEYWORDS:
|
||||
// :CREATED:2015-07-17 13:16:29
|
||||
// :EDITED:2015-07-17 12:16:29
|
||||
// :ID:27
|
||||
// :NUM:1810
|
||||
// :REV:1
|
||||
// :WORLD:Second Life
|
||||
// :WORLD:Opensim
|
||||
// :DESCRIPTION:
|
||||
// Sample touch to go script for all in one NPC animator
|
||||
// :CODE:
|
||||
|
||||
default
|
||||
{
|
||||
state_entry() {
|
||||
llSetText("Click to make the NPC continue processing commands",<1,1,1>,1.0);
|
||||
}
|
||||
state_entry() {
|
||||
llSetText("Click to make the NPC continue processing commands",<1,1,1>,1.0);
|
||||
}
|
||||
|
||||
touch_start(integer total_number)
|
||||
{
|
||||
llMessageLinked(LINK_ROOT,0, "@go","");
|
||||
}
|
||||
touch_start(integer total_number)
|
||||
{
|
||||
llMessageLinked(LINK_ROOT,0, "@go","");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,67 +1,68 @@
|
||||
// :SHOW:1
|
||||
// :CATEGORY:Flying Bee
|
||||
// :CATEGORY:Flying Bee
|
||||
// :NAME:Flying Bee and Hive
|
||||
// :AUTHOR:Ferd Frederix
|
||||
// :AUTHOR:Ferd Frederix
|
||||
// :KEYWORDS:
|
||||
// :CREATED:2013-09-08 12:59:45
|
||||
// :EDITED:2015-03-17 09:26:22
|
||||
// :CREATED:2013-09-08 12:59:45
|
||||
// :ID:995
|
||||
// :NUM:1725
|
||||
// :REV:4
|
||||
// :REV:5
|
||||
// :WORLD:Opensim, SecondLife
|
||||
// :DESCRIPTION:
|
||||
// A free flying bee that gathers pollen and takes it to his hive for either OpenSim or Second Life
|
||||
// :CODE:
|
||||
// Simple Bee script to locate and gather pollen from all prims named "Flower" then returns to the "Beehive"
|
||||
// Simple Bee script to locate and gather pollen from all prims named "Flower" then returns to the "Beehive"
|
||||
// Requires 2 sounds buzz1 and buzz2
|
||||
// !!!!!!!!!!!!!!
|
||||
// Mods by Donjr Spiegelblatt for Opensim to remove chance of thread locking on 3/7/2015
|
||||
// Thank YOU very much, DonJr !
|
||||
// 03-17-2015 fixed up a problem reported by DonJr where the bees visited to flowers in the wrong sequence.
|
||||
|
||||
// Note: For Opensim, make sure to set the prim to PHYSICS type = NONE manually
|
||||
|
||||
// Note: For Opensim, make sure to set the prim to PHYSICS type = NONE manually
|
||||
//======================================================================
|
||||
// Note: Inworldz Revisions - 7/9/2016
|
||||
// RadioRoy Wattz (Inworldz)
|
||||
//======================================================================
|
||||
// Tunable items
|
||||
|
||||
|
||||
integer debug = FALSE; // enablefor chattiness
|
||||
integer PHYSICAL = TRUE; // for smooth movemenents enable physical.
|
||||
// For less lag, set this to false, but the motion willl be very quick and jerky.
|
||||
|
||||
string FLOWER_NAME = "Flower"; // the name of the thing we seek
|
||||
string HIVE_NAME = "Beehive";
|
||||
float DIST = 15.0; // gow far to fly, max
|
||||
// For less lag, set this to false, but the motion willl be very quick and jerky.
|
||||
|
||||
string FLOWER_NAME = "Flower"; // the name of the thing we seek
|
||||
string HIVE_NAME = "Beehive Box-1";
|
||||
float DIST = 25.0; // gow far to fly, max
|
||||
float SPEED = 1; // move in this number of seconds from place to place
|
||||
|
||||
|
||||
// code bits
|
||||
vector vInitROT = <90,0,0> ; // due to the sculpted body, this bee gets rotated 90 degrees.
|
||||
vector vFlowerOffset = <0,.10,0.1>;// due to the rotation on the sculpted body, this is back and up a bit.
|
||||
vector vHiveOffset = <0,.5,0>;
|
||||
vector vHiveOffset = <0,.5,0>;
|
||||
rotation r90; // a calculated 90 degree rotation ends up here
|
||||
integer iCount = 0; // hive counter
|
||||
string sLocatedName; // located name of item
|
||||
list lGlist; // This is used as a first in first out stack with 2 entries per element
|
||||
|
||||
string sLocatedName = "Beehive Box-1"; // located name of item
|
||||
list lGlist; // This is used as a first in first out stack with 2 entries per element
|
||||
|
||||
DEBUG(string str)
|
||||
{
|
||||
if (debug) llOwnerSay(llGetScriptName() + ":" + str);
|
||||
}
|
||||
|
||||
|
||||
// pop the top entry off the stack
|
||||
poplGlist() {
|
||||
lGlist = llDeleteSubList(lGlist,0,1);
|
||||
}
|
||||
|
||||
// Get the top Position
|
||||
vector Gpos() {
|
||||
return llList2Vector(lGlist,0);
|
||||
}
|
||||
|
||||
// Get the top Rotation
|
||||
rotation Grot() {
|
||||
return llList2Rot(lGlist,1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// pop the top entry off the stack
|
||||
poplGlist() {
|
||||
lGlist = llDeleteSubList(lGlist,0,1);
|
||||
}
|
||||
|
||||
// Get the top Position
|
||||
vector Gpos() {
|
||||
return llList2Vector(lGlist,0);
|
||||
}
|
||||
|
||||
// Get the top Rotation
|
||||
rotation Grot() {
|
||||
return llList2Rot(lGlist,1);
|
||||
}
|
||||
|
||||
SetRotPos(rotation rot, vector dest)
|
||||
{
|
||||
DEBUG("moveto:" + (string) dest);
|
||||
@@ -71,111 +72,118 @@ SetRotPos(rotation rot, vector dest)
|
||||
} else {
|
||||
llSetRegionPos(dest);
|
||||
llSetRot(rot);
|
||||
llSetStatus(STATUS_PHANTOM,TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
default
|
||||
{
|
||||
{
|
||||
state_entry()
|
||||
{
|
||||
{
|
||||
llStopMoveToTarget(); // new inworldz
|
||||
sLocatedName = "";
|
||||
llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN, [PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_NONE]);
|
||||
// set rotation for this sculpted bee - remove this if yiou use a base prim
|
||||
vector new = vInitROT * DEG_TO_RAD;
|
||||
llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN, [PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_NONE]); //new inworldz
|
||||
llSleep(2); //new Inworldz
|
||||
// set rotation for this sculpted bee - remove this if yiou use a base prim| saved-> PRIM_PHYSICS_SHAPE_TYPE
|
||||
vector new = vInitROT * DEG_TO_RAD;
|
||||
r90 = llEuler2Rot(new);
|
||||
|
||||
llSetTimerEvent(.1); // let's go!
|
||||
|
||||
if (PHYSICAL)
|
||||
llSetStatus(STATUS_PHYSICS,TRUE);
|
||||
else
|
||||
llSetStatus(STATUS_PHYSICS,FALSE);
|
||||
}
|
||||
|
||||
on_rez(integer p)
|
||||
{
|
||||
llResetScript();
|
||||
}
|
||||
|
||||
timer()
|
||||
{
|
||||
llSetTimerEvent(0);
|
||||
if (sLocatedName == FLOWER_NAME)
|
||||
{
|
||||
if ( lGlist != [] )
|
||||
{
|
||||
llPlaySound("buzz1",1.0);
|
||||
|
||||
SetRotPos(Grot() * r90 , Gpos() + vFlowerOffset); // orient to it
|
||||
llSetTimerEvent(4);
|
||||
poplGlist(); // pop the top entry off the stack
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
llSetTimerEvent(.2); // let's go!// move time up from .1 to .2
|
||||
|
||||
if (PHYSICAL) {
|
||||
llSetStatus(STATUS_PHYSICS,FALSE); // disable, then enable to get it to engage
|
||||
llSetStatus(STATUS_PHYSICS,TRUE);
|
||||
} else{
|
||||
llSetStatus(STATUS_PHYSICS,FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
on_rez(integer p)
|
||||
{
|
||||
llSetStatus(STATUS_PHYSICS,FALSE); //new Inworldz
|
||||
llStopMoveToTarget( ); // new - inworldz - I Know Overkill!
|
||||
llResetScript();
|
||||
}
|
||||
|
||||
timer()
|
||||
{
|
||||
llSetTimerEvent(0);
|
||||
if (sLocatedName == FLOWER_NAME)
|
||||
{
|
||||
if ( lGlist != [] )
|
||||
{
|
||||
llPlaySound("buzz1",1.0);
|
||||
|
||||
SetRotPos(Grot() * r90 , Gpos() + vFlowerOffset); // orient to it
|
||||
llSetTimerEvent(4);
|
||||
poplGlist(); // pop the top entry off the stack
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG("Look for Hive");
|
||||
llSensor(HIVE_NAME,NULL_KEY,ACTIVE|PASSIVE,DIST,PI); // Hive can be scripted, or not
|
||||
}
|
||||
}
|
||||
else if (sLocatedName == HIVE_NAME)
|
||||
{
|
||||
if ( iCount == 0 )
|
||||
{
|
||||
SetRotPos(llGetRot(), Gpos()); // move in
|
||||
llSetTimerEvent(10);
|
||||
}
|
||||
else if ( iCount == 1 )
|
||||
{
|
||||
llSetTimerEvent(2);
|
||||
SetRotPos(llGetRot(),Gpos() + vHiveOffset); // move out
|
||||
}
|
||||
else {
|
||||
sLocatedName = ""; // fall into llSensor FLOWER_NAME
|
||||
llSetTimerEvent(1); // adjust pause here
|
||||
}
|
||||
iCount++;
|
||||
}
|
||||
else if (sLocatedName == HIVE_NAME)
|
||||
{
|
||||
if ( iCount == 0 )
|
||||
{
|
||||
SetRotPos(llGetRot(), Gpos()); // move in
|
||||
llSetTimerEvent(10);
|
||||
}
|
||||
else if ( iCount == 1 )
|
||||
{
|
||||
llSetTimerEvent(2);
|
||||
SetRotPos(llGetRot(),Gpos() + vHiveOffset); // move out
|
||||
}
|
||||
else {
|
||||
sLocatedName = ""; // fall into llSensor FLOWER_NAME
|
||||
llSetTimerEvent(2); // adjust pause here
|
||||
}
|
||||
iCount++;
|
||||
} else { // fixed here
|
||||
// as you don't want to "fall" into here until after a 1 second pause
|
||||
|
||||
DEBUG("Look for Flower");
|
||||
// as you don't want to "fall" into here until after a 1 second pause
|
||||
|
||||
DEBUG("Look for Flower");
|
||||
llSensor(FLOWER_NAME, NULL_KEY, ACTIVE|PASSIVE, DIST,PI); // flowers can be scripted, or not
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sensor(integer numDetected)
|
||||
{
|
||||
DEBUG("detected:" + (string) numDetected);
|
||||
sLocatedName = llDetectedName(0);
|
||||
// Clear the stack and place the first entry on it
|
||||
lGlist = [ llDetectedPos(0), llDetectedRot(0) ];
|
||||
if (sLocatedName == FLOWER_NAME)
|
||||
{
|
||||
// Append any additional Flowers entries onto the stack
|
||||
integer i;
|
||||
for (i = 1; i < numDetected; i++)
|
||||
{
|
||||
lGlist += [ llDetectedPos(i), llDetectedRot(i) ];
|
||||
}
|
||||
} else {
|
||||
iCount = 0;
|
||||
llPlaySound("buzz1",1.0);
|
||||
// start moving towards the Hive
|
||||
SetRotPos(Grot() * r90,Gpos() + vHiveOffset); // orient to it
|
||||
}
|
||||
// next step is always timer event
|
||||
llSetTimerEvent(1);
|
||||
}
|
||||
|
||||
no_sensor()
|
||||
{
|
||||
sLocatedName = "";
|
||||
|
||||
|
||||
sensor(integer numDetected)
|
||||
{
|
||||
DEBUG("detected:" + (string) numDetected);
|
||||
sLocatedName = llDetectedName(0);
|
||||
// Clear the stack and place the first entry on it
|
||||
lGlist = [ llDetectedPos(0), llDetectedRot(0) ];
|
||||
if (sLocatedName == FLOWER_NAME)
|
||||
{
|
||||
// Append any additional Flowers entries onto the stack
|
||||
integer i;
|
||||
for (i = 1; i < numDetected; i++)
|
||||
{
|
||||
lGlist += [ llDetectedPos(i), llDetectedRot(i) ];
|
||||
}
|
||||
} else {
|
||||
iCount = 0;
|
||||
llPlaySound("buzz1",1.0);
|
||||
// start moving towards the Hive
|
||||
SetRotPos(Grot() * r90,Gpos() + vHiveOffset); // orient to it
|
||||
}
|
||||
// next step is always timer event
|
||||
llSetTimerEvent(1);
|
||||
}
|
||||
|
||||
no_sensor()
|
||||
{
|
||||
sLocatedName = "";
|
||||
llSetTimerEvent(15); // try again
|
||||
}
|
||||
|
||||
|
||||
changed(integer change)
|
||||
{
|
||||
if (change & CHANGED_REGION_START)
|
||||
llResetScript();
|
||||
llResetScript();
|
||||
}
|
||||
}
|
||||
// end of code
|
||||
}
|
||||
// end of code
|
||||
@@ -1,50 +1,80 @@
|
||||
// :SHOW:
|
||||
// :SHOW:1
|
||||
// :CATEGORY:OpenSim NPC
|
||||
// :NAME:NPC_Cat_Follower
|
||||
// :AUTHOR:Ferd Frederix
|
||||
// :KEYWORDS:
|
||||
// :CREATED:2013-11-27 13:33:04
|
||||
// :EDITED:2015-05-29 11:26:02
|
||||
// :EDITED:2016-07-09 14:33:57
|
||||
// :ID:1004
|
||||
// :NUM:785
|
||||
// :REV:1.1
|
||||
// :REV:2.0
|
||||
// :WORLD:OpenSim
|
||||
// :DESCRIPTION:
|
||||
// A NPC follower. Will follow close to any avatar.
|
||||
// Touch to turn on or off.
|
||||
// Has lots of mods by Ferd Frederix
|
||||
// License: http://creativecommons.org/licenses/by-nc
|
||||
// original author: jpvdgiessen
|
||||
// some code bits from author: jpvdgiessen
|
||||
// You are free:
|
||||
// to Share — to copy, distribute and transmit the work
|
||||
// to Remix — to adapt the work
|
||||
// :CODE:
|
||||
|
||||
|
||||
// Rev 2 - remove timers.
|
||||
// tunables
|
||||
float max_distance = 96; //distance for sensoring a real avatar
|
||||
string fName = "Orana";
|
||||
string lName = "Kitty";
|
||||
integer debug = FALSE;
|
||||
|
||||
string fName = "Orana";
|
||||
string lName = "Kthxbye";
|
||||
|
||||
float MIN = 5;
|
||||
float MAX = 10; // how long the cat waits or sits, is beteween these two values
|
||||
float TimerTick = 1; // keep this around a second
|
||||
float TIME = 5; // how often to look for avatar (keep this slow)
|
||||
float max_distance = 35; //distance for sensoring a real avatar
|
||||
float near_distance= 3; // how close the cat stays around
|
||||
float claw_distance= 1 ;// will claw you hen this close
|
||||
|
||||
// stuff
|
||||
integer iWaitCounter = 60;
|
||||
integer iWaitCounter = 60; // if we cannot get there in time,
|
||||
integer channel; // dialog channel
|
||||
integer listener; // holds the listener handle;
|
||||
key npc; // npc key
|
||||
integer npc_on = FALSE;
|
||||
vector Dest;
|
||||
string lastAnim;
|
||||
|
||||
float gTimer;
|
||||
|
||||
DEBUG(string str)
|
||||
{
|
||||
if (debug) llOwnerSay(str);
|
||||
}
|
||||
|
||||
Remove()
|
||||
{
|
||||
lastAnim = "";
|
||||
npc_on = TRUE;
|
||||
osNpcRemove(llGetObjectDesc());
|
||||
}
|
||||
|
||||
Play(string anima)
|
||||
{
|
||||
if (anima == lastAnim)
|
||||
if (anima == lastAnim) {
|
||||
DEBUG("Same");
|
||||
return;
|
||||
}
|
||||
|
||||
// 1/5 the time, ionstead of standing, we lay down
|
||||
if (anima == "Stand" && llFrand(5) < 1)
|
||||
{
|
||||
anima = "Sit1";
|
||||
}
|
||||
|
||||
gTimer =randBetween(MIN,MAX);
|
||||
llSensorRepeat("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI, gTimer);
|
||||
DEBUG(anima + " time = " + (string) gTimer);
|
||||
|
||||
osNpcPlayAnimation(npc,anima);
|
||||
osNpcStopAnimation(npc,lastAnim);
|
||||
lastAnim = anima;
|
||||
@@ -65,53 +95,54 @@ Sound()
|
||||
|
||||
walk_to_master(vector myPos)
|
||||
{
|
||||
vector myVector = <randBetween(-2,2),randBetween(-2,2),myPos.z> ;
|
||||
DEBUG( "walk to " + (string) Dest);
|
||||
vector myVector = <randBetween(-near_distance,near_distance),randBetween(-near_distance,near_distance),myPos.z> ;
|
||||
myPos.z = 0;
|
||||
|
||||
iWaitCounter = 60;
|
||||
Play("Walk");
|
||||
osNpcMoveToTarget(npc, myPos + myVector, OS_NPC_NO_FLY );
|
||||
llSetTimerEvent(0.5);
|
||||
Sound();
|
||||
llSetTimerEvent(TimerTick);
|
||||
if (llFrand(5) < .5)
|
||||
Sound();
|
||||
}
|
||||
|
||||
float randBetween(float min, float max)
|
||||
{
|
||||
return llFrand(max - min) + min ;
|
||||
}
|
||||
dialog()
|
||||
dialog(key avi)
|
||||
{
|
||||
channel = llCeil(llFrand(5000) + 5000);
|
||||
listener = llListen(channel,"","","");
|
||||
llDialog(llGetOwner(), "Choose:",["Start","Remove","Appearance"],channel);
|
||||
llDialog(avi, "Choose:",["Start","Remove","Appearance"],channel);
|
||||
}
|
||||
|
||||
Start()
|
||||
{
|
||||
vector npcPos = llGetPos() + <1.0,1.0,1.0>;
|
||||
Remove();
|
||||
vector npcPos = llGetPos() + <0.0,0.0,1.0>;
|
||||
npc = osNpcCreate(fName,lName, npcPos, "Appearance");
|
||||
llSetObjectDesc(npc);
|
||||
npc_on = TRUE;
|
||||
llSensor("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI);
|
||||
osSetSpeed(npc,0.8);
|
||||
llSensorRepeat("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI, TIME);
|
||||
llSetTimerEvent(TimerTick);
|
||||
}
|
||||
|
||||
default
|
||||
{
|
||||
|
||||
state_entry()
|
||||
{
|
||||
llSay(0,"Ready");
|
||||
osNpcRemove(llGetObjectDesc());
|
||||
dialog();
|
||||
llSay(0,"starting");
|
||||
Start();
|
||||
}
|
||||
|
||||
changed (integer what)
|
||||
{
|
||||
if (what & CHANGED_REGION_START)
|
||||
{
|
||||
if (npc_on)
|
||||
{
|
||||
Start();
|
||||
}
|
||||
Start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,8 +153,8 @@ default
|
||||
|
||||
touch_start(integer x)
|
||||
{
|
||||
if (llDetectedKey(0) == llGetOwner()) {
|
||||
dialog();
|
||||
if (llDetectedKey(0) == llGetOwner() || llSameGroup(llDetectedKey(0))) {
|
||||
dialog(llDetectedKey(0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,18 +162,16 @@ default
|
||||
llListenRemove (listener);
|
||||
if (msg == "Start")
|
||||
{
|
||||
if( !npc_on ) {
|
||||
Start();
|
||||
} else {
|
||||
llOwnerSay("Already running");
|
||||
}
|
||||
Start();
|
||||
} else if (msg == "Remove") {
|
||||
npc_on = FALSE;
|
||||
osNpcRemove(llGetObjectDesc());
|
||||
Remove();
|
||||
llSensorRemove();
|
||||
llSetTimerEvent(0);
|
||||
} else if (msg == "Appearance") {
|
||||
} else if (msg == "-") {
|
||||
osAgentSaveAppearance(llGetOwner(), "Appearance");
|
||||
llOwnerSay("Your appearance has been saved");
|
||||
Start();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -152,218 +181,39 @@ default
|
||||
Dest = llDetectedPos( 0 );
|
||||
walk_to_master(Dest);
|
||||
}
|
||||
|
||||
no_sensor()
|
||||
{
|
||||
Play("Stand");
|
||||
llSleep(10);
|
||||
llSensor("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI);
|
||||
Play("Sit1");
|
||||
llSensorRepeat("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI, TIME);
|
||||
llSetTimerEvent(0);
|
||||
}
|
||||
|
||||
timer()
|
||||
{
|
||||
vector pos;
|
||||
if (--iWaitCounter) {
|
||||
|
||||
list Poses = llGetObjectDetails(npc,[OBJECT_POS]);
|
||||
pos = llList2Vector(Poses, 0);
|
||||
|
||||
if (llVecDist(pos, Dest ) > 4) {
|
||||
return;
|
||||
}
|
||||
// for safety
|
||||
if (--iWaitCounter == 0) {
|
||||
DEBUG("Lost cat, rerezzing");
|
||||
Start();
|
||||
return;
|
||||
}
|
||||
|
||||
if (llFrand(5) < 0.5) {
|
||||
if (llVecDist(pos, Dest ) <1) {
|
||||
Play("Claw");
|
||||
llTriggerSound("kitten4",1.0);
|
||||
llSleep(1.5);
|
||||
} else {
|
||||
Play("Meow");
|
||||
llTriggerSound("kitten3",1.0);
|
||||
llSleep(1.5);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// get NPC position
|
||||
list P = llGetObjectDetails(npc,[OBJECT_POS]);
|
||||
vector Npcpos;
|
||||
Npcpos = llList2Vector(P, 0);
|
||||
|
||||
Play("Stand");
|
||||
if (llVecDist(Npcpos, Dest ) > 1) {
|
||||
Play("Stand");
|
||||
return;
|
||||
}
|
||||
|
||||
llSleep(llFrand(5) + 1);
|
||||
llSetTimerEvent(0);
|
||||
llSensor("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI);
|
||||
|
||||
}
|
||||
}
|
||||
// tunables
|
||||
float max_distance = 96; //distance for sensoring a real avatar
|
||||
string fName = "Orana";
|
||||
string lName = "Kitty";
|
||||
|
||||
// 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 == "Stand" && llFrand(5) < 1)
|
||||
{
|
||||
anima = "Sit1";
|
||||
}
|
||||
|
||||
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("Walk");
|
||||
osNpcMoveToTarget(npc, myPos + myVector, OS_NPC_NO_FLY );
|
||||
llSetTimerEvent(0.5);
|
||||
Sound();
|
||||
}
|
||||
|
||||
float randBetween(float min, float max)
|
||||
{
|
||||
return llFrand(max - min) + min ;
|
||||
}
|
||||
dialog()
|
||||
{
|
||||
channel = llCeil(llFrand(5000) + 5000);
|
||||
listener = llListen(channel,"","","");
|
||||
llDialog(llGetOwner(), "Choose:",["Start","Remove","Appearance"],channel);
|
||||
}
|
||||
Start()
|
||||
{
|
||||
vector npcPos = llGetPos() + <1.0,1.0,1.0>;
|
||||
npc = osNpcCreate(fName,lName, npcPos, "Appearance");
|
||||
llSetObjectDesc(npc);
|
||||
npc_on = TRUE;
|
||||
llSensor("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI);
|
||||
}
|
||||
|
||||
default
|
||||
{
|
||||
|
||||
state_entry()
|
||||
{
|
||||
llSay(0,"Ready");
|
||||
osNpcRemove(llGetObjectDesc());
|
||||
dialog();
|
||||
}
|
||||
|
||||
changed (integer what)
|
||||
{
|
||||
if (what & CHANGED_REGION_START)
|
||||
if (llVecDist(Npcpos, Dest ) < claw_distance)
|
||||
{
|
||||
if (npc_on)
|
||||
{
|
||||
Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
on_rez(integer p)
|
||||
{
|
||||
llResetScript();
|
||||
}
|
||||
|
||||
touch_start(integer x)
|
||||
{
|
||||
if (llDetectedKey(0) == llGetOwner()) {
|
||||
dialog();
|
||||
}
|
||||
}
|
||||
|
||||
listen(integer channel, string name, key id, string msg) {
|
||||
llListenRemove (listener);
|
||||
if (msg == "Start")
|
||||
{
|
||||
if( !npc_on ) {
|
||||
Start();
|
||||
} else {
|
||||
llOwnerSay("Already running");
|
||||
}
|
||||
} else if (msg == "Remove") {
|
||||
npc_on = FALSE;
|
||||
osNpcRemove(llGetObjectDesc());
|
||||
llSetTimerEvent(0);
|
||||
} else if (msg == "Appearance") {
|
||||
osAgentSaveAppearance(llGetOwner(), "Appearance");
|
||||
llOwnerSay("Your appearance has been saved");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sensor(integer num)
|
||||
{
|
||||
Dest = llDetectedPos( 0 );
|
||||
walk_to_master(Dest);
|
||||
}
|
||||
no_sensor()
|
||||
{
|
||||
Play("Stand");
|
||||
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("Claw");
|
||||
llTriggerSound("kitten4",1.0);
|
||||
llSleep(1.5);
|
||||
} else {
|
||||
Play("Meow");
|
||||
llTriggerSound("kitten3",1.0);
|
||||
llSleep(1.5);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Play("Stand");
|
||||
|
||||
llSleep(llFrand(5) + 1);
|
||||
llSetTimerEvent(0);
|
||||
llSensor("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI);
|
||||
|
||||
Play("Claw");
|
||||
llTriggerSound("kitten4",1.0);
|
||||
} else {
|
||||
Play("Stand");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user