Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Gate Drop
- */
- var gateSoundPositions = [
- [142, 0, 154],
- [98, 0, 167],
- [53, 0, 181]
- ];
- var gateSounds = [];
- var gateDropped = false;
- for (var i=0; i < gateSoundPositions.length; i++) {
- gateSounds.push(mx.add_sound("@sx2019/js/sounds/gatedrop.raw"));
- mx.set_sound_freq(gateSounds[i], 44100);
- mx.set_sound_vol(gateSounds[i], 1.0);
- mx.set_sound_pos(gateSounds[i], gateSoundPositions[i][0], gateSoundPositions[i][1], gateSoundPositions[i][2]);
- }
- function gateSound(seconds) {
- var gateDropTime = mx.get_gate_drop_time();
- if (gateDropTime > 0.0 && !gateDropped ) {
- for (var i=0; i < gateSounds.length; i++) {
- mx.start_sound(gateSounds[i]);
- mx.start_sound(g_roar);
- }
- gateDropped = true;
- }
- gateSoundPrev(seconds);
- }
- var gateSoundPrev = mx.frame_handler;
- mx.frame_handler = gateSound;
- /*
- Holeshot Pyro
- */
- var holeshotFlameSound = mx.add_sound("@sx2019/js/sounds/holeshotflame.raw");
- mx.set_sound_freq(holeshotFlameSound, 44100);
- mx.set_sound_vol(holeshotFlameSound, 1.0);
- mx.set_sound_pos(holeshotFlameSound, 157, 7, 417);
- var holeshotFlames = mx.read_texture('@sx2019/js/pyro/holeshotflames.seq');
- var currentFrame = 0;
- var totalFrames = 69;
- var playAnimation = false;
- var secondsSinceUpdate = 0;
- // hide billboard until called upon
- mx.color_billboard(3, 1, 1, 1, 0);
- // Detect holeshot
- var holeshot = false;
- function holeshotHandler(seconds) {
- var runningOrder = mx.get_running_order();
- for (var i=0; i < runningOrder.length; i++) {
- if (runningOrder[i].position >= 2 && !holeshot) {
- triggerAnimation();
- holeshot = true;
- }
- }
- holeshotHandlerPrev(seconds);
- }
- var holeshotHandlerPrev = mx.frame_handler;
- mx.frame_handler = holeshotHandler;
- // Reset all the animation variables incase an animation is triggered while another animation is already playing
- // this didn't really have to be a separate function but it just made it simpler to do
- function triggerAnimation() {
- currentFrame = 0;
- secondsSinceUpdate = 0;
- playAnimation = true;
- }
- // frame handler that animates the billboard if "playAnimation" is true
- function animateBillboard(seconds) {
- if (playAnimation) {
- if (seconds - secondsSinceUpdate < 1 / 32.0) {
- return;
- }
- secondsSinceUpdate = seconds;
- if (currentFrame <= totalFrames) {
- mx.begin_custom_frame(holeshotFlames);
- mx.paste_custom_frame(holeshotFlames, currentFrame, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0);
- mx.end_custom_frame(holeshotFlames);
- // if first frame show billboards
- if (currentFrame === 0) {
- mx.color_billboard(3, 1, 1, 1, 1);
- //start your sounds here as well
- mx.start_sound(holeshotFlameSound);
- }
- currentFrame++;
- }
- }
- animateBillboardPrev(seconds);
- }
- var animateBillboardPrev = mx.frame_handler;
- mx.frame_handler = animateBillboard;
- /*
- Start Pyro
- */
- // sounds
- var largeFlameBurst = mx.add_sound("@sx2019/js/sounds/largeflameburst.raw");
- mx.set_sound_freq(largeFlameBurst, 44100);
- mx.set_sound_vol(largeFlameBurst, 1.0);
- mx.set_sound_pos(largeFlameBurst, 254, 36, 280);
- var finishFlameSound = mx.add_sound("@sx2019/js/sounds/finishlineflame.raw");
- mx.set_sound_freq(finishFlameSound, 44100);
- mx.set_sound_vol(finishFlameSound, 1.0);
- mx.set_sound_pos(finishFlameSound, 448, 37, 239);
- // animations
- var finishFlames = mx.read_texture('@sx2019/js/pyro/finishflames.seq');
- var finishFlames2 = mx.read_texture('@sx2019/js/pyro/finishflames2.seq');
- var fireballTexture = mx.read_texture('@sx2019r13houston/js/pyro/fireball2.seq');
- var currentFrame = 0;
- var totalFrames = 69;
- var secondsSinceUpdate = 0;
- // hide billboard until called upon
- mx.color_billboard(0, 1, 1, 1, 0);
- mx.color_billboard(1, 1, 1, 1, 0);
- mx.color_billboard(2, 1, 1, 1, 0);
- // display animations
- function startPyro(seconds) {
- var gateDropCheck = mx.get_gate_drop_time() >= 0 && mx.seconds >= mx.get_gate_drop_time();
- if (gateDropCheck) {
- if (seconds - secondsSinceUpdate < 1 / 32.0) {
- return;
- }
- secondsSinceUpdate = seconds;
- if (currentFrame <= totalFrames) {
- mx.begin_custom_frame(fireballTexture);
- mx.begin_custom_frame(finishFlames);
- mx.begin_custom_frame(finishFlames2);
- mx.paste_custom_frame(fireballTexture, currentFrame, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0);
- mx.paste_custom_frame(finishFlames, currentFrame, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0);
- mx.paste_custom_frame(finishFlames2, currentFrame, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0);
- mx.end_custom_frame(fireballTexture);
- mx.end_custom_frame(finishFlames);
- mx.end_custom_frame(finishFlames2);
- // if its the first frame set the billboard color so its visible
- if (currentFrame === 0) {
- mx.color_billboard(0, 1, 1, 1, 1);
- mx.color_billboard(1, 1, 1, 1, 1);
- mx.color_billboard(2, 1, 1, 1, 1);
- mx.start_sound(largeFlameBurst);
- mx.start_sound(finishFlameSound);
- }
- currentFrame++;
- }
- }
- startPyroPrev(seconds);
- }
- var startPyroPrev = mx.frame_handler;
- mx.frame_handler = startPyro;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement