Exemplo n.º 1
0
 private void HandleInteractiveUseErrorMessage(IAccount arg1, InteractiveUseErrorMessage arg2)
 {
     Logger.Default.Log("HandleInteractiveUseErrorMessage", API.Utils.Enums.LogMessageType.Error);
     _account.PerformAction(Gather, 1000);
     if (IsFinished)
     {
         return;
     }
     if (ErrorCount >= 3)
     {
         IsFinished = true;
         GatherFinished?.Invoke(_account, new EventArgs());
         return;
     }
     ErrorCount++;
     Logger.Default.Log("Une erreur est survenue lors de la récolte, nouvel essai dans 2 secondes.");
     _account.PerformAction(Gather, 2000);
 }
Exemplo n.º 2
0
 private void OnGatherFinished(GatherResults result)
 {
     _stolen          = false;
     _elementToGather = null;
     GatherFinished?.Invoke(result);
 }
Exemplo n.º 3
0
        public void Gather(List <int> @params, bool autoGather, bool resetCounters = false)
        {
            Logger.Default.Log("Gather param called");
            if (resetCounters)
            {
                ErrorCount = 0;
                IsFinished = false;
            }
            if (@params.Count < 1)
            {
                return;
            }
            Launched   = true;
            AutoGather = autoGather;
            ToGather   = @params;
            var listDistance      = new List <int>();
            var listUsableElement = new List <IUsableElement>();

            try
            {
                foreach (var ressourceId in ToGather)
                {
                    foreach (var usableElement in _account.Character.Map.UsableElements)
                    {
                        foreach (var interactiveElement in _account.Character.Map.InteractiveElements.Values)
                        {
                            if (usableElement.Value.Element.Id != interactiveElement.Id ||
                                !interactiveElement.IsUsable)
                            {
                                continue;
                            }
                            if (interactiveElement.TypeId != ressourceId ||
                                !_account.Character.Map.NoEntitiesOnCell(usableElement.Value.CellId) ||
                                _account.Character.Map.MoveToElement((int)interactiveElement.Id, 1) == null)
                            {
                                continue;
                            }
                            listUsableElement.Add(usableElement.Value);
                            listDistance.Add(GetRessourceDistance((int)usableElement.Value.Element.Id));
                        }
                    }
                }
                if (listDistance.Count <= 0)
                {
                    if (!IsFinished)
                    {
                        IsFinished = true;
                        GatherFinished?.Invoke(_account, new EventArgs());
                    }
                    return;
                }
                foreach (var usableElement in TrierDistanceElement(listDistance, listUsableElement))
                {
                    if (GetRessourceDistance((int)usableElement.Element.Id) == 1 || IsFishing)
                    {
                        Logger.Default.Log("Récolte de " + D2OParsing.GetInteractiveName(usableElement.Element.TypeId) + " commencée. (CellID=" + usableElement.CellId.ToString() + ", ElementID=" + usableElement.Element.Id.ToString() + ")");
                        if (Moved)
                        {
                            _account.Character.Map.UseElement(Id, SkillInstanceUid);
                        }
                        else
                        {
                            _account.Character.Map.UseElement((int)usableElement.Element.Id,
                                                              usableElement.Skills[0].SkillInstanceUid);
                        }

                        Moved     = false;
                        IsFishing = false;
                        break;
                    }
                    Id = (int)usableElement.Element.Id;
                    SkillInstanceUid = usableElement.Skills[0].SkillInstanceUid;
                    if (Move != null)
                    {
                        Move.MovementFinished -= OnMovementFinished;
                    }
                    Move = _account.Character.Map.MoveToElement(Id, 1);
                    Logger.Default.Log("Déplacement vers la ressources cellid=" + usableElement.CellId.ToString());
                    Move.MovementFinished += OnMovementFinished;
                    Move.PerformMovement();
                    break;
                }
                Launched = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }