Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Zax's Scuba Scripts

Zax Aster
Registered User
Join date: 13 Nov 2006
Posts: 10
05-19-2007 14:35
Ok for those who were following that old thread hres the new one lol!

In this thread I will be trudging my way through writing scuba scripts from scratch. The first to tackle was the BCD. Buoyancy Compensator Device. This will keep the diver under the waters surface when swimming (so as not to fly out) and will also allow a very realsitic tread water at the waters surface as well. Avatar can still walk on land with the BCD on. While on land "Charge" The BCD with air by pressing the PGUP (FLY) button. You wont go up in the air with the BCD on. Now just move over to the waters edge and it will plunge you in and drop you just below the waters surface. While underwater your free to move up or down or in any direction but if you near the surface it will send a small warning and then nudge you back down a bit. Works fairly well so far with no problems. To tread at the surface TAP the pgup button very slowly untill your head and shoulders are just above water. Note if you move in any driection but up it will push you back under. Makes for a realsitic treadwater. Ok heres the script ENJOY. And thanks to those that helped with the suggestions in the prior thread, the move function worked great.

CODE

////////////////////////////////////////////////////////////////////////////////////////////
// Zax's Buoyancy Compensator Script
// FREE to use copy/mod/trans whatever you want ENJOY!
// Made for a Scuba Diving BCD will keep you in the water while swimming
// It will even allow you to tread at waters surface (move and it will force you back under)
// Feel free to use this however you like. Hope it helps...Zax
/////////////////////////////////////////////////////////////////////////////////////////////


default
{
moving_start( )// This will run checks below continuously while you are moving
//when you are not moving the script does nothing. (saves on lag and allows treadwater)
{
vector pos = llGetPos(); //Gets your Current position in world
float water = llWater(<0,0,14>); // Water height in the current Sim

if (pos.z >= water) // are we at or above water surface?
{
llOwnerSay("Surface Detected...compensating" ); //Lets us know (You CAN remove this)
llSetBuoyancy(-1.5); //This causes you to begin to sink
llApplyImpulse(<0,0,-10>,FALSE);// This is an extra nudge downward
}

else if (pos.z <= water) // If we are under water surface
{
llSetBuoyancy(0.0); //Do Nothing. Resets sinking command.
//If not here you would continue to sink.
}

}


}



Ok everyone hope that helps. Its not perfect but it works pretty darn good. Please feel free to use this script to learn from...make your own stuff or whatever you want. Hope it helps someone...Zax
Zax Aster
Registered User
Join date: 13 Nov 2006
Posts: 10
Regulator Script
05-19-2007 16:02
Ok woot its been a productive day!! Tests went great for the regulator!! Heres the reg script. Its actually pretty simple. Its just a small particle emittor with sound that activates only while underwater. I used the same underwater check i used for the bcd and it worked great! The script will emit bubbles and sound while under the waters surface. You will have to rename the bubble texture to whatever your texture name is and same for the sound. but have fun and enjoy learning with me!

CODE

//////////////////////////////////////////////////////
// Zax's Reguator Script
// This Script will make bubbles and a breathing noise while underwater
// Turns itself off automaticaly when you exit the water
// Feel free to mod/copy/trans however you like...enjoy...Zax
//////////////////////////////////////////////////////

// Mask Flags - set to TRUE to enable
integer glow = TRUE; // Make the particles glow
integer bounce = TRUE; // Make particles bounce on Z plan of object
integer interpColor = TRUE; // Go from start to end color
integer interpSize = TRUE; // Go from start to end size
integer wind = FALSE; // Particles effected by wind
integer followSource = TRUE; // Particles follow the source
integer followVel = TRUE; // Particles turn to velocity direction

// Choose a pattern from the following:
// PSYS_SRC_PATTERN_EXPLODE
// PSYS_SRC_PATTERN_DROP
// PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY
// PSYS_SRC_PATTERN_ANGLE_CONE
// PSYS_SRC_PATTERN_ANGLE
integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE;

// Select a target for particles to go towards
// "" for no target, "owner" will follow object owner
// and "self" will target this object
// or put the key of an object for particles to go to
key target = "";

// Particle paramaters
float age = 15; // Life of each particle
float maxSpeed = 1.0; // Max speed each particle is spit out at
float minSpeed = 0.26; // Min speed each particle is spit out at
string texture = "dive bubble"; // Texture used for particles, default used if blank
float startAlpha = 2.0; // Start alpha (transparency) value
float endAlpha = 1.0; // End alpha (transparency) value
vector startColor = <1,1,1>; // Start color of particles <R,G,B>
vector endColor = <1,1,1>; // End color of particles <R,G,B> (if interpColor == TRUE)
vector startSize = <0.10,0.10,0.10>; // Start size of particles
vector endSize = <0.5,0.5,0.5>; // End size of particles (if interpSize == TRUE)
vector push = <0,0,0.01>; // Force pushed on particles

// System paramaters
float rate = 0.02; // How fast (rate) to emit particles
float radius = .6; // Radius to emit particles for BURST pattern
integer count = 1; // How many particles to emit per BURST
float outerAngle = 0; // Outer angle for all ANGLE patterns
float innerAngle = 0; // Inner angle for all ANGLE patterns
vector omega = <0,0,0>; // Rotation of ANGLE patterns around the source
float life = 0; // Life in seconds for the system to make particles

// Script variables
integer flags;

updateParticles()
{
if (target == "owner") target = llGetOwner();
if (target == "self") target = llGetKey();
if (glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
if (bounce) flags = flags | PSYS_PART_BOUNCE_MASK;//
if (interpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK; //
if (interpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;//
if (wind) flags = flags | PSYS_PART_WIND_MASK;//
if (followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;//
if (followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;//
if (target != "") flags = flags | PSYS_PART_TARGET_POS_MASK;//

llParticleSystem([ PSYS_PART_MAX_AGE,age,//
PSYS_PART_FLAGS,flags,//
PSYS_PART_START_COLOR, startColor,//
PSYS_PART_END_COLOR, endColor,//
PSYS_PART_START_SCALE,startSize,//
PSYS_PART_END_SCALE,endSize, //
PSYS_SRC_PATTERN, pattern,//
PSYS_SRC_BURST_RATE,rate,//
PSYS_SRC_ACCEL, push, //
PSYS_SRC_BURST_PART_COUNT,count,//
PSYS_SRC_BURST_RADIUS,radius,//
PSYS_SRC_BURST_SPEED_MIN,minSpeed,//
PSYS_SRC_BURST_SPEED_MAX,maxSpeed,//
PSYS_SRC_TARGET_KEY,target,//
PSYS_SRC_INNERANGLE,innerAngle, //
PSYS_SRC_OUTERANGLE,outerAngle,//
PSYS_SRC_OMEGA, omega,//
PSYS_SRC_MAX_AGE, life,//
PSYS_SRC_TEXTURE, texture,//
PSYS_PART_START_ALPHA, startAlpha,//
PSYS_PART_END_ALPHA, endAlpha//
]);
}

default
{

moving_start( )
{
vector pos = llGetPos(); //Gets your Current position in world
float water = llWater(<0,0,14>); // Water height in the current Sim

if (pos.z <= water) // IF we are underwater...
{
llLoopSound( "zdive", 1.0 ); //Then Play Breathing sound
updateParticles(); // And start makin bubbles
}

else if (pos.z >= water) // If we are Above water level
{
llParticleSystem([]); // Stop Blowin Bubbles
llStopSound(); // and stop making the vadar breath lol
}

}


}




hope ya find this stuff usefull...Zax
Sterling Whitcroft
Registered User
Join date: 2 Jul 2006
Posts: 678
05-20-2007 21:05
YAY!
/me scurries off to buy a new wet suit!
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-21-2007 01:00
You may want to remove the unused portions of the particle script, i.e. no point having interpret colour set if your start and end colours are both white.
Also Alpha goes from 0.0 to 1.0 so using a value of 2.0 seems pointless?

As a total aside, I did start doing a very primitive deco model, basically just a hardcoded set of tables based on those produced by a well known diving organisation. Just gave NDL for current depth and I had an air consumption figure based on depth (air usage just doubled every 10m). Will see if I still have a working model if you want.
_____________________
I'm back......
Zax Aster
Registered User
Join date: 13 Nov 2006
Posts: 10
Heehee Thanks
05-22-2007 07:47
Yeah that was my first particle script. I took a lot of it from an open source partice gen script so Im not too familiar with it yet. But yeah I see what ya mean and ill adjust that one. The NDL ounds really cool if you get that working let me know and post it here id like to see it.

On another note I will be absent from SL for a few months. Doing my RL Divemaster Internship in Roatan Honduras and the lack of internet coupled with the fact i simply wont have time (will be diving every day in RL ) will keep me away from SL for a few months untill I get settled anyways. In the mean time i WILL be checking these forums and my emails at the local internet cafe once a week so please feelk free to follow up with the posts here.

Oh and for the swim anims just attatch the Eros AO (a free anim overider) and add two swimming anims. Tread water and diving. Abranimations has a good scuba animation set in thier AO set 2 or you can use mine (not as good as thiers but its free and full perms) If anyone would like to have the full set of FULL PERMS scuba gear with these scripts and anims already installed please see me in world or send me an IM before Thursday June 24, 2007 That is when i will be leaving SL for a while. I will still keep my account active but wont be logging on much if any for the next three months any ways. And if someone wants to take this opensource scuba project of mine a bit further Ill give you the gear. Just please give it away and not sell it is all I ask. People should know how fun it is to dive in SL thats why i made this stuff. And please leave it full perms so they can learn from the scripts and even improve upon them if they like. Anyone that does make improvements on the script please post them here so we can all learn fom them. Thanks everyone and Ill see you on the flip side...HAVE FUN!

Zax
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-22-2007 12:23
Good luck with your DM, been doing mine on and off for 3 yrs now!!!
I never seem to stay in the UK long enough in one go to complete it.

And no I'm not bloody jealous!!!!
_____________________
I'm back......
IgenG Amsterdam
Registered User
Join date: 7 Dec 2006
Posts: 6
05-23-2007 13:42
Hello Zax,

thanks again for your gear and the regulator but they are both nocopy/nomod so i cant give them away in our beachbar :(
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
05-23-2007 16:45
heyas;

very cool, zax!

you might want to consider doing a check on whether the agent is flying before doing the buoyancy stuff. when i put my snorkel on before walking into the water, it was hard to walk, cuz it kept trying to shove me down into the ground ;D walking should probably be normal, and flying should be for swimming.
_____________________
Why Johnny Can't Rotate:
http://forums.secondlife.com/showthread.php?t=94705
Zax Aster
Registered User
Join date: 13 Nov 2006
Posts: 10
Check for flying
05-24-2007 13:26
Yeah I tried to find a check for flying but couldnt find one. If anyone knows what that function is let me know please here and ill try to add it. Its still a work in progress so I apreciate all the feedback. Igen Im so sorry must have given you the beta by mistake I have the full perms version, soon as i log in ill send it to ya.
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
05-24-2007 13:50
if (llGetAgentInfo(user_key) & (AGENT_FLYING | AGENT_IN_AIR)) {
// Do stuffs
}

http://lslwiki.net/lslwiki/wakka.php?wakka=llGetAgentInfo
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
07-06-2007 10:04
From: Zax Aster
And if someone wants to take this opensource scuba project of mine a bit further Ill give you the gear. Just please give it away and not sell it is all I ask. People should know how fun it is to dive in SL thats why i made this stuff.


If you're still around I could use some gear to give away at my place (or from anyone for that matter). What a great idea to give away the gear so people will actually do the dive and explore my underwater world and cave instead of just walking around.