Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Name: Sonar
- Description: how to kill a sim with llCastRay
- Creator: Chaser.Zaks
- License: CC-BY
- Construction:
- 1) Create 3 prims, set their positions to the same spot.
- 2) Set the first prim to Cylinder, 2x2x0.13, slice 0.1 to 1.0.
- 3) Set the second prim to Cylinder, 2x2x0.13, slice 0.0 to 0.1.
- 4) Set the third prim to transparent.
- 5) Link the prims so that the first prim is the root prim.
- 6) Set the "rayPrim" variable in this script to the transparent prim.
- 7) Drop this script in.
- */
- integer frame;
- float dist = 64;
- key self;
- integer rayPrim = 2;
- default{
- on_rez(integer i){
- llResetScript();
- }
- state_entry(){
- llSetTimerEvent(0.1);
- self = llGetKey();
- llLinkParticleSystem(rayPrim, [
- PSYS_SRC_PATTERN,PSYS_SRC_PATTERN_DROP,
- PSYS_SRC_BURST_RADIUS,0,
- PSYS_SRC_ANGLE_BEGIN,0,
- PSYS_SRC_ANGLE_END,0,
- PSYS_SRC_TARGET_KEY,llGetKey(),
- PSYS_PART_START_COLOR,<0.000000,1.000000,0.000000>,
- PSYS_PART_END_COLOR,<0.000000,1.000000,0.000000>,
- PSYS_PART_START_ALPHA,0.5,
- PSYS_PART_END_ALPHA,0,
- PSYS_PART_START_GLOW,0,
- PSYS_PART_END_GLOW,0,
- PSYS_PART_BLEND_FUNC_SOURCE,PSYS_PART_BF_SOURCE_ALPHA,
- PSYS_PART_BLEND_FUNC_DEST,PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA,
- PSYS_PART_START_SCALE,<0.050000,0.050000,0.000000>,
- PSYS_PART_END_SCALE,<0.500000,0.500000,0.000000>,
- PSYS_SRC_TEXTURE,"d425d79f-c52a-2761-970c-c1e46ad96c1c",
- PSYS_SRC_MAX_AGE,0,
- PSYS_PART_MAX_AGE,20,
- PSYS_SRC_BURST_RATE,0.1,
- PSYS_SRC_BURST_PART_COUNT,1,
- PSYS_SRC_ACCEL,<0.000000,0.000000,0.000000>,
- PSYS_SRC_OMEGA,<0.000000,0.000000,0.000000>,
- PSYS_SRC_BURST_SPEED_MIN,0.5,
- PSYS_SRC_BURST_SPEED_MAX,0.5,
- PSYS_PART_FLAGS,
- 0 |
- PSYS_PART_INTERP_COLOR_MASK
- ]);
- }
- timer(){
- float f = (frame++%360) * DEG_TO_RAD * 2;
- vector s = llGetPos();
- vector r = <llSin(f),llCos(f),0>;
- list rc = llCastRay(s, s+(r*dist), [
- RC_MAX_HITS, 10,
- RC_DETECT_PHANTOM, FALSE,
- RC_DATA_FLAGS, RC_GET_ROOT_KEY
- ]);
- float detectedDist = 0;
- integer dtn = llList2Integer(rc, -1);
- if(llList2Integer(rc, -1) > 0){
- integer i;
- integer l = llGetListLength(rc)-1;
- while(i<l){
- key dt = llList2Key(rc, i);
- if(dt != self){
- detectedDist = llVecDist(s, llList2Vector(rc, i+1));
- jump break;
- }else i += 2;
- }
- @break;
- }
- detectedDist = detectedDist/dist;
- llSetLinkPrimitiveParamsFast(rayPrim,[
- PRIM_POS_LOCAL, r*detectedDist
- ]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement