User:Cow Taurog/Interceptor

From Second Life Wiki
< User:Cow Taurog
Revision as of 15:36, 5 April 2015 by Cow Taurog (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Invalid language.

You need to specify a language like this: <source lang="html4strict">...</source>

Supported languages for syntax highlighting:

4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, arm, asm, asp, asymptote, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcl, dcpu16, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, freeswitch, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, haxe, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, ldif, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, nagios, netrexx, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, octave, oobas, oorexx, oracle11, oracle8, oxygene, oz, parasail, parigp, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, pys60, python, q, qbasic, rails, rebol, reg, rexx, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, spark, sparql, sql, stonescript, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, upc, urbi, uscript, vala, vb, vbnet, vedit, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic


float gfFreq=0.01; // The scanning speed
float gfRange=15; // The scanning range
vector gvOffset=<2,0,0>; // Shield plate offset from the avatar
float gfTolerance=0.05; // The sensitivity for detecting speed (anything slower than this is considered to be still)
float gfInnerLimit=0.95; // Object is too close, don't intercept to avoid putting panels through you
integer giChan=74347;
integer listen0;
integer giStatus;
 
default{
    link_message(integer sender,integer num,string mess,key id){
        if(mess=="getstatus"){if(id=="interceptor"){llMessageLinked(LINK_SET,1,"status|interceptor|"+(string)giStatus,"status");}}
        if(llToLower(mess)=="touched"){if(id=="interceptor"){state running;}}
    }
    state_entry(){
        giStatus=0;
        llMessageLinked(LINK_SET,1,"status|interceptor|"+(string)giStatus,"status");
    }
}
state running{
    link_message(integer sender,integer num,string mess,key id){
        if(mess=="getstatus"){if(id=="interceptor"){llMessageLinked(LINK_SET,1,"status|interceptor|"+(string)giStatus,"status");}}
        if(llToLower(mess)=="touched"){if(id=="interceptor"){llMessageLinked(LINK_SET,1,"status|interceptor|0","status");llOwnerSay("Interceptors off.");state default;}}
        if(llToLower(mess)=="held"){if(id=="interceptor"){
            listen0=llListen(giChan,"","","");
            llSetTimerEvent(30);
            llTextBox(llGetOwner(),"Say sensor range and rez distance seperated by commas\n(i.e. 15,2)\nRange: "+(string)llRound(gfRange)+"m, Rez distance: "+(string)llRound(gvOffset.x)+"m",giChan);
        }}
    }
    changed(integer change){if(change&CHANGED_OWNER){llResetScript();}}
    state_entry(){
        giStatus=1;
        llMessageLinked(LINK_SET,1,"status|interceptor|1","status");
        llOwnerSay("Interceptors on. Scan range: "+(string)llRound(gfRange)+"m. Intercept distance: "+(string)llRound(gvOffset.x)+"m.");
        llSensorRepeat("","",AGENT|ACTIVE,gfRange,PI,gfFreq);
    }
    timer(){llListenRemove(listen0);llSetTimerEvent(0);}
    listen(integer chan,string name,key id,string mess){if(llGetOwnerKey(id)==llGetOwner()){if(mess!=""){
        list lR=llParseString2List(mess,[",","|","/"],[]);
        gfRange=(float)llList2String(lR,0);
        if((float)llList2String(lR,1)>10){llOwnerSay("The maximum inctercept distance is 10m.");gvOffset=<10,0,0>;}
        else{gvOffset=<(float)llList2String(lR,1),0,0>;}
        llSensorRepeat("","",AGENT|ACTIVE,gfRange,PI,gfFreq);
        llOwnerSay("Sensor range is now "+(string)llRound(gfRange)+"m, rez distance is now "+(string)llRound(gvOffset.x)+"m.");
        llListenRemove(listen0);
    }}}
    sensor(integer num){
        integer x;
        integer i;
        for(i=0;i<num;i++){if(llDetectedOwner(i)!=llGetOwner()){ // if not the owner's
            if(llVecMag(llDetectedVel(i))>gfTolerance){ //if moving
            //if(llVecDist(llGetPos(),llDetectedPos(i))>=gvOffset.x){
            if(llVecDist(llGetPos(),llDetectedPos(i))<=(gvOffset.x*PI)){ //*2
            if(llVecDist(llGetPos(),llDetectedPos(i))<gvOffset.x){ // inner shield //
                vector vCloseOffset=<((llVecMag(llGetPos()-llDetectedPos(i)))/1),0,0>; ///pos/2
                if(llVecDist(llGetPos(),llGetPos()+(<vCloseOffset.x,0,0>*llGetRot()*llRotBetween(<1.33,0,0>*llGetRot(),llDetectedPos(i)-llGetPos())))>gfInnerLimit){
                    // Inner shield
                    llRezObject("Shield panel",
                    llGetPos()+(<vCloseOffset.x-0.375,0,0>*llGetRot()*llRotBetween(<1.33,0,0>*llGetRot(),llDetectedPos(i)-llGetPos())),
                    ZERO_VECTOR,
                    llGetRot()*llRotBetween(<1.33,0,0>*llGetRot(),llDetectedPos(i)-llGetPos()),4
                    );
                    // Outer shield
                    llRezObject("Shield panel",
                    llGetPos()+(<vCloseOffset.x-0.25,0,0>*llGetRot()*llRotBetween(<1.33,0,0>*llGetRot(),llDetectedPos(i)-llGetPos())),
                    ZERO_VECTOR,
                    llGetRot()*llRotBetween(<1.33,0,0>*llGetRot(),llDetectedPos(i)-llGetPos()),4
                    );
                    return;
                }
            }}
            if(llVecMag(llDetectedVel(i))>gfTolerance){ // perimeter shield
                llRezObject("Shield panel",
                    llGetPos()+(gvOffset*llGetRot()*llRotBetween(<1.33,0,0>*llGetRot(),llDetectedPos(i)-llGetPos())),
                    ZERO_VECTOR,
                    llGetRot()*llRotBetween(<1.33,0,0>*llGetRot(),llDetectedPos(i)-llGetPos()),
                    4);
                    llRezObject("Shield panel",
                    llGetPos()+((gvOffset+<0.125,0,0>)*llGetRot()*llRotBetween(<1.33,0,0>*llGetRot(),llDetectedPos(i)-llGetPos())),
                    ZERO_VECTOR,
                    llGetRot()*llRotBetween(<1.33,0,0>*llGetRot(),llDetectedPos(i)-llGetPos()),
                    4);
                } // distance check
            } // moving check
        }} // loop and owner check
    }
}