Jump to content

Need help in walk-stand instead of sitting vehicle.


Fazida Yalin
 Share

You are about to reply to a thread that has been inactive for 4689 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Recently I discover a script through browsing the old script forums. It allows the user to walk and stand like normal avatar instead of the usual driving vehicle. I try it in-world and it worked.I can passed through walls and griefers were unable to cage or  cage me. However, the problem is when the land is uneven such as mountain , here comes the funny movement. Both my legs were pulled upwards. I need help with experiend scripter to improve on the scripts.:

Herer is the script. Sorry I am not able to remember the user post nickname:

=>

string WALKANIM = "female_walk";   
string FLYANIM = "fly";            
string HOVERANIM = "hover";        
string UPANIM = "hover_up";        
string DOWNANIM = "hover_down";    
integer WALKSPEED = 1;           
integer FLYSPEED = 10;             
integer PHANTOM = TRUE;            
integer TOUCHABLE = TRUE;          


float zoffset;

integer flying = FALSE;

default {
    state_entry() {
        llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE);
        llCollisionFilter(llKey2Name(llGetOwner()), llGetOwner(), FALSE);
        vector avatarsize = llGetAgentSize(llGetOwner());
        zoffset = avatarsize.z / 2;
        //llSitTarget(<0, 0, -0.5>, ZERO_ROTATION);
         llSitTarget(<0, 0, -0.1>, ZERO_ROTATION);
        llCollisionSound("", 0);
    }

    changed(integer change) {
        if(change & CHANGED_LINK) {
            key agent = llAvatarOnSitTarget();
            if(agent) {
                if(agent != llGetOwner()) {
                    llUnSit(agent);
                } else {
                    llSetAlpha(0, ALL_SIDES);
                llMessageLinked(LINK_SET, 0, "hide", NULL_KEY);
                    llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
                }
            } else {
                llSetAlpha(1, ALL_SIDES);
                llSetStatus(STATUS_PHYSICS, FALSE);
                llReleaseControls();
                llResetScript();
            }
        }
    }

    run_time_permissions(integer perm) {
        if(perm) {
            llStopAnimation("sit");
            llStartAnimation("stand");           
            llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_UP | CONTROL_DOWN |
                CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT, TRUE, FALSE);
        }
    }
   
    control(key id, integer level, integer edge) {
        //Any button pressed

        if(edge & level) {
            llSetStatus(STATUS_PHYSICS, TRUE);
            llStopAnimation(HOVERANIM);
        }
       
        //Forward or backwards pressed

        if(edge & level & (CONTROL_FWD|CONTROL_BACK)) {
            if(flying == TRUE) {
                llStartAnimation(FLYANIM);
            } else {
                llStartAnimation(WALKANIM); //Start the walk animation
            }
        }
        //All buttons released

        if((~level & CONTROL_FWD) && (~level & CONTROL_BACK) && (~level & CONTROL_RIGHT) &&
                (~level & CONTROL_LEFT) && (~level & CONTROL_ROT_RIGHT) && (~level & CONTROL_ROT_LEFT)
                && (~level & CONTROL_UP) && (~level & CONTROL_DOWN) ) {
                   
            llTargetOmega(<0,0,0>, 0, 1);           
            llSetStatus(STATUS_PHYSICS, FALSE);
           
            llSetPos(llGetPos());
 //Workaround for weird prim movement behavior
         
  llSetRot(llGetRot());
           
            llStopAnimation(WALKANIM);
            llStopAnimation(UPANIM);
            llStopAnimation(DOWNANIM);
            llStopAnimation(FLYANIM);
            if(flying == TRUE) {
                llStartAnimation(HOVERANIM);
            } else {
                llStartAnimation("stand");
            }
        }
        //Turning key released

        if((~level & edge & CONTROL_RIGHT) || (~level & edge & CONTROL_LEFT) ||
                (~level & edge & CONTROL_ROT_RIGHT) || (~level & edge & CONTROL_ROT_LEFT)) {
            llTargetOmega(<0,0,1>, 0, 1);
            llTargetOmega(<0,0,-1>, 0, 1);       
        }
        //Turn right

        if(level & edge & (CONTROL_RIGHT|CONTROL_ROT_RIGHT)) {
            llTargetOmega(<0,0,-1>, PI / 3.5, 1);    
        //Turn left   
  
        } else if(level & edge & (CONTROL_LEFT|CONTROL_ROT_LEFT)) {
            llTargetOmega(<0,0,1>, PI / 3.5, 1);
        }
        //Forward

        if(level & CONTROL_FWD) {
           vector pos;
            if(flying == FALSE) {
                pos   = llGetPos() + WALKSPEED*llRot2Fwd(llGetRot());
                pos.z = zoffset + llGround(ZERO_VECTOR);
            } else {
                pos = llGetPos() + FLYSPEED*llRot2Fwd(llGetRot());
            }
            llMoveToTarget(pos, 0.1);           
        //Backwards

        } else if(level & CONTROL_BACK) {
            vector pos;
            if(flying == FALSE) {
                pos   = llGetPos() - WALKSPEED*llRot2Fwd(llGetRot());
                pos.z = zoffset + llGround(ZERO_VECTOR);
            } else {
                pos   = llGetPos() - FLYSPEED*llRot2Fwd(llGetRot());
            }
            llMoveToTarget(pos, 0.1);        
        }
        //Flying

        if(level & CONTROL_UP) {
            flying = TRUE;
            llStartAnimation(UPANIM);
            llMoveToTarget(llGetPos() + <0,0,3.5>, 0.1);
        } else if(level & CONTROL_DOWN) {
            llStartAnimation(DOWNANIM);
            vector pos = llGetPos();
            if( (pos.z - llGround(ZERO_VECTOR)) < 2.5 ) {
                flying = FALSE;
            }
            llMoveToTarget(llGetPos() - <0,0,3.5>, 0.1);
        }
    }
   
    //Move through solid objects

    collision(integer det_num) {
        if(PHANTOM == TRUE) {
            llSetStatus(STATUS_PHYSICS, FALSE);
            llSetPos(llGetPos() + llRot2Fwd(llGetRot()));
            llSetStatus(STATUS_PHYSICS, TRUE);
        }
    }  
   
    touch_start(integer det_num) {
        if(TOUCHABLE == TRUE) {
            llSetRot(llGetRot() * llEuler2Rot(<90*DEG_TO_RAD,0,0>));
        }     
    }
}


Anyway to work around the funny movement is much appreciated.

Thank you. 



Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4689 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...