Prim Mover

float   cnfSpeed        =   1.0;
string  cnfSitAnim      =   "backflip";
 
///////////////////////////////////////////////////////////////////////////
vector  velocity    =   <0,0,0>;
 
warpPos( vector destpos ){
    integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
 
    if (jumps > 100 )
        jumps = 100;
 
    list rules = [ PRIM_POSITION, destpos ];
 
    integer count = 1;
    while ( ( count = count << 1 ) < jumps)
        rules = (rules=[]) + rules + rules;
 
    llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );
 
    if ( llVecDist( llGetPos(), destpos ) > .001 )
        while ( --jumps )
            llSetPos( destpos );
}
 
default
{
 
    state_entry()
    {
        llSitTarget(<0,0,-110>,<0,0,0,0>);
        llSetCameraEyeOffset(<0.0, 0.0, -108>);
        llSetCameraAtOffset(<0.0, 0.0, -108>);
        llListen(4,"",llGetOwner(),"");
    }
 
    changed(integer c)
    {
        if(c & CHANGED_LINK && llAvatarOnSitTarget() == llGetOwner())
        {
            llRequestPermissions(llAvatarOnSitTarget(),PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS | PERMISSION_CONTROL_CAMERA);
            warpPos(llGetPos() + <0,0,110>);
        } else if(c & CHANGED_LINK && llAvatarOnSitTarget() == NULL_KEY){
            warpPos(llGetPos() - <0,0,110>);
        }
    }
 
    listen(integer c, string n, key id, string msg){
        cnfSpeed = (float)msg;
    }
 
    run_time_permissions(integer perm){
        if(perm & PERMISSION_TRIGGER_ANIMATION && llAvatarOnSitTarget() == llGetOwner()){
            llStopAnimation("Sit");
            llStartAnimation(cnfSitAnim);
        }
        if(perm & PERMISSION_TAKE_CONTROLS && llAvatarOnSitTarget() == llGetOwner()){
            llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_UP | CONTROL_DOWN | CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT,TRUE,FALSE);
        }
    }
 
    touch_start(integer n){
        llRequestPermissions(llAvatarOnSitTarget(),PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS | PERMISSION_CONTROL_CAMERA);
    }
 
    control(key id, integer held, integer change){
        rotation rot;
        if(held & CONTROL_FWD)
            velocity.x = velocity.x + cnfSpeed;
        else
            velocity.x *= 0.75;
 
        if(held & CONTROL_BACK)
            velocity.x = velocity.x - cnfSpeed;
        else
            velocity.x *= 0.75;
 
        if(held & CONTROL_LEFT)
            velocity.y = velocity.y - cnfSpeed;
        else
            velocity.y *= 0.75;
 
        if(held & CONTROL_RIGHT)
            velocity.y = velocity.y + cnfSpeed;
        else
            velocity.y *= 0.75;
 
        if(held & CONTROL_UP)
            llSetPos(llGetPos() + <0,0,cnfSpeed>);
 
        if(held & CONTROL_DOWN)
            llSetPos(llGetPos() + <0,0,-cnfSpeed>);
 
        if(held & CONTROL_ROT_LEFT)
        {
            rot = llGetRot() * llEuler2Rot(<0,0,0.12>);
            llSetRot(rot);
        }
 
        if(held & CONTROL_ROT_RIGHT)
        {
            rot = llGetRot() * llEuler2Rot(<0,0,-0.12>);
            llSetRot(rot);
        }
 
        llSetPos(velocity * llGetRot() + llGetPos());
    }
}
Navigation

Alternative Startseite
Helpdesk
Links
Maps
Radio
Suchmaschine


Drucken/exportieren