|
Bonjour
Dabord je te conseille de faire les freebies ce que tu demande y est et ca irais plus vite.
sinon y a ca pour que un objet te suive
// From Open Basic Follower/Facing Script, by Logan Bauer. //
///////////////////////////////////////////////////////////////////////
// OFFSET is the position of your pet in relation to it's owner's position.
// For example, in the default setting below, "vector offset =<-1,0,1>;"
// I.E. (x,y,z), the -1 puts it 1m back behind owner, the 0 means don't have
// it stay left or right, and 1 means have it stay 1m above it's owner.
// So, if you wanted the script to make it follow directly in front of you,
// and to the left, then you would change it to "vector offset =<1,1,0>;"
// llFrand(float max)
vector offset =<-1.2,0,1>;
vector currentoffset =<0,0,0>;
float xshift =.2; //How far it roams forward and back.
float yshift =1.25; //How wide it roams left to right.
float bob =2; //multiplyer of the BobCycle listed below.
float shifttime =5; //average time it takes to shift to another XY position.
integer timeset=0; //Is the timer running?
float currentxshift =0; //current X shift position
float currentyshift =0; //current Y shift position
float currentyfacing =0; //currentyfacing storage
integer currentbob; //current state of the BobCycle
float bobbing =0; //bob storage
list BobCycle = [0.0, 0.08, 0.12, 0.14, 0.15, 0.14, 0.12, 0.08, 0.0, -0.08, -0.12, -0.14, -0.15, -0.14, -0.12, -0.08];
startup()
{
vector pos = llGetPos();
llSetStatus(STATUS_ROTATE_Z,TRUE);
llSetStatus(STATUS_PHYSICS, TRUE);
key id = llGetOwner();
llSensorRemove();
llSensorRepeat("",llGetOwner(),AGENT,200,2*PI,.5);
}
default
{
state_entry()
{
startup();
}
on_rez(integer start_param)
{
startup();
}
sensor(integer total_number)
{
vector pos = llDetectedPos(0);
bobbing = llList2Float(BobCycle, currentbob)*bob;
llSetTimerEvent(llFrand(shifttime));
currentoffset = <currentxshift, currentyshift, bobbing>;
llMoveToTarget(pos+(offset+currentoffset)*llDetectedRot(0),.3);
if (currentyshift>=0)
{
currentyfacing = currentyshift;
} else {
currentyfacing = currentyshift*-1;
}
llLookAt(pos+<0,0+(currentyfacing*.33),1+bobbing>, 1 , 2);
currentbob = currentbob +1;
if (currentbob == 16)
{
currentbob = 0;
}
if(timeset==0)
{
timeset = 1;
llSetTimerEvent(((llFrand(shifttime)+llFrand(shifttime)+llFrand(shifttime))/3)*2);
}
}
timer()
{
timeset = 0;
currentyshift = llFrand(yshift*2)-yshift;
currentxshift = llFrand(xshift*2)-xshift;
}
}
Et ca pour ton tapis volant.
// Cubey Terra Helicopter Style Flight script
// Do not delete these script credits! If you modify this script, *add* your name and date and make your work available in Public Domain.
// * Portions based on a public-domain flight script from Jack Digeridoo.
// * Portions based on hoverboard script by Linden Lab.
// * Nov 30, 2003 - Significant modifications and additions by Cubey Terra... (apologies for the crappy indenting). -CT
// * Jan 11, 2004 - Fixed listen bug. Thanks to Trimming Hedges for the solution. -TH
// * March 27, 2004 - Adapted to work as helicopter-style vehicle -CT
// * April 8, 2004 - Adapted to work as U-Fly Taxi -CT
// * April 15, 2004 - Adapted to work as DIY helicopter script -CT
// * ???, 2004 - Adapted to work as magic carpet. -CT
// * April 10, 2006 - Released to public. Tidied some code. Added beacon. Allowed anyone to pilot, no longer keyed to owner. -CT
integer sit = FALSE;
integer listenTrack;
integer brake = TRUE;
integer BEACON_INT = 1440; //# of mins between beacon messages
integer beaconMins; // current # of minutes elapsed since last beacon message
float X_THRUST = 20;
float Z_THRUST = 15;
float xMotor;
float zMotor;
key agent;
key pilot;
vector SIT_POS = <0.25, 0.0, 0.65>;
vector CAM_OFFSET = <-10.0, 0.0, 2.0>;
vector CAM_ANG = <0.0, 0.0, 2.0>;
listenState(integer on) // start/stop listen
{
if (listenTrack)
{
llListenRemove(listenTrack);
listenTrack = 0;
}
if (on) listenTrack = llListen(0, "", pilot, "");
}
help()
{
llWhisper(0,"O Master of the Carpet, you may use these commands to fly me...");
llWhisper(0," Say START to begin moving.");
llWhisper(0," Say STOP to stop moving.");
llWhisper(0," PgUp/PgDn or E/C = hover up/down");
llWhisper(0," Arrow keys or WASD = forward, back, left, right");
llWhisper(0," Say HELP to display help.");
}
default {
state_entry()
{
llSetSitText("Fly");
llSitTarget(SIT_POS, ZERO_ROTATION);
llSetCameraEyeOffset(CAM_OFFSET);
llSetCameraAtOffset(CAM_ANG);
llCollisionSound("",0.0);
//SET VEHICLE PARAMETERS
llSetVehicleType(VEHICLE_TYPE_AIRPLANE);
llSetVehicleVectorParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, <200, 20, 20> );
// uniform angular friction
llSetVehicleFloatParam( VEHICLE_ANGULAR_FRICTION_TIMESCALE, 2 );
// linear motor
llSetVehicleVectorParam( VEHICLE_LINEAR_MOTOR_DIRECTION, <0, 0, 0> );
llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_TIMESCALE, 2 );
llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 120 );
// agular motor
llSetVehicleVectorParam( VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0, 0> );
llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0 );
llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, .4);
// hover
llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, 2 );
llSetVehicleFloatParam( VEHICLE_HOVER_EFFICIENCY, 0 );
llSetVehicleFloatParam( VEHICLE_HOVER_TIMESCALE, 10000 );
llSetVehicleFloatParam( VEHICLE_BUOYANCY, 0.977 );
// no linear deflection
llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0 );
llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 5 );
// no angular deflection
llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0);
llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 5);
// no vertical attractor
llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 1 );
llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 1 );
// banking
llSetVehicleFloatParam( VEHICLE_BANKING_EFFICIENCY, 1);
llSetVehicleFloatParam( VEHICLE_BANKING_MIX, .5);
llSetVehicleFloatParam( VEHICLE_BANKING_TIMESCALE, 0.01);
// default rotation of local frame
llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME, <0,0,0,1>);
// remove these flags
llRemoveVehicleFlags( VEHICLE_FLAG_NO_DEFLECTION_UP
| VEHICLE_FLAG_HOVER_WATER_ONLY
| VEHICLE_FLAG_LIMIT_ROLL_ONLY
| VEHICLE_FLAG_HOVER_TERRAIN_ONLY
| VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT
| VEHICLE_FLAG_HOVER_UP_ONLY
| VEHICLE_FLAG_LIMIT_MOTOR_UP );
}
on_rez(integer num)
{
llSetStatus(STATUS_PHYSICS, FALSE);
pilot = llGetOwner();
llSetTimerEvent(60); // beacon timer for 1 min intervals
}
listen(integer channel, string name, key id, string message)
{
message == llToLower(message);
if (message == "help")
{
help();
}
if (message == "stop")
{
brake = TRUE;
llWhisper(0,"We are stopped, O Master of the Carpet. You may say START to resume flight.");
llSetStatus(STATUS_PHYSICS, FALSE);
}
else if (message == "start")
{
brake = FALSE;
llWhisper(0,"I hear and obey, O Master of the Carpet. We now begin flight.");
llSetStatus(STATUS_PHYSICS, TRUE);
}
}
// DETECT AV SITTING/UNSITTING AND GIVE PERMISSIONS
changed(integer change)
{
agent = llAvatarOnSitTarget();
if(change & CHANGED_LINK)
{
if((agent == NULL_KEY) && (sit))
{
//
// Avatar gets off vehicle
//
llSetStatus(STATUS_PHYSICS, FALSE);
llStopAnimation("sit_ground");
llMessageLinked(LINK_SET, 0, "unseated", "");
llStopSound();
llReleaseControls();
sit = FALSE;
listenState(FALSE);
}
else if ((agent == llGetOwner()) && (!sit))
{
//
// Avatar gets on vehicle
//
pilot = llAvatarOnSitTarget();
sit = TRUE;
llRequestPermissions(pilot, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
listenState(TRUE);
llWhisper(0,"O Master of the Carpet, "+llKey2Name(pilot)+", command me as you will. Should you need assistance, please speak the word HELP.");
llMessageLinked(LINK_SET, 0, "seated", "");
}
}
}
//CHECK PERMISSIONS AND TAKE CONTROLS
run_time_permissions(integer perm)
{
if (perm & (PERMISSION_TAKE_CONTROLS))
{
llTakeControls(CONTROL_UP | CONTROL_DOWN | CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT, TRUE, FALSE);
}
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
// Admittedly, animations are bugged. I'll let you figure it out. :) -CT
llStartAnimation("sit_ground");
llStopAnimation("sit");
}
}
//FLIGHT CONTROLS
control(key id, integer level, integer edge)
{
vector angular_motor;
integer motor_changed;
if ((level & CONTROL_FWD) || (level & CONTROL_BACK))
{
if (edge & CONTROL_FWD) xMotor = X_THRUST;
if (edge & CONTROL_BACK) xMotor = -X_THRUST;
}
else
{
xMotor = 0;
}
if ((level & CONTROL_UP) || (level & CONTROL_DOWN))
{
if (level & CONTROL_UP)
{
zMotor = Z_THRUST;
}
if (level & CONTROL_DOWN)
{
zMotor = -Z_THRUST;
}
}
else
{
zMotor = 0;
}
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <xMotor,0,zMotor>);
if (level & CONTROL_RIGHT) {
angular_motor.x = TWO_PI;
angular_motor.y /= 8;
}
if (level & CONTROL_LEFT) {
angular_motor.x = -TWO_PI;
angular_motor.y /= 8;
}
if (level & CONTROL_ROT_RIGHT) {
angular_motor.x = TWO_PI;
angular_motor.y /= 8;
}
if (level & CONTROL_ROT_LEFT) {
angular_motor.x = -TWO_PI;
angular_motor.y /= 8;
}
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, angular_motor);
}
timer()
{
//This is a beacon. Vehicles that are not keyed to owner will often get stolen.
// To avoid leaving vehicle litter all over the world, this beacon notifies the owner of it's location.
if (beaconMins < BEACON_INT)
{
beaconMins += 1;
}
else
{
beaconMins = 0;
vector pos = llGetPos();
llInstantMessage(llGetOwner(), "O Master of the Carpet, I have been left unattended in "+llGetRegionName()+" "+(string)((integer)pos.x)+", "+(string)((integer)pos.y)+", at an altitude of "+(string)((integer)pos.z)+" meters.");
}
}
}
|