boat scriptは、ギア変速タイプがB、ギア変速なしがAと分けています。
お約束、このスクリプトは私の製作記録として残しておきます。参考になさられてかまいませんが、動作やそれにまつわる損害等を保証出来ません。
今回のfishing boat mm_expressでの変更点
- 設定ファイルにカメラの詳しい設定を書き正しく変更出来るようにした。
- アニメーションにllSetAnimationOverrideをつかってみる。(利点、負荷が軽くなるらしい?前のアニメを止めなくて、次のにかえられる。欠点 パーミション取得の確認が表示されて、うざい。そのため、ドライバー以外は見送った。あと、落ちたときなど、アニメーションが戻らないことが多い)
- 運転席が2カ所あるので、座ったあとアバターを移動させる。
- 不具合解消、CHANGE_LINKイベントで毎回パーミション取得していたので、最初だけにした。
- 不具合解消、ステアリングホイールがうまく回らなかった記入ミス修正(テストしてたプリムナンバー2をそのまま書いていた正くはLINK_THIS)
rootプリムのなかのスクリプト
設定ファイルとメインのboat scriptを変更しました
config
//sit_pos <Front, Left, up> <-0.2, 0.0, 2.05> //sit_rot <0.0, 0.0, 0.0> //distance to the tower <0.4, 0.0, 3.95> //camera_eye <-10.0, 0.0,4.0> //camera_at <0.0,0.0,2.0> //CAMERA_ACTIVE ( TRUE = 1 or FALSE = 0 )// 1 //CAMERA_BEHINDNESS_ANGLE ( 0 to 180 float degrees )// 30 //CAMERA_BEHINDNESS_LAG ( 0 to 3 float seconds )// 0.4 //CAMERA_DISTANCE ( 0.5 to 50 float meters )// 10.0 //CAMERA_FOCUS_LAG ( 0 to 3 float seconds )// 0.1 //CAMERA_FOCUS_LOCKED ( TRUE = 1 or FALSE = 0 )// 0 //CAMERA_FOCUS_THRESHOLD ( 0 to 4 float meters )// 1.0 //CAMERA_PITCH ( -45 to 80 float degrees )// 15 //CAMERA_POSITION_LAG ( 0 to 3 float seconds )// 0.1 //CAMERA_POSITION_LOCKED ( TRUE = 1 or FALSE = 0 )// 0 //CAMERA_POSITION_THRESHOLD ( 0 to 4 float meters )// 1.0 //CAMERA_FOCUS_OFFSET ( <-10,-10,-10> to <10,10,10> vector meters ZERO_VECTOR = <0.0,0.0,0.0> )// <0.0,0.0,0.0>
boat script
string mainname = "mm_express"; string animation_name1="mm_boat11_ca"; string animation_name2="mm_boat11_car"; string animation_name3="mm_boat11_cal"; string animation_name4="mm_boat11_cb"; string animation_name5="mm_boat11_cbr"; string animation_name6="mm_boat11_cbl"; string owneridname; vector sit_pos; vector sit_pos1; vector sit_pos2; vector sit_rot1; vector camera_eye1; vector camera_at1; integer cp1; float cp2; float cp3; float cp4; float cp5; integer cp6; float cp7; float cp8; float cp9; integer cp10; float cp11; vector cp12; vector autolinear; float yaw = 4.0; float kasoku = 1.0; float gear = 1; float maxspeedpergear = 18; float speed = 0; float nowspeed = 0; float maxrot = 1.0; float hoverhight; float hoverhightH = 0.6; float hoverhightL = 0.01; integer pm = FALSE; integer kaji = 0; integer power = FALSE; integer auto = FALSE; integer light = FALSE; integer bridge = FALSE; integer steeringLinkNum; integer steering2LinkNum; integer WBREZ = 666; integer MTIMERON = 667; integer MTIMEROFF = 668; integer MTIMEOUT = 669; integer cmin = 1000000000; //chat canel -2147483647 < integer cmax = 2000000000; // < 2147483647 integer dialogchannel; integer handle; integer driverMode;//0=owner,1=group,3=anu key agent; //sit driver avatar key key ownerid; //object owner avatar key key notelinpos = NULL_KEY; key notelinrot = NULL_KEY; key notelinmov = NULL_KEY; key notelineye = NULL_KEY; key notelincat = NULL_KEY; key notelincp1 = NULL_KEY; key notelincp2 = NULL_KEY; key notelincp3 = NULL_KEY; key notelincp4 = NULL_KEY; key notelincp5 = NULL_KEY; key notelincp6 = NULL_KEY; key notelincp7 = NULL_KEY; key notelincp8 = NULL_KEY; key notelincp9 = NULL_KEY; key notelincp10 = NULL_KEY; key notelincp11 = NULL_KEY; key notelincp12 = NULL_KEY; list mainmenulist = ["Owner","Group","Anyone","Light","Cancel"]; list drivemenulist = ["Bridge","Cockpit","Light","Cancel"]; vector getavlocal(key av) { integer i; integer avlinknum = 0; vector avlocalpos = <0, 0, 0>; if (av) //keyが有効で座っているならば { for (i = 1; i <= llGetNumberOfPrims() && avlinknum == 0; i++) //アバターのリンクナンバーを探す if (llGetLinkKey(i) == agent)avlinknum= i; list params = llGetLinkPrimitiveParams(avlinknum,[PRIM_POS_LOCAL]); avlocalpos = llList2Vector(params, 0); return avlocalpos; } else return avlocalpos; //座ったアバターのローカルポジションを返す } makechanelnum() { ownerid =llGetOwner(); owneridname = llKey2Name(ownerid); dialogchannel = ((integer)llFrand(cmax - cmin) + cmin); } loadNoteConfig() { notelinpos = llGetNotecardLine("config", 1); notelinrot = llGetNotecardLine("config", 3); notelinmov = llGetNotecardLine("config", 5); notelineye = llGetNotecardLine("config", 7); notelincat = llGetNotecardLine("config", 9); notelincp1 = llGetNotecardLine("config", 11); notelincp2 = llGetNotecardLine("config", 13); notelincp3 = llGetNotecardLine("config", 15); notelincp4 = llGetNotecardLine("config", 17); notelincp5 = llGetNotecardLine("config", 19); notelincp6 = llGetNotecardLine("config", 21); notelincp7 = llGetNotecardLine("config", 23); notelincp8 = llGetNotecardLine("config", 25); notelincp9 = llGetNotecardLine("config", 27); notelincp10 = llGetNotecardLine("config", 29); notelincp11 = llGetNotecardLine("config", 31); notelincp12 = llGetNotecardLine("config", 33); } initcamera() { llSetCameraParams([ CAMERA_ACTIVE, cp1, CAMERA_BEHINDNESS_ANGLE, cp2, CAMERA_BEHINDNESS_LAG, cp3, CAMERA_DISTANCE, cp4, CAMERA_FOCUS_LAG, cp5, CAMERA_FOCUS_LOCKED, cp6, CAMERA_FOCUS_THRESHOLD, cp7, CAMERA_PITCH, cp8, CAMERA_POSITION_LAG, cp9, CAMERA_POSITION_LOCKED, cp10, CAMERA_POSITION_THRESHOLD, cp11, CAMERA_FOCUS_OFFSET, cp12 ]); } initParam() { llSetVehicleType(VEHICLE_TYPE_BOAT); llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 1.0); llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 2.5); llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.5); llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 1.0); llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 3.0); llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.5); llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_OFFSET, <-5, 0, 0>); llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 3.0); llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.5); llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.10); llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 3.00); llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, hoverhight); llSetVehicleFloatParam(VEHICLE_HOVER_EFFICIENCY, 0.9); llSetVehicleFloatParam(VEHICLE_HOVER_TIMESCALE, 3.00); llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, 1.0); llSetVehicleFloatParam(VEHICLE_BANKING_MIX, 1.0); llSetVehicleFloatParam(VEHICLE_BANKING_TIMESCALE, 1.0); llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,3,0> * DEG_TO_RAD)); llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <50.0,0.0,1000.0>); llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE,<10.0,10.0,10.0>); llSetVehicleFlags(VEHICLE_FLAG_NO_DEFLECTION_UP // | VEHICLE_FLAG_LIMIT_ROLL_ONLY | VEHICLE_FLAG_LIMIT_MOTOR_UP | VEHICLE_FLAG_HOVER_WATER_ONLY); gear = 1; } getLinkNums() { integer i; integer linkcount=llGetNumberOfPrims(); for (i=1;i<=linkcount;++i) { string str=llGetLinkName(i); if (str=="steering_wheel") steeringLinkNum=i; else if (str=="steering_wheel2") steering2LinkNum=i; } } default { state_entry() { agent = NULL_KEY; hoverhight = hoverhightL; loadNoteConfig(); makechanelnum(); getLinkNums(); llMessageLinked(LINK_SET, 0, "Lightoff", ""); llCollisionSound("", 0.0); llSetSitText("Sit"); llSitTarget(sit_pos1, llEuler2Rot(sit_rot1 * DEG_TO_RAD)); llSetCameraEyeOffset(camera_eye1); llSetCameraAtOffset(camera_at1); initParam(); driverMode = 0; llPreloadSound("1centurion_1"); } on_rez(integer num) { vector pos = llGetPos(); float water_height = llWater(llGetVel()); float ground_height = llGround(llGetVel()); if (water_height > ground_height) { pos.z = water_height + hoverhightL; llSetPos(pos); } llResetScript(); } touch_start(integer total_number) { if (agent == NULL_KEY) { if (llDetectedKey(0) == llGetOwner()) { llDialog(llGetOwner(),"Set operator mode and select color.",mainmenulist,dialogchannel); handle = llListen(dialogchannel,"","",""); llMessageLinked(LINK_THIS,MTIMERON,(string)nowspeed,""); } else { } } else { if (llDetectedKey(0) == agent) { llDialog(agent,"Change driver's position. Light on/off",drivemenulist,dialogchannel); handle = llListen(dialogchannel,"","",""); llMessageLinked(LINK_THIS,MTIMERON,(string)nowspeed,""); } } } listen(integer channel, string name, key id, string message) { if (id == llGetOwner() && agent == NULL_KEY ) { if (llListFindList(mainmenulist,[message]) == 0) { driverMode = 0; if(!auto){llSetPrimitiveParams([PRIM_TEMP_ON_REZ, FALSE]);} llSay(0,"set owner only."); llListenRemove(handle); llMessageLinked(LINK_THIS,MTIMEROFF,(string)nowspeed,""); } else if (llListFindList(mainmenulist,[message]) == 1) { driverMode = 1; //llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE]); llSay(0,"set group driver."); llListenRemove(handle); llMessageLinked(LINK_THIS,MTIMEROFF,(string)nowspeed,""); } else if (llListFindList(mainmenulist,[message]) == 2) { driverMode = 3; llSay(0,"set anyone drive."); //llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE]); llListenRemove(handle); llMessageLinked(LINK_THIS,MTIMEROFF,(string)nowspeed,""); } else if (llListFindList(mainmenulist,[message]) == 3) { if (light == FALSE) { llMessageLinked(LINK_SET, 0, "Lighton", ""); light = TRUE; } else { llMessageLinked(LINK_SET, 0, "Lightoff", ""); light = FALSE; } llListenRemove(handle); llMessageLinked(LINK_THIS,MTIMEROFF,(string)nowspeed,""); } else if (llListFindList(mainmenulist,[message]) == 4) { llListenRemove(handle); llMessageLinked(LINK_THIS,MTIMEROFF,(string)nowspeed,""); } } else if (id == agent) { if (llListFindList(drivemenulist,[message]) == 0) { integer i; integer avlinknum = 0; if (agent == NULL_KEY) return; for (i = 1; i <= llGetNumberOfPrims() && avlinknum == 0; i++) if (llGetLinkKey(i) == agent)avlinknum= i; if (bridge != TRUE) { llSetLinkPrimitiveParamsFast(avlinknum,[PRIM_POSITION, sit_pos + sit_pos2]); llSetAnimationOverride("Sitting", animation_name4); bridge = TRUE; initcamera(); } llListenRemove(handle); llMessageLinked(LINK_THIS,MTIMEROFF,(string)nowspeed,""); } else if (llListFindList(drivemenulist,[message]) == 1) { integer i; integer avlinknum = 0; if (agent == NULL_KEY) return; for (i = 1; i <= llGetNumberOfPrims() && avlinknum == 0; i++) if (llGetLinkKey(i) == agent)avlinknum= i; if (bridge == TRUE) { llSetLinkPrimitiveParamsFast(avlinknum,[PRIM_POSITION, (sit_pos)]); llSetAnimationOverride("Sitting", animation_name1); bridge = FALSE; initcamera(); } llListenRemove(handle); llMessageLinked(LINK_THIS,MTIMEROFF,(string)nowspeed,""); } else if (llListFindList(drivemenulist,[message]) == 2) { if (light == FALSE) { llMessageLinked(LINK_SET, 0, "Lighton", ""); light = TRUE; } else { llMessageLinked(LINK_SET, 0, "Lightoff", ""); light = FALSE; } llListenRemove(handle); llMessageLinked(LINK_THIS,MTIMEROFF,(string)nowspeed,""); } else if (llListFindList(drivemenulist,[message]) == 3) { llListenRemove(handle); llMessageLinked(LINK_THIS,MTIMEROFF,(string)nowspeed,""); } } } link_message(integer sender_number, integer number, string message, key id) { if (number == MTIMEOUT) { llWhisper(0,"Dialog Menu is time out."); llListenRemove(handle); } } changed(integer change) { if (change & CHANGED_LINK) { llListenRemove(handle); agent = llAvatarOnSitTarget(); if (agent != NULL_KEY) { if (driverMode == 0)//owner only mode { if (agent == llGetOwner()) { if(!pm) { llSetStatus(STATUS_PHYSICS, TRUE); //llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE]); llRequestPermissions(agent, PERMISSION_OVERRIDE_ANIMATIONS | PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS | PERMISSION_CONTROL_CAMERA); llMessageLinked(LINK_SET, 0, "seated", ""); pm = TRUE; sit_pos = getavlocal(agent); //座った最初の位置を記録 llTriggerSound("1centurion_1", 1); llSleep(3); } } else { llSay(0,"You are not my owner!"); llUnSit(agent); llMessageLinked(LINK_SET, 0, "unseated", ""); } } else if (driverMode == 1)//group mode { if (llSameGroup(agent)) { if(!pm) { llSetStatus(STATUS_PHYSICS, TRUE); llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE]); llRequestPermissions(agent, PERMISSION_OVERRIDE_ANIMATIONS | PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS | PERMISSION_CONTROL_CAMERA); llMessageLinked(LINK_SET, 0, "seated", ""); pm = TRUE; sit_pos = getavlocal(agent); llTriggerSound("1centurion_1", 1); llSleep(3); } } else { llSay(0,"You are not same group!"); llUnSit(agent); llMessageLinked(LINK_SET, 0, "unseated", ""); } } else if (driverMode == 3)//anyone driver mode { if(!pm) { llSetStatus(STATUS_PHYSICS, TRUE); llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE]); llRequestPermissions(agent, PERMISSION_OVERRIDE_ANIMATIONS | PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS | PERMISSION_CONTROL_CAMERA); llMessageLinked(LINK_SET, 0, "seated", ""); pm = TRUE; sit_pos = getavlocal(agent); llTriggerSound("1centurion_1", 1); llSleep(3); } } } else { key perm_key = llGetPermissionsKey(); if (perm_key != NULL_KEY) { //if (perm_key == llGetOwner() && driverMode == 0) //{ // llSetPrimitiveParams([PRIM_TEMP_ON_REZ, FALSE]); //} llClearCameraParams(); llReleaseControls(); llResetAnimationOverride("Sitting"); //llStopAnimation(animation_name1); bridge = FALSE; pm = FALSE; } llSetStatus(STATUS_PHYSICS, FALSE); llMessageLinked(LINK_SET, 0, "unseated", ""); llStopSound(); llMessageLinked(LINK_ALL_OTHERS,0,"0",""); llSetTimerEvent(0.0); } } else if (change & CHANGED_INVENTORY) { llResetScript(); } } dataserver(key queryid , string data) { if (queryid == notelinpos) { sit_pos1 = (vector)data; } if (queryid == notelinmov) { sit_pos2 = (vector)data; } else if (queryid == notelinrot) { sit_rot1 = (vector)data; } else if (queryid == notelineye) { camera_eye1 = (vector)data; } else if (queryid == notelincat) { camera_at1= (vector)data; } else if (queryid == notelincp1) { cp1= (integer)data; } else if (queryid == notelincp2) { cp2= (float)data; } else if (queryid == notelincp3) { cp3= (float)data; } else if (queryid == notelincp4) { cp4= (float)data; } else if (queryid == notelincp5) { cp5= (float)data; } else if (queryid == notelincp6) { cp6= (integer)data; } else if (queryid == notelincp7) { cp7= (float)data; } else if (queryid == notelincp8) { cp8= (float)data; } else if (queryid == notelincp9) { cp9= (float)data; } else if (queryid == notelincp10) { cp10= (integer)data; } else if (queryid == notelincp11) { cp11= (float)data; } else if (queryid == notelincp12) { cp12= (vector)data; } llSitTarget(sit_pos1, llEuler2Rot(sit_rot1 * DEG_TO_RAD)); llSetCameraEyeOffset(camera_eye1); llSetCameraAtOffset(camera_at1); } run_time_permissions(integer perm) { if (perm & PERMISSION_CONTROL_CAMERA) { initcamera(); } if (perm != 0) { llSetAnimationOverride("Sitting", animation_name1); //llStartAnimation(animation_name1); llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT | CONTROL_UP | CONTROL_DOWN , TRUE, FALSE); llLoopSound("1centurion_2", 1.0); llSetTimerEvent(0.5); } } timer() { if (auto) { llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, autolinear); } vector nowvel = llGetVel() / llGetRot(); nowspeed = nowvel.x / 4; llMessageLinked(LINK_ALL_OTHERS,kaji,(string)nowspeed,""); if (nowspeed >= 4) { if(power == TRUE) { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,12,0> * DEG_TO_RAD)); } else { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,6,0> * DEG_TO_RAD)); } llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, hoverhight + 0.3); llLoopSound("1centurion_10", 1.0); } else if (nowspeed >= 3 && nowspeed < 4) { if(power == TRUE) { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,10,0> * DEG_TO_RAD)); } else { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,5,0> * DEG_TO_RAD)); } llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, hoverhight + 0.2); llLoopSound("1centurion_9", 1.0); } else if (nowspeed >= 2 && nowspeed < 3) { if(power == TRUE) { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,8,0> * DEG_TO_RAD)); } else { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,4,0> * DEG_TO_RAD)); } llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, hoverhight + 0.15); llLoopSound("1centurion_8", 1.0); } else if (nowspeed >= 1 && nowspeed < 2) { if(power == TRUE) { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,8,0> * DEG_TO_RAD)); } else { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,4,0> * DEG_TO_RAD)); } llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, hoverhight + 0.1); llLoopSound("1centurion_7", 1.0); } else if (nowspeed >= 0.8 && nowspeed < 1) { if(power == TRUE) { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,6,0> * DEG_TO_RAD)); } else { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,3,0> * DEG_TO_RAD)); } llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, hoverhight + 0.08); llLoopSound("1centurion_6", 1.0); } else if (nowspeed >= 0.6 && nowspeed < 0.8) { if(power == TRUE) { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,7,0> * DEG_TO_RAD)); } else { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,3,0> * DEG_TO_RAD)); } llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, hoverhight + 0.05); llLoopSound("1centurion_5", 1.0); } else if (nowspeed >= 0.4 && nowspeed < 0.6) { if(power == TRUE) { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,8,0> * DEG_TO_RAD)); } else { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,2,0> * DEG_TO_RAD)); } llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, hoverhight + 0.01); llLoopSound("1centurion_4", 1.0); } else if (nowspeed > 0.01 && nowspeed < 0.4) { if(power == TRUE) { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,10,0> * DEG_TO_RAD)); } else { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,0,0> * DEG_TO_RAD)); } llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, hoverhight); llLoopSound("1centurion_2", 0.5); } else { llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME,llEuler2Rot(<0,0,0> * DEG_TO_RAD)); llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, hoverhight); llLoopSound("1centurion_2", 0.5); } } control(key id, integer held, integer change) { vector mlinear; vector mangular; if((change & CONTROL_FWD) && (held & CONTROL_FWD)) { hoverhight = hoverhightH; power = TRUE; } if((change & CONTROL_FWD) && !(held & CONTROL_FWD)) { hoverhight = hoverhightL; power = FALSE; } if(held & CONTROL_FWD) { if (speed < 0) { speed = 0; } else if (speed < maxspeedpergear) { speed += kasoku; } else { } mlinear.x = speed * gear; mangular.y = -maxrot * gear; autolinear = mlinear; } if(held & CONTROL_BACK) { if (speed > 0) { speed -= kasoku; } else if (speed > -maxspeedpergear/2) { speed -= kasoku; } else { } mlinear.x = speed * gear; autolinear = mlinear; } if(change & CONTROL_UP && held & CONTROL_UP) { if (!auto) { if (driverMode == 0){llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE]);} auto = TRUE; llSay(0,"Cruise Control ON"); } } if(change & CONTROL_DOWN && held & CONTROL_DOWN) { if (auto) { if (driverMode == 0){llSetPrimitiveParams([PRIM_TEMP_ON_REZ, FALSE]);} auto = FALSE; llSay(0,"Cruise Control OFF"); } } if(change & (CONTROL_RIGHT|CONTROL_ROT_RIGHT) && (held & (CONTROL_RIGHT|CONTROL_ROT_RIGHT))) { llMessageLinked(steeringLinkNum,3,"",""); llMessageLinked(steering2LinkNum,3,"",""); //llStopAnimation(animation_name1); //llStartAnimation(animation_name2); if (bridge)llSetAnimationOverride("Sitting", animation_name5); else llSetAnimationOverride("Sitting", animation_name2); } if(held & (CONTROL_RIGHT|CONTROL_ROT_RIGHT)) { mangular.x += yaw; mangular.z -= yaw * 1.2; kaji = 1; } if(change & (CONTROL_RIGHT|CONTROL_ROT_RIGHT) && !(held & (CONTROL_RIGHT|CONTROL_ROT_RIGHT))) { kaji = 0; llMessageLinked(steeringLinkNum,4,"",""); llMessageLinked(steering2LinkNum,4,"",""); //llStopAnimation(animation_name2); //llStartAnimation(animation_name1); if (bridge)llSetAnimationOverride("Sitting", animation_name4); else llSetAnimationOverride("Sitting", animation_name1); } if(change & (CONTROL_LEFT|CONTROL_ROT_LEFT) && (held & (CONTROL_LEFT|CONTROL_ROT_LEFT))) { llMessageLinked(steeringLinkNum,4,"",""); llMessageLinked(steering2LinkNum,4,"",""); //llStopAnimation(animation_name1); //llStartAnimation(animation_name3); if (bridge)llSetAnimationOverride("Sitting", animation_name6); else llSetAnimationOverride("Sitting", animation_name3); } if(held & (CONTROL_LEFT|CONTROL_ROT_LEFT)) { mangular.x -= yaw; mangular.z += yaw * 1.2; kaji = 2; } if(change & (CONTROL_LEFT|CONTROL_ROT_LEFT) && !(held & (CONTROL_LEFT|CONTROL_ROT_LEFT))) { kaji = 0; llMessageLinked(steeringLinkNum,3,"",""); llMessageLinked(steering2LinkNum,3,"",""); //llStopAnimation(animation_name3); //llStartAnimation(animation_name1); if (bridge)llSetAnimationOverride("Sitting", animation_name4); else llSetAnimationOverride("Sitting", animation_name1); } else { } llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, mlinear); llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, mangular); } }
以下2つのスクリプトは変更点無し
boatbund
vector defaultbound = <0, -1, 0>; float boatmass = 1.0; float wavetime = 4.0; boundBoat(vector boundvec) { vector impulse = <boundvec.x,boundvec.y,boundvec.z>* boatmass; llApplyRotationalImpulse(impulse, TRUE); } jumpdBoat(vector jumpvec) { vector impulsej = <jumpvec.x,jumpvec.y,jumpvec.z>* boatmass; llApplyImpulse(impulsej, FALSE); } default { state_entry() { boatmass = llGetMass(); wavetime = 2.0; defaultbound = <0, -0.5, 0>; llSetTimerEvent(wavetime); } timer() { vector nowvel = llGetVel() / llGetRot(); float nowspeed = nowvel.x / 4; if (nowspeed > 2.5) { wavetime = 1.8; defaultbound = <0, -1.0, 0>; llSetTimerEvent(wavetime); } else if (nowspeed > 1.5) { wavetime = 1.5; defaultbound = <0, -0.8, 0>; llSetTimerEvent(wavetime); } else if (nowspeed > 1.0) { wavetime = 1.3; defaultbound = <0, -0.7, 0>; llSetTimerEvent(wavetime); } else if (nowspeed > 0.5) { wavetime = 1.5; defaultbound = <0, -0.6, 0>; llSetTimerEvent(wavetime); } else { wavetime = 4.0; defaultbound = <0, -0.5, 0>; llSetTimerEvent(wavetime); } boundBoat(defaultbound); } }
DialogTimer
integer WBREZ = 666; integer MTIMERON = 667; integer MTIMEROFF = 668; integer MTIMEOUT = 669; default { state_entry() { } on_rez(integer num) { llResetScript(); } link_message(integer sender_number, integer number, string message, key id) { if (number != 0) { if (number == MTIMERON) { llSetTimerEvent(60.0); } if (number == MTIMEROFF) { llSetTimerEvent(0.0); } } } timer() { llMessageLinked(LINK_THIS,MTIMEOUT,"",""); llSetTimerEvent(0.0); } }
次は子プリムのスクリプト
ハンドルのオブジェクトはsteering_wheel、steering_wheel2の名前
RotateSteeringWheel script
LINK_THISとなってる所が今回直したところ。
</pre> rotation q; default { state_entry() { q = ZERO_ROTATION; } on_rez(integer num) { llResetScript(); } link_message(integer sender_num,integer num,string message,key id) { if (num == 3) { rotation childRot = llList2Rot(llGetLinkPrimitiveParams(LINK_THIS, [PRIM_ROTATION]),0); vector targetEluer= DEG_TO_RAD*<30.0,0.0,0.0>; rotation targetQ = llEuler2Rot(targetEluer); q = targetQ*childRot/llGetRootRotation()/llGetRootRotation(); llSetLinkPrimitiveParams(LINK_THIS,[PRIM_ROTATION,q]); } else if (num == 4) { rotation childRot = llList2Rot(llGetLinkPrimitiveParams(LINK_THIS, [PRIM_ROTATION]),0); vector targetEluer= DEG_TO_RAD*<-30.0,0.0,0.0>; rotation targetQ = llEuler2Rot(targetEluer); q = targetQ*childRot/llGetRootRotation()/llGetRootRotation(); llSetLinkPrimitiveParams(LINK_THIS,[PRIM_ROTATION,q]); } else { } } }
船外機の中には
boat2kaji script
rotation defaultrot; rotation kajirot; rotation tempkajirot; default { state_entry() { defaultrot = llGetLocalRot(); tempkajirot = llEuler2Rot(<0,0,30> * DEG_TO_RAD); } link_message(integer sender_num,integer num,string message,key id) { if (num == 1) { kajirot = defaultrot * tempkajirot; llSetLocalRot(kajirot); } else if (num == 2) { kajirot = defaultrot / tempkajirot; llSetLocalRot(kajirot); } else { llSetLocalRot(defaultrot); } } } <span style="line-height: 1.5em;">
Particle_1_scrip
integer flags; integer on; set_particle() { llParticleSystem( [ PSYS_SRC_TEXTURE, llGetInventoryName(INVENTORY_TEXTURE, 0), PSYS_PART_START_SCALE, <1.0,1.0, 0>, PSYS_PART_END_SCALE, <0.5,10.0, 0>, PSYS_PART_START_COLOR, <1,1,1>, PSYS_PART_END_COLOR, <1,1,1>, PSYS_PART_START_ALPHA, 1.0, PSYS_PART_END_ALPHA, 0.0, PSYS_SRC_BURST_PART_COUNT, 5, PSYS_SRC_BURST_RATE, 0.1, PSYS_PART_MAX_AGE, 6.0, PSYS_SRC_MAX_AGE, 0.0, PSYS_SRC_PATTERN, 4, PSYS_SRC_ACCEL, <0.0,0.0,0.0>, PSYS_SRC_BURST_SPEED_MIN, 1.0, PSYS_SRC_BURST_SPEED_MAX, 3.0, PSYS_SRC_ANGLE_BEGIN, 0*DEG_TO_RAD, PSYS_SRC_ANGLE_END, 0*DEG_TO_RAD, PSYS_SRC_OMEGA, <0,0,0>, PSYS_PART_FLAGS, ( 0 | PSYS_PART_INTERP_COLOR_MASK | PSYS_PART_INTERP_SCALE_MASK | PSYS_PART_EMISSIVE_MASK | PSYS_PART_FOLLOW_VELOCITY_MASK ) ] ); } default { state_entry() { on = FALSE; llParticleSystem([]); } link_message(integer sender_num,integer num,string message,key id) { if ((float)message > 0.3) { on = TRUE; set_particle(); } else { on = FALSE; llParticleSystem([]); } } }
その他のプリムでは
人が座る場所それぞれに
sitanimescript
今回から”if (av1 != NULL_KEY && siton1 == NULL_KEY)”のとこに”&& siton1 == NULL_KEY”を追加、パーミションをとってない時だけ取得するようにした。
string animation_name1="animationname"; key siton1 = NULL_KEY; vector sit_pos1 = <0.0, 0.7, -0.1>; vector sit_rot1 = <270.0, 0.0,270.0>; default { state_entry() { llSetText("", <0.0, 0.0, 1.0>, 1.0); llSitTarget(sit_pos1, llEuler2Rot(sit_rot1 * DEG_TO_RAD)); } changed(integer change1) { if (change1 & CHANGED_LINK) { key av1 = llAvatarOnSitTarget(); if (siton1 != NULL_KEY) { if (av1 == NULL_KEY) { llStopAnimation(animation_name1); llSetText("", <0.0, 0.0, 1.0>, 1.0); // llSetAlpha(1.0, ALL_SIDES); siton1 = NULL_KEY; } } else { if (av1 != NULL_KEY && siton1 == NULL_KEY) { siton1 = av1; llSetText("", <0.0, 0.0, 1.0>, 1.0); // llSetAlpha(0.0, ALL_SIDES); llRequestPermissions(siton1, PERMISSION_TRIGGER_ANIMATION); } } } } run_time_permissions(integer perm1) { key perm_key1 = llGetPermissionsKey(); if (perm_key1 == siton1) { if (perm1 & PERMISSION_TRIGGER_ANIMATION) { list anms1 = llGetAnimationList(siton1); integer i1; for (i1 = 0; i1 < llGetListLength(anms1); i1++) { llStopAnimation(llList2Key(anms1, i1)); } llStartAnimation(animation_name1); } } } }
ライトのプリムには
boat light Script0
//============================== //Light param //============================== vector Color = <1, 1, 0.75>; float Intensity = 1.0; float Radius = 3.0; float Falloff = 0.75; //============================== //Glow param //============================== float Gintensity = 0.00; //============================== // Script variables //============================== integer lightsOn = FALSE; //============================== default { state_entry() { //llSetTexture("Blue",ALL_SIDES); } link_message(integer sender_number, integer number, string message, key id) { if (message == "Lighton") { llSetPrimitiveParams([ PRIM_FULLBRIGHT, ALL_SIDES, FALSE, PRIM_POINT_LIGHT, TRUE, Color, Intensity, Radius, Falloff, PRIM_GLOW, ALL_SIDES, 0 ]); } else if (message == "Lightoff") { llSetPrimitiveParams([ PRIM_FULLBRIGHT, ALL_SIDES, FALSE, PRIM_POINT_LIGHT, FALSE, Color, Intensity, Radius, Falloff, PRIM_GLOW, ALL_SIDES, 0 ]); } } }
牽波を発生させるプリムには、エンジン(スクリュー)のと同じだけどパラメーターがちょっとちがう
Particle script
integer flags; integer on; set_particle() { llParticleSystem( [ PSYS_SRC_TEXTURE, llGetInventoryName(INVENTORY_TEXTURE, 0), PSYS_PART_START_SCALE, <0.1,1.0, 0>, PSYS_PART_END_SCALE, <5.5,10.0, 0>, PSYS_PART_START_COLOR, <1,1,1>, PSYS_PART_END_COLOR, <1,1,1>, PSYS_PART_START_ALPHA, 1.0, PSYS_PART_END_ALPHA, 0.0, PSYS_SRC_BURST_PART_COUNT, 5, PSYS_SRC_BURST_RATE, 0.1, PSYS_PART_MAX_AGE, 4.0, PSYS_SRC_MAX_AGE, 0.0, PSYS_SRC_PATTERN, 4, PSYS_SRC_ACCEL, <0.0,0.0,0.0>, PSYS_SRC_BURST_SPEED_MIN, 1.0, PSYS_SRC_BURST_SPEED_MAX, 3.0, PSYS_SRC_ANGLE_BEGIN, 0*DEG_TO_RAD, PSYS_SRC_ANGLE_END, 0*DEG_TO_RAD, PSYS_SRC_OMEGA, <0,0,0>, PSYS_PART_FLAGS, ( 0 | PSYS_PART_INTERP_COLOR_MASK | PSYS_PART_INTERP_SCALE_MASK | PSYS_PART_EMISSIVE_MASK | PSYS_PART_FOLLOW_VELOCITY_MASK ) ] ); } default { state_entry() { on = FALSE; llParticleSystem([]); } link_message(integer sender_num,integer num,string message,key id) { if ((float)message > 0.3) { on = TRUE; set_particle(); llLoopSound("SubmarineWave", 1.0); } else { on = FALSE; llParticleSystem([]); llLoopSound("nami", 1.0); } } }
レーダーを回転させる
radar_rotate script
</pre> rotation q; default { state_entry() { q = ZERO_ROTATION; llSetTimerEvent(0); } on_rez(integer num) { llResetScript(); } link_message(integer sender_num,integer num,string message,key id) { if (message == "seated") { llSetTimerEvent(0.1); } else if (message == "unseated") { llSetTimerEvent(0); } } timer() { rotation childRot = llList2Rot(llGetLinkPrimitiveParams(LINK_THIS, [PRIM_ROTATION]),0); vector targetEluer= DEG_TO_RAD*<17.0,0.0,0.0>; rotation targetQ = llEuler2Rot(targetEluer); q = targetQ*childRot/llGetRootRotation()/llGetRootRotation(); llSetLinkPrimitiveParams(LINK_THIS,[PRIM_ROTATION,q]); } } <pre>
アニメーションファイルやサウンドファイルについては省略します。