////////////////////////////////////////////////////////// // (c) Wizardry and Steamworks - 2012, License GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html // // for legal details, rights of fair usage and // // the disclaimer and warranty conditions. // ////////////////////////////////////////////////////////// list jumps = []; // Calculate jump gates list jumpGates(vector iPos, vector dPos, integer jumpDistance) { list gates = []; if(jumpDistance == 0) return gates; float dist = llVecDist(iPos, dPos); if(dist > jumpDistance) { // We move 1/jumpDistance from the initial position // towards the final destination in the description. iPos = iPos + jumpDistance * (dPos-iPos) / dist; gates += iPos; return gates + jumpGates(iPos, dPos, jumpDistance); } return gates + jumpGates(iPos, dPos, --jumpDistance); } vector oPos = ZERO_VECTOR; vector cross = ZERO_VECTOR; key nQuery = NULL_KEY; //pragma inline string nName = "UNO Grand Prix"; float regionTimeDilation = 2; default { state_entry() { llSetObjectDesc("0"); llSitTarget(<0,0,1>, ZERO_ROTATION); } on_rez(integer num) { llSetObjectDesc("0"); } changed(integer change) { if(change & CHANGED_LINK) { key a = llAvatarOnSitTarget(); if(a) state read; } } } state read { state_entry() { integer itra = llGetInventoryNumber(INVENTORY_NOTECARD)-1; do { if(llGetInventoryName(INVENTORY_NOTECARD, itra) == nName) jump found_notecard; } while(--itra>=0); llOwnerSay("Failed to find notecard."); return; @found_notecard; integer nLinePos = (integer)llGetObjectDesc(); llOwnerSay("Reading at: " + (string)nLinePos); nQuery = llGetNotecardLine(nName, nLinePos); } dataserver(key id, string data) { if(id != nQuery) return; if(data == EOF || data == "") { // DEBUG // llOwnerSay("FINISH!!"); key a = llAvatarOnSitTarget(); if(a) llUnSit(llAvatarOnSitTarget()); state default; return; } // Now extract the coordinates. list nextCoordinates = llParseString2List(data, ["<", ">", ","], []); oPos.x = llList2Integer(nextCoordinates, 0); oPos.y = llList2Integer(nextCoordinates, 1); oPos.z = llList2Integer(nextCoordinates, 2); state process; } } state process { state_entry() { // If we are at the margin, we switch to cross- // drive in order to cross the sim border. vector sPos = llGetPos(); if(llFloor(sPos.x) == 0) { cross = <-1,0,0>; state crossdrive; } if(llFloor(sPos.y) == 0) { cross = <0,-1,0>; state crossdrive; } if(llCeil(sPos.x) == 255) { cross = <1,0,0>; state crossdrive; } if(llCeil(sPos.y) == 255) { cross = <0,1,0>; state crossdrive; } // 1.175494351E-38 is the smallest float. // pad that with the lag of the simulator. regionTimeDilation = 1 - llGetRegionTimeDilation() + 1.175494351E-38; state jumpdrive; } } state crossdrive { state_entry() { llOwnerSay("Crossdriving..."); llSetStatus(STATUS_PHYSICS|STATUS_BLOCK_GRAB, TRUE); llSetStatus(STATUS_ROTATE_X|STATUS_ROTATE_Y|STATUS_ROTATE_Z, FALSE); llSetBuoyancy(1.0); llSetForce(cross, FALSE); } changed(integer change) { if(change & CHANGED_REGION) { // 1.175494351E-38 is the smallest float. // pad that with the lag of the simulator. regionTimeDilation = 1 - llGetRegionTimeDilation() + 1.175494351E-38; llSetTimerEvent(regionTimeDilation); } } timer() { vector sPos = llGetPos(); if(llFloor(sPos.x) == 0 || llFloor(sPos.y) == 0 || llCeil(sPos.x) == 255 || llCeil(sPos.y) == 255) return; llSetStatus(STATUS_PHYSICS, FALSE); llSetTimerEvent(0); state read; } } state jumpdrive { state_entry() { llOwnerSay("Jumpdrive..."); // Grab local position again. vector sPos = llGetPos(); // Calculate list of intermediary jump gates. jumps = jumpGates(llGetPos(), oPos, 10); llSetTimerEvent(regionTimeDilation); } timer() { if(llGetListLength(jumps) == 0) { llSetTimerEvent(0); integer nLinePos = (integer)llGetObjectDesc() + 1; llSetObjectDesc((string)nLinePos); state read; } vector nPos = llList2Vector(jumps, 0); jumps = llDeleteSubList(jumps, 0, 0); llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION, nPos]); } }