Reply
Honored Resident
LuckyCreations
Posts: 46

Fish wander script?

I have searched and searched but have had no luck finding this kind of script. I was wondering if someone could point me in the direction of a preferably free script that will allow a flexible prim with a fish texture applied to it randomly wander around a fish tank?

Honored Resident
Dev Khaos
Posts: 23

Re: Fish wander script?

Reply to LuckyCreations - view message

I have a great collection of animal scripts that ive created. Find me in-world for specifics or check out the bulk package here on the marketplace:  https://marketplace.secondlife.com/p/First-Class-Developer-Pack-Advanced-Creature-Code/1917547

 

For a free version, try:

 

 

integer random=5;//swim timer

//global vectors  -  wanders within these points
list points = [
<84,61,50>,
<83,62,50>,
<82,63,50>,
<81,64,50>
];

swim(){
 vector swimpoint=llList2Vector(points,(integer)llFrand(llGetListLength(points)));
 llLookAt(swimpoint,0.6,4.7);
 llSleep(1.2);
 llMoveToTarget(swimpoint,8.0);
 llSetTimerEvent(llFrand(random));
}


default{
state_entry(){llSetStatus(STATUS_PHYSICS,TRUE);swim();}
timer(){swim();}
}

 



 

 

Web/SL Developer since 2006
ECO - Breeds Script Package : http://eco.takecopy.com
Networked Vending : http://takecopy.com
Member
Henry Darkthief
Posts: 1,326

Re: Fish wander script?

Reply to Dev Khaos - view message

 


Dev Khaos wrote:

I have a great collection of animal scripts that ive created. Find me in-world for specifics or check out the bulk package here on the marketplace:  https://marketplace.secondlife.com/p/First-Class-Developer-Pack-Advanced-Creature-Code/1917547

 

For a free version, try:

 

 

integer random=5;//swim timer

//global vectors  -  wanders within these points
list points = [
<84,61,50>,
<83,62,50>,
<82,63,50>,
<81,64,50>
];

swim(){
 vector swimpoint=llList2Vector(points,(integer)llFrand(llGetListLength(points)));
 llLookAt(swimpoint,0.6,4.7);
 llSleep(1.2);
 llMoveToTarget(swimpoint,8.0);
 llSetTimerEvent(llFrand(random));
}


default{
state_entry(){llSetStatus(STATUS_PHYSICS,TRUE);swim();}
timer(){swim();}
}

 



 

 


 

Would setting a range for random coordinates also work for the waypoints? Using the coordinates you have listed, x= a random number between 80 and 85, y= a random numer between 60 and 65, z= a random number between 5 and 19 (that's to keep teh fish underwater :smileyhappy: )

Then, as the fish reaches a generated waypoint, a new set of coordinates are generated. I'm not a scritper, but it should go something like;

get the rezzed position;

start loop

x = random number

y = random number

z = random number

waypoint = (x,y,z)

travel to waypoint

go back to start loop

 

The only time rank matters is when determining the need for a shower.
Honored Resident
Dev Khaos
Posts: 23

Re: Fish wander script?

Reply to Henry Darkthief - view message



That would look something like this:

*additionally, you could add a little something to randomize positive AND negative distances 

 

integer random=5;//swim timer
integer totalpoints =5;//number of random save points
integer distance = 5;
list points =[]; swim(){ vector swimpoint=llList2Vector(points,(integer)llFrand(llGetListLength(points))); llLookAt(swimpoint,0.6,4.7); llSleep(1.2); llMoveToTarget(swimpoint,8.0); llSetTimerEvent(llFrand(random)); }

getpoints(){ integer i;
for(i=0;i<totalpoints;i++){
vector pos=llGetPos();
points+=<pos.x+llFrand(distance),pos.y+llFrand(distance),pos.z+llFrand(distance)>;
}
} default{ on_rez(integer p){llResetScript();}
state_entry(){getpoints();llSetStatus(STATUS_PHYSICS,TRUE);swim();} timer(){swim();} }
Web/SL Developer since 2006
ECO - Breeds Script Package : http://eco.takecopy.com
Networked Vending : http://takecopy.com