Jump to content

Making an Avatar Stay still?


amarock Amat
 Share

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

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

Recommended Posts

So, am brain dead and strugglign to rember, on how to make a avatar not move, I am making a sort of like crossbow turrent, but I don't want folks to cheat and walk half a mile away while fireing it, any suggestions?

 

key toucher;
string toucherS;
float SPEED         = 60.0;         
integer LIFETIME    = 7;            
float DELAY         = 0.2;          
vector vel;                          
vector pos;                         
rotation rot;                       
integer in_use;
integer have_permissions = FALSE;   
integer armed = TRUE;               
fire()
{
    
        rot = llGetRot();               
        vel = llRot2Fwd(rot);           
        pos = llGetPos();               
        pos = pos + vel;                
        pos.z += 0.0;                   
        vel = vel * SPEED;              
        llTriggerSound("shoot", 1.0);
        llRezObject("bullet", pos, vel, rot, 1); 
}
default
{
    state_entry()
    {
       in_use = FALSE;        
    }
    touch_start(integer total_number)
    {
        if(in_use == FALSE)
        {
            toucher = llDetectedKey(0);
            llRequestPermissions(toucher, PERMISSION_TAKE_CONTROLS|PERMISSION_TRIGGER_ANIMATION);   
            llSetText("Requesting Permissions", <1,1,1>, 1); 
        }
        if(in_use == TRUE) 
        {
            if(llDetectedKey(0) == toucher)
            {
            llReleaseControls();
            llSensorRemove();
            llSetRot(<-0.00000, -0.00000, 0.70711, 0.70711>);
            llSetText("", <1,1,1>, 1); 
            in_use = FALSE;
            }
        }              
    }
    sensor(integer sense)
    {
        rotation k = llDetectedRot(0);
        llRotLookAt(k, .1, .1);
    }
    no_sensor()
    {
        llReleaseControls();
        llSensorRemove();
        llSetRot(<-0.00000, -0.00000, 0.70711, 0.70711>);
        llSetText("", <1,1,1>, 1); 
        in_use = FALSE;
    }
    run_time_permissions(integer perm)
    {
        if(perm)
        {
            llSetText("", <1,1,1>, 1);
            llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);
            llSensorRepeat("", toucher, AGENT, 20, TWO_PI, .1);
            llSetText("Current User: "+llKey2Name(toucher), <1,1,1>, 1);
            in_use = TRUE;
        }
        else
        {
            in_use = FALSE;
            llSetText("", <1,3,1>, 1);
        }
    }
    control(key name, integer levels, integer edges) 
    {
        if ((levels & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) 
        {
            fire();
        }
    }
    
}

 

Link to comment
Share on other sites

Well..... you could separate the touch_start event and the control event in different states.  Use the touch_start event to determine where the person is and then check in the control event to be sure that the person is no more than, say, 5m from that spot when he fires the crossbow.  Let the script return to state default only when the crossbow has been fired.

Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...