daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Mar 24th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Gate Drop
  3. */
  4. var gateSoundPositions = [
  5.     [142, 0, 154],
  6.     [98, 0, 167],
  7.     [53, 0, 181]
  8. ];
  9.  
  10. var gateSounds = [];
  11.  
  12. var gateDropped = false;
  13.  
  14. for (var i=0; i < gateSoundPositions.length; i++) {
  15.     gateSounds.push(mx.add_sound("@sx2019/js/sounds/gatedrop.raw"));
  16.     mx.set_sound_freq(gateSounds[i], 44100);
  17.     mx.set_sound_vol(gateSounds[i], 1.0);
  18.     mx.set_sound_pos(gateSounds[i], gateSoundPositions[i][0], gateSoundPositions[i][1], gateSoundPositions[i][2]);
  19. }
  20.  
  21. function gateSound(seconds) {
  22.     var gateDropTime = mx.get_gate_drop_time();
  23.     if (gateDropTime > 0.0 && !gateDropped ) {
  24.         for (var i=0; i < gateSounds.length; i++) {
  25.             mx.start_sound(gateSounds[i]);
  26.             mx.start_sound(g_roar);
  27.         }
  28.         gateDropped = true;
  29.     }
  30.    
  31.     gateSoundPrev(seconds);
  32. }
  33.  
  34.  
  35. var gateSoundPrev = mx.frame_handler;
  36. mx.frame_handler = gateSound;
  37. /*
  38. Holeshot Pyro
  39. */
  40. var holeshotFlameSound = mx.add_sound("@sx2019/js/sounds/holeshotflame.raw");
  41. mx.set_sound_freq(holeshotFlameSound, 44100);
  42. mx.set_sound_vol(holeshotFlameSound, 1.0);
  43. mx.set_sound_pos(holeshotFlameSound, 157, 7, 417);
  44. var holeshotFlames = mx.read_texture('@sx2019/js/pyro/holeshotflames.seq');
  45. var currentFrame = 0;
  46. var totalFrames = 69;
  47. var playAnimation = false;
  48. var secondsSinceUpdate = 0;
  49.  
  50. // hide billboard until called upon
  51. mx.color_billboard(3, 1, 1, 1, 0);
  52.  
  53. // Detect holeshot
  54. var holeshot = false;
  55. function holeshotHandler(seconds) {
  56.     var runningOrder = mx.get_running_order();
  57.     for (var i=0; i < runningOrder.length; i++) {
  58.         if (runningOrder[i].position >= 2 && !holeshot) {
  59.             triggerAnimation();
  60.             holeshot = true;
  61.         }
  62.     }
  63.     holeshotHandlerPrev(seconds);
  64. }
  65.  
  66. var holeshotHandlerPrev = mx.frame_handler;
  67. mx.frame_handler = holeshotHandler;
  68.  
  69. // Reset all the animation variables incase an animation is triggered while another animation is already playing
  70. // this didn't really have to be a separate function but it just made it simpler to do
  71. function triggerAnimation() {
  72.     currentFrame = 0;
  73.     secondsSinceUpdate = 0;
  74.     playAnimation = true;
  75. }
  76.  
  77. // frame handler that animates the billboard if "playAnimation" is true
  78. function animateBillboard(seconds) {
  79.     if (playAnimation) {
  80.         if (seconds - secondsSinceUpdate < 1 / 32.0) {
  81.             return;
  82.         }
  83.         secondsSinceUpdate = seconds;
  84.                
  85.         if (currentFrame <= totalFrames) {
  86.             mx.begin_custom_frame(holeshotFlames);
  87.             mx.paste_custom_frame(holeshotFlames, currentFrame, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0);
  88.             mx.end_custom_frame(holeshotFlames);
  89.             // if first frame show billboards
  90.             if (currentFrame === 0) {
  91.                 mx.color_billboard(3, 1, 1, 1, 1);
  92.                 //start your sounds here as well
  93.                 mx.start_sound(holeshotFlameSound);
  94.             }
  95.             currentFrame++;
  96.         }
  97.     }  
  98.     animateBillboardPrev(seconds);
  99. }
  100.  
  101. var animateBillboardPrev = mx.frame_handler;
  102. mx.frame_handler = animateBillboard;
  103.  
  104. /*
  105. Start Pyro
  106. */
  107. // sounds
  108. var largeFlameBurst = mx.add_sound("@sx2019/js/sounds/largeflameburst.raw");
  109. mx.set_sound_freq(largeFlameBurst, 44100);
  110. mx.set_sound_vol(largeFlameBurst, 1.0);
  111. mx.set_sound_pos(largeFlameBurst, 254, 36, 280);
  112. var finishFlameSound = mx.add_sound("@sx2019/js/sounds/finishlineflame.raw");
  113. mx.set_sound_freq(finishFlameSound, 44100);
  114. mx.set_sound_vol(finishFlameSound, 1.0);
  115. mx.set_sound_pos(finishFlameSound, 448, 37, 239);
  116.  
  117. // animations
  118. var finishFlames = mx.read_texture('@sx2019/js/pyro/finishflames.seq');
  119. var finishFlames2 = mx.read_texture('@sx2019/js/pyro/finishflames2.seq');
  120. var fireballTexture = mx.read_texture('@sx2019r13houston/js/pyro/fireball2.seq');
  121. var currentFrame = 0;
  122. var totalFrames = 69;
  123. var secondsSinceUpdate = 0;
  124.  
  125. // hide billboard until called upon
  126. mx.color_billboard(0, 1, 1, 1, 0);
  127. mx.color_billboard(1, 1, 1, 1, 0);
  128. mx.color_billboard(2, 1, 1, 1, 0);
  129.  
  130. // display animations
  131. function startPyro(seconds) {
  132.     var gateDropCheck = mx.get_gate_drop_time() >= 0 && mx.seconds >= mx.get_gate_drop_time();
  133.     if (gateDropCheck) {
  134.         if (seconds - secondsSinceUpdate < 1 / 32.0) {
  135.             return;
  136.         }
  137.         secondsSinceUpdate = seconds;
  138.        
  139.         if (currentFrame <= totalFrames) {
  140.             mx.begin_custom_frame(fireballTexture);
  141.             mx.begin_custom_frame(finishFlames);
  142.             mx.begin_custom_frame(finishFlames2);
  143.             mx.paste_custom_frame(fireballTexture, currentFrame, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0);
  144.             mx.paste_custom_frame(finishFlames, currentFrame, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0);
  145.             mx.paste_custom_frame(finishFlames2, currentFrame, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0);
  146.             mx.end_custom_frame(fireballTexture);
  147.             mx.end_custom_frame(finishFlames);
  148.             mx.end_custom_frame(finishFlames2);
  149.             // if its the first frame set the billboard color so its visible
  150.             if (currentFrame === 0) {
  151.                 mx.color_billboard(0, 1, 1, 1, 1);
  152.                 mx.color_billboard(1, 1, 1, 1, 1);
  153.                 mx.color_billboard(2, 1, 1, 1, 1);
  154.                 mx.start_sound(largeFlameBurst);
  155.                 mx.start_sound(finishFlameSound);
  156.             }
  157.             currentFrame++;
  158.         }
  159.     }
  160.     startPyroPrev(seconds);
  161. }
  162.  
  163. var startPyroPrev = mx.frame_handler;
  164. mx.frame_handler = startPyro;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top