Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Crowd Sounds
  3. */
  4. var g_crowd = mx.add_sound("@sx2019/js/sounds/crowdconstant.raw");
  5. var g_crowd2 = mx.add_sound("@sx2019/js/sounds/crowdconstant.raw");
  6. var g_crowd3 = mx.add_sound("@sx2019/js/sounds/crowdconstant.raw");
  7. var g_crowd4 = mx.add_sound("@sx2019/js/sounds/crowdconstant.raw");
  8. var p = [], r = [];
  9. mx.set_sound_freq(g_crowd, 44100);
  10. mx.set_sound_freq(g_crowd2, 44100);
  11. mx.set_sound_freq(g_crowd3, 44100);
  12. mx.set_sound_freq(g_crowd4, 44100);
  13. mx.set_sound_vol(g_crowd, 1.5);
  14. mx.set_sound_vol(g_crowd2, 1.5);
  15. mx.set_sound_vol(g_crowd3, 1.5);
  16. mx.set_sound_vol(g_crowd4, 1.5);
  17. mx.set_sound_loop(g_crowd, 1);
  18. mx.set_sound_loop(g_crowd2, 1);
  19. mx.set_sound_loop(g_crowd3, 1);
  20. mx.set_sound_loop(g_crowd4, 1);
  21. mx.set_sound_pos(g_crowd, 336, 0, 79);
  22. mx.set_sound_pos(g_crowd2, 336, 0, 535);
  23. mx.set_sound_pos(g_crowd3, -19, 0, 306);
  24. mx.set_sound_pos(g_crowd4, 622, 0, 307);
  25. mx.start_sound(g_crowd);
  26. mx.start_sound(g_crowd2);
  27. mx.start_sound(g_crowd3);
  28. mx.start_sound(g_crowd4);
  29.  
  30. var g_roar = mx.add_sound("@sx2019/js/sounds/crowdroar.raw");
  31. mx.set_sound_freq(g_roar, 44100);
  32. mx.set_sound_vol(g_roar, 25.0);
  33.  
  34. function updateCamPosition() {
  35.    mx.get_camera_location(p, r);
  36.    mx.set_sound_pos(g_roar, p[0], p[1], p[2]);
  37.    updateCamPositionPrev();
  38. }
  39.  
  40. var updateCamPositionPrev = mx.frame_handler;
  41. mx.frame_handler = updateCamPosition;
  42. /*
  43. Gate Drop
  44. */
  45. var gateSoundPositions = [
  46.     [142, 0, 154],
  47.     [98, 0, 167],
  48.     [53, 0, 181]
  49. ];
  50.  
  51. var gateSounds = [];
  52.  
  53. var gateDropped = false;
  54.  
  55. for (var i=0; i < gateSoundPositions.length; i++) {
  56.     gateSounds.push(mx.add_sound("@sx2019/js/sounds/gatedrop.raw"));
  57.     mx.set_sound_freq(gateSounds[i], 44100);
  58.     mx.set_sound_vol(gateSounds[i], 1.0);
  59.     mx.set_sound_pos(gateSounds[i], gateSoundPositions[i][0], gateSoundPositions[i][1], gateSoundPositions[i][2]);
  60. }
  61.  
  62. function gateSound(seconds) {
  63.     var gateDropTime = mx.get_gate_drop_time();
  64.     if (gateDropTime > 0.0 && !gateDropped ) {
  65.         for (var i=0; i < gateSounds.length; i++) {
  66.             mx.start_sound(gateSounds[i]);
  67.             mx.start_sound(g_roar);
  68.         }
  69.         gateDropped = true;
  70.     }
  71.    
  72.     gateSoundPrev(seconds);
  73. }
  74.  
  75.  
  76. var gateSoundPrev = mx.frame_handler;
  77. mx.frame_handler = gateSound;
  78. /*
  79. Holeshot Pyro
  80. */
  81. var holeshotFlameSound = mx.add_sound("@sx2019/js/sounds/holeshotflame.raw");
  82. mx.set_sound_freq(holeshotFlameSound, 44100);
  83. mx.set_sound_vol(holeshotFlameSound, 1.0);
  84. mx.set_sound_pos(holeshotFlameSound, 157, 7, 417);
  85. var holeshotFlames = mx.read_texture('@sx2019/js/pyro/holeshotflames.seq');
  86. var currentFrame = 0;
  87. var totalFrames = 69;
  88. var playAnimation = false;
  89. var secondsSinceUpdate = 0;
  90.  
  91. // hide billboard until called upon
  92. mx.color_billboard(3, 1, 1, 1, 0);
  93.  
  94. // Detect holeshot
  95. var holeshot = false;
  96. function holeshotHandler(seconds) {
  97.     var runningOrder = mx.get_running_order();
  98.     for (var i=0; i < runningOrder.length; i++) {
  99.         if (runningOrder[i].position >= 2 && !holeshot) {
  100.             triggerAnimation();
  101.             holeshot = true;
  102.         }
  103.     }
  104.     holeshotHandlerPrev(seconds);
  105. }
  106.  
  107. var holeshotHandlerPrev = mx.frame_handler;
  108. mx.frame_handler = holeshotHandler;
  109.  
  110. // Reset all the animation variables incase an animation is triggered while another animation is already playing
  111. // this didn't really have to be a separate function but it just made it simpler to do
  112. function triggerAnimation() {
  113.     currentFrame = 0;
  114.     secondsSinceUpdate = 0;
  115.     playAnimation = true;
  116. }
  117.  
  118. // frame handler that animates the billboard if "playAnimation" is true
  119. function animateBillboard(seconds) {
  120.     if (playAnimation) {
  121.         if (seconds - secondsSinceUpdate < 1 / 32.0) {
  122.             return;
  123.         }
  124.         secondsSinceUpdate = seconds;
  125.                
  126.         if (currentFrame <= totalFrames) {
  127.             mx.begin_custom_frame(holeshotFlames);
  128.             mx.paste_custom_frame(holeshotFlames, currentFrame, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0);
  129.             mx.end_custom_frame(holeshotFlames);
  130.             // if first frame show billboards
  131.             if (currentFrame === 0) {
  132.                 mx.color_billboard(3, 1, 1, 1, 1);
  133.                 //start your sounds here as well
  134.                 mx.start_sound(holeshotFlameSound);
  135.             }
  136.             currentFrame++;
  137.         }
  138.     }  
  139.     animateBillboardPrev(seconds);
  140. }
  141.  
  142. var animateBillboardPrev = mx.frame_handler;
  143. mx.frame_handler = animateBillboard;
  144.  
  145. /*
  146. Start Pyro
  147. */
  148. // sounds
  149. var largeFlameBurst = mx.add_sound("@sx2019/js/sounds/largeflameburst.raw");
  150. mx.set_sound_freq(largeFlameBurst, 44100);
  151. mx.set_sound_vol(largeFlameBurst, 1.0);
  152. mx.set_sound_pos(largeFlameBurst, 254, 36, 280);
  153. var finishFlameSound = mx.add_sound("@sx2019/js/sounds/finishlineflame.raw");
  154. mx.set_sound_freq(finishFlameSound, 44100);
  155. mx.set_sound_vol(finishFlameSound, 1.0);
  156. mx.set_sound_pos(finishFlameSound, 448, 37, 239);
  157.  
  158. // animations
  159. var finishFlames = mx.read_texture('@sx2019/js/pyro/finishflames.seq');
  160. var finishFlames2 = mx.read_texture('@sx2019/js/pyro/finishflames2.seq');
  161. var fireballTexture = mx.read_texture('@sx2019r13houston/js/pyro/fireball2.seq');
  162. var currentFrame = 0;
  163. var totalFrames = 69;
  164. var secondsSinceUpdate = 0;
  165.  
  166. // hide billboard until called upon
  167. mx.color_billboard(0, 1, 1, 1, 0);
  168. mx.color_billboard(1, 1, 1, 1, 0);
  169. mx.color_billboard(2, 1, 1, 1, 0);
  170.  
  171. // display animations
  172. function startPyro(seconds) {
  173.     var gateDropCheck = mx.get_gate_drop_time() >= 0 && mx.seconds >= mx.get_gate_drop_time();
  174.     if (gateDropCheck) {
  175.         if (seconds - secondsSinceUpdate < 1 / 32.0) {
  176.             return;
  177.         }
  178.         secondsSinceUpdate = seconds;
  179.        
  180.         if (currentFrame <= totalFrames) {
  181.             mx.begin_custom_frame(fireballTexture);
  182.             mx.begin_custom_frame(finishFlames);
  183.             mx.begin_custom_frame(finishFlames2);
  184.             mx.paste_custom_frame(fireballTexture, currentFrame, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0);
  185.             mx.paste_custom_frame(finishFlames, currentFrame, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0);
  186.             mx.paste_custom_frame(finishFlames2, currentFrame, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0);
  187.             mx.end_custom_frame(fireballTexture);
  188.             mx.end_custom_frame(finishFlames);
  189.             mx.end_custom_frame(finishFlames2);
  190.             // if its the first frame set the billboard color so its visible
  191.             if (currentFrame === 0) {
  192.                 mx.color_billboard(0, 1, 1, 1, 1);
  193.                 mx.color_billboard(1, 1, 1, 1, 1);
  194.                 mx.color_billboard(2, 1, 1, 1, 1);
  195.                 mx.start_sound(largeFlameBurst);
  196.                 mx.start_sound(finishFlameSound);
  197.             }
  198.             currentFrame++;
  199.         }
  200.     }
  201.     startPyroPrev(seconds);
  202. }
  203.  
  204. var startPyroPrev = mx.frame_handler;
  205. mx.frame_handler = startPyro;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement