Sandworm Scripts

From The SchomEmunity Wiki
Jump to: navigation, search

This script is developing quite a history for being annoying. The intention is that, when applied to the Sandworm currently in the sandbox, it will move forward on command, worming its way slowly across the landscape. Taking successively easier routes when the plan failed this has moved from the idea of a Worm flowing in a transverse wave (probably the best example here would be to imagine the path a dolphin takes) through a longitudinal wave (the less impressive movement of earthworms and like) to the vehicle script now displayed, which would treat the Worm as, to all intents and purposes, a solid block sliding along.

Worm Start for Vehicle (non-functional)

This is mainly from the Linden Vehicle Scripting Tutorial as provided by lslwiki.net and frankly, doesn't work. Although the preparation etc sections run just as well as in a normal Worm Start the Worm just doesn't move, which is rather depressing.

key a;
integer i;
integer ii;

default
{
    state_entry()
    {
//List of vehicle attributes
        llSetVehicleType(VEHICLE_TYPE_SLED);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 5.0);
        llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 200.0);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 1.0);
        llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.0);
        llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_OFFSET, <0,0,2>);
        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 2.0);
        llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <0,0,0.5>);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 2.0);
        llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, 0.3);
        llSetVehicleFloatParam(VEHICLE_BANKING_MIX,0.7);
        llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <50, 5, 1000>);
        llSetVehicleFlags(VEHICLE_FLAG_MOUSELOOK_BANK);
        llSetVehicleFloatParam(VEHICLE_BUOYANCY,0.2);
        llSitTarget(<0,0,1>, <0,0,0,0>);
        i=1;
        ii=1;
    }

    touch_start(integer total_number)
    {
//Reset to save time resetting manually
        if(i==3)
        {
            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0,0,0>);
            llResetScript();
        }
//Request permissions to make the Worm start
        if(i==2)
        {
            a=llAvatarOnSitTarget();
            llRequestPermissions(a,PERMISSION_TRIGGER_ANIMATION|PERMISSION_TAKE_CONTROLS);  
        }
//Initialisation and preperation         
        if(i==1)
        {
            a=llAvatarOnSitTarget();
            vector pos=llGetPos();
            llRezObject("Maker Hook left", pos, <0,0,0>, <0,0,0,0>, 1);
            llRezObject("Maker Hook right", pos, <0,0,0>, <0,0,0,0>, 1);
            llSay(5,(string)a);
            llSay(0,"Ready...");
            i++;
        }
    }
//Starting the Worm    
    run_time_permissions(integer perm)
    {  
            llStopAnimation("sit");
            llStartAnimation("stand_4");
            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <10,0,0>);
            llSay(0,"Go!");
            i++;
    }
//If the rider wants to slow down    
    control(key id, integer held, integer change)
    {
        if(change & 2)
        {
            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0,0,0>);
        }
    }
}

Worm Start for Worm Movement (functional)

This works completely fine, though to be honest it is the easy bit.

key a;
integer i;
integer ii;

default
{
    state_entry()
    {
        llSitTarget(<0,0,1>, <0,0,0,0>);
        i=1;
        ii=1;
    }

    touch_start(integer total_number)
    {
//Reset to save time resetting manually
        if(i==3)
        {
            llResetScript();
        }
//Request permissions to make the Worm start
        if(i==2)
        {
            llRequestPermissions(a,PERMISSION_TRIGGER_ANIMATION);  
        }
//Initialisation and preparation        
        if(i==1)
        {
            a=llAvatarOnSitTarget();
            vector pos=llGetPos();
            llRezObject("Maker Hook left", pos, <0,0,0>, <0,0,0,0>, 1);
            llRezObject("Maker Hook right", pos, <0,0,0>, <0,0,0,0>, 1);
            llSay(5,(string)a);
            llSay(0,"Ready...");
            i++;
        }
    }
//Starting the Worm
    run_time_permissions(integer perm)
    {  
            llStopAnimation("sit");
            llStartAnimation("stand_4");
            llMessageLinked(LINK_SET,1,"",a);
            llSay(0,"Go!");
            i++;
    }
}

Worm Movement (partly functional)

This script works for single prims. Unfortunately, I cannot find a single movement function which works when the prim is being sat on so when applied to the Sandworm, this script just makes the pieces in which the script is embedded contract and re expand without any movement. Most of the idea behind this script is from Decimus so my thanks go to him.

vector p;
vector s;
vector pc;
vector np;
float n;
integer i;

default
{
    state_entry()
    {
//Defines starting conditions
        p=llGetPos();
        s=llGetScale();
        pc=p;
        np=<pc.x+0.5,pc.y,pc.z>;
    }
//Gets message from the Worm Start    
    link_message(integer sender, integer num, string str, key a)
    {
        key av=llAvatarOnSitTarget();
        while(av==a);
    {
//Runs the shrinking stage
        for(n=1; n>0.1; n=n-0.3)
        {
            pc=llGetPos(); 
            np=<pc.x+1.2,pc.y,pc.z>;
            llSetScale(<s.x,s.y,s.z*n>);
            llSetPos(np);
        }
        llSleep(0.1);
//Returns to normal
        for(n=0.4; n<1; n=n+0.3)
        {
            pc=llGetPos(); 
            np=<pc.x+1.2,pc.y,pc.z>;
            llSetScale(<s.x,s.y,s.z*n>);
            llSetPos(np);
        }
        av=llAvatarOnSitTarget();
    }
//Resets
        llSetPos(p);
        llSetScale(s);
        llResetScript();        
    }
}