internal bool MyMoveToSell(bool noMount = false)
        {
            try
            {
                var mountSell = SpellManager.GetSpell(61447); //Тундровый мамонт путешественника
                if (mountSell == null)
                {
                    mountSell = SpellManager.GetSpell(61425); //Тундровый мамонт путешественника
                }

                if (noMount)
                {
                    mountSell = null;
                }

                if (mountSell != null && IsOutdoors)
                {
                    if (CharacterSettings.UseMountMyLoc)
                    {
                    }
                    else
                    {
                        if (Math.Abs(CharacterSettings.MountLocX) > 0)
                        {
                            if (!MoveTo(CharacterSettings.MountLocX, CharacterSettings.MountLocY, CharacterSettings.MountLocZ))
                            {
                                return(false);
                            }
                        }
                    }


                    CommonModule.MyUnmount();
                    CanselForm();
                    CancelMoveTo();
                    Thread.Sleep(500);
                    MyCheckIsMovingIsCasting();
                    var result = SpellManager.CastSpell(mountSell.Id);

                    if (result != ESpellCastError.SUCCESS)
                    {
                        log("Не удалось призвать маунта " + mountSell.Name + "  " + result, LogLvl.Error);
                        return(false);
                    }
                    else
                    {
                        log("Призвал маунта", LogLvl.Ok);
                    }

                    Thread.Sleep(2000);
                    while (SpellManager.IsCasting)
                    {
                        Thread.Sleep(100);
                    }

                    Thread.Sleep(2000);
                    foreach (var npc in GetEntities <Unit>())
                    {
                        if (npc.Id == 32641 || npc.Id == 32639)
                        {
                            Thread.Sleep(1000);
                            if (!OpenShop(npc))
                            {
                                log("Не смог открыть шоп 7 " + npc.Name + "[" + npc.Id + "]  " + GetLastError(),
                                    LogLvl.Error);
                                if (InteractionObject != null)
                                {
                                    log("Открыт диалог с " + InteractionObject.Name + "  " + InteractionObject.Id +
                                        "  " + Me.Distance(InteractionObject.Location) + " " + CurrentInteractionGuid);
                                }
                                else
                                {
                                    log("InteractionNpc = null " + CurrentInteractionGuid);
                                }

                                Thread.Sleep(5000);

                                /* if (GetLastError() != ELastError.ActionNotAllowed)
                                 * {
                                 *   return false;
                                 * }*/
                            }


                            Thread.Sleep(1000);
                            if (CharacterSettings.PikPocket)
                            {
                                foreach (var spell in Me.GetAuras())
                                {
                                    if (spell.SpellName == "Stealth")
                                    {
                                        spell.Cancel();
                                    }
                                }
                            }
                            MySellItems();
                            MyBuyItems();

                            Thread.Sleep(1000);
                            if (CharacterSettings.CheckRepair && npc.IsArmorer)
                            {
                                if (!ItemManager.RepairAllItems())
                                {
                                    log("Не смог отремонтировать " + GetLastError(), LogLvl.Error);
                                    if (GetLastError() == ELastError.NoItemForRepair)
                                    {
                                        return(true);
                                    }

                                    Thread.Sleep(10000);
                                    return(false);
                                }
                                else
                                {
                                    AutoQuests.NeedActionNpcRepair = false;
                                    log("Отремонтировал ", LogLvl.Ok);
                                }
                            }

                            AutoQuests.NeedActionNpcSell = false;

                            CommonModule.MyUnmount();
                            return(true);
                        }
                    }
                }


                var armorer = MyGetArmorer();

                if (armorer == null)
                {
                    var vendor = FindNpcForActionVendor();
                    if (vendor == null)
                    {
                        double   bestDist = 9999999;
                        MyNpcLoc npcLoc   = null;
                        foreach (var myNpcLoc in MyNpcLocss.NpcLocs)
                        {
                            if (myNpcLoc.MapId != MapID)
                            {
                                continue;
                            }
                            if (_badNpcForSell.Contains(myNpcLoc.Id))
                            {
                                continue;
                            }

                            if (IsBadNpcLocs.Contains(myNpcLoc))
                            {
                                continue;
                            }

                            if (!myNpcLoc.IsArmorer)
                            {
                                continue;
                            }

                            if (Me.Team == ETeam.Horde && myNpcLoc.Team == ETeam.Alliance)
                            {
                                continue;
                            }

                            if (Me.Team == ETeam.Alliance && myNpcLoc.Team == ETeam.Horde)
                            {
                                continue;
                            }

                            if (Area.Id == 215) //Плато Красного облака
                            {
                                if (myNpcLoc.Id == 10380)
                                {
                                    continue;
                                }
                            }

                            if (Me.Race == ERace.Tauren)
                            {
                                if (myNpcLoc.Id == 3539)
                                {
                                    continue;
                                }
                                if (myNpcLoc.Id == 3537)
                                {
                                    continue;
                                }
                            }

                            if (CharacterSettings.Mode == Mode.QuestingClassic || Area.Id == 148)
                            {
                                if (myNpcLoc.Id == 4188)
                                {
                                    continue;
                                }
                            }


                            if (Me.Distance(myNpcLoc.Loc) > bestDist)
                            {
                                continue;
                            }

                            bestDist = Me.Distance(myNpcLoc.Loc);
                            npcLoc   = myNpcLoc;
                        }

                        if (npcLoc != null)
                        {
                            log("Выбрал нпс 2 " + npcLoc.Id);
                            if (!CommonModule.MoveTo(npcLoc.Loc, 10))
                            {
                                return(false);
                            }

                            var listUnit2 = GetEntities <Unit>();

                            foreach (var npc in listUnit2.OrderBy(i => Me.Distance(i)))
                            {
                                if (!npc.IsArmorer)
                                {
                                    continue;
                                }

                                if (!CommonModule.MoveTo(npc, 3))
                                {
                                    return(false);
                                }

                                CanselForm();
                                if (CharacterSettings.PikPocket)
                                {
                                    foreach (var spell in Me.GetAuras())
                                    {
                                        if (spell.SpellName == "Stealth")
                                        {
                                            spell.Cancel();
                                        }
                                    }
                                }
                                Thread.Sleep(1000);
                                if (!OpenShop(npc))
                                {
                                    log("Не смог открыть шоп 3 " + npc.Name + "[" + npc.Id + "]  " + GetLastError(),
                                        LogLvl.Error);
                                    if (InteractionObject != null)
                                    {
                                        log("Открыт диалог с " + InteractionObject.Name + "  " + InteractionObject.Id +
                                            "  " + Me.Distance(InteractionObject.Location) + "  " +
                                            CurrentInteractionGuid);
                                    }
                                    else
                                    {
                                        log("InteractionNpc = null " + CurrentInteractionGuid);
                                    }

                                    Thread.Sleep(5000);
                                    if (GetLastError() == ELastError.TooFarDistance)
                                    {
                                        log("подбегаю поближе");
                                        CommonModule.MoveTo(npc, 0);
                                        return(false);
                                    }
                                }


                                Thread.Sleep(1000);
                                foreach (var gossipOptionsData in GetNpcDialogs())
                                {
                                    if (gossipOptionsData.Text.Contains("buy from you"))
                                    {
                                        SelectNpcDialog(gossipOptionsData);
                                    }

                                    log(gossipOptionsData.Text);
                                }

                                MySellItems();
                                Thread.Sleep(1000);
                                if (CharacterSettings.CheckRepair && npc.IsArmorer)
                                {
                                    if (!ItemManager.RepairAllItems())
                                    {
                                        log("Не смог отремонтировать " + GetLastError(), LogLvl.Error);
                                        if (GetLastError() == ELastError.NoItemForRepair)
                                        {
                                            return(true);
                                        }

                                        Thread.Sleep(10000);
                                        return(false);
                                    }
                                    else
                                    {
                                        AutoQuests.NeedActionNpcRepair = false;
                                        log("Отремонтировал ", LogLvl.Ok);
                                    }
                                }
                                MyBuyItems();
                                Thread.Sleep(1000);
                                if (CharacterSettings.CheckRepair && npc.IsArmorer)
                                {
                                    if (!ItemManager.RepairAllItems())
                                    {
                                        log("Не смог отремонтировать " + GetLastError(), LogLvl.Error);
                                        if (GetLastError() == ELastError.NoItemForRepair)
                                        {
                                            return(true);
                                        }

                                        Thread.Sleep(10000);
                                        return(false);
                                    }
                                    else
                                    {
                                        AutoQuests.NeedActionNpcRepair = false;
                                        log("Отремонтировал ", LogLvl.Ok);
                                    }
                                }
                                return(true);
                            }

                            IsBadNpcLocs.Add(npcLoc);
                            log("Не указаны координаты бакалейщика " + npcLoc.Id, LogLvl.Error);
                        }

                        Thread.Sleep(10000);
                        return(false);
                    }


                    log("Выбран НПС для продажи " + vendor.Name, LogLvl.Ok);

                    if (vendor.AreaId != Area.Id || Me.Distance(vendor.Loc) > 1000)
                    {
                        if (!MyUseTaxi(vendor.AreaId, vendor.Loc))
                        {
                            return(false);
                        }
                    }

                    if (!CommonModule.MoveTo(vendor.Loc, 5))
                    {
                        return(false);
                    }
                }

                if (CharacterSettings.PikPocket)
                {
                    foreach (var spell in Me.GetAuras())
                    {
                        if (spell.SpellName == "Stealth")
                        {
                            spell.Cancel();
                        }
                    }
                }

                var listUnit = GetEntities <Unit>();

                foreach (var npc in listUnit.OrderBy(i => Me.Distance(i)))
                {
                    if (armorer != null)
                    {
                        if (!npc.IsArmorer)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (!npc.IsVendor)
                        {
                            continue;
                        }
                    }

                    if (!CommonModule.MoveTo(npc.Location, 3))
                    {
                        return(false);
                    }

                    CanselForm();
                    Thread.Sleep(1000);
                    if (!OpenShop(npc))
                    {
                        if (GetLastError() == ELastError.TooFarDistance)
                        {
                            CommonModule.MoveTo(npc, 0);
                        }

                        log("Не смог открыть шоп 4 " + npc.Name + "[" + npc.Id + "]  " + GetLastError(), LogLvl.Error);
                        if (InteractionObject != null)
                        {
                            log("Открыт диалог с " + InteractionObject.Name + "  " + InteractionObject.Id + "  " +
                                Me.Distance(InteractionObject.Location) + "  " + CurrentInteractionGuid);
                        }
                        else
                        {
                            log("InteractionNpc = null " + CurrentInteractionGuid);
                        }

                        Thread.Sleep(5000);
                    }

                    Thread.Sleep(1000);

                    MySellItems();
                    if (CharacterSettings.CheckRepair && npc.IsArmorer)
                    {
                        if (!ItemManager.RepairAllItems())
                        {
                            log("Не смог отремонтировать " + GetLastError(), LogLvl.Error);
                            if (GetLastError() == ELastError.NoItemForRepair)
                            {
                                return(true);
                            }

                            Thread.Sleep(10000);
                            return(false);
                        }
                        else
                        {
                            AutoQuests.NeedActionNpcRepair = false;
                            log("Отремонтировал ", LogLvl.Ok);
                        }
                    }
                    MyBuyItems();
                    if (CharacterSettings.CheckRepair && npc.IsArmorer)
                    {
                        if (!ItemManager.RepairAllItems())
                        {
                            log("Не смог отремонтировать " + GetLastError(), LogLvl.Error);
                            if (GetLastError() == ELastError.NoItemForRepair)
                            {
                                return(true);
                            }

                            Thread.Sleep(10000);
                            return(false);
                        }
                        else
                        {
                            AutoQuests.NeedActionNpcRepair = false;
                            log("Отремонтировал ", LogLvl.Ok);
                        }
                    }
                    return(true);
                }
            }
            catch (ThreadAbortException)
            {
                return(false);
            }
            catch (Exception e)
            {
                log(e.ToString());
                return(false);
            }

            return(false);
        }
Beispiel #2
0
        internal bool MyMoveToRepair()
        {
            try
            {
                if (!MyAllItemsRepair())
                {
                    return(true);
                }

                if (CharacterSettings.Mode == Mode.QuestingClassic && Me.Distance(-3296.27, -2431.77, 18.60) < 100)
                {
                    MyUseStone();
                }

                if (CharacterSettings.SummonMount && IsOutdoors)
                {
                    var mountSell = SpellManager.GetSpell(61447); //Тундровый мамонт путешественника
                    if (mountSell == null)
                    {
                        mountSell = SpellManager.GetSpell(61425); //Тундровый мамонт путешественника
                    }

                    if (mountSell != null)
                    {
                        if (CharacterSettings.UseMountMyLoc)
                        {
                        }
                        else
                        {
                            if (Math.Abs(CharacterSettings.MountLocX) > 0)
                            {
                                if (!MoveTo(CharacterSettings.MountLocX, CharacterSettings.MountLocY, CharacterSettings.MountLocZ))
                                {
                                    return(false);
                                }
                            }
                        }

                        CommonModule.MyUnmount();
                        CanselForm();
                        CancelMoveTo();
                        Thread.Sleep(500);
                        MyCheckIsMovingIsCasting();
                        var result = SpellManager.CastSpell(mountSell.Id);

                        if (result != ESpellCastError.SUCCESS)
                        {
                            log("Не удалось призвать маунта " + mountSell.Name + "  " + result, LogLvl.Error);
                            return(false);
                        }
                        else
                        {
                            log("Призвал маунта", LogLvl.Ok);
                        }

                        Thread.Sleep(2000);
                        while (SpellManager.IsCasting)
                        {
                            Thread.Sleep(100);
                        }

                        Thread.Sleep(2000);
                        foreach (var npc in GetEntities <Unit>())
                        {
                            if (npc.Id == 32641 || npc.Id == 32639)
                            {
                                Thread.Sleep(1000);
                                if (!OpenShop(npc))
                                {
                                    log("Не смог открыть шоп 5 " + npc.Name + "[" + npc.Id + "]  " + GetLastError(),
                                        LogLvl.Error);
                                    if (InteractionObject != null)
                                    {
                                        log("Открыт диалог с " + InteractionObject.Name + "  " + InteractionObject.Id +
                                            "  " + Me.Distance(InteractionObject.Location) + " " +
                                            CurrentInteractionGuid);
                                    }
                                    else
                                    {
                                        log("InteractionNpc = null " + CurrentInteractionGuid);
                                    }

                                    Thread.Sleep(5000);

                                    /* if (GetLastError() != ELastError.ActionNotAllowed)
                                     * {
                                     *   return false;
                                     * }*/
                                }


                                Thread.Sleep(1000);
                                if (CharacterSettings.CheckRepair)
                                {
                                    if (!ItemManager.RepairAllItems())
                                    {
                                        log("Не смог отремонтировать " + GetLastError(), LogLvl.Error);

                                        /* if (GetLastError() == ELastError.NoItemForRepair)
                                         *   return true;*/
                                        Thread.Sleep(10000);
                                        //  return false;
                                    }
                                    else
                                    {
                                        log("Отремонтировал ", LogLvl.Ok);
                                    }
                                }

                                Thread.Sleep(1000);

                                MySellItems();
                                MyBuyItems();
                                CommonModule.MyUnmount();
                                AutoQuests.NeedActionNpcSell   = false;
                                AutoQuests.NeedActionNpcRepair = false;
                                return(true);
                            }
                        }
                    }
                }


                var armorer = MyGetArmorer();
                if (armorer == null)
                {
                    var vendor = FindNpcForActionArmored();
                    if (vendor == null)
                    {
                        double   bestDist = 9999999;
                        MyNpcLoc npcLoc   = null;
                        foreach (var myNpcLoc in MyNpcLocss.NpcLocs)
                        {
                            if (_badNpcForSell.Contains(myNpcLoc.Id))
                            {
                                continue;
                            }

                            if (IsBadNpcLocs.Contains(myNpcLoc))
                            {
                                continue;
                            }

                            if (!myNpcLoc.IsArmorer)
                            {
                                continue;
                            }

                            if (Me.Distance(myNpcLoc.Loc) > bestDist)
                            {
                                continue;
                            }

                            bestDist = Me.Distance(myNpcLoc.Loc);
                            npcLoc   = myNpcLoc;
                        }

                        if (npcLoc != null)
                        {
                            log("Выбрал нпс 1 " + npcLoc.Id);
                            if (!CommonModule.MoveTo(npcLoc.Loc, 10))
                            {
                                return(false);
                            }

                            var listUnit2 = GetEntities <Unit>();

                            foreach (var npc in listUnit2.OrderBy(i => Me.Distance(i)))
                            {
                                if (!npc.IsArmorer)
                                {
                                    continue;
                                }

                                if (!CommonModule.MoveTo(npc, 3))
                                {
                                    return(false);
                                }

                                CanselForm();
                                Thread.Sleep(1000);
                                if (!OpenShop(npc))
                                {
                                    log("Не смог открыть шоп 2 " + npc.Name + "[" + npc.Id + "]  " + GetLastError(), LogLvl.Error);
                                    if (InteractionObject != null)
                                    {
                                        log("Открыт диалог с " + InteractionObject.Name + "  " + InteractionObject.Id + "  " + Me.Distance(InteractionObject.Location) + "  " + CurrentInteractionGuid);
                                    }
                                    else
                                    {
                                        log("InteractionNpc = null " + CurrentInteractionGuid);
                                    }
                                    Thread.Sleep(5000);
                                }


                                foreach (var gossipOptionsData in GetNpcDialogs())
                                {
                                    if (gossipOptionsData.Text.Contains("buy from you"))
                                    {
                                        SelectNpcDialog(gossipOptionsData);
                                    }

                                    log(gossipOptionsData.Text);
                                }

                                Thread.Sleep(1000);
                                if (CharacterSettings.CheckRepair)
                                {
                                    if (!ItemManager.RepairAllItems())
                                    {
                                        log("Не смог отремонтировать " + GetLastError(), LogLvl.Error);
                                        Thread.Sleep(10000);
                                    }
                                    else
                                    {
                                        log("Отремонтировал ", LogLvl.Ok);
                                    }
                                }

                                MySellItems();
                                MyBuyItems();
                                return(true);
                            }
                        }
                        IsBadNpcLocs.Add(npcLoc);
                        log("Не указаны координаты для ремонта", LogLvl.Error);
                        Thread.Sleep(10000);
                        return(false);
                    }

                    log("Выбран НПС для ремонта  " + vendor.Name, LogLvl.Ok);

                    if (vendor.AreaId != Area.Id || Me.Distance(vendor.Loc) > 1000)
                    {
                        if (!MyUseTaxi(vendor.AreaId, vendor.Loc))
                        {
                            return(false);
                        }
                    }

                    if (!CommonModule.MoveTo(vendor.Loc, 10))
                    {
                        return(false);
                    }
                }


                var listUnit = GetEntities <Unit>();

                foreach (var npc in listUnit.OrderBy(i => Me.Distance(i)))
                {
                    if (!npc.IsArmorer)
                    {
                        continue;
                    }

                    if (!CommonModule.MoveTo(npc, 3))
                    {
                        return(false);
                    }

                    CanselForm();
                    Thread.Sleep(1000);
                    if (CurrentInteractionGuid == npc.Guid)
                    {
                        if (InteractionObject != null)
                        {
                            log("Открыт диалог с " + InteractionObject.Name + "  " + InteractionObject.Id + "  " + Me.Distance(InteractionObject.Location) + " " + CurrentInteractionGuid);
                        }
                        else
                        {
                            log("InteractionNpc = null " + CurrentInteractionGuid);
                        }
                    }
                    else
                    {
                        if (!OpenShop(npc))
                        {
                            if (GetLastError() == ELastError.TooFarDistance)
                            {
                                CommonModule.MoveTo(npc, 0);
                            }

                            log("Не смог открыть шоп 6 " + npc.Name + "[" + npc.Id + "]  " + GetLastError(),
                                LogLvl.Error);
                            if (InteractionObject != null)
                            {
                                log("Открыт диалог с " + InteractionObject.Name + "  " + InteractionObject.Id + "  " + Me.Distance(InteractionObject.Location) + " " + CurrentInteractionGuid);
                            }
                            else
                            {
                                log("InteractionNpc = null " + CurrentInteractionGuid);
                            }
                            Thread.Sleep(5000);
                        }
                    }


                    foreach (var gossipOptionsData in GetNpcDialogs())
                    {
                        if (gossipOptionsData.Text.Contains("I need to repair"))
                        {
                            SelectNpcDialog(gossipOptionsData);
                            Thread.Sleep(1000);
                        }
                    }

                    Thread.Sleep(1000);
                    if (CharacterSettings.CheckRepair)
                    {
                        if (!ItemManager.RepairAllItems())
                        {
                            log("Не смог отремонтировать " + GetLastError(), LogLvl.Error);
                            Thread.Sleep(10000);
                        }
                        else
                        {
                            log("Отремонтировал ", LogLvl.Ok);
                            Thread.Sleep(2000);
                        }
                    }

                    MySellItems();
                    MyBuyItems();
                    return(true);
                }
            }
            catch (Exception e)
            {
                log(e.ToString());
            }

            return(false);
        }