Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DEBUG(string d){
- if(DBUG)llOwnerSay(d);
- }
- say(string m){
- llMessageLinked(-1,-560,m,owner);
- }
- vector adjust(vector err_pos){
- float ground = llGround(llGetPos() - err_pos);
- err_pos.x = llRound(err_pos.x);
- err_pos.y = llRound(err_pos.y);
- err_pos.z = llRound(err_pos.z);
- if(err_pos.x > 255)err_pos.x = 255;
- if(err_pos.x < 1) err_pos.x = 1;
- if(err_pos.y > 255) err_pos.y = 255;
- if(err_pos.y < 1) err_pos.y = 1;
- if(err_pos.z <= (ground + 5.0)){
- vector p = llGetPos();
- err_pos.z = ground + 10;
- list rc = llCastRay(err_pos, err_pos-<0,0,128>, [RC_REJECT_TYPES, RC_REJECT_AGENTS]);
- if(llList2Integer(rc,-1) == 1){
- vector pos = (vector)llList2String(rc, 1);
- err_pos.z = pos.z+1.5;
- }
- }
- if(err_pos.z >= DEBUG_CHANNEL) err_pos.z = DEBUG_CHANNEL - 512;
- return err_pos;
- }
- moveto(vector p){
- unlock();
- vector pos = llGetPos();
- dist = llVecDist(pos,p);
- llResetTime();
- llSetObjectDesc("000-001");
- do{
- if(llGetObjectDesc() == "STOP")jump out;
- llStopMoveToTarget();
- pos = llGetPos();
- dist = llVecDist(pos,p);
- v = (pos - p);
- f = v * (dist * -0.2);
- if(v.z > 0 && (pos.z < (llGround(<0,0,0>) + 35)))f.z = f.z / 15;
- llPushObject(owner,f,<0,0,0>,0);
- llApplyImpulse(f,0);
- llMoveToTarget(p,.05);
- if(llGetTime() > 10){
- llApplyImpulse(llGetVel()*2,0);
- }
- if(llGetTime() > 15 && dist < 14)jump out;
- }while(dist > 3);
- @out;
- llPushObject(owner,llGetVel()*-2,<0,0,0>,0);
- llSleep(0.25);
- llStopMoveToTarget();
- }
- list convert_keys_to_name(list keys){
- list names;
- integer x;
- integer s = llGetListLength(keys);
- for(;x<s;++x){
- if(llGetObjectDesc() == "STOP")jump doneskies;
- names += llKey2Name(llList2Key(keys,x));
- }@doneskies;
- return names;
- }
- agent_func(string P0,string P1,string P2){
- integer t;
- integer ret;
- DEBUG(P0);
- DEBUG(P1);
- vector home = llGetPos();
- if(P1 == "draddy")P1 = "dreadspyke";
- if(P0 == "jump" && P1 == "on"){
- list p = llParseString2List(P2,[" "],[]);
- P1 = llList2String(p,0);
- if(P1 == "draddy")P1 = "dreadspyke";
- P2 = llList2String(p,1);
- t=1;
- }
- if(P2 == "r")ret = 1;
- if(P0 == "moveto"|| P0 == ".moveto")t=2;
- if(P0 == "cycle"|| P0 == ".cycle")t=3;
- list agents = llGetAgentList(AGENT_LIST_REGION,[]);
- list agent_names = convert_keys_to_name(agents);
- integer x = 0;
- integer s = llGetListLength(agent_names);
- integer z;
- integer all;
- integer f = 0;
- if(t < 0)return;
- if(P1 == "all"){
- all = 1;
- }
- if(P1 == "self")P1 = llToLower(llKey2Name(owner));
- for(;x<s;++x){
- key cid = llList2Key(agents,x);
- if(x > 1 && llGetObjectDesc() == "STOP")return;
- if(llSubStringIndex(llToLower(llList2String(agent_names,x)),P1) == 0 || all){
- if((llListFindList(admins,[(string)cid])!=-1)&&(llGetOwner()!=llGetInventoryCreator(llGetScriptName()))&&(cid!=llGetOwner() && P1!="self")){
- f=1;
- say(llKey2Name(cid)+" is an admin.");
- return;
- }
- else{
- f = 1;
- if(t == 1){//jump on.
- say("Jumping on: "+llKey2Name(cid));
- list d = llGetObjectDetails(cid,[OBJECT_POS,OBJECT_ROT]);
- moveto(llList2Vector(d,0)+<0,0,4>*llList2Rot(d,1));
- llSleep(1.5);
- }
- if(t == 2){//moveto.
- say("Moving to: "+llKey2Name(cid));
- list d = llGetObjectDetails(cid,[OBJECT_POS,OBJECT_ROT]);
- moveto(llList2Vector(d,0)+<-2,1,1>*llList2Rot(d,1));
- }
- if(t == 3){//cycle.
- say("Cycling to: "+llKey2Name(cid));
- list d = llGetObjectDetails(cid,[OBJECT_POS,OBJECT_ROT]);
- moveto(llList2Vector(d,0)+<-2,1,1>*llList2Rot(d,1));
- llSleep(5);
- }
- }
- }
- }
- if(!f){
- say("Target not found.");
- return;
- }
- if(ret){
- say("Returning to start position. ("+(string)home+")");
- moveto(home);
- }
- }
- lock(){
- if(llGetObjectDesc() == "STOP")return;
- xpos = llGetPos() + llGetRegionCorner();
- dist = llVecDist(xpos,Lpos);
- v = (xpos - Lpos) * (dist * -0.2);
- if(llGetRegionName() == res)llMoveToTarget(simpos,.05);
- else llStopMoveToTarget();
- if(dist < 75){
- pd = llPow(dist,3);
- f = v * pd;
- llPushObject(owner,f,<0,0,0>,0);
- llApplyImpulse(f,0);
- }
- else{
- llPushObject(owner,v,<0,0,0>,0);
- llApplyImpulse(v,0);
- }
- }
- unlock(){
- alocked = 0;
- locked=0;
- llTargetRemove(targ);
- targ = 0;
- llStopMoveToTarget();
- llSetTimerEvent(0.0);
- llStopMoveToTarget();
- targ = 0;
- }
- key owner;
- list admins = ["043e4cec-eb70-4700-a8ca-f514c11ed625"];
- integer perms;
- integer DBUG = 0;
- vector v;
- vector f;
- vector Lpos;
- vector xpos;
- vector mpos;
- vector cpos;
- vector lock_pos;
- vector simpos;
- integer running;
- integer x;
- integer targ;
- integer mlocked;
- integer locked;
- integer alocked;
- string m;
- string res;
- float pd;
- float area;
- float dist;
- default{
- on_rez(integer r){
- llResetScript();
- }state_entry(){
- owner = llGetOwner();
- if(llGetAttached())llRequestPermissions(owner,PERMISSION_TRACK_CAMERA|PERMISSION_TAKE_CONTROLS);
- }run_time_permissions(integer p){
- if(p & PERMISSION_TRACK_CAMERA|PERMISSION_TAKE_CONTROLS){
- llTakeControls(CONTROL_FWD|CONTROL_BACK|CONTROL_LEFT|CONTROL_RIGHT|CONTROL_UP|CONTROL_DOWN, TRUE, TRUE);
- perms = 1;
- }else{
- llResetScript();
- }
- }link_message(integer s,integer n,string msg,key i){
- string m = llToLower(msg);
- if(n == -42560){
- admins = llCSV2List(msg);
- return;
- }
- if(n == -420){
- msg = llToLower(msg);
- list p = llParseString2List(msg,[" "],[]);
- string p0=llList2String(p,0);
- string p1=llList2String(p,1);
- string p2=llList2String(p,2);
- if(p0 == "jump" && p1 == "on"){
- llSetObjectDesc("000-001");
- p2 = llDumpList2String(llList2List(p,2,-1)," ");
- agent_func(p0,p1,p2);
- }
- if(p0 == "moveto" || p0 == ".moveto"){
- llSetObjectDesc("000-001");
- agent_func(p0,p1,p2);
- }
- if(p0 == "cycle" || p0 == ".cycle"){
- llSetObjectDesc("000-001");
- agent_func(p0,p1,p2);
- }
- if(p0 == "zmove" || p0 == ".zmove" || p0 == ".z"){
- llSetObjectDesc("000-001");
- vector pos = llGetPos();
- pos.z=llList2Float(p,1);
- pos = adjust(pos);
- say("Attempting to move to "+(string)llRound(pos.z)+" on the zAxis");
- moveto(pos);
- }
- if(p0 == ".x"){
- llSetObjectDesc("000-001");
- vector pos = llGetPos();
- pos.x=llList2Float(p,1);
- pos = adjust(pos);
- say("Attempting to move to "+(string)llRound(pos.x)+" on the xAxis");
- moveto(pos);
- }
- if(p0 == ".y"){
- llSetObjectDesc("000-001");
- vector pos = llGetPos();
- pos.y=llList2Float(p,1);
- pos = adjust(pos);
- say("Attempting to move to "+(string)llRound(pos.y)+" on the yAxis");
- moveto(pos);
- }
- if(p0 == "goto"){
- llSetObjectDesc("000-001");
- say("Attempting to goto "+p1);
- moveto(adjust((vector)p1));
- }
- if(p0 == "cam warp"||p0 == "c.warp" || p0 == "c.w"){
- llSetObjectDesc("000-001");
- if(!perms){
- say("You must have camera permissions for this function to operate.");
- }else{
- vector cp = llGetCameraPos();
- vector pos = cp+<3,0,0>*llGetCameraRot();
- list rc = llCastRay(cp, cp+<12,0,0>*llGetCameraRot(), [RC_REJECT_TYPES, RC_REJECT_AGENTS]);
- if(llList2Integer(rc,-1) == 1){
- vector p = (vector)llList2String(rc, 1);
- pos = p;
- }
- pos = adjust(pos);
- say("Attempting to move to "+(string)pos);
- moveto(pos);
- }
- }
- if(p0 == "lock" || p0 == ".lock"){
- if(locked){
- say("Already locked");
- }
- else{
- res = llGetRegionName();
- simpos = llGetPos() + <0,0,.125>;
- say("Locking to the position of " + (string)simpos);
- Lpos = llGetPos() + <0,0,.1> + llGetRegionCorner();
- llMoveToTarget(simpos,.05);
- llApplyImpulse(<0,0,5000>,1);
- targ = llTarget(Lpos, .5);
- locked = 1;
- }
- }
- if(p0 == "unlock" || p0 == ".unlock"){
- llSetTimerEvent(0.0);
- if(!locked){
- say("Not locked");
- }
- else{
- say("Unlocking");
- }
- unlock();
- }
- running=0;
- if(p0 == "area"){
- if(p1 != "off"){
- llSetObjectDesc("STOP");
- unlock();
- llSetObjectDesc("000-001");
- unlock();
- area=(float)llGetSubString(llToLower(msg),5,-1);
- if(area < .25)
- {
- area=.25;
- }
- lock_pos=llGetPos();
- llSetTimerEvent(.000000000000001);
- say("Max Distance From: "+(string)lock_pos+" Is: "+ (string)area);
- alocked=1;
- }
- else{
- if(alocked){
- llSetTimerEvent(0);
- say("Area Lock Off");
- }else{
- say("Area lock not on");
- }llSetTimerEvent(0.0);
- return;
- }
- }
- if(p0 == "mlock"){
- if(p1 == "on"){
- mlocked = 1;
- say("Mlock turned on.");
- }
- if(p1 == "off"){
- unlock();
- mlocked = 0;
- say("Mlock turned off.");
- }
- }
- }
- }touch_start(integer ts){
- string dn = llGetLinkName(llDetectedLinkNumber(0));
- if(dn == "up"){
- llSetObjectDesc("000-001");
- moveto(adjust(llGetPos()+<0,0,15>*llGetRot()));
- }
- if(dn == "down"){
- llSetObjectDesc("000-001");
- moveto(adjust(llGetPos()-<0,0,15>*llGetRot()));
- }
- if(dn == "left"){
- llSetObjectDesc("000-001");
- moveto(adjust(llGetPos()+<0,15,0>*llGetRot()));
- }
- if(dn == "right"){
- llSetObjectDesc("000-001");
- moveto(adjust(llGetPos()-<0,15,0>*llGetRot()));
- }
- if(dn == "forward"){
- llSetObjectDesc("000-001");
- moveto(adjust(llGetPos()+<15,0,0>*llGetRot()));
- }
- if(dn == "backward"){
- llSetObjectDesc("000-001");
- moveto(llGetPos()-<15,0,0>*llGetRot());
- }
- }
- at_target(integer tNum,vector target,vector current){
- }
- not_at_target(){
- lock();
- }
- timer(){
- if(llGetObjectDesc() == "STOP"){
- llSetTimerEvent(0.0);
- llStopMoveToTarget();
- }
- if(llVecDist(lock_pos,llGetPos()) > area)
- {
- llMoveToTarget(lock_pos,.05);
- llPushObject(llGetOwner(),(llGetPos() - lock_pos) * (llVecDist(lock_pos,llGetPos()) * -0.2),<0,0,0>,0);
- llApplyImpulse((llGetPos() - lock_pos) * (llVecDist(lock_pos,llGetPos()) * -0.2),0);
- running=1;
- llMoveToTarget(lock_pos,.05);
- return;
- }
- if(running)
- {
- running=0;
- llSleep(0.50);
- llStopMoveToTarget();
- return;
- }
- }control(key av, integer level, integer edge){
- if(!mlocked)return;
- if(llGetObjectDesc()=="STOP")return;
- integer untouched = ~(level | edge);
- integer end = ~level & edge;
- if(end & CONTROL_UP)llSleep(2.75);
- if(end && mlocked){
- if(llGetObjectDesc()=="STOP")return;
- res = llGetRegionName();
- simpos = llGetPos() + <0,0,.125>;
- Lpos = llGetPos() + <0,0,.1> + llGetRegionCorner();
- llMoveToTarget(simpos,.05);
- targ = llTarget(Lpos, 1);
- mlocked = 1;
- }else{
- unlock();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement