Esempio n. 1
0
File: Form1.cs Progetto: Styrlitz/zi
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "WAV Files (*.wav)|*.wav";
            if (ofd.ShowDialog() != DialogResult.OK) return;
            OutPut(ofd.SafeFileName, ofd.FileName, true);

            waveViewer1.SamplesPerPixel = 450;
            waveViewer1.WaveStream = new NAudio.Wave.WaveFileReader(ofd.FileName);

            string WaveStr = "wave" + DateTime.Now.ToString();
            chart1.Series.Clear();
            chart1.Series.Add(WaveStr);
            chart1.Series[WaveStr].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
            chart1.Series[WaveStr].ChartArea = "ChartArea1";

            NAudio.Wave.WaveChannel32 wave = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(ofd.FileName));

            byte[] buffer = new byte[16384];
            int read = 0;

            while (wave.Position < wave.Length)
            {
                read = wave.Read(buffer, 0, 16384);

                for (int i = 0; i < read / 4; i++)
                {
                    chart1.Series[WaveStr].Points.Add(BitConverter.ToSingle(buffer, i * 4));
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Plays sound from start
        /// </summary>
        public void PlaySound()
        {
            if (fileName.EndsWith(".mp3"))
            {
                NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(fileName));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            }
            else if (fileName.EndsWith(".wav"))
            {
                NAudio.Wave.WaveStream pcm = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(fileName));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            }
            else
            {
                throw new InvalidOperationException("Not a correct audio file type. Supports mp3 and wav only!");
            }

            if (output == null)
            {
                output = new NAudio.Wave.DirectSoundOut();
            }

            output.Init(stream);
            output.Play();
        }
        private void openFileButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Audio File (*.mp3;*.wav)|*.mp3;*.wav;";
            if (open.ShowDialog() != DialogResult.OK) return;

            DisposeWave();

            if (open.FileName.EndsWith(".mp3"))
            {
                NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(open.FileName));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            }
            else if (open.FileName.EndsWith(".wav"))
            {
                NAudio.Wave.WaveStream pcm = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            }
            else throw new InvalidOperationException("Not a correct audio file type.");

            output = new NAudio.Wave.DirectSoundOut();
            output.Init(stream);
            output.Play();

            pauseButton.Enabled = true;
        }
Esempio n. 4
0
        private void Open_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();

            open.Filter = "Wave File (*.wav)|*.wav;";
            if (open.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            waveViewer1.SamplesPerPixel = 450;
            waveViewer1.WaveStream      = new NAudio.Wave.WaveFileReader(open.FileName);

            chart1.Series.Add("wave");
            chart1.Series["wave"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
            chart1.Series["wave"].ChartArea = "ChartArea1";

            NAudio.Wave.WaveChannel32 wave = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));

            byte[] buffer = new byte[16384];
            int    read   = 0;

            while (wave.Position < wave.Length)
            {
                read = wave.Read(buffer, 0, 16384);

                for (int i = 0; i < read / 4; i++)
                {
                    chart1.Series["wave"].Points.Add(BitConverter.ToSingle(buffer, i * 4));
                }
            }
        }
Esempio n. 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();

            open.Filter = "Wave File (*.wav)|*.wav;";
            if (open.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            this.label1.Text = open.FileName;
            chart1.Series.Clear();


            //waveViewer1.Visible = true;
            chart1.Series.Add("wave");
            chart1.Series["wave"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
            chart1.Series["wave"].ChartArea = "ChartArea1";

            NAudio.Wave.WaveChannel32 wave = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));

            byte[] buffer = new byte[16384];
            int    read   = 0;

            while (wave.Position < wave.Length)
            {
                read = wave.Read(buffer, 0, 16384);

                for (int i = 0; i < read / 8; i++)
                {
                    chart1.Series["wave"].Points.Add(BitConverter.ToSingle(buffer, i * 8));
                }
            }

            textBox1.Text = Convert.ToString(wave.Length);
        }
Esempio n. 6
0
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LoadLabel.Visible    = false;
            LoadingLabel.Visible = true;
            //Opening wave file
            OpenFileDialog open = new OpenFileDialog();

            open.Filter = "Wave file (*.wav) | *.wav";
            if (open.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            //Loads file onto wave viewer
            chart1.Series.Clear();
            chart1.Series.Add("wave");
            chart1.Series["wave"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
            chart1.Series["wave"].ChartArea = "ChartArea1";
            NAudio.Wave.WaveChannel32 wave = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));
            //Sizing wave to Programs width
            int read = 0;

            //Validation check for options
            byte[] buffer = new byte[ByteLength];
            while (wave.Position < wave.Length)
            {
                //Sampling
                read = wave.Read(buffer, 0, buffer.Length);
                for (int i = 0; i < read / SamplingDivider; i++)
                {
                    chart1.Series["wave"].Points.AddY(BitConverter.ToSingle(buffer, i * SamplingDivider));
                }
            }
            WaveformLoaded       = true;
            LoadingLabel.Visible = false;
        }
Esempio n. 7
0
        public async void loadSound(string filname, int height, int stepsPerSecond, Chart chart1, IntPtr Handle, PictureBox picture)
        {
            filename = filname;
            chart1.Series.Clear();
            chart1.Series.Add("wave");
            chart1.Series["wave"].ChartType         = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            chart1.Series["wave"].IsVisibleInLegend = false;
            chart1.Series["wave"].Color             = System.Drawing.Color.Green;
            chart1.Series["wave"].ChartArea         = "ChartArea1";
            NAudio.Wave.WaveChannel32 wave = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(filename));

            byte[] buffer = new byte[426565];
            int    read;

            while (wave.Position < wave.Length)
            {
                read = wave.Read(buffer, 0, 426565);
                for (int i = 0; i < read / 4; i++)
                {
                    chart1.Series["wave"].Points.Add(BitConverter.ToSingle(buffer, i * 4));
                }
            }

            wave.Dispose();

            picture.Image = DrawSpectrogram(filename, height, stepsPerSecond, Handle);
            System.Windows.Forms.Cursor.Current = Cursors.Default;
        }
Esempio n. 8
0
        private void bt_Abrir_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();

            open.Filter = "Audio File (*.mp3;*.wav)|*.mp3;*.wav;";
            if (open.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            DisposeWave();

            if (open.FileName.EndsWith(".mp3"))
            {
                NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(open.FileName));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            }
            else if (open.FileName.EndsWith(".wav"))
            {
                NAudio.Wave.WaveStream pcm = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            }
            else
            {
                throw new InvalidOperationException("Not a correct audio file type.");
            }

            output = new NAudio.Wave.DirectSoundOut();
            output.Init(stream);
            output.Play();

            bt_Play_Stop.Enabled = true;
        }
Esempio n. 9
0
        private void onKeyDown(object sender, KeyEventArgs e)
        {
            if (modActive == true)
            {
                // Sheathe / Unsheathe
                if (e.KeyCode == sheathe && !keyUp && !Game.Player.Character.IsSittingInVehicle())
                {
                    keyUp = true;

                    if (!spear.IsAttachedTo(Game.Player.Character))
                    {
                        spearActive = false;
                    }
                    else
                    {
                        spearActive = !spearActive;
                    }

                    // Sheathe
                    if (!spearActive)
                    {
                        spear.Detach();
                        unsheathed = false;

                        NAudio.Wave.WaveFileReader mp3whis1 = new NAudio.Wave.WaveFileReader(@"scripts\Spear Files\unsheathe.wav");
                        NAudio.Wave.WaveChannel32  waveDown = new NAudio.Wave.WaveChannel32(mp3whis1);
                        NAudio.Wave.DirectSoundOut output   = new NAudio.Wave.DirectSoundOut();
                        output.Init(waveDown);
                        output.Play();
                        waveDown.Volume = 0.05f;
                    }
                    else if (spear.IsAttachedTo(Game.Player.Character))
                    {
                        // Unsheathe
                        spear.AttachTo(Game.Player.Character, Game.Player.Character.GetBoneIndex(Bone.SKEL_Head),
                                       new Vector3(0.2f, 1, -0.2f),
                                       new Vector3(90, 0, 0)
                                       );

                        unsheathed = true;

                        NAudio.Wave.WaveFileReader recall  = new NAudio.Wave.WaveFileReader(@"scripts\Spear Files\return.wav");
                        NAudio.Wave.WaveChannel32  waveRec = new NAudio.Wave.WaveChannel32(recall);
                        NAudio.Wave.DirectSoundOut output3 = new NAudio.Wave.DirectSoundOut();
                        output3.Init(waveRec);
                        output3.Play();
                        waveRec.Volume = 0.05f;
                    }
                }
            }
        }
Esempio n. 10
0
        // event. click on 2nd 'Parcourir' boutton
        private void wavFileChooseBtn2_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            //openFileDialog1.InitialDirectory = @"C:\";
            openFileDialog1.Title      = "Choisir un fichier audio .wav";
            openFileDialog1.DefaultExt = "wav";
            openFileDialog1.Filter     = "audio files (*.wav)|*.wav";
            if (openFileDialog1.ShowDialog() == DialogResult.OK && file2TxtBox.Text != openFileDialog1.FileName)
            {
                // show file path
                file2TxtBox.Text = openFileDialog1.FileName;

                // create graph/spectrum
                this.Cursor = Cursors.WaitCursor;

                try
                {
                    chart2.Series.Clear();
                    chart2.Series.Add("wave");
                    chart2.Series["wave"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
                    chart2.Series["wave"].ChartArea = "ChartArea1";

                    // NAudio is a reference to NAudio dll
                    NAudio.Wave.WaveChannel32 wave = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(openFileDialog1.FileName));

                    byte[] buffer = new byte[16384];
                    int    read   = 0;

                    while (wave.Position < wave.Length)
                    {
                        read = wave.Read(buffer, 0, 16384);

                        for (int i = 0; i < read / 4; i++)
                        {
                            chart2.Series["wave"].Points.Add(BitConverter.ToSingle(buffer, i * 4));
                        }
                    } // fin while

                    wave.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }

                this.Cursor = Cursors.Default;
            } // fin if
        }
Esempio n. 11
0
        private void openWaveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();

            // This will get the current WORKING directory (i.e. \bin\Debug)
            string workingDirectory = Environment.CurrentDirectory;
            // or: Directory.GetCurrentDirectory() gives the same result

            // This will get the current PROJECT bin directory (ie ../bin/)
            string projectDirectory = Directory.GetParent(workingDirectory).Parent.FullName;

            // This will get the current PROJECT directory
            string projectDirectory2 = Directory.GetParent(workingDirectory).Parent.Parent.FullName;

            open.InitialDirectory = projectDirectory + "\\WAV_Files";
            open.Filter           = "Wave File (*.wav)|*.wav;";

            if (open.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            waveViewer1.SamplesPerPixel = 23;
            waveViewer1.WaveStream      = new NAudio.Wave.WaveFileReader(open.FileName);

            if (chart1.Series.Count > 0)
            {
                chart1.Series.RemoveAt(0);
            }
            chart1.Series.Add("wave");
            chart1.Series["wave"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
            chart1.Series["wave"].ChartArea = "ChartArea1";

            NAudio.Wave.WaveChannel32 wave = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));

            byte[] buffer = new byte[16384];
            int    read   = 0;

            while (wave.Position < wave.Length)
            {
                read = wave.Read(buffer, 0, 16384);

                for (int i = 0; i < read / 4; i++)
                {
                    chart1.Series["wave"].Points.Add(BitConverter.ToSingle(buffer, i * 4));
                }
            }
        }
Esempio n. 12
0
        private void btnOpen_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                OpenFileDialog open = new OpenFileDialog();
                open.Filter = "Sound Files (*.mp3;*.wav)|*.mp3;*.wav;";
                open.ShowDialog();

                DisposeWave();
                //wave = new NAudio.Wave.WaveFileReader(open.FileName);
                if (open.FileName.EndsWith(".mp3"))
                {
                    NAudio.Wave.WaveStream pcm = new NAudio.Wave.Mp3FileReader(open.FileName);
                    stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
                }
                else if (open.FileName.EndsWith(".wav"))
                {
                    NAudio.Wave.WaveStream pcm = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));
                    stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
                }

                output = new NAudio.Wave.WaveOutEvent();
                output.Init(new NAudio.Wave.WaveChannel32(stream));
                output.Play();
                StopWatch();
                if (stopWatch.IsRunning)
                {
                    stopWatch.Stop();
                }
                else
                {
                    stopWatch.Start();
                }

                btnPausePlay.IsEnabled = true;
            }catch (ArgumentException) {
                System.Windows.MessageBox.Show("Choose a real file");
            }
        }
Esempio n. 13
0
        private void lstSongBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            foreach (Song find in songDll)
            {
                if (lstSongBox.SelectedItem.ToString() == find.gsSongName)
                {
                    DisposeWave();
                    //check if mp3 or wav
                    if (find.gsSongURL.EndsWith(".mp3"))
                    {
                        //take the pcm data into a new stream and play the mp3 file
                        NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(find.gsSongURL));
                        stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
                    }
                    else if (find.gsSongURL.EndsWith(".wav"))
                    {
                        //do the same as the above but with a wav file
                        NAudio.Wave.WaveStream pcm = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(find.gsSongURL));
                        stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
                    }
                    else
                    {
                        throw new InvalidOperationException("Not a correct audio file type");
                    }
                    output = new NAudio.Wave.DirectSoundOut();
                    output.Init(stream);
                    output.Play();

                    btnPlay.IsEnabled  = true;
                    btnStop.IsEnabled  = true;
                    btnPause.IsEnabled = true;

                    txtNowPlaying.Text = "Now playing: " + lstSongBox.SelectedItem.ToString();
                }
            }
        }
Esempio n. 14
0
File: Form1.cs Progetto: Styrlitz/zi
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "WAV Files (*.wav)|*.wav";
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            OutPut(ofd.SafeFileName, ofd.FileName, true);

            waveViewer1.SamplesPerPixel = 450;
            waveViewer1.WaveStream      = new NAudio.Wave.WaveFileReader(ofd.FileName);

            string WaveStr = "wave" + DateTime.Now.ToString();

            chart1.Series.Clear();
            chart1.Series.Add(WaveStr);
            chart1.Series[WaveStr].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
            chart1.Series[WaveStr].ChartArea = "ChartArea1";

            NAudio.Wave.WaveChannel32 wave = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(ofd.FileName));

            byte[] buffer = new byte[16384];
            int    read   = 0;

            while (wave.Position < wave.Length)
            {
                read = wave.Read(buffer, 0, 16384);

                for (int i = 0; i < read / 4; i++)
                {
                    chart1.Series[WaveStr].Points.Add(BitConverter.ToSingle(buffer, i * 4));
                }
            }
        }
Esempio n. 15
0
        private void tick(object sender, EventArgs e)
        {
            if (Game.CurrentInputMode == InputMode.GamePad)
            {
                // Select button
                if (Game.IsControlPressed(2, GTA.Control.ScriptRDown) && Mod_Menu.modActivator() == 1 && on == 0 && !keyUp)
                {
                    modActivate();
                    keyUp = true;
                }
                if (Game.IsControlPressed(2, GTA.Control.ScriptRDown) && Mod_Menu.modActivator() == 0 && on == 1 && !keyUp)
                {
                    modActivate();
                    keyUp = true;
                }
                if (Game.IsControlJustReleased(2, GTA.Control.ScriptRDown))
                {
                    keyUp = false;
                }
            }

            if (modActive)
            {
                Game.DisableControlThisFrame(2, GTA.Control.Aim);
                Game.DisableControlThisFrame(81, GTA.Control.Cover);
                Game.DisableControlThisFrame(2, GTA.Control.LookBehind);
                Game.DisableControlThisFrame(2, GTA.Control.Phone);

                if (superSpeed)
                {
                    Game.Player.SetRunSpeedMultThisFrame(1.49f);
                }
                if (superJump)
                {
                    Game.Player.SetSuperJumpThisFrame();
                }

                Game.Player.Character.CanRagdoll = false;
                Function.Call(Hash.REMOVE_WEAPON_FROM_PED, Game.Player.Character, 0xFBAB5776);

                pedsToTarget     = World.GetNearbyPeds(Game.Player.Character, 45f);
                vehicles         = World.GetNearbyVehicles(Game.Player.Character.Position, 30f);
                vehiclesToTarget = World.GetClosestVehicle(Game.Player.Character.Position, 10f);
                nearbyPeds       = World.GetNearbyPeds(dagger.Position, 20f);
                nearbyVehs       = World.GetNearbyVehicles(dagger.Position, 20f);
                nearbyStuff      = World.GetNearbyEntities(dagger.Position, 20f);

                UI.DrawTexture("scripts\\Dagger Files\\crosshair.png", 0, 0, 100, new Point(550, 255), new Size(185, 185), 2f, Color.Orange);
                if (attached == true)
                {
                    UI.DrawTexture("scripts\\Dagger Files\\hooked.png", 0, 0, 100, new Point(200, 600), new Size(130, 100), 2f, Color.White);
                }

                try {
                    // Peds
                    foreach (Ped p in pedsToTarget)
                    {
                        dagger.SetNoCollision(p, true);
                        p.SetNoCollision(dagger, true);

                        if (Game.IsControlJustPressed(2, GTA.Control.Phone) && !keyUp)
                        {
                            i     = 1;
                            keyUp = true;
                        }
                        if (Game.IsControlJustReleased(2, GTA.Control.Phone))
                        {
                            i     = 0;
                            keyUp = false;
                        }

                        // attach checks
                        if (p != Game.Player.Character)
                        {
                            if (dagger.IsInRangeOf(p.Position, 1.5f) && !dagger.IsAttachedTo(Game.Player.Character) && p.IsAlive)
                            {
                                attached = true;
                            }
                            if (dagger.IsInRangeOf(p.Position, 1.5f) && !dagger.IsAttachedTo(Game.Player.Character) && !p.IsAlive)
                            {
                                attached = false;
                            }
                            if (dagger.IsInRangeOf(p.Position, 1.5f) && Game.IsKeyPressed(Keys.Z) || i == 1)
                            {
                                attached = false;
                            }
                            if (attached == true && Game.IsKeyPressed(Keys.Z) || i == 1)
                            {
                                attached = false;
                            }
                        }

                        // reset ped flag
                        if (dagger.IsAttached() && Game.IsKeyPressed(Keys.Z) || i == 1)
                        {
                            p.CanFlyThroughWindscreen = true;
                        }

                        // target ped + ped flag
                        if (p != Game.Player.Character)
                        {
                            distPed            = p.Position.DistanceTo(GameplayCamera.Position);
                            comparePositionPed = GameplayCamera.Position + GameplayCamera.Direction * distPed;

                            if (attached == false)
                            {
                                if (p.Position.DistanceTo(comparePositionPed) < 0.5 && p.IsAlive && !p.IsSittingInVehicle())
                                {
                                    World.DrawMarker(MarkerType.UpsideDownCone, (p.Position + new Vector3(0f, 0f, 1.5f)), new Vector3(0f, 0f, 0f),
                                                     new Vector3(0f, 0f, 0f), new Vector3(0.2f, 0.2f, 0.2f), Color.White, false, false, 0, false, "", "", false);

                                    // throw anim
                                    if (Game.IsDisabledControlPressed(2, GTA.Control.Aim) && dagger.IsAttachedTo(Game.Player.Character) && !Game.Player.Character.IsGettingUp && !Game.Player.Character.IsInVehicle())
                                    {
                                        Game.Player.Character.Task.PlayAnimation("weapons@projectile@grenade_str",
                                                                                 "throw_m_fb_forward", 8.0f, -5.0f, 600, AnimationFlags.None, 0f);
                                    }

                                    // throw dagger
                                    if (Game.IsDisabledControlPressed(2, GTA.Control.Aim) && !Game.Player.Character.IsSittingInVehicle() && !Game.Player.Character.IsGettingUp)
                                    {
                                        dagger.Detach();
                                        dagger.ApplyForce((p.Position - dagger.Position) * 3f);

                                        p.CanFlyThroughWindscreen = false;

                                        World.DrawMarker(MarkerType.UpsideDownCone, (p.Position + new Vector3(0f, 0f, 1.5f)), new Vector3(0f, 0f, 0f),
                                                         new Vector3(0.2f, 0.2f, 0.2f), new Vector3(0.2f, 0.2f, 0.2f), Color.DarkOrange, false, false, 0, false, "", "", false);
                                    }
                                }
                            }
                        }

                        // collisions
                        if (attached == true)
                        {
                            p.SetNoCollision(Game.Player.Character, true);
                        }
                        if (Game.IsKeyPressed(Keys.Z) || Game.IsDisabledControlPressed(1, GTA.Control.Attack))
                        {
                            p.SetNoCollision(Game.Player.Character, false);
                        }

                        // attach ped
                        if (dagger.IsInRangeOf(p.Position, 1.5f) && !Game.IsKeyPressed(Keys.Z) && p.IsAlive && attached == true && p.CanFlyThroughWindscreen == false)
                        {
                            Function.Call(Hash.SET_PED_TO_RAGDOLL, p, 1000, 1000, 2);
                            Function.Call(Hash.ATTACH_ENTITY_TO_ENTITY_PHYSICALLY, p, dagger, p.GetBoneIndex(Bone.RB_Neck_1), 0,
                                          0f, 0f, 0.30f,
                                          0f, 0f, 0f,
                                          0, 0, 0,
                                          0f, false, 0, false, false, 2);
                        }

                        // detach
                        if (Game.IsKeyPressed(Keys.Z) || i == 1 && dagger.IsInRangeOf(p.Position, 1.4f) && attached == false || p.IsDead)
                        {
                            p.Detach();
                        }
                        if (Game.IsKeyPressed(recall) && dagger.IsInRangeOf(vehCompPosFront, 10f))
                        {
                            dagger.Detach();
                        }

                        // recall methods
                        if (Game.IsKeyPressed(recall) && !dagger.IsAttachedTo(Game.Player.Character))
                        {
                            dagger.FreezePosition = false;
                            dagger.Detach();
                            dagger.ApplyForce((dagger.Position - Game.Player.Character.Position) * -2f);
                        }
                        if (Game.IsKeyPressed(recall) && dagger.IsInRangeOf(Game.Player.Character.Position, 1.5f))
                        {
                            dagger.AttachTo(Game.Player.Character, Game.Player.Character.GetBoneIndex(Bone.PH_R_Hand),
                                            new Vector3(0.05f, -0.02f, -0.03f),
                                            new Vector3(118f, 0f, 0f)
                                            );
                        }

                        if (Game.IsControlJustPressed(2, GTA.Control.ScriptRB) && !keyUp)
                        {
                            r     = 1;
                            keyUp = true;
                        }
                        if (Game.IsControlJustReleased(2, GTA.Control.ScriptRB))
                        {
                            r     = 0;
                            keyUp = false;
                        }

                        if (r == 1 && !dagger.IsAttachedTo(Game.Player.Character))
                        {
                            dagger.FreezePosition = false;
                            dagger.Detach();
                            dagger.ApplyForce((dagger.Position - Game.Player.Character.Position) * -2f);
                        }
                        if (r == 1 && dagger.IsInRangeOf(Game.Player.Character.Position, 1.5f))
                        {
                            dagger.AttachTo(Game.Player.Character, Game.Player.Character.GetBoneIndex(Bone.PH_R_Hand),
                                            new Vector3(0.05f, -0.02f, -0.03f),
                                            new Vector3(118f, 0f, 0f)
                                            );
                        }

                        // shove + 1 hit KO
                        if (Game.Player.Character.IsTouching(p))
                        {
                            p.ApplyForce(p.Position - Game.Player.Character.Position);
                        }
                        if (Game.Player.Character.IsInMeleeCombat)
                        {
                            Ped a = Game.Player.Character.GetMeleeTarget();
                            if (a.HasBeenDamagedBy(Game.Player.Character))
                            {
                                a.ApplyDamage(300);
                            }
                        }

                        // power selections
                        if (powerMode < -1 || powerMode > 5)
                        {
                            powerMode = 0;
                        }
                        if (powerMode == -1)
                        {
                            powerMode = 5;
                        }

                        if (Game.IsKeyPressed(powerModeDown) && !keyUp)
                        {
                            keyUp = true;
                            powerMode--;
                        }
                        if (Game.IsKeyPressed(powerModeUp) && !keyUp)
                        {
                            keyUp = true;
                            powerMode++;
                        }

                        if (Game.CurrentInputMode == InputMode.GamePad)
                        {
                            if (Game.IsControlJustPressed(2, GTA.Control.ScriptPadRight) && !keyUp)
                            {
                                keyUp = true;
                                powerMode++;
                            }
                            if (Game.IsControlJustReleased(2, GTA.Control.ScriptPadRight))
                            {
                                keyUp = false;
                            }
                            if (Game.IsControlJustPressed(2, GTA.Control.ScriptPadLeft) && !keyUp)
                            {
                                keyUp = true;
                                powerMode--;
                            }
                            if (Game.IsControlJustReleased(2, GTA.Control.ScriptPadLeft))
                            {
                                keyUp = false;
                            }
                        }

                        // passive
                        if (Game.IsKeyPressed(passive) && !keyUp)
                        {
                            keyUp     = true;
                            passiveOn = !passiveOn;
                        }

                        if (Game.IsControlJustPressed(2, GTA.Control.LookBehind) && !keyUp)
                        {
                            keyUp     = true;
                            passiveOn = !passiveOn;
                        }
                        if (Game.IsControlJustReleased(2, GTA.Control.LookBehind))
                        {
                            keyUp = false;
                        }


                        if (passiveOn)
                        {
                            UI.DrawTexture("scripts\\Dagger Files\\magazine.png", 0, 0, 100, new Point(285, 650), new Size(25, 25), 2f, Color.White);
                            if (p.IsInCombatAgainst(Game.Player.Character))
                            {
                                p.Weapons.Current.Ammo       = 0;
                                p.Weapons.Current.AmmoInClip = 0;
                            }
                        }

                        // kill
                        if (powerMode == 0)
                        {
                            UI.DrawTexture("scripts\\Dagger Files\\skull.png", 0, 0, 100, new Point(200, 600), new Size(130, 100), 2f, Color.White);

                            if (dagger.IsInRangeOf(p.Position, 1.5f) && attached == true)
                            {
                                Game.DisableControlThisFrame(1, GTA.Control.Attack);
                                if (Game.IsDisabledControlJustPressed(1, GTA.Control.Attack))
                                {
                                    p.Kill();
                                    attached = false;
                                }
                            }
                        }

                        // attach to objects
                        if (powerMode == 1)
                        {
                            UI.DrawTexture("scripts\\Dagger Files\\attach.png", 0, 0, 100, new Point(200, 600), new Size(130, 100), 2f, Color.White);

                            if (dagger.IsInRangeOf(p.Position, 1.5f) && dagger.IsInRangeOf(Game.Player.Character.Position, 1.5f) && attached == true)
                            {
                                Game.DisableControlThisFrame(1, GTA.Control.Attack);
                                if (Game.IsDisabledControlJustPressed(1, GTA.Control.Attack))
                                {
                                    dagger.Detach();
                                    dagger.FreezePosition = true;

                                    // Left door
                                    if (Game.Player.Character.IsInRangeOf(vehCompPosLeft, 1.5f))
                                    {
                                        dagger.AttachTo(vehiclesToTarget, vehiclesToTarget.GetBoneIndex("handle_dside_f"),
                                                        new Vector3(0, 0, 0),
                                                        new Vector3(0, -90, 0)
                                                        );
                                    }

                                    // Right door
                                    if (Game.Player.Character.IsInRangeOf(vehCompPosRight, 1.5f))
                                    {
                                        dagger.AttachTo(vehiclesToTarget, vehiclesToTarget.GetBoneIndex("handle_pside_f"),
                                                        new Vector3(0, 0, 0),
                                                        new Vector3(0, 90, 0)
                                                        );
                                    }

                                    // Front
                                    if (Game.Player.Character.IsInRangeOf(vehCompPosFront, 1.5f))
                                    {
                                        dagger.AttachTo(vehiclesToTarget, vehiclesToTarget.GetBoneIndex("bonnet"),
                                                        new Vector3(0, 1, 0),
                                                        new Vector3(0, 0, 0)
                                                        );
                                    }

                                    // Back
                                    if (Game.Player.Character.IsInRangeOf(vehCompPosBack, 1.5f))
                                    {
                                        dagger.AttachTo(vehiclesToTarget, vehiclesToTarget.GetBoneIndex("boot"),
                                                        new Vector3(0, -0.5f, 0),
                                                        new Vector3(0, 0, 0)
                                                        );
                                    }
                                }
                            }
                        }
                        else
                        {
                            dagger.FreezePosition = false;
                        }

                        // throw
                        if (powerMode == 2)
                        {
                            UI.DrawTexture("scripts\\Dagger Files\\throw.png", 0, 0, 100, new Point(200, 600), new Size(130, 100), 2f, Color.White);

                            if (dagger.IsInRangeOf(p.Position, 1.5f) && dagger.IsInRangeOf(Game.Player.Character.Position, 1.5f) && attached == true)
                            {
                                Game.DisableControlThisFrame(1, GTA.Control.Attack);
                                if (Game.IsDisabledControlJustPressed(1, GTA.Control.Attack))
                                {
                                    Game.Player.Character.Task.PlayAnimation("weapons@projectile@grenade_str",
                                                                             "throw_m_fb_forward", 8.0f, -5.0f, 600, AnimationFlags.None, 0f);
                                    p.Detach();
                                    attached = false;
                                    p.ApplyForce(Vector3.RelativeTop * 25 + GameplayCamera.Direction * 35);
                                }
                            }
                        }

                        // lightning
                        if (powerMode == 3)
                        {
                            UI.DrawTexture("scripts\\Dagger Files\\lightning.png", 0, 0, 100, new Point(200, 600), new Size(130, 100), 2f, Color.White);
                            Game.DisableControlThisFrame(1, GTA.Control.Attack);

                            if (Game.IsDisabledControlJustPressed(1, GTA.Control.Attack))
                            {
                                foreach (Ped x in nearbyPeds)
                                {
                                    if (x.IsAlive && x != Game.Player.Character)
                                    {
                                        World.ShootBullet(dagger.Position, x.Position, Game.Player.Character, "WEAPON_STUNGUN", 1, 10);

                                        if (x.IsBeingStunned)
                                        {
                                            if (Function.Call <bool>(Hash.HAS_NAMED_PTFX_ASSET_LOADED, "core"))
                                            {
                                                Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, "core");

                                                Function.Call <int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "sp_foundry_sparks", x,
                                                                    0, 0, 0.06,
                                                                    90f, 0, 0,
                                                                    0.05f, 0, 0, 0);
                                            }
                                            else
                                            {
                                                Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, "core");
                                            }
                                        }
                                    }
                                }

                                foreach (Vehicle v in nearbyVehs)
                                {
                                    if (Game.IsDisabledControlJustPressed(1, GTA.Control.Attack))
                                    {
                                        if (v.IsAlive)
                                        {
                                            v.StartAlarm();
                                            v.ApplyForce(Vector3.WorldDown * 0.1f);
                                            v.EngineRunning = false;

                                            if (Function.Call <bool>(Hash.HAS_NAMED_PTFX_ASSET_LOADED, "core"))
                                            {
                                                Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, "core");

                                                Function.Call <int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "sp_foundry_sparks", v,
                                                                    0, 0, 0.06,
                                                                    90f, 0, 0,
                                                                    0.05f, 0, 0, 0);
                                            }
                                            else
                                            {
                                                Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, "core");
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        // drop and or flee
                        if (powerMode == 4)
                        {
                            UI.DrawTexture("scripts\\Dagger Files\\flee.png", 0, 0, 100, new Point(200, 600), new Size(130, 100), 2f, Color.White);
                            Game.DisableControlThisFrame(1, GTA.Control.Attack);

                            if (Game.IsDisabledControlJustPressed(1, GTA.Control.Attack))
                            {
                                foreach (Ped z in nearbyPeds)
                                {
                                    if (z != Game.Player.Character)
                                    {
                                        z.Weapons.Drop();
                                        z.Task.ReactAndFlee(Game.Player.Character);
                                    }
                                }
                            }
                        }

                        // nuke
                        if (powerMode == 5)
                        {
                            UI.DrawTexture("scripts\\Dagger Files\\nuke.png", 0, 0, 100, new Point(200, 600), new Size(130, 100), 2f, Color.White);
                            Game.DisableControlThisFrame(1, GTA.Control.Attack);

                            if (Game.IsDisabledControlJustPressed(1, GTA.Control.Attack))
                            {
                                foreach (Ped x in nearbyPeds)
                                {
                                    if (x != Game.Player.Character && x.IsAlive)
                                    {
                                        World.AddExplosion(x.Position, ExplosionType.Grenade, 2f, 0f);
                                    }
                                }

                                foreach (Vehicle v in nearbyVehs)
                                {
                                    if (v.IsAlive)
                                    {
                                        World.AddExplosion(v.Position, ExplosionType.Grenade, 2f, 0f);
                                    }
                                }

                                foreach (Entity q in nearbyStuff)
                                {
                                    if (q != Game.Player.Character)
                                    {
                                        q.ApplyForce(q.Position - dagger.Position);
                                    }
                                }
                            }
                        }
                    }

                    // Vehicle target
                    foreach (Vehicle v in vehicles)
                    {
                        vehCompPosFront      = v.GetOffsetInWorldCoords(Vector3.RelativeFront * v.Model.GetDimensions().Y * 0.4f);
                        distFront            = vehCompPosFront.DistanceTo(GameplayCamera.Position);
                        comparePositionFront = GameplayCamera.Position + GameplayCamera.Direction * distFront;

                        vehCompPosBack      = v.GetOffsetInWorldCoords(Vector3.RelativeBack * v.Model.GetDimensions().Y * 0.4f);
                        distBack            = vehCompPosBack.DistanceTo(GameplayCamera.Position);
                        comparePositionBack = GameplayCamera.Position + GameplayCamera.Direction * distBack;

                        vehCompPosLeft      = v.GetOffsetInWorldCoords(Vector3.RelativeLeft * v.Model.GetDimensions().X * 0.4f);
                        distLeft            = vehCompPosLeft.DistanceTo(GameplayCamera.Position);
                        comparePositionLeft = GameplayCamera.Position + GameplayCamera.Direction * distLeft;

                        vehCompPosRight      = v.GetOffsetInWorldCoords(Vector3.RelativeRight * v.Model.GetDimensions().X * 0.4f);
                        distRight            = vehCompPosRight.DistanceTo(GameplayCamera.Position);
                        comparePositionRight = GameplayCamera.Position + GameplayCamera.Direction * distRight;

                        distCenter            = v.Position.DistanceTo(GameplayCamera.Position);
                        comparePositionCenter = GameplayCamera.Position + GameplayCamera.Direction * distCenter;

                        if (vehCompPosFront.DistanceTo(comparePositionFront) < 0.5 && v.IsAlive ||
                            vehCompPosBack.DistanceTo(comparePositionBack) < 0.5 && v.IsAlive ||
                            vehCompPosLeft.DistanceTo(comparePositionLeft) < 0.5 && v.IsAlive ||
                            vehCompPosRight.DistanceTo(comparePositionRight) < 0.5 && v.IsAlive ||
                            v.Position.DistanceTo(comparePositionCenter) < 0.5 && v.IsAlive)
                        {
                            // throw anim
                            if (Game.IsDisabledControlPressed(2, GTA.Control.Aim) && dagger.IsAttachedTo(Game.Player.Character) && !Game.Player.Character.IsGettingUp && !Game.Player.Character.IsInVehicle())
                            {
                                Game.Player.Character.Task.PlayAnimation("weapons@projectile@grenade_str",
                                                                         "throw_m_fb_forward", 8.0f, -5.0f, 600, AnimationFlags.None, 0f);
                            }

                            // target vehicle
                            if (Game.IsDisabledControlPressed(2, GTA.Control.Aim))
                            {
                                dagger.Detach();
                                dagger.ApplyForce((v.Position - dagger.Position) * 3f);

                                if (dagger.IsInRangeOf(v.Position, 3f))
                                {
                                    dagger.AttachTo(v, v.GetBoneIndex("engine"),
                                                    new Vector3(0, 0.5f, 0.6f),
                                                    new Vector3(0, -180, 0)
                                                    );
                                }

                                if (!dagger.IsAttachedTo(v))
                                {
                                    World.DrawMarker(MarkerType.UpsideDownCone, (v.Position + new Vector3(0f, 0f, 2f)), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f),
                                                     new Vector3(0.4f, 0.4f, 0.4f), Color.Orange, false, false, 0, false, "", "", false);
                                }
                            }
                            else
                            {
                                World.DrawMarker(MarkerType.UpsideDownCone, (v.Position + new Vector3(0f, 0f, 2f)), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f),
                                                 new Vector3(0.4f, 0.4f, 0.4f), Color.White, false, false, 0, false, "", "", false);
                            }
                        }

                        // amplified powers (on vehs)
                        if (dagger.IsAttachedTo(v))
                        {
                            UI.DrawTexture("scripts\\Dagger Files\\amplified.png", 0, 0, 100, new Point(200, 600), new Size(130, 100), 2f, Color.White);

                            // kill
                            if (powerMode == 0)
                            {
                                Ped p = v.GetPedOnSeat(VehicleSeat.Passenger);
                                Ped w = v.GetPedOnSeat(VehicleSeat.LeftRear);
                                Ped r = v.GetPedOnSeat(VehicleSeat.RightRear);
                                if (v.Driver.IsAlive || p.IsAlive || w.IsAlive || r.IsAlive)
                                {
                                    Game.DisableControlThisFrame(1, GTA.Control.Attack);
                                }

                                if (Game.IsDisabledControlJustPressed(1, GTA.Control.Attack))
                                {
                                    v.Driver.Kill();
                                    p.Kill();
                                    w.Kill();
                                    r.Kill();

                                    v.SmashWindow(VehicleWindow.BackLeftWindow);
                                    v.SmashWindow(VehicleWindow.BackRightWindow);
                                    v.SmashWindow(VehicleWindow.FrontLeftWindow);
                                    v.SmashWindow(VehicleWindow.FrontRightWindow);
                                }
                            }

                            // throw
                            if (powerMode == 2)
                            {
                                Game.DisableControlThisFrame(1, GTA.Control.Attack);
                                if (Game.IsDisabledControlJustPressed(1, GTA.Control.Attack))
                                {
                                    v.ApplyForce(GameplayCamera.Direction * 20f);
                                }
                            }

                            // lightning
                            if (powerMode == 3)
                            {
                                if (Game.IsDisabledControlJustPressed(1, GTA.Control.Attack))
                                {
                                    v.EngineHealth = -10;
                                    v.LightsOn     = true;
                                    v.OpenDoor(VehicleDoor.FrontLeftDoor, true, false);
                                    v.OpenDoor(VehicleDoor.BackLeftDoor, true, false);
                                    v.OpenDoor(VehicleDoor.FrontRightDoor, true, false);
                                    v.OpenDoor(VehicleDoor.BackRightDoor, true, false);
                                }
                            }

                            // flee
                            if (powerMode == 4)
                            {
                                if (Game.IsDisabledControlJustPressed(1, GTA.Control.Attack))
                                {
                                    if (!v.IsTireBurst(0) & !v.IsTireBurst(1) & !v.IsTireBurst(2) & !v.IsTireBurst(3) & !v.IsTireBurst(4) & !v.IsTireBurst(5) & !v.IsTireBurst(6) & !v.IsTireBurst(7))
                                    {
                                        v.BurstTire(0);
                                        v.BurstTire(1);
                                        v.BurstTire(2);
                                        v.BurstTire(3);
                                        v.BurstTire(4);
                                        v.BurstTire(5);
                                        v.BurstTire(6);
                                        v.BurstTire(7);
                                    }

                                    v.SmashWindow(VehicleWindow.BackLeftWindow);
                                    v.SmashWindow(VehicleWindow.BackRightWindow);
                                    v.SmashWindow(VehicleWindow.FrontLeftWindow);
                                    v.SmashWindow(VehicleWindow.FrontRightWindow);
                                    v.BreakDoor(VehicleDoor.BackLeftDoor);
                                    v.BreakDoor(VehicleDoor.FrontLeftDoor);
                                    v.BreakDoor(VehicleDoor.BackRightDoor);
                                    v.BreakDoor(VehicleDoor.FrontRightDoor);
                                    v.BreakDoor(VehicleDoor.Hood);
                                    v.BreakDoor(VehicleDoor.Trunk);
                                }
                            }
                        }
                    }
                } catch (Exception f**k) { }

                // ptfx (on dagger)
                if (powerMode == 3 & Game.IsDisabledControlJustPressed(1, GTA.Control.Attack))
                {
                    if (Function.Call <bool>(Hash.HAS_NAMED_PTFX_ASSET_LOADED, "core"))
                    {
                        Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, "core");

                        Function.Call <int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "sp_foundry_sparks", dagger,
                                            0, 0, 0.06,
                                            90f, 0, 0,
                                            0.05f, 0, 0, 0);
                    }
                    else
                    {
                        Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, "core");
                    }
                }
                if (powerMode == 5 & Game.IsDisabledControlJustPressed(1, GTA.Control.Attack))
                {
                    if (Function.Call <bool>(Hash.HAS_NAMED_PTFX_ASSET_LOADED, "core"))
                    {
                        Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, "core");

                        Function.Call <int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "exp_grd_boat_lod", dagger,
                                            0, 0, 0.06,
                                            0f, 0f, 0,
                                            0.6f, 0, 0, 0);
                    }
                    else
                    {
                        Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, "core");
                    }
                }

                if (powerMode == 4 & Game.IsDisabledControlJustPressed(1, GTA.Control.Attack))
                {
                    if (Function.Call <bool>(Hash.HAS_NAMED_PTFX_ASSET_LOADED, "scr_carsteal4"))
                    {
                        Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, "scr_carsteal4");
                        Function.Call(Hash.SET_PARTICLE_FX_NON_LOOPED_COLOUR, 255.0f, 0, 0);

                        Function.Call <int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "scr_carsteal4_wheel_burnout", dagger,
                                            0, 0, 2f,
                                            0f, 0f, 0,
                                            2f, 0, 0, 0);
                    }
                    else
                    {
                        Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, "scr_carsteal4");
                    }
                }

                // sounds
                if (Game.IsDisabledControlJustPressed(1, GTA.Control.Attack))
                {
                    // kill
                    if (powerMode == 0)
                    {
                        NAudio.Wave.WaveFileReader neck   = new NAudio.Wave.WaveFileReader(@"scripts\Dagger Files\neck.wav");
                        NAudio.Wave.WaveChannel32  waveAt = new NAudio.Wave.WaveChannel32(neck);
                        NAudio.Wave.DirectSoundOut output = new NAudio.Wave.DirectSoundOut();

                        output.Init(waveAt);
                        output.Play();
                        waveAt.Volume = 0.30f;
                    }

                    // attach
                    if (powerMode == 1)
                    {
                        NAudio.Wave.WaveFileReader attach  = new NAudio.Wave.WaveFileReader(@"scripts\Dagger Files\attach.wav");
                        NAudio.Wave.WaveChannel32  waveAt3 = new NAudio.Wave.WaveChannel32(attach);
                        NAudio.Wave.DirectSoundOut output2 = new NAudio.Wave.DirectSoundOut();

                        output2.Init(waveAt3);
                        output2.Play();
                        waveAt3.Volume = 0.30f;
                    }

                    // throw
                    if (powerMode == 2)
                    {
                        NAudio.Wave.WaveFileReader throww  = new NAudio.Wave.WaveFileReader(@"scripts\Dagger Files\throw.wav");
                        NAudio.Wave.WaveChannel32  waveAt3 = new NAudio.Wave.WaveChannel32(throww);
                        NAudio.Wave.DirectSoundOut output3 = new NAudio.Wave.DirectSoundOut();

                        output3.Init(waveAt3);
                        output3.Play();
                        waveAt3.Volume = 0.30f;
                    }

                    // lightning
                    if (powerMode == 3)
                    {
                        NAudio.Wave.WaveFileReader lightning = new NAudio.Wave.WaveFileReader(@"scripts\Dagger Files\lightning.wav");
                        NAudio.Wave.WaveChannel32  waveAt4   = new NAudio.Wave.WaveChannel32(lightning);
                        NAudio.Wave.DirectSoundOut output4   = new NAudio.Wave.DirectSoundOut();

                        output4.Init(waveAt4);
                        output4.Play();
                        waveAt4.Volume = 1f;
                    }

                    // flee
                    if (powerMode == 4)
                    {
                        NAudio.Wave.WaveFileReader flee    = new NAudio.Wave.WaveFileReader(@"scripts\Dagger Files\flee.wav");
                        NAudio.Wave.WaveChannel32  waveAt5 = new NAudio.Wave.WaveChannel32(flee);
                        NAudio.Wave.DirectSoundOut output5 = new NAudio.Wave.DirectSoundOut();

                        output5.Init(waveAt5);
                        output5.Play();
                        waveAt5.Volume = 0.30f;
                    }

                    //nuke
                    if (powerMode == 5)
                    {
                        NAudio.Wave.WaveFileReader nuke    = new NAudio.Wave.WaveFileReader(@"scripts\Dagger Files\nuke.wav");
                        NAudio.Wave.WaveChannel32  waveAt5 = new NAudio.Wave.WaveChannel32(nuke);
                        NAudio.Wave.DirectSoundOut output5 = new NAudio.Wave.DirectSoundOut();

                        output5.Init(waveAt5);
                        output5.Play();
                        waveAt5.Volume = 0.10f;
                    }
                }
            }
            else
            {
                Game.Player.SetRunSpeedMultThisFrame(1.0f);
            }
        }
Esempio n. 16
0
        private void onTick(object sender, EventArgs e)
        {
            if (Game.CurrentInputMode == InputMode.GamePad)
            {
                // Select button
                if (Game.IsControlJustPressed(2, GTA.Control.ScriptRDown) && Mod_Menu.modActivator() == 2 && on == 0 && !keyUp)
                {
                    modActivate();
                    keyUp = true;
                }
                if (Game.IsControlJustPressed(2, GTA.Control.ScriptRDown) && Mod_Menu.modActivator() == 0 && on == 1 && !keyUp)
                {
                    modActivate();
                    keyUp = true;
                }
                if (Game.IsControlJustReleased(2, GTA.Control.ScriptRDown))
                {
                    keyUp = false;
                }
            }

            if (modActive == true)
            {
                pedsToTarget     = World.GetNearbyPeds(Game.Player.Character, pedTargetDistance);
                vehiclesToTarget = World.GetNearbyVehicles(Game.Player.Character, vehTargetDistance);

                speed = Function.Call <int>(Hash.GET_ENTITY_SPEED, spear);

                Game.DisableControlThisFrame(2, GTA.Control.Aim);
                Game.DisableControlThisFrame(81, GTA.Control.Cover);
                Game.DisableControlThisFrame(17, GTA.Control.Duck);
                Game.DisableControlThisFrame(2, GTA.Control.LookBehind);
                Game.DisableControlThisFrame(1, GTA.Control.Phone);

                if (superSpeed)
                {
                    Game.Player.SetRunSpeedMultThisFrame(1.49f);
                }
                if (superJump)
                {
                    Game.Player.SetSuperJumpThisFrame();
                }

                Game.Player.Character.CanRagdoll = false;

                Function.Call(Hash.REMOVE_WEAPON_FROM_PED, Game.Player.Character, 0xFBAB5776);

                UI.DrawTexture("scripts\\Spear Files\\crosshair.png", 0, 0, 100, new Point(615, 320), new Size(55, 55), 0, Color.White);

                // Target method
                try {
                    // Peds
                    foreach (Ped p in pedsToTarget)
                    {
                        if (p != Game.Player.Character)
                        {
                            distPed            = p.Position.DistanceTo(GameplayCamera.Position);
                            comparePositionPed = GameplayCamera.Position + GameplayCamera.Direction * distPed;

                            if (powerIndex != 2)
                            {
                                if (spear.IsAttachedTo(p) && !p.IsRagdoll || !p.IsRagdoll && p.MaxHealth == 1)
                                {
                                    p.Kill();
                                }
                            }

                            if (p.IsDead && p.IsOnFire)
                            {
                                Function.Call(Hash.STOP_ENTITY_FIRE, p);
                            }

                            if (!spear.IsAttachedTo(p))
                            {
                                if (powerIndex == 4)
                                {
                                    Game.DisableControlThisFrame(1, GTA.Control.Attack);

                                    if (p.IsAlive && p.CanFlyThroughWindscreen == false)
                                    {
                                        World.DrawMarker(MarkerType.UpsideDownCone, (p.Position + new Vector3(0f, 0f, 1.5f)), new Vector3(0f, 0f, 0f),
                                                         new Vector3(0f, 0f, 0f), new Vector3(0.2f, 0.2f, 0.2f), Color.Red, false, false, 0, false, "", "", false);
                                    }

                                    if (Game.IsDisabledControlJustPressed(1, GTA.Control.Attack))
                                    {
                                        p.CanFlyThroughWindscreen = false;
                                    }
                                    else if (Game.IsDisabledControlJustPressed(1, GTA.Control.Aim) && p.CanFlyThroughWindscreen == false)
                                    {
                                        spear.Detach();
                                        spear.ApplyForce((p.Position - spear.Position) * 5);

                                        if (spear.IsAttachedTo(p) && p.CanFlyThroughWindscreen == false)
                                        {
                                            Function.Call(Hash.SET_PED_TO_RAGDOLL, p, 300, 0, 2);
                                            p.ApplyForce(Vector3.WorldDown * 500);
                                            p.MaxHealth = 1;
                                        }
                                    }
                                }

                                if (p.Position.DistanceTo(comparePositionPed) < 0.5 && p.IsAlive && !p.IsSittingInVehicle() && !p.IsInVehicle())
                                {
                                    World.DrawMarker(MarkerType.UpsideDownCone, (p.Position + new Vector3(0f, 0f, 1.5f)), new Vector3(0f, 0f, 0f),
                                                     new Vector3(0f, 0f, 0f), new Vector3(0.2f, 0.2f, 0.2f), Color.White, false, false, 0, false, "", "", false);

                                    if (Game.IsDisabledControlPressed(2, GTA.Control.Aim) && !Game.Player.Character.IsSittingInVehicle())
                                    {
                                        if (unsheathed == true || !spear.IsAttachedTo(Game.Player.Character))
                                        {
                                            if (powerIndex != 4)
                                            {
                                                spear.Detach();
                                                spear.ApplyForce((p.Position - spear.Position) * 5);
                                            }

                                            if (spear.IsInRangeOf(p.Position, 5f))
                                            {
                                                spear.AttachTo(p, p.GetBoneIndex(Bone.SKEL_Head),
                                                               new Vector3(0, 1f, 0),
                                                               new Vector3(90, 0, 0)
                                                               );

                                                if (powerIndex == 0)
                                                {
                                                    Function.Call(Hash.SET_PED_TO_RAGDOLL, p, 300, 0, 2);
                                                    p.ApplyForce(GameplayCamera.Direction * 15f);
                                                    p.MaxHealth = 1;
                                                }
                                            }

                                            // sounds
                                            if (Game.IsDisabledControlJustPressed(2, GTA.Control.Aim))
                                            {
                                                NAudio.Wave.WaveFileReader attack  = new NAudio.Wave.WaveFileReader(@"scripts\Spear Files\attack2.wav");
                                                NAudio.Wave.WaveChannel32  waveAt  = new NAudio.Wave.WaveChannel32(attack);
                                                NAudio.Wave.DirectSoundOut output2 = new NAudio.Wave.DirectSoundOut();

                                                output2.Init(waveAt);
                                                output2.Play();
                                                waveAt.Volume = 0.05f;
                                            }

                                            if (powerIndex == 1)
                                            {
                                                if (spear.IsAttachedTo(p))
                                                {
                                                    Function.Call(Hash.SET_PED_TO_RAGDOLL, p, 300, 0, 2);
                                                    p.ApplyForce(Vector3.WorldDown * 500);
                                                    p.MaxHealth = 1;
                                                }
                                            }

                                            if (powerIndex == 2)
                                            {
                                                if (spear.IsAttachedTo(p))
                                                {
                                                    World.AddExplosion(spear.Position, ExplosionType.Grenade, 10f, 1f);
                                                }
                                            }

                                            Model tmp = new Model("S_M_Y_Fireman_01");
                                            if (powerIndex == 3)
                                            {
                                                if (spear.IsAttachedTo(p) && p.IsAlive)
                                                {
                                                    Function.Call(Hash.START_ENTITY_FIRE, p);
                                                    if (!p.IsOnFire)
                                                    {
                                                        p.Kill();
                                                    }
                                                }

                                                if (p.Model.Equals(tmp))
                                                {
                                                    p.Kill();
                                                }
                                            }

                                            World.DrawMarker(MarkerType.UpsideDownCone, (p.Position + new Vector3(0f, 0f, 1.5f)), new Vector3(0f, 0f, 0f),
                                                             new Vector3(0.2f, 0.2f, 0.2f), new Vector3(0.2f, 0.2f, 0.2f), Color.Red, false, false, 0, false, "", "", false);
                                        }
                                        else
                                        {
                                            World.DrawMarker(MarkerType.UpsideDownCone, (p.Position + new Vector3(0f, 0f, 1.5f)), new Vector3(0f, 0f, 0f),
                                                             new Vector3(0.2f, 0.2f, 0.2f), new Vector3(0.2f, 0.2f, 0.2f), Color.Blue, false, false, 0, false, "", "", false);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    // Vehicles
                    foreach (Vehicle v in vehiclesToTarget)
                    {
                        vehCompPosFront      = v.GetOffsetInWorldCoords(Vector3.RelativeFront * v.Model.GetDimensions().Y * 0.4f);
                        distFront            = vehCompPosFront.DistanceTo(GameplayCamera.Position);
                        comparePositionFront = GameplayCamera.Position + GameplayCamera.Direction * distFront;

                        vehCompPosBack      = v.GetOffsetInWorldCoords(Vector3.RelativeBack * v.Model.GetDimensions().Y * 0.4f);
                        distBack            = vehCompPosBack.DistanceTo(GameplayCamera.Position);
                        comparePositionBack = GameplayCamera.Position + GameplayCamera.Direction * distBack;

                        vehCompPosLeft      = v.GetOffsetInWorldCoords(Vector3.RelativeLeft * v.Model.GetDimensions().X * 0.4f);
                        distLeft            = vehCompPosLeft.DistanceTo(GameplayCamera.Position);
                        comparePositionLeft = GameplayCamera.Position + GameplayCamera.Direction * distLeft;

                        vehCompPosRight      = v.GetOffsetInWorldCoords(Vector3.RelativeRight * v.Model.GetDimensions().X * 0.4f);
                        distRight            = vehCompPosRight.DistanceTo(GameplayCamera.Position);
                        comparePositionRight = GameplayCamera.Position + GameplayCamera.Direction * distRight;

                        vehCompPosTop      = v.GetOffsetInWorldCoords(Vector3.RelativeRight * v.Model.GetDimensions().Z * 0.4f);
                        distTop            = vehCompPosTop.DistanceTo(GameplayCamera.Position);
                        comparePositionTop = GameplayCamera.Position + GameplayCamera.Direction * distTop;

                        distCenter            = v.Position.DistanceTo(GameplayCamera.Position);
                        comparePositionCenter = GameplayCamera.Position + GameplayCamera.Direction * distCenter;

                        if (vehCompPosFront.DistanceTo(comparePositionFront) < 0.5 && v.IsAlive ||
                            vehCompPosBack.DistanceTo(comparePositionBack) < 0.5 && v.IsAlive ||
                            vehCompPosLeft.DistanceTo(comparePositionLeft) < 0.5 && v.IsAlive ||
                            vehCompPosRight.DistanceTo(comparePositionRight) < 0.5 && v.IsAlive ||
                            vehCompPosTop.DistanceTo(comparePositionTop) < 0.5 && v.IsAlive ||
                            v.Position.DistanceTo(comparePositionCenter) < 0.5 && v.IsAlive)
                        {
                            World.DrawMarker(MarkerType.UpsideDownCone, (v.Position + new Vector3(0f, 0f, 2f)), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f),
                                             new Vector3(0.4f, 0.4f, 0.4f), Color.White, false, false, 0, false, "", "", false);

                            if (Game.IsDisabledControlPressed(2, GTA.Control.Aim) && !Game.Player.Character.IsSittingInVehicle())
                            {
                                if (unsheathed == true || !spear.IsAttachedTo(Game.Player.Character))
                                {
                                    spear.Detach();
                                    spear.ApplyForce((v.Position - spear.Position) * 5);

                                    if (spear.IsInRangeOf(v.Position, 5f))
                                    {
                                        if (powerIndex == 1 || powerIndex == 2)
                                        {
                                            spear.AttachTo(v, v.GetBoneIndex("engine"), new Vector3(0, 0, 0), new Vector3(0, 0, 0));
                                            v.ApplyForceRelative(Vector3.WorldDown * 50.0f);
                                            // spearCrush
                                            if (powerIndex == 1)
                                            {
                                                v.IsInvincible = true;
                                            }
                                        }
                                    }

                                    // sounds (v)
                                    if (Game.IsDisabledControlJustPressed(2, GTA.Control.Aim))
                                    {
                                        NAudio.Wave.WaveFileReader attack  = new NAudio.Wave.WaveFileReader(@"scripts\Spear Files\attack2.wav");
                                        NAudio.Wave.WaveChannel32  waveAt  = new NAudio.Wave.WaveChannel32(attack);
                                        NAudio.Wave.DirectSoundOut output2 = new NAudio.Wave.DirectSoundOut();

                                        output2.Init(waveAt);
                                        output2.Play();

                                        waveAt.Volume = 0.05f;
                                    }

                                    // spearNormal
                                    if (powerIndex == 0 || powerIndex == 3)
                                    {
                                        if (v.Driver.IsAlive || !v.Driver.IsAlive && !v.IsSeatFree(VehicleSeat.Driver))
                                        {
                                            if (spear.IsInRangeOf(v.Position, 5f))
                                            {
                                                spear.AttachTo(v.Driver, v.Driver.GetBoneIndex(Bone.SKEL_Head),
                                                               new Vector3(0, 1f, 0),
                                                               new Vector3(90, 0, 0)
                                                               );
                                                v.SmashWindow(VehicleWindow.FrontLeftWindow);
                                            }
                                        }

                                        if (v.IsSeatFree(VehicleSeat.Driver) && spear.IsInRangeOf(v.Position, 5))
                                        {
                                            if (!v.IsDoorBroken(VehicleDoor.FrontLeftDoor))
                                            {
                                                spear.AttachTo(v, v.GetBoneIndex("handle_dside_f"), new Vector3(0.5f, 0, 0), new Vector3(0, -90, 0));
                                            }
                                            else
                                            {
                                                spear.AttachTo(v, v.GetBoneIndex("engine"), new Vector3(0.5f, 0, 0), new Vector3(0, -90, 0));
                                            }
                                        }
                                    }

                                    // spearFire
                                    if (powerIndex == 3)
                                    {
                                        if (v.Driver.IsAlive || !v.Driver.IsAlive && !v.IsSeatFree(VehicleSeat.Driver))
                                        {
                                            if (spear.IsInRangeOf(v.Position, 5f))
                                            {
                                                spear.AttachTo(v.Driver, v.Driver.GetBoneIndex(Bone.SKEL_Head),
                                                               new Vector3(0, 1f, 0),
                                                               new Vector3(90, 0, 0)
                                                               );
                                                v.SmashWindow(VehicleWindow.FrontLeftWindow);
                                                if (!v.IsTireBurst(0))
                                                {
                                                    v.BurstTire(0);
                                                }
                                                v.Driver.Kill();
                                                Function.Call(Hash.START_ENTITY_FIRE, v.Driver);
                                            }
                                        }

                                        if (v.IsSeatFree(VehicleSeat.Driver) && spear.IsInRangeOf(v.Position, 5))
                                        {
                                            if (!v.IsDoorBroken(VehicleDoor.FrontLeftDoor))
                                            {
                                                spear.AttachTo(v, v.GetBoneIndex("handle_dside_f"), new Vector3(0.5f, 0, 0), new Vector3(0, -90, 0));
                                            }
                                            else
                                            {
                                                spear.AttachTo(v, v.GetBoneIndex("engine"), new Vector3(0.5f, 0, 0), new Vector3(0, -90, 0));
                                            }
                                        }
                                    }

                                    // spearExplode
                                    if (powerIndex == 2)
                                    {
                                        if (spear.IsAttachedTo(v))
                                        {
                                            World.AddOwnedExplosion(Game.Player.Character, spear.Position, ExplosionType.Grenade, 10f, 1f);
                                        }
                                    }

                                    World.DrawMarker(MarkerType.UpsideDownCone, (v.Position + new Vector3(0f, 0f, 2f)), new Vector3(0f, 0f, 0f),
                                                     new Vector3(0f, 0f, 0f), new Vector3(0.4f, 0.4f, 0.4f), Color.Red, false, false, 0, false, "", "", false);
                                }
                                else
                                {
                                    World.DrawMarker(MarkerType.UpsideDownCone, (v.Position + new Vector3(0f, 0f, 2f)), new Vector3(0f, 0f, 0f),
                                                     new Vector3(0f, 0f, 0f), new Vector3(0.4f, 0.4f, 0.4f), Color.Blue, false, false, 0, false, "", "", false);
                                }
                            }
                            else
                            {
                                v.IsInvincible = false;
                            }
                        }
                    }

                    // recall methods
                    if (Game.IsKeyPressed(sheathe) & !spear.IsAttachedTo(Game.Player.Character))
                    {
                        spear.ApplyForce((spear.Position - Game.Player.Character.Position) * -5f);
                    }
                    if (Game.IsKeyPressed(unstuck) & !spear.IsAttachedTo(Game.Player.Character) && !keyUp)
                    {
                        spear.ApplyForce(Vector3.WorldUp * 1000f);
                        keyUp = true;
                    }
                    if (!spear.IsAttached() && !Game.IsDisabledControlPressed(2, GTA.Control.Aim))
                    {
                        if (spear.IsInRangeOf(Game.Player.Character.Position, 1.5f))
                        {
                            spear.AttachTo(Game.Player.Character, Game.Player.Character.GetBoneIndex(Bone.SKEL_Spine0),
                                           new Vector3(-0.8f, -0.13f, 0.5f),
                                           new Vector3(0, 115, 0)
                                           );
                        }
                    }
                } catch (Exception ugh) { }

                // Slowmo
                if (Game.IsDisabledControlPressed(17, GTA.Control.Duck) && !Game.Player.Character.IsSittingInVehicle())
                {
                    Game.TimeScale = 0.4f;
                }
                else
                {
                    Game.TimeScale = 1.0f;
                }

                // Player current vehicle check
                if (Game.Player.Character.IsSittingInVehicle())
                {
                    spear.Detach();
                    spear.ApplyForce((spear.Position - Game.Player.Character.Position) * -5f);
                    if (!spear.IsAttached() && spear.IsInRangeOf(Game.Player.Character.Position, 2f))
                    {
                        spear.AttachTo(Game.Player.Character.CurrentVehicle, Game.Player.Character.CurrentVehicle.GetBoneIndex("engine"), new Vector3(0, 0, 0), new Vector3(0, 0, 0));
                    }
                }

                // Particle effects
                if (!spear.IsAttachedTo(Game.Player.Character))
                {
                    if (Function.Call <bool>(Hash.HAS_NAMED_PTFX_ASSET_LOADED, "scr_rcbarry2"))
                    {
                        Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, "scr_rcbarry2");

                        if (spear.IsVisible || !spear.IsVisible)
                        {
                            Function.Call <int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "scr_exp_clown_trails", spear,
                                                0, 0, 2.33f,
                                                0, 0, 0,
                                                0.3f, 0, 0, 0);
                        }

                        /* works:
                         * sp_clown_appear_trails /not colorable
                         * scr_exp_clown_trails / not color
                         * scr_clown_appears / no color
                         * scr_exp_clown / no color
                         * eject_clown / no color
                         * muz_clown / no color
                         */
                    }
                    else
                    {
                        Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, "scr_rcbarry2");
                    }
                }

                if (speed > 0 || !spear.IsAttached())
                {
                    if (Function.Call <bool>(Hash.HAS_NAMED_PTFX_ASSET_LOADED, "scr_carsteal4"))
                    {
                        Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, "scr_carsteal4");
                        Function.Call(Hash.SET_PARTICLE_FX_NON_LOOPED_COLOUR, 255.0f, 0f, 0f);

                        Function.Call <int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "scr_carsteal4_wheel_burnout", fin,
                                            0, 0, 0.06,
                                            90f, 0, 0,
                                            0.05f, 0, 0, 0);
                    }
                    else
                    {
                        Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, "scr_carsteal4");
                    }
                }

                // All controller controls (only works in tick)
                // powerIndex
                if (Game.CurrentInputMode == InputMode.GamePad)
                {
                    if (Game.IsControlJustPressed(2, GTA.Control.ScriptPadRight) && !keyUpController)
                    {
                        keyUpController = true;
                        powerIndex++;
                    }
                    if (Game.IsControlJustReleased(2, GTA.Control.ScriptPadRight))
                    {
                        keyUpController = false;
                    }
                    if (Game.IsControlJustPressed(2, GTA.Control.ScriptPadLeft) && !keyUpController)
                    {
                        keyUpController = true;
                        powerIndex--;
                    }
                    if (Game.IsControlJustReleased(2, GTA.Control.ScriptPadLeft))
                    {
                        keyUpController = false;
                    }

                    // Z-Unstuck
                    if (Game.IsControlJustPressed(2, GTA.Control.ScriptPadUp) && !keyUpController)
                    {
                        r = 1;
                        keyUpController = true;
                    }
                    if (Game.IsControlJustReleased(2, GTA.Control.ScriptPadUp))
                    {
                        r = 0;
                        keyUpController = false;
                    }

                    if (r == 1 && !spear.IsAttachedTo(Game.Player.Character))
                    {
                        spear.ApplyForce(Vector3.WorldUp * 1000f);
                    }

                    // Recall
                    if (Game.IsControlJustPressed(2, GTA.Control.ScriptRB) && !keyUpController)
                    {
                        a = 1;
                        keyUpController = true;
                    }
                    if (Game.IsControlJustReleased(2, GTA.Control.ScriptRB))
                    {
                        a = 0;
                        keyUpController = false;
                    }

                    if (a == 1 && !spear.IsAttachedTo(Game.Player.Character))
                    {
                        spear.ApplyForce((Game.Player.Character.Position - spear.Position) * 5);
                    }

                    // Sheathe / Unsheathe
                    if (Game.IsControlJustPressed(2, GTA.Control.ScriptRB) && !keyUpController)
                    {
                        keyUpController = true;
                    }
                    if (Game.IsControlJustReleased(2, GTA.Control.ScriptRB))
                    {
                        spearActive = !spearActive;
                        // Sheathe
                        if (!spearActive)
                        {
                            spear.Detach();
                            unsheathed = false;

                            NAudio.Wave.WaveFileReader mp3whis1 = new NAudio.Wave.WaveFileReader(@"scripts\Spear Files\unsheathe.wav");
                            NAudio.Wave.WaveChannel32  waveDown = new NAudio.Wave.WaveChannel32(mp3whis1);
                            NAudio.Wave.DirectSoundOut output   = new NAudio.Wave.DirectSoundOut();
                            output.Init(waveDown);
                            output.Play();
                            waveDown.Volume = 0.05f;
                        }
                        else if (spear.IsAttachedTo(Game.Player.Character))
                        {
                            // Unsheathe
                            spear.AttachTo(Game.Player.Character, Game.Player.Character.GetBoneIndex(Bone.SKEL_Head),
                                           new Vector3(0.2f, 1, -0.2f),
                                           new Vector3(90, 0, 0)
                                           );

                            NAudio.Wave.WaveFileReader recall  = new NAudio.Wave.WaveFileReader(@"scripts\Spear Files\return.wav");
                            NAudio.Wave.WaveChannel32  waveRec = new NAudio.Wave.WaveChannel32(recall);
                            NAudio.Wave.DirectSoundOut output3 = new NAudio.Wave.DirectSoundOut();
                            output3.Init(waveRec);
                            output3.Play();
                            waveRec.Volume = 0.05f;

                            unsheathed = true;
                        }

                        keyUpController = false;
                    }
                }
            }
        }
        //string stopButtonState = "Stop";
        private void play_pause(object sender, EventArgs e)
        {
            if (output == null)
            {
                OpenFileDialog open = new OpenFileDialog();
                open.InitialDirectory = musicDir;
                open.Filter = "Audio File (*.mp3;*.wav)|*.mp3;*.wav;";
                if (open.ShowDialog() != DialogResult.OK) return;

                DisposeWave();

                if (open.FileName.EndsWith(".mp3"))
                {
                    NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(open.FileName));
                    stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
                }
                else if (open.FileName.EndsWith(".wav"))
                {
                    NAudio.Wave.WaveStream pcm = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));
                    stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
                }
                else throw new InvalidOperationException("Not a correct audio file type.");

                output = new NAudio.Wave.DirectSoundOut();
                output.Init(stream);
                output.Play();
            }
            else if (output != null)
            {
                if (output.PlaybackState == NAudio.Wave.PlaybackState.Playing) output.Pause();
                else if (output.PlaybackState == NAudio.Wave.PlaybackState.Paused) output.Play();
            }
        }
Esempio n. 18
0
        public Soundsystem()
        {
            NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(
                new NAudio.Wave.Mp3FileReader("sounds/ambience-wind1.mp3"));

            ambience = new NAudio.Wave.BlockAlignReductionStream(pcm);

            pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(
                new NAudio.Wave.Mp3FileReader("music/zombi-drone.mp3"));

            drone = new NAudio.Wave.BlockAlignReductionStream(pcm);

            fire1 = new NAudio.Wave.WaveFileReader("sounds/gun-fire1.wav");
            fire2 = new NAudio.Wave.WaveFileReader("sounds/gun-fire2.wav");
            empty = new NAudio.Wave.WaveFileReader("sounds/gun-empty.wav");
            load = new NAudio.Wave.WaveFileReader("sounds/gun-load.wav");

            hitflesh1 = new NAudio.Wave.WaveFileReader("sounds/hit-flesh1.wav");
            hitflesh2 = new NAudio.Wave.WaveFileReader("sounds/hit-flesh2.wav");
            hitflesh3 = new NAudio.Wave.WaveFileReader("sounds/hit-flesh3.wav");
            hitmetal1 = new NAudio.Wave.WaveFileReader("sounds/hit-metal1.wav");
            hitmetal2 = new NAudio.Wave.WaveFileReader("sounds/hit-metal2.wav");
            hitmetal3 = new NAudio.Wave.WaveFileReader("sounds/hit-metal3.wav");
            hitrock = new NAudio.Wave.WaveFileReader("sounds/hit-rock1.wav");
            hitglass = new NAudio.Wave.WaveFileReader("sounds/hit-glass1.wav");

            walk1 = new NAudio.Wave.WaveFileReader("sounds/walk1.wav");
            walk2 = new NAudio.Wave.WaveFileReader("sounds/walk2.wav");
            walk3 = new NAudio.Wave.WaveFileReader("sounds/walk3.wav");
            walk4 = new NAudio.Wave.WaveFileReader("sounds/walk4.wav");
            walk5 = new NAudio.Wave.WaveFileReader("sounds/walk5.wav");
            walk6 = new NAudio.Wave.WaveFileReader("sounds/walk6.wav");
            walk7 = new NAudio.Wave.WaveFileReader("sounds/walk7.wav");
            walk8 = new NAudio.Wave.WaveFileReader("sounds/walk8.wav");

            zombi1 = new NAudio.Wave.WaveFileReader("sounds/zombi-moan1.wav");
            zombi2 = new NAudio.Wave.WaveFileReader("sounds/zombi-moan2.wav");
            zombi3 = new NAudio.Wave.WaveFileReader("sounds/zombi-moan3.wav");
            zombi4 = new NAudio.Wave.WaveFileReader("sounds/zombi-moan4.wav");
            zombi5 = new NAudio.Wave.WaveFileReader("sounds/zombi-moan5.wav");
            zombi6 = new NAudio.Wave.WaveFileReader("sounds/zombi-moan6.wav");
            zombi7 = new NAudio.Wave.WaveFileReader("sounds/zombi-moan7.wav");

            fire1_channel = new NAudio.Wave.WaveChannel32(fire1);
            fire1_channel.Volume = 0.0f;
            fire2_channel = new NAudio.Wave.WaveChannel32(fire2);
            fire2_channel.Volume = 0.0f;
            load_channel = new NAudio.Wave.WaveChannel32(load);
            load_channel.Volume = 0.0f;
            empty_channel = new NAudio.Wave.WaveChannel32(empty);
            empty_channel.Volume = 0.0f;

            hitglass_channel = new NAudio.Wave.WaveChannel32(hitglass);
            hitglass_channel.Volume = 0.0f;
            hitflesh1_channel = new NAudio.Wave.WaveChannel32(hitflesh1);
            hitflesh1_channel.Volume = 0.0f;
            hitflesh2_channel = new NAudio.Wave.WaveChannel32(hitflesh2);
            hitflesh2_channel.Volume = 0.0f;
            hitflesh3_channel = new NAudio.Wave.WaveChannel32(hitflesh3);
            hitflesh3_channel.Volume = 0.0f;
            hitrock_channel = new NAudio.Wave.WaveChannel32(hitrock);
            hitrock_channel.Volume = 0.0f;
            hitmetal1_channel = new NAudio.Wave.WaveChannel32(hitmetal1);
            hitmetal1_channel.Volume = 0.0f;
            hitmetal2_channel = new NAudio.Wave.WaveChannel32(hitmetal2);
            hitmetal2_channel.Volume = 0.0f;
            hitmetal3_channel = new NAudio.Wave.WaveChannel32(hitmetal3);
            hitmetal3_channel.Volume = 0.0f;

            walk1_channel = new NAudio.Wave.WaveChannel32(walk1);
            walk1_channel.Volume = 0.0f;
            walk2_channel = new NAudio.Wave.WaveChannel32(walk2);
            walk2_channel.Volume = 0.0f;
            walk3_channel = new NAudio.Wave.WaveChannel32(walk3);
            walk3_channel.Volume = 0.0f;
            walk4_channel = new NAudio.Wave.WaveChannel32(walk4);
            walk4_channel.Volume = 0.0f;
            walk5_channel = new NAudio.Wave.WaveChannel32(walk5);
            walk5_channel.Volume = 0.0f;
            walk6_channel = new NAudio.Wave.WaveChannel32(walk6);
            walk6_channel.Volume = 0.0f;
            walk7_channel = new NAudio.Wave.WaveChannel32(walk7);
            walk7_channel.Volume = 0.0f;
            walk8_channel = new NAudio.Wave.WaveChannel32(walk8);
            walk8_channel.Volume = 0.0f;

            zombi1_channel = new NAudio.Wave.WaveChannel32(zombi1);
            zombi1_channel.Volume = 0.0f;
            zombi2_channel = new NAudio.Wave.WaveChannel32(zombi2);
            zombi2_channel.Volume = 0.0f;

            zombi3_channel = new NAudio.Wave.WaveChannel32(zombi3);
            zombi3_channel.Volume = 0.0f;

            zombi4_channel = new NAudio.Wave.WaveChannel32(zombi4);
            zombi4_channel.Volume = 0.0f;

            zombi5_channel = new NAudio.Wave.WaveChannel32(zombi5);
            zombi5_channel.Volume = 0.0f;

            zombi6_channel = new NAudio.Wave.WaveChannel32(zombi6);
            zombi6_channel.Volume = 0.0f;

            zombi7_channel = new NAudio.Wave.WaveChannel32(zombi7);
            zombi7_channel.Volume = 0.0f;

            mikseri = new NAudio.Wave.WaveMixerStream32();

            ambience_channel = new NAudio.Wave.WaveChannel32(ambience);
            ambience_channel.Volume = 0.2f;

            drone_channel = new NAudio.Wave.WaveChannel32(drone);
            drone_channel.Volume = 0.5f;

            mikseri.AddInputStream(fire1_channel);
            mikseri.AddInputStream(fire2_channel);
            mikseri.AddInputStream(empty_channel);
            mikseri.AddInputStream(load_channel);

            mikseri.AddInputStream(hitflesh1_channel);
            mikseri.AddInputStream(hitflesh2_channel);
            mikseri.AddInputStream(hitflesh3_channel);
            mikseri.AddInputStream(hitmetal1_channel);
            mikseri.AddInputStream(hitmetal2_channel);
            mikseri.AddInputStream(hitmetal3_channel);
            mikseri.AddInputStream(hitrock_channel);
            mikseri.AddInputStream(hitglass_channel);

            mikseri.AddInputStream(walk1_channel);
            mikseri.AddInputStream(walk2_channel);
            mikseri.AddInputStream(walk3_channel);
            mikseri.AddInputStream(walk4_channel);
            mikseri.AddInputStream(walk5_channel);
            mikseri.AddInputStream(walk6_channel);
            mikseri.AddInputStream(walk7_channel);
            mikseri.AddInputStream(walk8_channel);

            mikseri.AddInputStream(zombi1_channel);
            mikseri.AddInputStream(zombi2_channel);
            mikseri.AddInputStream(zombi3_channel);
            mikseri.AddInputStream(zombi4_channel);
            mikseri.AddInputStream(zombi5_channel);
            mikseri.AddInputStream(zombi6_channel);
            mikseri.AddInputStream(zombi7_channel);

            mikseri.AddInputStream(ambience_channel);
            mikseri.AddInputStream(drone_channel);

            mikseri.AutoStop = false;

            output = new NAudio.Wave.DirectSoundOut();
            output.Init(mikseri);

            soundson = true;
            output.Play();
        }