Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. /*
  2. Name: Sonar
  3. Description: how to kill a sim with llCastRay
  4. Creator: Chaser.Zaks
  5. License: CC-BY
  6.  
  7. Construction:
  8. 1) Create 3 prims, set their positions to the same spot.
  9. 2) Set the first prim to Cylinder, 2x2x0.13, slice 0.1 to 1.0.
  10. 3) Set the second prim to Cylinder, 2x2x0.13, slice 0.0 to 0.1.
  11. 4) Set the third prim to transparent.
  12. 5) Link the prims so that the first prim is the root prim.
  13. 6) Set the "rayPrim" variable in this script to the transparent prim.
  14. 7) Drop this script in.
  15. */
  16. integer frame;
  17. float dist = 64;
  18. key self;
  19. integer rayPrim = 2;
  20. default{
  21. on_rez(integer i){
  22. llResetScript();
  23. }
  24.  
  25. state_entry(){
  26. llSetTimerEvent(0.1);
  27. self = llGetKey();
  28. llLinkParticleSystem(rayPrim, [
  29. PSYS_SRC_PATTERN,PSYS_SRC_PATTERN_DROP,
  30. PSYS_SRC_BURST_RADIUS,0,
  31. PSYS_SRC_ANGLE_BEGIN,0,
  32. PSYS_SRC_ANGLE_END,0,
  33. PSYS_SRC_TARGET_KEY,llGetKey(),
  34. PSYS_PART_START_COLOR,<0.000000,1.000000,0.000000>,
  35. PSYS_PART_END_COLOR,<0.000000,1.000000,0.000000>,
  36. PSYS_PART_START_ALPHA,0.5,
  37. PSYS_PART_END_ALPHA,0,
  38. PSYS_PART_START_GLOW,0,
  39. PSYS_PART_END_GLOW,0,
  40. PSYS_PART_BLEND_FUNC_SOURCE,PSYS_PART_BF_SOURCE_ALPHA,
  41. PSYS_PART_BLEND_FUNC_DEST,PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA,
  42. PSYS_PART_START_SCALE,<0.050000,0.050000,0.000000>,
  43. PSYS_PART_END_SCALE,<0.500000,0.500000,0.000000>,
  44. PSYS_SRC_TEXTURE,"d425d79f-c52a-2761-970c-c1e46ad96c1c",
  45. PSYS_SRC_MAX_AGE,0,
  46. PSYS_PART_MAX_AGE,20,
  47. PSYS_SRC_BURST_RATE,0.1,
  48. PSYS_SRC_BURST_PART_COUNT,1,
  49. PSYS_SRC_ACCEL,<0.000000,0.000000,0.000000>,
  50. PSYS_SRC_OMEGA,<0.000000,0.000000,0.000000>,
  51. PSYS_SRC_BURST_SPEED_MIN,0.5,
  52. PSYS_SRC_BURST_SPEED_MAX,0.5,
  53. PSYS_PART_FLAGS,
  54. 0 |
  55. PSYS_PART_INTERP_COLOR_MASK
  56. ]);
  57. }
  58.  
  59. timer(){
  60. float f = (frame++%360) * DEG_TO_RAD * 2;
  61. vector s = llGetPos();
  62. vector r = <llSin(f),llCos(f),0>;
  63. list rc = llCastRay(s, s+(r*dist), [
  64. RC_MAX_HITS, 10,
  65. RC_DETECT_PHANTOM, FALSE,
  66. RC_DATA_FLAGS, RC_GET_ROOT_KEY
  67. ]);
  68. float detectedDist = 0;
  69. integer dtn = llList2Integer(rc, -1);
  70. if(llList2Integer(rc, -1) > 0){
  71. integer i;
  72. integer l = llGetListLength(rc)-1;
  73. while(i<l){
  74. key dt = llList2Key(rc, i);
  75. if(dt != self){
  76. detectedDist = llVecDist(s, llList2Vector(rc, i+1));
  77. jump break;
  78. }else i += 2;
  79. }
  80. @break;
  81. }
  82. detectedDist = detectedDist/dist;
  83. llSetLinkPrimitiveParamsFast(rayPrim,[
  84. PRIM_POS_LOCAL, r*detectedDist
  85. ]);
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement