SHARE
TWEET

Untitled

a guest Dec 12th, 2018 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  //Drifting Thoughts Car script with flight
  2. //by Kayla Stonecutter
  3. //
  4. //
  5.  
  6.  
  7. //Basic settings
  8. list        ForwardPowerGears = [2, 07, 15, 30, 35, 260]; //Forward power for each gear, any number of gears. Jump/Crouch to change gears
  9. float       ReversePower = -13; //Reverse power
  10. float       TurnPower = 4; //Turning power
  11. float       TurnSpeedAdjust = 0.0; //how much effect speed has on turning, higher numbers effect more. 0.0 to disable
  12.  
  13. float       FlightForwardPower = 20; //Power for flight modes
  14. float       FlightReversePower = -13;
  15. float       FlightUpPower = 14;
  16. float       FlightDownPower = -14;
  17. float       FlightStrafePower = 12;
  18. float       FlightTurnPower = 4;
  19.  
  20.  
  21. string      SitText = "Drive"; //Text to show on pie menu
  22. string      NonOwnerMessage = "Sorry ! Not yours ! Don't touch !"; //Message when someone other than owner tries to sit
  23.  
  24. integer     ListenCh = 911; //channel to listen for commands
  25. string      HornCommand = "h"; //command to sound the horn
  26. string      RevCommand = "r"; //command to rev the engine
  27. string      IdleCommand = "i"; //command to start engine
  28. string      StopCommand = "s"; //command to stop engine
  29. string      FlightCommand = "f"; //command to switch to flight mode
  30. string      GroundCommand = "g"; //command to switch to ground mode
  31.  
  32. integer     EnableFlight = 0;//set to 0 to not allow flight mode
  33.  
  34. //You can leave Horn, Rev, and Startup sounds at "" to not use them. Idle, Run, and Flight must be filled (Idle and Run can be the same)
  35. //sounds must either be the name of a sound in the contents, or a UUID. Horn and Rev sounds go with the Horn/Rev script in a different prim
  36. string      FlightSound = "Flight"; //Sound to play while flying
  37. string      HornSound = "Horn"; //Sound to play for horn
  38. string      RevSound = "Rev"; //Sound to play for engine rev
  39. string      IdleSound = "Idle"; //Sound to play when idling
  40. string      RunSound = "Run"; //Sound to play when the gas in pressed
  41. string      StartupSound = "Startup"; //Sound to play when owner sits
  42. string      CollisionSound = "Collisionn"; //Sound to play when colliding with something else
  43.  
  44. vector      SitTarget = <-0.3,0.0, 0.4>; //Position relative to root to place driver
  45. vector      SitRotation = <0, 0, 0>; //Rotation of the avatar, in degrees
  46. string      DrivingAnim = "ride"; //Animation to play when owner sits, leave blank for no anim
  47.  
  48. //Other variables
  49. key         Owner;
  50. string      OwnerName;
  51. float       ForwardPower;
  52. integer     NumGears;
  53. integer     Gear;
  54. integer     NewSound;
  55. string      Sound;
  56. integer     CurDir;
  57. integer     LastDir;
  58. integer     Forward;
  59. vector      SpeedVec;
  60. vector      Linear;
  61. vector      Angular;
  62. integer     Active;
  63. key         sitting;
  64. integer     Moving;
  65. string      SimName;
  66.  
  67. integer     DIR_STOP = 100;
  68. integer     DIR_START = 101;
  69. integer     DIR_NORM = 102;
  70. integer     DIR_LEFT = 103;
  71. integer     DIR_RIGHT = 104;
  72. integer     DIR_FLIGHT = 105;
  73.  
  74.  
  75. default
  76. {
  77.     state_entry()
  78.     {
  79.         if(llGetInventoryType("DT Unpacker") == -1)
  80.         {
  81.             Owner = llGetOwner();
  82.             OwnerName = llKey2Name(Owner);
  83.             TurnSpeedAdjust *= 50.0;
  84.             ForwardPower = llList2Integer(ForwardPowerGears, 0);
  85.             NumGears = llGetListLength(ForwardPowerGears);
  86.             llSetSitText(SitText);
  87.             llCollisionSound(CollisionSound, 1.0);
  88.             llSitTarget(SitTarget, llEuler2Rot(SitRotation * DEG_TO_RAD));
  89.             state Ground;
  90.         }
  91.     }
  92.    
  93.     on_rez(integer param)
  94.     {
  95.         llResetScript();
  96.     }
  97. }
  98.  
  99. state Ground
  100. {
  101.     state_entry()
  102.     {
  103.         llListen(ListenCh, "", NULL_KEY, "");
  104.         llStopSound();
  105.         if(!Active)
  106.         {
  107.             llSetStatus(STATUS_PHYSICS, FALSE);
  108.             llMessageLinked(LINK_ALL_CHILDREN , DIR_STOP, "", NULL_KEY);
  109.             llUnSit(llAvatarOnSitTarget());
  110.         }else{
  111.             SimName = llGetRegionName();
  112.             llMessageLinked(LINK_ALL_CHILDREN, DIR_START, "", NULL_KEY);
  113.             llMessageLinked(LINK_ALL_CHILDREN, DIR_NORM, "", NULL_KEY);
  114.             NewSound = 1;
  115.             Sound = IdleSound;
  116.             Linear = <0,0,-2>;
  117.             Gear = 0;
  118.             ForwardPower = llList2Integer(ForwardPowerGears, 0);
  119.             llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT | CONTROL_UP | CONTROL_DOWN | CONTROL_LBUTTON, TRUE, FALSE);
  120.         }
  121.        
  122.         llSetVehicleType(VEHICLE_TYPE_CAR);
  123.         llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.80);
  124.         llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.10);
  125.        
  126.         llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.2);
  127.         llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 0.10);
  128.        
  129.         llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1.0);
  130.         llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.1);
  131.        
  132.         llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.1);
  133.         llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.1);
  134.        
  135.         llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1000.0, 10.0, 1000.0> );
  136.         llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <500.0, 500.0, 1000.0> );
  137.        
  138.         llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.50);
  139.         llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 0.50);
  140.        
  141.         llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, 0 );
  142.         llSetVehicleFloatParam(VEHICLE_HOVER_EFFICIENCY, 0 );
  143.         llSetVehicleFloatParam(VEHICLE_HOVER_TIMESCALE, 1000 );
  144.         llSetVehicleFloatParam(VEHICLE_BUOYANCY, 0 );
  145.        
  146.         llRemoveVehicleFlags(VEHICLE_FLAG_HOVER_WATER_ONLY | VEHICLE_FLAG_HOVER_TERRAIN_ONLY | VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT);
  147.        
  148.         llSetVehicleFlags(VEHICLE_FLAG_NO_DEFLECTION_UP | VEHICLE_FLAG_LIMIT_ROLL_ONLY | VEHICLE_FLAG_HOVER_UP_ONLY | VEHICLE_FLAG_LIMIT_MOTOR_UP);
  149.  
  150.     }
  151.    
  152.     on_rez(integer param)
  153.     {
  154.         llResetScript();
  155.     }
  156.    
  157.     listen(integer channel, string name, key id, string message)
  158.     {
  159.         if (llGetOwnerKey(id) == llGetOwner())
  160.         {
  161.             message = llToLower(message);
  162.             if((message == HornCommand) && (HornSound != "")) llMessageLinked(LINK_SET, 12345, HornSound, NULL_KEY);
  163.             else if((message == RevCommand) && (RevSound != "")) llMessageLinked(LINK_SET, 12345, RevSound, NULL_KEY);
  164.             else if(message == IdleCommand) llLoopSound(IdleSound, 1.0);
  165.             else if(message == StopCommand) llStopSound();
  166.             else if((message == FlightCommand) && Active && EnableFlight) state Flight;
  167.             else if (message == "gethud") llGiveInventory(id, "SPD Patrol Car HUD II");
  168.             else if (message == "getattachments") llGiveInventory(id, "SPD Patrol Car Attachments");
  169.             else if (message == "getmanual") llGiveInventory(id, "SPD Patrol Car Manual");
  170.         }
  171.     }
  172.    
  173.     changed(integer change)
  174.     {
  175.         if((change & CHANGED_LINK) == CHANGED_LINK)
  176.         {
  177.             sitting = llAvatarOnSitTarget();
  178.             if(sitting)
  179.             {
  180.                 if(llSameGroup(sitting) != TRUE)
  181.                 {
  182.                     llWhisper(0, NonOwnerMessage);
  183.                     llUnSit(sitting);
  184.                 }else if(!Active)
  185.                 {
  186.                     llWhisper(0, "ATV Quad Bike by Bethi Catteneo" );
  187.  
  188.                     llRequestPermissions(sitting, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS | PERMISSION_CONTROL_CAMERA);
  189.                     if(StartupSound != "") llTriggerSound(StartupSound, 1.0);
  190.                     llMessageLinked(LINK_ALL_CHILDREN, DIR_START, "", NULL_KEY);
  191.                     llSetPos(llGetPos() + <0,0,0.15>);
  192.                     llSetStatus(STATUS_PHYSICS, TRUE);
  193.                     SimName = llGetRegionName();
  194.                     llLoopSound(IdleSound, 1.0);
  195.                     llWhisper(0, "Engine ready.");
  196.                     llSetTimerEvent(0.1);
  197.                     CurDir = DIR_NORM;
  198.                     LastDir = DIR_NORM;
  199.                 }
  200.             }else if(Active)
  201.             {
  202.                 llSetTimerEvent(0.0);
  203.                 if(DrivingAnim != "") llStopAnimation(DrivingAnim);
  204.                 Active = 0;
  205.                 llStopSound();
  206.                 llSetStatus(STATUS_PHYSICS, FALSE);
  207.                 llMessageLinked(LINK_ALL_CHILDREN , DIR_STOP, "", NULL_KEY);
  208.                 llReleaseControls();
  209.             }
  210.         }
  211.     }
  212.    
  213.     run_time_permissions(integer perms)
  214.     {
  215.         if(perms == (PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS | PERMISSION_CONTROL_CAMERA))
  216.         {
  217.             Active = 1;
  218.             Gear = 0;
  219.             Linear = <0,0,-2>;
  220.             Angular = <0,0,0>;
  221.             if(DrivingAnim != "")
  222.             {
  223.                 llStopAnimation("sit");
  224.                 llStartAnimation(DrivingAnim);
  225.             }
  226.             llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_DOWN | CONTROL_UP | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT, TRUE, FALSE);
  227.             llSetCameraParams([
  228.                 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
  229.                 CAMERA_BEHINDNESS_ANGLE, 2.0, // (0 to 180) degrees
  230.                 CAMERA_BEHINDNESS_LAG, 0.1, // (0 to 3) seconds
  231.                 CAMERA_DISTANCE, 8.0, // ( 0.5 to 10) meters
  232.                 // CAMERA_FOCUS, <0,0,0>, // region-relative position
  233.                 CAMERA_FOCUS_LAG, 0.1 , // (0 to 3) seconds
  234.                 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
  235.                 CAMERA_FOCUS_THRESHOLD, 0.5, // (0 to 4) meters
  236.                 CAMERA_PITCH, 20.0, // (-45 to 80) degrees
  237.                 // CAMERA_POSITION, <0,0,0>, // region-relative position
  238.                 CAMERA_POSITION_LAG, 0.1, // (0 to 3) seconds
  239.                 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
  240.                 CAMERA_POSITION_THRESHOLD, 0.5, // (0 to 4) meters
  241.                 CAMERA_FOCUS_OFFSET, <0,0,0> // <-10,-10,-10> to <10,10,10> meters
  242.             ]);
  243.         }
  244.     }
  245.    
  246.     control(key id, integer levels, integer edges)
  247.     {
  248.         if((edges & levels & CONTROL_FWD) && (edges & levels & CONTROL_BACK) && EnableFlight) state Flight;
  249.        
  250.         if(!Moving)
  251.         {
  252.             Moving = 1;
  253.             llSetStatus(STATUS_PHYSICS, TRUE);
  254.         }
  255.        
  256.         SpeedVec = llGetVel() / llGetRot();
  257.        
  258.         if((edges & levels & CONTROL_UP))
  259.         {
  260.             if((Gear + 1) != NumGears)
  261.             {
  262.                 ++Gear;
  263.                 llWhisper(0, "Gear " + (string)(Gear + 1));
  264.                 ForwardPower = llList2Float(ForwardPowerGears, Gear);
  265.                 if(Linear.x > 0) Linear.x = ForwardPower;
  266.             }
  267.         }else if((edges & levels & CONTROL_DOWN))
  268.         {
  269.             if((Gear - 1) != -1)
  270.             {
  271.                 --Gear;
  272.                 llWhisper(0, "Gear " + (string)(Gear + 1));
  273.                 ForwardPower = llList2Float(ForwardPowerGears, Gear);
  274.                 if(Linear.x > 0) Linear.x = ForwardPower;
  275.             }
  276.         }
  277.        
  278.         if((edges & levels & CONTROL_FWD))
  279.         {
  280.             Linear.x = ForwardPower;
  281.             NewSound = 1;
  282.             Sound = RunSound;
  283.         }else if((edges & levels & CONTROL_BACK))
  284.         {
  285.             Linear.x = ReversePower;
  286.             NewSound = 1;
  287.             Sound = RunSound;
  288.         }else if((edges & ~levels & CONTROL_FWD) || (edges & ~levels & CONTROL_BACK))
  289.         {
  290.             Linear.x = 0.0;
  291.             NewSound = 1;
  292.             Sound = IdleSound;
  293.         }
  294.        
  295.         if(llFabs(SpeedVec.x) < 0.5)
  296.         {
  297.             if(levels & CONTROL_ROT_LEFT) CurDir = DIR_LEFT;
  298.             else if(levels & CONTROL_ROT_RIGHT) CurDir = DIR_RIGHT;
  299.             else CurDir = DIR_NORM;
  300.             Angular.z = 0.0;
  301.         }else{
  302.             if(SpeedVec.x < 0.0)
  303.             {
  304.                 Forward = -1;
  305.                 SpeedVec.x *= -TurnSpeedAdjust;
  306.             }else{
  307.                 Forward = 1;
  308.                 SpeedVec.x *= TurnSpeedAdjust;
  309.             }
  310.            
  311.             if(levels & CONTROL_ROT_LEFT)
  312.             {
  313.                 CurDir = DIR_LEFT;
  314.                 Angular.z = (TurnPower - SpeedVec.x) * Forward;
  315.             }else if(levels & CONTROL_ROT_RIGHT)
  316.             {
  317.                 CurDir = DIR_RIGHT;
  318.                 Angular.z = -((TurnPower - SpeedVec.x) * Forward);
  319.             }else if((edges & ~levels & CONTROL_ROT_LEFT) || (edges & ~levels & CONTROL_ROT_RIGHT))
  320.             {
  321.                 CurDir = DIR_NORM;
  322.                 Angular.z = 0;
  323.             }
  324.         }
  325.     }
  326.    
  327.     moving_end()
  328.     {
  329.         if(llGetRegionName() == SimName)
  330.         {
  331.             Moving = 0;
  332.             llSetStatus(STATUS_PHYSICS, FALSE);
  333.         }else{
  334.             SimName = llGetRegionName();
  335.         }
  336.     }
  337.    
  338.     timer()
  339.     {
  340.         if(Linear != <0.0,  0.0, -2.0>)
  341.         {
  342.             llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, Linear);
  343.             llApplyImpulse(Linear, TRUE);
  344.         }
  345.         if(Angular != <0.0, 0.0, 0.0>) llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, Angular);
  346.         if(CurDir != LastDir)
  347.         {
  348.             llMessageLinked(LINK_ALL_CHILDREN, CurDir, "", NULL_KEY);
  349.             LastDir = CurDir;
  350.         }
  351.         if(NewSound)
  352.         {
  353.             llStopSound();
  354.             NewSound = 0;
  355.             llLoopSound(Sound, 1.0);
  356.         }
  357.     }
  358. }
  359.  
  360. state Flight
  361. {
  362.     state_entry()
  363.     {
  364.         Linear = <0,0,0>;
  365.         llStopSound();
  366.         llMessageLinked(LINK_ALL_CHILDREN, DIR_FLIGHT, "", NULL_KEY);
  367.         llLoopSound(FlightSound, 1.0);
  368.         llSetStatus(STATUS_PHYSICS, FALSE);
  369.         llSetPos(llGetPos() + <0,0,0.25>);
  370.         vector rot = llRot2Euler(llGetRot());
  371.         llSetRot(llEuler2Rot(<0,0,rot.z>));
  372.         llListen(ListenCh, "", NULL_KEY, "");
  373.         llSetVehicleType(VEHICLE_TYPE_AIRPLANE);
  374.        
  375.         // linear friction
  376.         llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <100.0, 100.0, 100.0>);
  377.        
  378.         // uniform angular friction
  379.         llSetVehicleFloatParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, 0.5);
  380.        
  381.         // linear motor
  382.         llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0.0, 0.0, 0.0>);
  383.         llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1.0);
  384.         llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 1.0);
  385.        
  386.         // angular motor
  387.         llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <0.0, 0.0, 0.0>);
  388.         llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 1.0);
  389.         llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 2.0);
  390.        
  391.         // hover
  392.         llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, 0.0);
  393.         llSetVehicleFloatParam(VEHICLE_HOVER_EFFICIENCY, 0.0);
  394.         llSetVehicleFloatParam(VEHICLE_HOVER_TIMESCALE, 360.0);
  395.         llSetVehicleFloatParam(VEHICLE_BUOYANCY, 0.988);
  396.        
  397.         // linear deflection
  398.         llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.0);
  399.         llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 1.0);
  400.        
  401.         // angular deflection
  402.         llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.25);
  403.         llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 100.0);
  404.        
  405.         // vertical attractor
  406.         llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.5);
  407.         llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 1.0);
  408.        
  409.         // banking
  410.         llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, 0.0);
  411.         llSetVehicleFloatParam(VEHICLE_BANKING_MIX, 1.0);
  412.         llSetVehicleFloatParam(VEHICLE_BANKING_TIMESCALE, 1.0);
  413.        
  414.         // default rotation of local frame
  415.         llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0.00000, 0.00000, 0.00000, 0.00000>);
  416.        
  417.         // removed vehicle flags
  418.         llRemoveVehicleFlags(VEHICLE_FLAG_NO_DEFLECTION_UP | VEHICLE_FLAG_HOVER_WATER_ONLY | VEHICLE_FLAG_HOVER_TERRAIN_ONLY | VEHICLE_FLAG_HOVER_UP_ONLY | VEHICLE_FLAG_LIMIT_MOTOR_UP | VEHICLE_FLAG_LIMIT_ROLL_ONLY);
  419.        
  420.         // set vehicle flags
  421.         llSetVehicleFlags(VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT);
  422.         llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT | CONTROL_UP | CONTROL_DOWN | CONTROL_LBUTTON, TRUE, FALSE);
  423.        
  424.         llSetStatus(STATUS_PHYSICS, TRUE);
  425.        
  426.         llWhisper(0, "Modo Voo Ativado.");
  427.     }
  428.    
  429.     on_rez(integer param)
  430.     {
  431.         llResetScript();
  432.     }
  433.    
  434.     listen(integer channel, string name, key id, string message)
  435.     {
  436.         if (llGetOwnerKey(id) == llGetOwner())
  437.         {
  438.             message = llToLower(message);
  439.             if((message == HornCommand) && (HornSound != "")) llMessageLinked(LINK_SET, 12345, HornSound, NULL_KEY);
  440.             else if(message == GroundCommand) state Ground;
  441.         }
  442.     }
  443.    
  444.     control(key name, integer levels, integer edges)
  445.     {
  446.         if((edges & levels & CONTROL_FWD) && (edges & levels & CONTROL_BACK)) state Ground;
  447.        
  448.         if((levels & CONTROL_LBUTTON))
  449.         {
  450.             llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0,0,0>);
  451.             llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <0,0,0>);
  452.             llSetStatus(STATUS_PHYSICS, FALSE);
  453.             llSleep(0.1);
  454.             llSetStatus(STATUS_PHYSICS, TRUE);
  455.             return;
  456.         }
  457.        
  458.         if((edges & levels & CONTROL_UP)) Linear.z = FlightUpPower;
  459.         else if((edges & levels & CONTROL_DOWN)) Linear.z = FlightDownPower;
  460.         else if((edges & ~levels & CONTROL_UP) || (edges & ~levels & CONTROL_DOWN)) Linear.z = 0.0;
  461.  
  462.         if((edges & levels & CONTROL_FWD)) Linear.x = FlightForwardPower;
  463.         else if((edges & levels & CONTROL_BACK)) Linear.x = FlightReversePower;
  464.         else if((edges & ~levels & CONTROL_FWD) || (edges & ~levels & CONTROL_BACK)) Linear.x = 0.0;
  465.        
  466.         if((edges & levels & CONTROL_LEFT)) Linear.y = FlightStrafePower;
  467.         else if((edges & levels & CONTROL_RIGHT)) Linear.y = -FlightStrafePower;
  468.         else if((edges & ~levels & CONTROL_LEFT) || (edges & ~levels & CONTROL_RIGHT)) Linear.y = 0.0;
  469.        
  470.         if((edges & levels & CONTROL_ROT_LEFT)) Angular.z = FlightTurnPower;
  471.         else if((edges & levels & CONTROL_ROT_RIGHT)) Angular.z = -FlightTurnPower;
  472.         else if((edges & ~levels & CONTROL_ROT_LEFT) || (edges & ~levels & CONTROL_ROT_RIGHT)) Angular.z = 0.0;
  473.     }
  474.    
  475.     changed(integer change)
  476.     {
  477.         if((change & CHANGED_LINK) == CHANGED_LINK)
  478.         {
  479.             sitting = llAvatarOnSitTarget();
  480.             if(sitting == NULL_KEY)
  481.             {
  482.                 llSetTimerEvent(0.0);
  483.                 if(DrivingAnim != "") llStopAnimation(DrivingAnim);
  484.                 Active = 0;
  485.                 llStopSound();
  486.                 llSetStatus(STATUS_PHYSICS, FALSE);
  487.                 llMessageLinked(LINK_ALL_CHILDREN , DIR_STOP, "", NULL_KEY);
  488.                 llReleaseControls();
  489.                 state Ground;
  490.             }
  491.         }
  492.     }
  493.    
  494.     timer()
  495.     {
  496.         llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, Linear);
  497.  
  498.         llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, Angular);
  499.     }
  500.     state_exit()
  501.     {
  502.         llWhisper(0, "Modo Voo Destivado.");
  503.     }
  504. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top