Beam Particle effects.lsl 5.8 KB

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