Change font size
It is currently Mon Nov 19, 2018 10:32 am

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 2 posts ]
Author Message
 Post subject: Super awesome fish script, object rezzer & timed delete...
PostPosted: Sat Apr 21, 2012 3:14 pm 

Joined: Mon Apr 27, 2009 1:52 am
Posts: 6
Hello all,

I am usually one of those "side line guys" when it comes to forums and such but recently I have setup 4 sims on your beautiful grid and have been having myself quite the dandy time enjoying everyone's creativity and how much everyone shares around here.

So, here I am pitching in.

For those of you whom would just like the fish and scripts without having to go through all the reading below, lol, just go to my sims and grab yourselves a copy from the island area (underwater near the surfboards and shack). You can also use that opportunity to watch them in action. Be careful though, if you're a fish lover, lol, you might just find yourself mesmerized for a bit, like any aquarium full of fish might do. Easiest way to find my sims, I've found, is to search for keyword "uber" on the big map view. So far, I have the only sims with this in the name and they should pop right up.

Couple of errors I noticed with this script (maybe someone around here could let me know what parts I borked up, lol) but I have "work arounds" for now.

The fish have to be physical and for some reason the temporary prim option messes with that and causes all kindsa' errors. So what I have done is replaced this with a timed self deletion script instead of making the prim temporary.

Odd thing, even this does not sometimes work as you will occasionally find the "rogue" fish floating somewhere in your sim. Only to find if you relog (or restart your sim) it will be gone. If you grab the fish via edit, and then move it, this will also delete it from your view. This I believe, might be client side and for some reason your viewer just isn't deleting the fish until you relog or attempt to move it.

One other thing I've noticed is for the llmovetotarget or lllookattarget when given the direction that is opposite it's current facing rotation, it will over/under loop rather than turn on it's Z axis (gosh that sounds messy but it's the best way I can explain it, lol). What this basically does is makes the fish (at close inspection) go upside down for about 30% of it's movement. I've messed around with llsetrotation but I'm either not putting it in there right or it's just not the function I need to use.

You may notice a lot of calls to die_at_edge and switching between physical, phantom and non-physical. This is due in part to collision problems and it's issue with deleting. Briefly and temporarily setting it to non-physical minimized this problem for me. Again, if any of you script guru's could clean it up, great.

Also, the "die" on land collision is due to it spinning off into no-man's land when it does. As a work around, I simply have the fish delete on collision with land. This does not adversely affect the fish activity as they rarely collide with the ground.

Anywho, as I mentioned it's not something that bothers me, as the fish themselves are pretty awesome.

With enough tweaking these scripts could probably be used for birds and other "roaming" animals. So feel free to edit and use as you like. :)

Okay, 1st for the fish script...

{L_CODE}:
//Roaming Fish
// Edit the X,Y,Z max values and set the min height from ground.
// Reset Script to reset the starting position.

float maxx=9.7;  //Edit max movement from starting positions
float maxy=9.3;
float maxz=5.3;

float minz=0.0;  //Edit min distance from bottom


//System Variables
vector startpos; //variable to remember start position

//System Functions
float newp(float max) //function to make random new position
{
    return llFrand(max*2) - max;
}

//Default Running State
default
{
    on_rez(integer p)   //Reset script when I am rezzed
    {
        llSetStatus(STATUS_PHYSICS, FALSE);
       
        llResetScript();
    }
   
    state_entry()  //script starting point
    {
        llSetStatus(STATUS_PHYSICS, FALSE);

llSetStatus(STATUS_DIE_AT_EDGE | STATUS_PHANTOM, TRUE); //make prim phantom, non-physical and die at edge of world
          startpos=llGetPos(); //get position of ground
        llSetTimerEvent(5);  //start the timer (10 seconds)
    }
land_collision_start( vector pos )
    {
      llDie();
    }
    collision_start(integer total_number)
    {   
        llSetStatus(STATUS_DIE_AT_EDGE | STATUS_PHANTOM, FALSE);
        llSetStatus(STATUS_PHYSICS, TRUE);
        llSetBuoyancy(1.1);
        llSleep(2);
        llResetScript();
    }
    timer()
    {
        llSetStatus(STATUS_DIE_AT_EDGE | STATUS_PHANTOM, FALSE);
        llSleep(0.1);
        vector newpos;  //make new position
        newpos.x=startpos.x+newp(maxx);  //make X
        newpos.y=startpos.y+newp(maxy);  //make Y
        newpos.z=startpos.z+newp(maxz)+minz; //make Z
       
        llLookAt(newpos,0.0,0.0); //point to new position
        llSetStatus(STATUS_DIE_AT_EDGE | STATUS_PHYSICS, TRUE);
        llSetBuoyancy(1.05);
        llMoveToTarget(newpos,19.5); //move to new position
       
    }
}


The object you would place this fish script in would be a small invisible box and attached to it would be a flexi-prim upon which you would have your fish texture. Again, I have copies of these on my sim, so feel free to get yourself one and use it for an example.

This next script I use to delete the fish after about 1 minute (you could set this to any amount of time you wish). Place this script in the same prim you place the roaming fish script.

{L_CODE}:
//Simple Timer W/ delete object
{
    on_rez( integer Parameter )
    {
       
     llResetScript();   
    }
    state_entry()
    {
        llSetTimerEvent(70);//timer set for 1 minute, 10 seconds.
    }

    timer()
    {
        llDie();
    }
}


This final script I put inside another invisible box about 3-5m above the area I would like the fish to be. Inside the box place 5 "fish" objects and then reset your rez script. It rezzes a random number of fish once every minute but you could convert it to use for rezzing anything and set the time for whatever you like.

{L_CODE}:

//random object rez script
default
{
    state_entry()
    {
        llSetTimerEvent(60);
    }

    timer()
    {
    vector position = llGetPos();
        rotation angle = llGetRot();
        vector offset = <0, 0, 0>;
    float SoundVal = llFrand(100);
    if (SoundVal <= 16) llRezObject( "fish1k", position + (offset * angle), ZERO_VECTOR, angle, 0 );
if (SoundVal <= 32) llRezObject( "fish2k", position + (offset * angle), ZERO_VECTOR, angle, 0 );
if (SoundVal <= 48) llRezObject( "fish3k", position + (offset * angle), ZERO_VECTOR, angle, 0 );
if (SoundVal <= 64) llRezObject( "fish4k", position + (offset * angle), ZERO_VECTOR, angle, 0 ); 
    else if (SoundVal >= 85) llRezObject( "fish5k", position + (offset * angle), ZERO_VECTOR, angle, 0 );   
           
    else llRezObject( "fish6k", position + (offset * angle), ZERO_VECTOR, angle, 0 );

    }
}


I'll add in some more stuff as I get time and thanks for having me on OSGrid!


Top
 Profile  
 
 Post subject: Re: Super awesome fish script, object rezzer & timed delete...
PostPosted: Tue Apr 24, 2012 12:47 pm 
Furious Typer

Joined: Mon Jan 16, 2012 1:44 pm
Posts: 87
You are more then welcome and i really have to get your fishing rode:)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 2 posts ]


Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  


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