Exemplo n.º 1
0
        private void BgwScriptDncDoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            const double scanInterval = 0.3;

            while (botRunning && !bgw_script_dnc.CancellationPending)
            {
                //TargetInfo.SetTarget(0);
                if ((PlayerInfo.Status == 2 || PlayerInfo.Status == 3) && File.Exists(Application.StartupPath + @"\dead.wav"))
                {
                    using (SoundPlayer player = new SoundPlayer(Application.StartupPath + @"\dead.wav"))
                    {
                        player.PlaySync();
                        player.Dispose();
                    }
                }
                if (checkZone.Checked && startzone != api.Player.ZoneId)
                {
                    ToolStopClick(null, null);
                }
                if (DeathWarp.Checked && (PlayerInfo.Status == 2 || PlayerInfo.Status == 3))
                {
                    PlayerDead();
                }

                if (isCasting)
                {
                    continue;
                }
                if (followplayer.Checked && PlayerInfo.Status == 0)
                {
                    FollowTarget();
                }

                if ((assist.Checked || partyAssist.Checked) && PlayerInfo.Status == 0)
                {
                    Assist();
                }

                if (aggro.Checked && PlayerInfo.Status == 0 && !isPulled)
                {
                    DetectAggro();
                }

                if (PlayerInfo.Status == 0 && !isPulled && SelectedTargets.Items.Count != 0)
                {
                    FindTarget();
                }

                while (PlayerInfo.Status == 1 && botRunning && TargetInfo.ID > 0)
                {
                    isPulled = true;

                    if (naviMove)
                    {
                        naviMove = false;
                    }

                    if (ignoreTarget.Count > 0)
                    {
                        ignoreTarget.Clear();
                    }

                    #region Check Target Distance
                    if (mobdist.Checked)
                    {
                        if (TargetInfo.Distance >= (float)KeepTargetRange.Value && TargetInfo.HPP > 1)
                        {
                            isMoving = true;
                            while (TargetMoving() && PlayerInfo.Status == 1 && botRunning)
                            {
                                Thread.Sleep(TimeSpan.FromSeconds(0.1));
                            }

                            while (TargetInfo.Distance >= (float)KeepTargetRange.Value &&
                                   TargetInfo.HPP > 1 && PlayerInfo.Status == 1 && botRunning)
                            {
                                api.AutoFollow.SetAutoFollowCoords(TargetInfo.X - PlayerInfo.X,
                                                                   TargetInfo.Y - PlayerInfo.Y, TargetInfo.Z - PlayerInfo.Z);

                                api.AutoFollow.IsAutoFollowing = true;

                                Thread.Sleep(TimeSpan.FromSeconds(0.1));

                                if (TargetInfo.ID == 0 || TargetInfo.ID == PlayerInfo.ServerID)
                                {
                                    break;
                                }
                                if (mobStuckWatch.Checked && isStuck(true))
                                {
                                    int   count = 0;
                                    float dir   = -45;
                                    while (isStuck(true))
                                    {
                                        if (TargetInfo.ID == 0 || TargetInfo.ID == PlayerInfo.ServerID)
                                        {
                                            break;
                                        }
                                        api.Entity.GetLocalPlayer().H = PlayerInfo.H + (float)((Math.PI / 180) * dir);
                                        WindowInfo.KeyDown(API.Keys.NUMPAD8);
                                        Thread.Sleep(TimeSpan.FromSeconds(2));
                                        WindowInfo.KeyUp(API.Keys.NUMPAD8);
                                        count++;
                                        if (count == 4)
                                        {
                                            dir   = (dir == -45 ? 45 : -45);
                                            count = 0;
                                        }
                                    }
                                    WindowInfo.KeyUp(API.Keys.NUMPAD8);
                                }
                            }
                            api.AutoFollow.IsAutoFollowing = false;
                            isMoving = false;
                        }
                        if (TargetInfo.Distance < 2 && TargetInfo.HPP > 1 &&
                            PlayerInfo.Status == 1 && TargetInfo.ID > 0)
                        {
                            while (TargetInfo.Distance < 2 && TargetInfo.HPP > 1 &&
                                   PlayerInfo.Status == 1 && TargetInfo.ID > 0)
                            {
                                WindowInfo.KeyDown(API.Keys.NUMPAD2);
                                Thread.Sleep(TimeSpan.FromSeconds(0.1));
                            }
                            WindowInfo.KeyUp(API.Keys.NUMPAD2);
                        }
                    }
                    #endregion
                    WindowInfo.KeyUp(API.Keys.NUMPAD8);
                    WindowInfo.KeyUp(API.Keys.NUMPAD2);

                    if (!TargetInfo.IsFacingTarget(PlayerInfo.X, PlayerInfo.Z, PlayerInfo.H, TargetInfo.X, TargetInfo.Z) &&
                        facetarget.Checked && TargetInfo.HPP > 1)
                    {
                        TargetInfo.FaceTarget(TargetInfo.X, TargetInfo.Z);
                    }

                    ninjaShadows();

                    #region Check Hate Control
                    if (tank.Checked && selectedHateControl.Text != "" &&
                        PlayerInfo.Status == 1 && TargetInfo.ID > 0)
                    {
                        if (selectedHateControl.Text == @"Animated Flourish" &&
                            PlayerInfo.GetFinishingMoves() > 0 &&
                            Recast.GetAbilityRecast(221) == 0)
                        {
                            if (TargetInfo.HPP >= numericUpDown7.Value &&
                                TargetInfo.HPP <= numericUpDown6.Value &&
                                PlayerInfo.Status == 1 && TargetInfo.ID > 0)
                            {
                                api.ThirdParty.SendString("/ja \"Animated Flourish\" <t>");
                                Thread.Sleep(TimeSpan.FromSeconds(1.0));
                            }
                        }
                        if (selectedHateControl.Text == @"Provoke" &&
                            Recast.GetAbilityRecast(5) == 0)
                        {
                            if (TargetInfo.HPP >= numericUpDown7.Value &&
                                TargetInfo.HPP <= numericUpDown6.Value &&
                                PlayerInfo.Status == 1 && TargetInfo.ID > 0)
                            {
                                api.ThirdParty.SendString("/ja \"Provoke\" <t>");
                                Thread.Sleep(TimeSpan.FromSeconds(1.0));
                            }
                        }
                        if (selectedHateControl.Text == @"Flash" && PlayerInfo.MPP >= 25 &&
                            Recast.GetAbilityRecast(112) == 0)
                        {
                            if (TargetInfo.HPP >= numericUpDown7.Value &&
                                TargetInfo.HPP <= numericUpDown6.Value &&
                                PlayerInfo.Status == 1 && TargetInfo.ID > 0)
                            {
                                api.ThirdParty.SendString("/ma \"Flash\" <t>");
                                Casting();
                            }
                        }
                    }
                    #endregion

                    HealingWaltz();
                    if (usecurev.Checked || usecureiv.Checked || usecureiii.Checked || usecureii.Checked || usecure.Checked)
                    {
                        CuringWaltzSelf();
                    }
                    if (ptusecurev.Checked || ptusecureiv.Checked || ptusecureiii.Checked || ptusecureii.Checked || ptusecure.Checked)
                    {
                        CuringWaltzParty();
                    }
                    if ((usedrain.Checked || usedrainii.Checked || usedrainiii.Checked || useaspir.Checked || useaspirii.Checked ||
                         usehaste.Checked) && !noSamba.Checked)
                    {
                        Sambas();
                    }
                    if ((usequickstep.Checked || useboxstep.Checked || usestutterstep.Checked || usefeatherstep.Checked) &&
                        !NoSteps.Checked)
                    {
                        Steps();
                    }

                    #region Check AutoRange Attack
                    if (autoRangeAttack.Checked && TargetInfo.ID > 0)
                    {
                        api.ThirdParty.SendString(textBox7.Text);

                        var delay = DateTime.Now.AddSeconds((double)autoRangeDelay.Value);

                        while (DateTime.Now < delay)
                        {
                            if (PlayerInfo.Status == 0)
                            {
                                break;
                            }

                            TargetInfo.FaceTarget(TargetInfo.X, TargetInfo.Z);
                            Thread.Sleep(TimeSpan.FromSeconds(1.0));
                        }
                    }
                    #endregion
                    #region Check Use Food
                    if (usefood.Checked)
                    {
                        var name = foodName.Text;

                        if (!PlayerInfo.HasBuff(251) && name != "" &&
                            Inventory.ItemQuantityByName(name) > 0)
                        {
                            api.ThirdParty.SendString("/item \"" + name + "\" <me>");
                            Thread.Sleep(TimeSpan.FromSeconds(10.0));
                        }
                    }
                    #endregion

                    PlayerJA();
                    PlayerWS();
                    PlayerMA();

                    if (PlayerInfo.GetFinishingMoves() > 0)
                    {
                        if (userevfloValue.Value > 0 ||
                            usebldfloValue.Value > 0 ||
                            usewldfloValue.Value > 0 ||
                            useclmfloValue.Value > 0 ||
                            usestkfloValue.Value > 0 ||
                            useterfloValue.Value > 0)
                        {
                            if (TargetInfo.ID > 0)
                            {
                                UseFlourish();
                            }
                        }
                    }

                    Thread.Sleep(TimeSpan.FromSeconds(0.1));
                }

                #region check: scan delay & idle

                if (usenav.Checked && api.AutoFollow.IsAutoFollowing && !naviMove)
                {
                    api.AutoFollow.IsAutoFollowing = false;
                }

                if (PlayerInfo.Status == 0 && PlayerInfo.Status != 0 && TargetInfo.HPP == 0)
                {
                    SetTarget(0);
                }
                if (ScanDelay.Checked && !naviMove)
                {
                    Thread.Sleep(TimeSpan.FromSeconds((double)numericUpDown38.Value));
                }
                else if (!ScanDelay.Checked)
                {
                    Thread.Sleep(TimeSpan.FromSeconds(scanInterval));
                }
                if (IdleLocation.Checked && PlayerInfo.Status == 0 && (TargetInfo.ID == 0 || TargetInfo.ID == PlayerInfo.TargetID))
                {
                    ReturnIdleLocation();
                }

                if (PlayerInfo.Status == 0 && isPulled)
                {
                    isPulled = false;

                    if (aggro.Checked && PlayerInfo.Status == 0)
                    {
                        DetectAggro();
                    }

                    if (PlayerInfo.Status == 0 && ((HealHP.Checked && PlayerInfo.HPP <= healHPcount.Value) ||
                                                   (HealMP.Checked && PlayerInfo.MPP <= healMPcount.Value) ||
                                                   (healforAutomatonHP.Checked && PetInfo.HPP <= healforAutomatonHPset.Value) ||
                                                   (healforAutomatonMP.Checked && PetInfo.MPP <= healforAutomatonMPset.Value)))
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(1.0));
                        if ((PlayerInfo.MainJob == 15 || PlayerInfo.SubJob == 15) && PetInfo.ID > 0)
                        {
                            if (SMNPetNames.Contains(PetInfo.Name))
                            {
                                api.ThirdParty.SendString("/pet \"Release\" <me>");
                                Thread.Sleep(TimeSpan.FromSeconds(1.0));
                            }
                        }
                        api.ThirdParty.SendString("/heal on");
                        Thread.Sleep(TimeSpan.FromSeconds(1.0));
                        if (textBox6.Text != "")
                        {
                            PreHealMain = api.Resources.GetItem(api.Player.Main).Name[0];
                            PreHealSub  = api.Resources.GetItem(api.Player.Sub).Name[0];
                            api.ThirdParty.SendString($"/equip Main \"{textBox6.Text}\"");
                        }

                        SetTarget(0);
                    }
                    if (PlayerInfo.Status == 0 && !isPulled)
                    {
                        FindTarget();
                    }
                }

                if ((TargetInfo.ID == 0 || TargetInfo.ID == PlayerInfo.TargetID) && PlayerInfo.Status == 0 && !naviMove)
                {
                    useTrust();
                    if (Recast.GetAbilityRecast(218) == 0 && UseJigs.Checked)
                    {
                        if (SpectralJig.Checked && !PlayerInfo.HasBuff(69))
                        {
                            api.ThirdParty.SendString("/ja \"Spectral Jig\" <me>");
                        }
                        else if (ChocoboJig.Checked)
                        {
                            api.ThirdParty.SendString("/ja \"Chocobo Jig\" <me>");
                        }
                        else if (ChocoboJigII.Checked)
                        {
                            api.ThirdParty.SendString("/ja \"Chocobo Jig II\" <me>");
                        }
                    }
                    SetTarget(0);
                }

                if (usenav.Checked && !naviMove && PlayerInfo.Status == 0)
                {
                    if (TargetInfo.ID > 0)
                    {
                        SetTarget(0);
                    }

                    naviMove = true;
                }
                if (PlayerInfo.Status == 33)
                {
                    var healdone = false;
                    while (PlayerInfo.Status == 33 && (HealHP.Checked || HealMP.Checked || healforAutomatonHP.Checked || healforAutomatonMP.Checked))
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(0.1));
                        if (fullheal.Checked)
                        {
                            if ((PlayerInfo.MainJob == 9 || PlayerInfo.SubJob == 9) && PetInfo.Name != null)
                            {
                                if (PlayerInfo.HPP == 100 && PlayerInfo.MPP == 100 && PetInfo.HPP == 100 && PetInfo.MPP == 100)
                                {
                                    healdone = true;
                                }
                            }
                            else if (PlayerInfo.HPP == 100 && PlayerInfo.MPP == 100)
                            {
                                healdone = true;
                            }
                        }
                        else if ((HealHP.Checked? PlayerInfo.HPP == 100 : true) && (HealMP.Checked? PlayerInfo.MPP == 100 : true) &&
                                 (healforAutomatonHP.Checked? PetInfo.HPP == 100 : true) && (healforAutomatonMP.Checked? PetInfo.MPP == 100 : true))
                        {
                            healdone = true;
                        }

                        if (healdone)
                        {
                            if (textBox6.Text != "" && healdone)
                            {
                                api.ThirdParty.SendString($"/equip Main \"{PreHealMain}\"");
                                Thread.Sleep(TimeSpan.FromSeconds(1.0));
                                api.ThirdParty.SendString($"/equip Sub \"{PreHealSub}\"");
                            }
                            api.ThirdParty.SendString("/heal off");
                            Thread.Sleep(TimeSpan.FromSeconds(1.0));
                        }
                    }
                }
                #endregion
            }
            WindowInfo.KeyUp(API.Keys.NUMPAD8);
            WindowInfo.KeyUp(API.Keys.NUMPAD2);
            api.AutoFollow.IsAutoFollowing = false;
            isMoving = false;
        }
Exemplo n.º 2
0
        private void BgwScriptDncDoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            const double scanInterval = 0.1;

            while (botRunning && !bgw_script_dnc.CancellationPending)
            {
                if (DeathWarp.Checked && (PlayerInfo.Status == 2 || PlayerInfo.Status == 3))
                {
                    PlayerDead();
                }

                if (followplayer.Checked && PlayerInfo.Status == 0)
                {
                    FollowTarget();
                }

                if (assist.Checked && PlayerInfo.Status == 0)
                {
                    CheckPlayerAssist();
                }

                if (aggro.Checked && PlayerInfo.Status == 0 && !isPulled)
                {
                    DetectAggro();
                }

                if (PlayerInfo.Status == 0 && !isPulled && SelectedTargets.Items.Count != 0)
                {
                    FindTarget();
                }

                while (PlayerInfo.Status == 1 && botRunning && TargetInfo.ID > 0)
                {
                    isPulled = true;

                    if (naviMove)
                    {
                        naviMove = false;
                    }

                    if (ignoreTarget.Count > 0)
                    {
                        ignoreTarget.Clear();
                    }

                    #region Check Target Distance
                    if (mobdist.Checked)
                    {
                        if (TargetInfo.Distance >= (float)KeepTargetRange.Value && TargetInfo.HPP > 1)
                        {
                            isMoving = true;
                            while (TargetMoving() && PlayerInfo.Status == 1 && botRunning)
                            {
                                Thread.Sleep(TimeSpan.FromSeconds(0.1));
                            }

                            while (TargetInfo.Distance >= (float)KeepTargetRange.Value &&
                                   TargetInfo.HPP > 1 && PlayerInfo.Status == 1 && botRunning)
                            {
                                api.AutoFollow.SetAutoFollowCoords(TargetInfo.X - PlayerInfo.X,
                                                                   TargetInfo.Y - PlayerInfo.Y,
                                                                   TargetInfo.Z - PlayerInfo.Z);

                                api.AutoFollow.IsAutoFollowing = true;
                                Thread.Sleep(TimeSpan.FromSeconds(0.1));

                                if (TargetInfo.ID == 0 || TargetInfo.ID == PlayerInfo.ServerID)
                                {
                                    break;
                                }
                            }
                            api.AutoFollow.IsAutoFollowing = false;
                            isMoving = false;
                        }
                        if (TargetInfo.Distance < 2 && TargetInfo.HPP > 1 &&
                            PlayerInfo.Status == 1 && TargetInfo.ID > 0)
                        {
                            while (TargetInfo.Distance < 2 && TargetInfo.HPP > 1 &&
                                   PlayerInfo.Status == 1)
                            {
                                api.ThirdParty.KeyPress(API.Keys.NUMPAD2);
                            }
                        }
                    }
                    #endregion

                    if (!TargetInfo.IsFacingTarget(PlayerInfo.X, PlayerInfo.Z, PlayerInfo.H, TargetInfo.X, TargetInfo.Z) &&
                        facetarget.Checked && TargetInfo.HPP > 1)
                    {
                        TargetInfo.FaceTarget(TargetInfo.X, TargetInfo.Z);
                    }

                    ninjaShadows();

                    #region Check Hate Control
                    if (tank.Checked && selectedHateControl.Text != "" &&
                        PlayerInfo.Status == 1 && TargetInfo.ID > 0)
                    {
                        if (selectedHateControl.Text == @"Animated Flourish" &&
                            (PlayerInfo.HasBuff(381) ||
                             PlayerInfo.HasBuff(382) ||
                             PlayerInfo.HasBuff(383) ||
                             PlayerInfo.HasBuff(384) ||
                             PlayerInfo.HasBuff(385) ||
                             PlayerInfo.HasBuff(588)) &&
                            Recast.GetAbilityRecast(221) == 0)
                        {
                            if (TargetInfo.HPP >= numericUpDown7.Value &&
                                TargetInfo.HPP <= numericUpDown6.Value &&
                                PlayerInfo.Status == 1 && TargetInfo.ID > 0)
                            {
                                api.ThirdParty.SendString("/ja \"Animated Flourish\" <t>");
                                Thread.Sleep(TimeSpan.FromSeconds(2.0));
                            }
                        }
                        if (selectedHateControl.Text == @"Provoke" &&
                            Recast.GetAbilityRecast(5) == 0)
                        {
                            if (TargetInfo.HPP >= numericUpDown7.Value &&
                                TargetInfo.HPP <= numericUpDown6.Value &&
                                PlayerInfo.Status == 1 && TargetInfo.ID > 0)
                            {
                                api.ThirdParty.SendString("/ja \"Provoke\" <t>");
                                Thread.Sleep(TimeSpan.FromSeconds(2.0));
                            }
                        }
                        if (selectedHateControl.Text == @"Flash" && PlayerInfo.MPP >= 25 &&
                            Recast.GetAbilityRecast(112) == 0)
                        {
                            if (TargetInfo.HPP >= numericUpDown7.Value &&
                                TargetInfo.HPP <= numericUpDown6.Value &&
                                PlayerInfo.Status == 1 && TargetInfo.ID > 0)
                            {
                                api.ThirdParty.SendString("/ma \"Flash\" <t>");
                                Thread.Sleep(TimeSpan.FromSeconds(2.0));
                            }
                        }
                    }
                    #endregion

                    HealingWaltz();
                    CuringWaltzSelf();

                    Sambas();
                    Steps();

                    #region Check AutoRange Attack
                    if (autoRangeAttack.Checked && TargetInfo.ID > 0)
                    {
                        api.ThirdParty.SendString(textBox7.Text);

                        var delay = DateTime.Now.AddSeconds((double)autoRangeDelay.Value);

                        while (DateTime.Now < delay)
                        {
                            if (PlayerInfo.Status == 0)
                            {
                                break;
                            }

                            TargetInfo.FaceTarget(TargetInfo.X, TargetInfo.Z);
                            Thread.Sleep(TimeSpan.FromSeconds(1.0));
                        }
                    }
                    #endregion
                    #region Check Use Food
                    if (usefood.Checked)
                    {
                        var foodname = textBox8.Text;

                        if (!PlayerInfo.HasBuff(251) && foodname != "" &&
                            ItemQuantityByName(foodname) > 0)
                        {
                            api.ThirdParty.SendString("/item \"" + foodname + "\" <me>");
                            Thread.Sleep(TimeSpan.FromSeconds(10.0));
                        }
                    }
                    #endregion

                    PlayerJA();
                    PlayerWS();

                    if (PlayerInfo.HasBuff(381) ||
                        PlayerInfo.HasBuff(382) ||
                        PlayerInfo.HasBuff(383) ||
                        PlayerInfo.HasBuff(384) ||
                        PlayerInfo.HasBuff(385) ||
                        PlayerInfo.HasBuff(588))
                    {
                        if (userevfloValue.Value > 0 ||
                            usebldfloValue.Value > 0 ||
                            usewldfloValue.Value > 0 ||
                            useclmfloValue.Value > 0 ||
                            usestkfloValue.Value > 0 ||
                            useterfloValue.Value > 0)
                        {
                            if (TargetInfo.ID > 0)
                            {
                                UseFlourish();
                            }
                        }
                    }

                    Thread.Sleep(TimeSpan.FromSeconds(0.1));
                }

                #region check: scan delay & idle

                if (usenav.Checked && api.AutoFollow.IsAutoFollowing && !naviMove)
                {
                    api.AutoFollow.IsAutoFollowing = false;
                }

                if (ScanDelay.Checked && !naviMove)
                {
                    Thread.Sleep(TimeSpan.FromSeconds((double)numericUpDown38.Value));
                }
                else if (!ScanDelay.Checked)
                {
                    Thread.Sleep(TimeSpan.FromSeconds(scanInterval));
                }

                if (PlayerInfo.Status == 0 && isPulled)
                {
                    isPulled = false;

                    if (aggro.Checked && PlayerInfo.Status == 0)
                    {
                        DetectAggro();
                    }

                    if (PlayerInfo.Status == 0 && !isPulled)
                    {
                        FindTarget();
                    }
                }

                if (usenav.Checked && !naviMove && PlayerInfo.Status == 0)
                {
                    if (TargetInfo.ID > 0)
                    {
                        TargetInfo.SetTarget(0);
                    }

                    naviMove = true;
                }

                #endregion
            }
        }