Particle effects.lsl 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // Particle effects for the UFO cone
  2. // makes particles when triggered by xs_cryocrate
  3. // 11-15-2011 Added Link message EFFECTS_ON for particles or other effects when rezzing an egg
  4. /////////////////////////////////////////////////////////////////////
  5. // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike
  6. // See http://creativecommons.org/licenses/by-nc-sa/3.0/
  7. // Noncommercial -- You may not use this work for commercial purposes
  8. // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
  9. // This means that you cannot sell this code but you may share this code.
  10. // You must attribute authorship to me and leave this notice intact.
  11. //
  12. // Exception: I am allowing this script to be sold inside an original build.
  13. // You are not selling the script, you are selling the build.
  14. // Ferd Frederix
  15. // Particle Script 0.3
  16. // Originally Created by Ama Omega
  17. // tunables
  18. integer debug = TRUE; //if set to TRUE a touch to the base will turn on effects
  19. // Constants
  20. integer LINK_EFFECTS_ON = 2000; // special particle plug in effects enabled
  21. // Mask Flags - set to TRUE to enable
  22. integer glow = TRUE; // Make the particles glow
  23. integer bounce = TRUE; // Make particles bounce on Z plan of object
  24. integer interpColor = TRUE; // Go from start to end color
  25. integer interpSize = TRUE; // Go from start to end size
  26. integer wind = FALSE; // Particles effected by wind
  27. integer followSource = FALSE; // Particles follow the source
  28. integer followVel = TRUE; // Particles turn to velocity direction
  29. // Choose a pattern from the following:
  30. // PSYS_SRC_PATTERN_EXPLODE
  31. // PSYS_SRC_PATTERN_DROP
  32. // PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY
  33. // PSYS_SRC_PATTERN_ANGLE_CONE
  34. // PSYS_SRC_PATTERN_ANGLE
  35. integer pattern = PSYS_SRC_PATTERN_EXPLODE;
  36. // Select a target for particles to go towards
  37. // "" for no target, "owner" will follow object owner
  38. // and "self" will target this object
  39. // or put the key of an object for particles to go to
  40. key target = "self";
  41. // Particle paramaters
  42. float age = 5; // Life of each particle
  43. float maxSpeed = .05; // Max speed each particle is spit out at
  44. float minSpeed = 0; // Min speed each particle is spit out at
  45. string texture = ""; // Texture used for particles, default used if blank
  46. float startAlpha = 1; // Start alpha (transparency) value
  47. float endAlpha = .1; // End alpha (transparency) value
  48. vector startColor = <1,0,1>; // Start color of particles <R,G,B>
  49. vector endColor = <1,0,1>; // End color of particles <R,G,B> (if interpColor == TRUE)
  50. vector startSize = <0.050,0.05,1.9>; // Start size of particles
  51. vector endSize = <.020,.020,1.9>; // End size of particles (if interpSize == TRUE)
  52. vector push = <0.0,0.0,0>; // Force pushed on particles
  53. // System paramaters
  54. float rate = 0.1; // How fast (rate) to emit particles
  55. float radius = .02; // Radius to emit particles for BURST pattern
  56. integer count = 10; // How many particles to emit per BURST
  57. float outerAngle = 0.5; // Outer angle for all ANGLE patterns
  58. float innerAngle = 10; // Inner angle for all ANGLE patterns
  59. vector omega = <0,0,0>; // Rotation of ANGLE patterns around the source
  60. float life = 0; // Life in seconds for the system to make particles
  61. // Script variables
  62. integer flags;
  63. updateParticles()
  64. {
  65. flags = 0;
  66. if (target == "owner") target = llGetOwner();
  67. if (target == "self") target = llGetKey();
  68. if (glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
  69. if (bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
  70. if (interpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
  71. if (interpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
  72. if (wind) flags = flags | PSYS_PART_WIND_MASK;
  73. if (followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
  74. if (followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
  75. if (target != "") flags = flags | PSYS_PART_TARGET_POS_MASK;
  76. llParticleSystem([ PSYS_PART_MAX_AGE,age,
  77. PSYS_PART_FLAGS,flags,
  78. PSYS_PART_START_COLOR, startColor,
  79. PSYS_PART_END_COLOR, endColor,
  80. PSYS_PART_START_SCALE,startSize,
  81. PSYS_PART_END_SCALE,endSize,
  82. PSYS_SRC_PATTERN, pattern,
  83. PSYS_SRC_BURST_RATE,rate,
  84. PSYS_SRC_ACCEL, push,
  85. PSYS_SRC_BURST_PART_COUNT,count,
  86. PSYS_SRC_BURST_RADIUS,radius,
  87. PSYS_SRC_BURST_SPEED_MIN,minSpeed,
  88. PSYS_SRC_BURST_SPEED_MAX,maxSpeed,
  89. PSYS_SRC_TARGET_KEY,target,
  90. PSYS_SRC_INNERANGLE,innerAngle,
  91. PSYS_SRC_OUTERANGLE,outerAngle,
  92. PSYS_SRC_OMEGA, omega,
  93. PSYS_SRC_MAX_AGE, life,
  94. PSYS_SRC_TEXTURE, texture,
  95. PSYS_PART_START_ALPHA, startAlpha,
  96. PSYS_PART_END_ALPHA, endAlpha
  97. ]);
  98. }
  99. Move()
  100. {
  101. llSetAlpha(0.3,ALL_SIDES); // visible
  102. updateParticles();
  103. // no need to turn them off, we will die, but it is possible there was an errors mso we wait a while and shut themdown.
  104. llSleep(10);
  105. llParticleSystem([]); // particles OFF
  106. llSetAlpha(0,ALL_SIDES); // invisible
  107. }
  108. default
  109. {
  110. state_entry()
  111. {
  112. llSetAlpha(0,ALL_SIDES); // invisible
  113. llParticleSystem([]); // particles OFF
  114. }
  115. touch_start(integer p)
  116. {
  117. if (debug)
  118. Move();
  119. }
  120. link_message(integer sender_num, integer num, string str, key id)
  121. {
  122. if (num == LINK_EFFECTS_ON)
  123. {
  124. Move();
  125. }
  126. }
  127. }