throw.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2014 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, the disclaimer and warranty conditions.        //
///////////////////////////////////////////////////////////////////////////
 
default {
    state_entry() {
        llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS|PERMISSION_TRIGGER_ANIMATION);
    }
    run_time_permissions(integer perm) {
        if(perm & PERMISSION_TAKE_CONTROLS == 0 || perm & PERMISSION_TRIGGER_ANIMATION == 0) return;
        llTakeControls(CONTROL_ML_LBUTTON, TRUE, TRUE);
    }
    control(key id, integer level, integer edge) {
        if((level & CONTROL_ML_LBUTTON) && (edge & CONTROL_ML_LBUTTON)) {
            llGetAndResetTime();
            return;
        }
        if(level & CONTROL_ML_LBUTTON || !(edge & CONTROL_ML_LBUTTON)) return;
        vector op = llList2Vector(llGetObjectDetails(llGetOwner(), [OBJECT_POS]), 0);
        vector as = llGetAgentSize(llGetOwner());
        float f = llGetAndResetTime()*90;
        if(f > 60) f = 60;
        llStartAnimation("throw");
        llRezObject("[WaS-K] Javelin", <0,0,as.z/2> + op, llRot2Fwd(llGetRot()) * f, llGetRot(), 0); 
    }
    on_rez(integer num) {
        llResetScript();
    }
}