Пример #1
0
        private async Task <bool> Move()
        {
            Core.Logger.Verbose($"Moving to Interact: {Actor}");
            await CommonCoroutines.MoveTo(Actor.Position, Actor.Name);

            return(true);
        }
Пример #2
0
        public static async Task <CoroutineResult> EnsureInRift()
        {
            if (!ZetaDia.IsInTown)
            {
                return(CoroutineResult.NoAction);
            }

            if (!IsRiftPortalOpen)
            {
                return(CoroutineResult.NoAction);
            }

            var rp = RiftPortal;

            if (rp != null)
            {
                return(await CommonCoroutines.MoveAndInteract(
                           rp,
                           () => ZetaDia.IsInGame &&
                           !ZetaDia.Globals.IsLoadingWorld &&
                           !ZetaDia.Globals.IsPlayingCutscene &&
                           !ZetaDia.IsInTown));
            }

            // TODO: Make sure we move somewhere we expect the portal to show up.
            await CommonCoroutines.MoveTo(ZetaDia.Actors.GetActorsOfType <DiaGizmo>()
                                          .Where(g => g.Distance > 10f)
                                          .OrderBy(g => g.Distance)
                                          .FirstOrDefault());

            return(CoroutineResult.Running);
        }
Пример #3
0
        public static async Task <bool> MoveToAndOpenStash()
        {
            // Move to Stash
            if (Stash == null || (Stash != null && Stash.Position.Distance2D(ZetaDia.Me.Position) > 10f))
            {
                var moveResult = await CommonCoroutines.MoveTo(TownRun.StashLocation, "Shared Stash Location");

                if (moveResult == MoveResult.ReachedDestination)
                {
                    return(false);
                }
                if (moveResult == MoveResult.Moved)
                {
                    return(true);
                }
            }
            if (Stash == null)
            {
                return(false);
            }

            if (!UIElements.StashWindow.IsVisible)
            {
                Stash.Interact();
                return(true);
            }
            return(false);
        }
Пример #4
0
        private async Task UseItem(int x)
        {
            var g = Geomancer(_spots[x]);

            if (!Query.IsViable(g))
            {
                return;
            }

            if (g.DistanceSqr > 5 * 5)
            {
                await CommonCoroutines.MoveTo(g.Location);

                return;
            }

            if (Me.CurrentTarget != g)
            {
                g.Target();
                return;
            }

            await CommonCoroutines.Dismount();

            Rock.Use();
        }
Пример #5
0
        public static async Task <bool> EnsureMeleeRange(WoWUnit target)
        {
            if (target == null || Me.IsWithinMeleeRangeOf(target) || !target.IsValidCombatUnit() ||
                Me.IsCasting || Me.IsChanneling || HK.RotationOnlyOn || !GeneralSettings.Instance.GeneralMovement)
            {
                return(false);
            }

            L.infoLog("Getting in melee range", InfoColor);
            if (Me.IsWithinMeleeRangeOf(target))
            {
                return(await CommonCoroutines.StopMoving());
            }
            if (!Me.IsWithinMeleeRangeOf(target))
            {
                if (await Spell.Cast(Spell_Book.Glide, CombatColor, ShouldGlideForVengefulRetreat, "May have jumped too far back.  Gliding back in."))
                {
                    fallingTimeout.Reset();
                    return(true);
                }

                await CommonCoroutines.MoveTo(target.RelativeLocation, target.SafeName);
            }
            return(true);
        }
Пример #6
0
        private async Task <bool> Move()
        {
            Core.Logger.Verbose($"Moving to Marker: {Marker}");
            await CommonCoroutines.MoveTo(Marker.Position, "ItemMarker");

            return(true);
        }
        protected async Task <bool> MainCoroutine()
        {
            if (IsDone)
            {
                return(false);
            }
            if (!StyxWoW.Me.HasAura(AuraId_MechasharkXSteam))
            {
                var controler = Controller;
                if (controler == null)
                {
                    QBCLog.Fatal("Controler could not be found in ObjectManager");
                    return(true);
                }
                if (!controler.WithinInteractRange)
                {
                    return((await CommonCoroutines.MoveTo(controler.Location)).IsSuccessful());
                }

                if (await CommonCoroutines.StopMoving())
                {
                    return(true);
                }

                controler.Interact();
                await Coroutine.Sleep(5000);

                return(true);
            }

            var hammer = Hammer;

            if (hammer == null)
            {
                QBCLog.Fatal("Hammer could not be found in ObjectManager");
                return(true);
            }
            if (hammer.IsAlive && StyxWoW.Me.CurrentTarget != hammer)
            {
                await DoQuest(hammer);

                return(true);
            }
            if (StyxWoW.Me.QuestLog.GetQuestById(24817).IsCompleted)
            {
                Lua.DoString("VehicleExit()");
                _isBehaviorDone = true;
                return(true);
            }
            return(false);
        }
Пример #8
0
        private async Task OpenMailbox()
        {
            WoWPoint      movetoPoint = _loc;
            WoWGameObject mailbox;

            if (AutoFindMailBox || movetoPoint == WoWPoint.Zero)
            {
                mailbox =
                    ObjectManager.GetObjectsOfType <WoWGameObject>().Where(
                        o => o.SubType == WoWGameObjectType.Mailbox && o.CanUse())
                    .OrderBy(o => o.DistanceSqr).FirstOrDefault();
            }
            else
            {
                mailbox =
                    ObjectManager.GetObjectsOfType <WoWGameObject>().Where(
                        o => o.SubType == WoWGameObjectType.Mailbox &&
                        o.Location.Distance(_loc) < 10 && o.CanUse())
                    .OrderBy(o => o.DistanceSqr).FirstOrDefault();
            }
            if (mailbox != null)
            {
                movetoPoint = mailbox.Location;
            }

            if (movetoPoint == WoWPoint.Zero)
            {
                PBLog.Warn(Strings["Error_UnableToFindMailbox"]);
                return;
            }

            if (mailbox == null || !mailbox.WithinInteractRange)
            {
                await CommonCoroutines.MoveTo(movetoPoint);

                return;
            }

            if (Me.IsMoving)
            {
                await CommonCoroutines.StopMoving();
            }
            mailbox.Interact();
        }
Пример #9
0
        public async Task <bool> PhaseOneLogic()
        {
            if (Me.RelativeLocation == _phase2RelativePos)
            {
                return(false);
            }
            WoWGameObject rifle = Rifle;

            if (!rifle.WithinInteractRange)
            {
                return((await CommonCoroutines.MoveTo(rifle.Location)).IsSuccessful());
            }
            await CommonCoroutines.StopMoving();

            rifle.Interact();
            await CommonCoroutines.SleepForRandomReactionTime();

            return(true);
        }
Пример #10
0
        /// <summary>
        ///     (Non-Blocking) Attempts to move to the specified target.
        /// </summary>
        /// <returns>Returns true if we are able to move towards the target.</returns>
        public static async Task MoveToTarget(WoWUnit target, Func <bool> conditionCheck = null)
        {
            if (conditionCheck != null && !conditionCheck())
            {
                return;
            }

            if (target == null)
            {
                return;
            }

            if (target.IsDead)
            {
                return;
            }

            await CommonCoroutines.MoveTo(target.Location);
        }
Пример #11
0
        private async Task <bool> TakeTownPortalBackTask()
        {
            var portal = ZetaDia.Actors.GetActorsOfType <DiaObject>(true).FirstOrDefault(o => o.ActorSNO == TownPortalSNO);

            if (portal == null)
            {
                return(false);
            }

            if (portal.Distance > 10f)
            {
                await CommonCoroutines.MoveTo(portal.Position, "Return Portal");
            }

            if (portal.Distance <= 10f)
            {
                portal.Interact();
            }

            return(true);
        }
Пример #12
0
        public static async Task <bool> DeathBehavor()
        {
            if (Me.IsDead)
            {
                L.infoLog(DateTime.Now.ToString("mm:ss:ffffff") + " RepopMe()", Core.Helpers.Common.InfoColor);
                Lua.DoString("RepopMe()");
            }

            if (Me.IsGhost)
            {
                if (Battlegrounds.IsInsideBattleground || Me.CurrentMap.Name == "Ashran")
                {
                    L.infoLog(DateTime.Now.ToString("mm:ss:ffffff") + " Waiting for spirit rez", Core.Helpers.Common.InfoColor);
                    await Coroutine.Sleep(1500);
                }
                else
                {
                    L.infoLog(DateTime.Now.ToString("mm:ss:ffffff") + " Move to corpse", Core.Helpers.Common.InfoColor);
                    await CommonCoroutines.MoveTo(Me.CorpsePoint);
                }
            }
            return(false);
        }
Пример #13
0
        public static async Task <CoroutineResult> TurnInQuest()
        {
            if (AdvDia.RiftQuest.Step != RiftStep.Cleared)
            {
                return(CoroutineResult.NoAction);
            }

            if (await EnsureIsInTown() == CoroutineResult.Running)
            {
                return(CoroutineResult.Running);
            }

            if (Orek == null)
            {
                await CommonCoroutines.MoveTo(ZetaDia.Actors.GetActorsOfType <DiaGizmo>()
                                              .Where(g => g.Distance > 10f)
                                              .OrderByDescending(g => g.Distance)
                                              .FirstOrDefault());

                return(CoroutineResult.Running);
            }

            if (!(Orek.IsValid &&
                  await CommonCoroutines.MoveAndInteract(
                      Orek,
                      () => !Orek.IsQuestGiver) != CoroutineResult.Running))
            {
                return(CoroutineResult.Running);
            }

            if (s_experienceTracker.IsStarted)
            {
                s_experienceTracker.StopAndReport(nameof(RiftCoroutine));
            }

            return(CoroutineResult.Done);
        }
Пример #14
0
        private async Task <bool> Moving()
        {
            if (_deathGateLocation != Vector3.Zero)
            {
                if (!await NavigationCoroutine.MoveTo(_deathGateLocation, 5))
                {
                    return(false);
                }

                _deathGateLocation = Vector3.Zero;
            }

            if (!await NavigationCoroutine.MoveTo(_objectiveLocation, 5))
            {
                return(false);
            }

            if (NavigationCoroutine.LastMoveResult == MoveResult.UnstuckAttempt)
            {
                Core.Logger.Debug("Navigation ended with unstuck attempts last result.");
                Navigator.Clear();
            }

            if (AdvDia.MyPosition.Distance(_objectiveLocation) > 50 && NavigationCoroutine.LastResult == CoroutineResult.Failure)
            {
                Core.Logger.Debug("[EnterLevelAreaCoroutine] Navigation ended, extending scan radius to continue searching.");
                NavigationCoroutine.Reset();
                _previouslyFoundLocation       = _objectiveLocation;
                _returnTimeForPreviousLocation = PluginTime.CurrentMillisecond;
                _objectiveLocation             = Vector3.Zero;
                _objectiveScanRange            = ActorFinder.LowerSearchRadius(_objectiveScanRange);
                if (_objectiveScanRange <= 0)
                {
                    _objectiveScanRange = 50;
                }
                State = States.Searching;
                return(false);
            }

            DiaGizmo portal = null;

            if (_portalActorIds != null)
            {
                foreach (var portalid in _portalActorIds)
                {
                    portal = ActorFinder.FindGizmo(portalid);
                    if (portal != null)
                    {
                        _portalActorId = portal.ActorSnoId;
                        break;
                    }
                }
            }
            else
            {
                portal = ActorFinder.FindGizmo(_portalActorId);
            }

            if (portal == null)
            {
                portal = BountyHelpers.GetPortalNearPosition(_objectiveLocation);
                if (portal != null)
                {
                    _discoveredPortalActorId = portal.ActorSnoId;
                }
                else if (_portalActorId == 0)
                {
                    portal = ZetaDia.Actors.GetActorsOfType <GizmoPortal>().OrderBy(d => d.Distance).FirstOrDefault();
                    if (portal != null)
                    {
                        _discoveredPortalActorId = portal.ActorSnoId;
                        Core.Logger.Log($"[EnterLevelArea] Unable to find the portal we needed, using this one instead {portal.Name} ({portal.ActorSnoId})");
                    }
                }
            }

            if (portal == null)
            {
                State = States.Searching;
                return(false);
            }

            _interactRange = portal.CollisionSphere.Radius;
            // Add some tolerance, sometimes the radius is pretty low and it will keep stuck trying to move to it even when it's right besides it.
            _interactRange += ZetaDia.Me.CollisionSphere.Radius;

            Core.Logger.Debug($"[EnterLevelArea] Using interact range from portal: {_interactRange}");

            if (portal.Position.Distance(_objectiveLocation) > _interactRange)
            {
                Core.Logger.Debug($"[EnterLevelArea] Portal is still too far away, something went wrong with NavigationCoroutine");
                await CommonCoroutines.MoveTo(portal.Position);

                State = States.Searching;
                return(false);
            }

            _objectiveLocation = portal.Position;
            State = States.Entering;
            _prePortalWorldDynamicId = AdvDia.CurrentWorldDynamicId;

            Core.PlayerMover.MoveTowards(portal.Position);
            await Coroutine.Sleep(1000);

            return(false);
        }
Пример #15
0
        private static Composite MoveTo()
        {
            return(new PrioritySelector(
                       new DecoratorContinue(ret => Navigator.CanNavigateWithin(StyxWoW.Me.Location, ImpMovePlugin.PointTo, 5) && ImpMovePlugin.PointTo.Distance(StyxWoW.Me.Location) >= 5,
                                             new Action(ret => CommonCoroutines.MoveTo(ImpMovePlugin.CalculatePoint))),
                       new Decorator(ret => ImpMovePlugin.PointTo.Distance(StyxWoW.Me.Location) < 5,
                                     new Action(ret =>
            {
                if (ImpMovePlugin.PathNav.Any())
                {
                    Logging.Write("PathNav не пустой; Старая точка {0}", ImpMovePlugin.PointTo);
                    var a = ImpMovePlugin.PathNav.Remove(ImpMovePlugin.PointTo);
                    Logging.Write("Удалил старую точку из пути - {0}", a);
                }
                if (ImpMovePlugin.PathNav.Any())
                {
                    ImpMovePlugin.PointTo = ImpMovePlugin.PathNav.FirstOrDefault();
                    Logging.Write("Новая точка - {0}", ImpMovePlugin.PointTo);
                    return;
                }
                if (!ImpMovePlugin.PathNav.Any() && ImpMovePlugin.PointTo != WoWPoint.Empty)
                {
                    Navigator.Clear();
                    Logging.Write("Сбросил навигатор");
                    ImpMovePlugin.NeedMove = false;
                    Logging.Write("Need Move - false");
                    ImpMovePlugin.PointTo = WoWPoint.Empty;
                    Logging.Write("PointTo - Empty");
                    CountGenerate = 0;
                }
            })
                                     ),

                       new Decorator(ret => !Navigator.CanNavigateWithin(StyxWoW.Me.Location, ImpMovePlugin.PointTo, 5) && ImpMovePlugin.NeedMove,
                                     new Action(ret =>
            {
                CountGenerate++;
                Logging.Write("Пробую сделать путь {0}", CountGenerate);

                //LoadMesh();
                if (CountGenerate >= 10)
                {
                    Navigator.Clear();
                    Logging.Write("Сбросил навигатор Попыток больше 10");
                    ImpMovePlugin.PointTo = WoWPoint.Empty;
                    ImpMovePlugin.NeedMove = false;
                    CountGenerate = 0;
                    return;
                }
                var location = StyxWoW.Me.Location;
                var path = Navigator.GeneratePath(location, ImpMovePlugin.PointTo).ToList();
                if (path.Any() && !ImpMovePlugin.PathNav.Any())
                {
                    Logging.Write("найден путь. в нем {0} элементов", path.Count);

                    ImpMovePlugin.PathNav =
                        path.ToList();
                }
                if (ImpMovePlugin.PathNav.Any())
                {
                    ImpMovePlugin.PointTo = ImpMovePlugin.PathNav.FirstOrDefault();
                    Logging.Write("PointTo = PathNav.FirstOrDefault. " + ImpMovePlugin.PointTo);
                }
            })
                                     )


                       ));
        }
Пример #16
0
        private async Task <bool> ScareSpiders()
        {
            // if not in a turret than move to one and interact with it
            if (!Query.IsInVehicle())
            {
                var mustang = GetMustang();
                if (mustang == null)
                {
                    QBCLog.Warning("No mustang was found nearby");
                    return(false);
                }

                TreeRoot.StatusText = "Moving To Mustang";
                if (mustang.DistanceSqr > 5 * 5)
                {
                    return((await CommonCoroutines.MoveTo(mustang.Location)).IsSuccessful());
                }

                await CommonCoroutines.LandAndDismount();

                QBCLog.Info("Interacting with Mustang");
                mustang.Interact();
                return(true);
            }

            // Find the nearest spider and if none exist then move to the spawn location
            if (!Query.IsViable(_currentTarget) || !_currentTarget.IsAlive)
            {
                _currentTarget = ObjectManager.GetObjectsOfType <WoWUnit>()
                                 .Where(u => u.IsAlive && u.Entry == 44284 && !Blacklist.Contains(u, BlacklistFlags.Interact))
                                 .OrderBy(u => u.DistanceSqr).FirstOrDefault();

                if (_currentTarget == null)
                {
                    if (!Navigator.AtLocation(_spiderSpawnLocation))
                    {
                        return((await CommonCoroutines.MoveTo(_spiderSpawnLocation)).IsSuccessful());
                    }
                    TreeRoot.StatusText = "Waiting for spiders to spawn";
                    return(true);
                }
                _noMoveBlacklistTimer.Reset();
                _blacklistTimer.Reset();
                QBCLog.Info("Locked on a new target. Distance {0}", _currentTarget.Distance);
            }

            TreeRoot.StatusText = "Scaring spider towards lumber mill";

            var moveToPoint = WoWMathHelper.CalculatePointFrom(_lumberMillLocation, _currentTarget.Location, -6);

            if (moveToPoint.DistanceSqr((WoWMovement.ActiveMover ?? StyxWoW.Me).Location) > 4 * 4)
            {
                return((await CommonCoroutines.MoveTo(moveToPoint)).IsSuccessful());
            }

            // spider not moving? blacklist and find a new target.
            if (_noMoveBlacklistTimer.ElapsedMilliseconds > 20000 && _currentTarget.Location.DistanceSqr(_spiderScareLoc) < 10 * 10)
            {
                Blacklist.Add(_currentTarget, BlacklistFlags.Interact, TimeSpan.FromMinutes(3), "Spider is not moving");
                _currentTarget = null;
            }
            else if (_blacklistTimer.IsFinished)
            {
                Blacklist.Add(_currentTarget, BlacklistFlags.Interact, TimeSpan.FromMinutes(3), "Took too long");
                _currentTarget = null;
            }
            else if (!_currentTarget.HasAura("Fear"))
            {
                await CommonCoroutines.StopMoving();

                Me.SetFacing(_lumberMillLocation);
                await CommonCoroutines.SleepForLagDuration();

                await Coroutine.Sleep(200);

                if (!_noMoveBlacklistTimer.IsRunning || _currentTarget.Location.DistanceSqr(_spiderScareLoc) >= 10 * 10)
                {
                    _noMoveBlacklistTimer.Restart();
                    _spiderScareLoc = _currentTarget.Location;
                }
                Lua.DoString("CastSpellByID(83605)");
                await Coroutine.Wait(3000, () => Query.IsViable(_currentTarget) && _currentTarget.HasAura("Fear"));
            }

            return(true);
        }
        private async Task <bool> MainCoroutine()
        {
            if (IsDone)
            {
                return(false);
            }

            if (!Query.IsInVehicle())
            {
                return(await UtilityCoroutine.MountVehicle((int)KovokId, _kovokLoc));
            }

            var ct        = Me.CurrentTarget;
            var transport = (WoWUnit)Me.Transport;

            if (transport == null)
            {
                return(false);
            }

            if (ct == null)
            {
                var newTarget = GetNearestAttacker() ?? GetNearestTarget();
                if (newTarget != null)
                {
                    newTarget.Target();
                    _targetTimer.Reset();
                    return(true);
                }
                // move to waypoints searching for targets.
                if (transport.Location.DistanceSqr(_path.Peek()) < 15 * 15)
                {
                    _path.Dequeue();
                }
                return((await CommonCoroutines.MoveTo(_path.Peek())).IsSuccessful());
            }

            if (ct.IsDead)
            {
                Me.ClearTarget();
                return(true);
            }

            // blacklist target if it's taking too long to kill.
            if (_targetTimer.IsFinished)
            {
                Blacklist.Add(ct, BlacklistFlags.Combat, TimeSpan.FromMinutes(3));
                Me.ClearTarget();
            }


            if (transport.Location.DistanceSqr(ct.Location) > 35 * 35)
            {
                return((await CommonCoroutines.MoveTo(ct.Location)).IsSuccessful());
            }

            if (!transport.IsSafelyFacing(ct, 40))
            {
                ct.Face();
                return(true);
            }

            if (transport.IsMoving)
            {
                //WoWMovement.MoveStop();
                // WoWMovement.MoveStop doesn't seem to work...
                WoWMovement.ClickToMove(transport.Location);
                return(true);
            }

            var actionButton = ActionBar.Active.Buttons.FirstOrDefault(b => b.Index != 2 && b.CanUse);

            if (actionButton != null)
            {
                actionButton.Use();
                await Coroutine.Sleep(Delay.AfterWeaponFire);

                return(true);
            }

            return(false);
        }
Пример #18
0
        protected async Task <bool> MoveToObjectiveRoutine()
        {
            if (ZetaDia.Me.IsDead || ZetaDia.IsLoadingWorld)
            {
                Logger.Log("IsDead={0} IsLoadingWorld={1}", ZetaDia.Me.IsDead, ZetaDia.IsLoadingWorld);
                return(false);
            }

            SceneSegmentation.Update();

            if (_route.Any() || _currentRouteDestination != Vector3.Zero)
            {
                return(MoveAlongRoute(_route));
            }

            // If the bot has failed to run directly towards the objective marker too many times
            // We'll blacklist it for 30 seconds to allow adjacent scenes to be explored.
            if (FailedAttempts >= FailedAttemptMax)
            {
                Logger.Log("Blacklisting Objective Marker for 60 seconds");
                BlacklistMarkerExpires = DateTime.UtcNow.AddSeconds(60);
                FailedAttempts         = 0;
                _route = CreateRouteToUnexploredScene();
                return(false);
            }

            // While the bot is currently blacklisted from directly running at the objective
            // Generate a route to go through some nearby scenes
            if (DateTime.UtcNow < BlacklistMarkerExpires)
            {
                _route = CreateRouteToObjective();
                return(false);
            }

            // 'ReachedDestination' is returned when finding a path to destination has failed.
            if (_lastMoveResult == MoveResult.ReachedDestination && _objectiveObject == null)
            {
                if (_miniMapMarker != null && _miniMapMarker.IsValid && _miniMapMarker.IsPointOfInterest)
                {
                    var distance = ZetaDia.Me.Position.Distance(_miniMapMarker.Position);
                    if (distance > 100)
                    {
                        FailedAttempts++;
                        Logger.Log("Direct Pathfinding failed towards Objective Marker. Attempts={0}/{1}", FailedAttempts, FailedAttemptMax);
                    }
                    else if (distance < 30)
                    {
                        Logger.Log("ReachedDestination no Objective found - finished!");
                        _isDone = true;
                        return(true);
                    }
                }
            }

            // Find the objective minimap marker
            FindObjectiveMarker();

            // If the marker is found or was previously found, find a nearby actor
            if (_mapMarkerLastPosition != Vector3.Zero)
            {
                RefreshActorInfo();
            }

            if (_objectiveObject == null && _miniMapMarker == null && Position == Vector3.Zero)
            {
                Logger.Log("Error: Could not find Objective Marker! {0}", Status());
                _isDone = true;
                return(true);
            }

            // Finish if World Changed
            if (ZetaDia.CurrentWorldId != _startWorldId)
            {
                Logger.Log("World changed from {0} to {1}, finished {2}", _startWorldId, ZetaDia.CurrentWorldId, Status());
                _isDone = true;
                return(true);
            }

            // Finish because Objective Found
            if (IsValidObjective() && _objectiveObject is DiaUnit && _objectiveObject.Position.Distance(ZetaDia.Me.Position) <= PathPrecision)
            {
                Logger.Log("We found the objective and its a monster, ending tag so we can kill it. {0}", Status());
                _isDone = true;
                return(true);
            }

            // Objective Object is available
            if (_objectiveObject != null && _objectiveObject.IsFullyValid())
            {
                // Move Closer to Objective Object
                if (_lastMoveResult != MoveResult.ReachedDestination)
                {
                    Logger.Debug("Moving to actor {0} {1}", _objectiveObject.ActorSNO, Status());
                    _lastMoveResult = await CommonCoroutines.MoveTo(_objectiveObject.Position);

                    return(true);
                }

                if (_objectiveObject is GizmoPortal)
                {
                    if (_lastMoveResult == MoveResult.ReachedDestination && _objectiveObject.Distance > InteractRange)
                    {
                        Logger.Log("ReachedDestination but not within InteractRange, finished");
                        _isDone = true;
                        return(true);
                    }
                    if (GameUI.PartyLeaderBossAccept.IsVisible || GameUI.PartyFollowerBossAccept.IsVisible)
                    {
                        Logger.Debug("Party Boss Button visible");
                        return(true);
                    }
                    if (ZetaDia.Me.Movement.IsMoving)
                    {
                        await CommonBehaviors.MoveStop().ExecuteCoroutine();
                    }
                    _objectiveObject.Interact();
                    _completedInteractAttempts++;
                    Logger.Debug("Interacting with portal object {0}, result: {1}", _objectiveObject.ActorSNO, Status());
                    await Coroutine.Sleep(500);

                    GameEvents.FireWorldTransferStart();
                    return(true);
                }
            }

            if (_miniMapMarker != null && ObjectiveObjectIsNullOrInvalid())
            {
                if (_miniMapMarker != null && _miniMapMarker.Position.Distance(ZetaDia.Me.Position) > PathPrecision)
                {
                    Logger.Debug("Moving to Objective Marker {0}, {1}", _miniMapMarker.NameHash, Status());
                    _lastMoveResult = await CommonCoroutines.MoveTo(_miniMapMarker.Position);

                    return(true);
                }

                if (_miniMapMarker != null && _miniMapMarker.Position.Distance(ZetaDia.Me.Position) < PathPrecision)
                {
                    Logger.Debug("Successfully Moved to Objective Marker {0}, {1}", _miniMapMarker.NameHash, Status());
                    _isDone = true;
                    return(true);
                }
            }
            if (_miniMapMarker == null && Position != Vector3.Zero && Position.Distance(ZetaDia.Me.Position) > PathPrecision)
            {
                _lastMoveResult = CommonCoroutines.MoveTo(Position).Result;
                if (_lastMoveResult == MoveResult.ReachedDestination)
                {
                    Logger.Log("ReachedDestination of Position, minimap marker not found, finished.");
                    _isDone = true;
                    return(true);
                }
            }

            Logger.Error("MoveToObjective Error: marker={0} actorNull={1} actorValid={2} completedInteracts={3} isPortal={4} dist={5} interactRange={6}",
                         _miniMapMarker != null,
                         _objectiveObject != null,
                         (_objectiveObject != null && _objectiveObject.IsFullyValid()),
                         _completedInteractAttempts,
                         IsPortal,
                         (_objectiveObject != null && _objectiveObject.IsFullyValid() ? _objectiveObject.Position.Distance(ZetaDia.Me.Position) : 0f),
                         InteractRange);

            return(false);
        }
Пример #19
0
        public static async Task <bool> OpenRift(RiftType riftType,
                                                 int maxLevel,
                                                 int maxEmpowerLevel,
                                                 bool shouldEmpower,
                                                 bool runNormalUntilXP)
        {
            if (IsRiftPortalOpen)
            {
                return(IsRiftPortalOpen);
            }

            var riftKeys = CurrentRiftKeyCount;

            if (riftType == RiftType.Greater &&
                riftKeys <= PluginSettings.Current.MinimumKeys &&
                !PluginSettings.Current.GreaterRiftRunNephalem)
            {
                s_logger.Error($"[{nameof(OpenRift)}] You have no Greater Rift Keys. Stopping the bot.");
                BotMain.Stop();
                return(false);
            }

            s_logger.Debug($"[{nameof(OpenRift)}] I have {riftKeys} rift keys.");

            if (await EnsureIsInTown() == CoroutineResult.Running)
            {
                return(false);
            }

            if (riftKeys <= PluginSettings.Current.MinimumKeys)
            {
                riftType = RiftType.Nephalem;
            }

            // TODO: Figure out why there is that check against that magic.
            var maximizeXp = runNormalUntilXP &&
                             riftType == RiftType.Greater &&
                             ZetaDia.Me.RestExperience <5000000000 &&
                                                        ZetaDia.Me.RestExperience> -1;

            if (maximizeXp)
            {
                riftType = RiftType.Nephalem;
            }

            var level       = Math.Min(riftType == RiftType.Greater ? RiftData.GetGreaterRiftLevel() : -1, maxLevel);
            var isEmpowered = riftType == RiftType.Greater &&
                              shouldEmpower &&
                              level <= maxEmpowerLevel &&
                              RiftData.EmpoweredRiftCost.TryGetValue(level, out var empoweredCost) &&
                              ZetaDia.Storage.PlayerDataManager.ActivePlayerData.Coinage >=
                              (empoweredCost + PluginSettings.Current.MinimumGold);

            DiaGizmo lrs = LootRunSwitch;

            if (lrs == null)
            {
                await CommonCoroutines.MoveTo(ZetaDia.Actors.GetActorsOfType <DiaGizmo>()
                                              .Where(g => g.Distance > 10f)
                                              .OrderByDescending(g => g.Distance)
                                              .FirstOrDefault());

                return(false);
            }

            if (!s_experienceTracker.IsStarted)
            {
                s_experienceTracker.Start();
            }

            if (await CommonCoroutines.MoveAndInteract(
                    lrs,
                    () => UIElements.RiftDialog.IsVisible) == CoroutineResult.Running)
            {
                return(false);
            }

            ZetaDia.Me.OpenRift(level, isEmpowered);
            return(await Coroutine.Wait(TimeSpan.FromSeconds(2), () => IsRiftPortalOpen));
        }
Пример #20
0
        private async Task <bool> MovingToDeathGate()
        {
            if (_deathGate != null && _deathGate.IsFullyValid())
            {
                if (AdvDia.MyPosition.Distance(_deathGate.Position) <= 7f)
                {
                    Navigator.PlayerMover.MoveStop();
                    MoveResult = MoveResult.ReachedDestination;
                }
                else
                {
                    _deathGate = ActorFinder.FindNearestDeathGate(_deathGateIgnoreList);
                    if (_deathGate == null)
                    {
                        MoveResult = MoveResult.Failed;
                        State      = States.Failed;
                        return(false);
                    }
                    MoveResult = await CommonCoroutines.MoveTo(_deathGate.Position);
                }
                switch (MoveResult)
                {
                case MoveResult.ReachedDestination:
                    var distance = AdvDia.MyPosition.Distance(_deathGate.Position);
                    if (distance <= 7f)
                    {
                        _interactionCoroutine = new InteractionCoroutine(_deathGate.ActorSnoId, new TimeSpan(0, 0, 1), new TimeSpan(0, 0, 3));
                        State = States.InteractingWithDeathGate;
                    }
                    else
                    {
                        _deathGateIgnoreList.Add(_deathGate.ACDId);
                        State = States.Moving;
                    }
                    break;

                case MoveResult.Failed:
                case MoveResult.PathGenerationFailed:
                    State = States.Failed;
                    break;

                case MoveResult.PathGenerated:
                    break;

                case MoveResult.UnstuckAttempt:
                    if (_unstuckAttemps > 1)
                    {
                        State = States.Failed;
                        return(false);
                    }
                    _unstuckAttemps++;
                    Logger.Debug("[Navigation] Unstuck attempt #{0}", _unstuckAttemps);
                    break;

                case MoveResult.Moved:
                case MoveResult.PathGenerating:
                    break;
                }
                return(false);
            }
            State = States.Failed;
            return(false);
        }
Пример #21
0
        public async Task <bool> MoveTo(bool allowDequeue = true)
        {
            if (CurrentMovementQueue.Count == 0)
            {
                return(false);
            }

            WoWPoint location        = CurrentLocation;
            WoWPoint playerPos       = Player.Location;
            float    currentDistance = location.Distance(playerPos);

            if (currentDistance <= Distance)
            {
                if (allowDequeue)
                {
                    Log("MoveTo", String.Format("has dequeued location - {0}", location.ToString()));

                    DequeuedPoints.Enqueue(CurrentMovementQueue.Dequeue());
                    DequeuedFinalPlayerPositionPoints.Add(playerPos);
                }

                if (CurrentMovementQueue.Count == 0 || CurrentMovementQueue.Count == 1 && !allowDequeue)
                {
                    Log("MoveTo", "is finished");
                    WoWMovement.MoveStop();
                    return(false);
                }

                return(true);
            }

            if (!IgnoreTaxiCheck && !_checkedShoulUseFlightPath)
            {
                _checkedShoulUseFlightPath = true;
                if (TaxiFlightHelper.ShouldTakeFlightPath(location))
                {
                    if (BehaviorManager.SwitchBehaviors.All(b => b.Type != BehaviorType.Taxi))
                    {
                        BehaviorManager.SwitchBehaviors.Add(new BehaviorUseFlightPath(location));
                    }

                    return(true);
                }
            }

            if (!_didResetStuckChecker)
            {
                StuckChecker.Reset();
                _didResetStuckChecker = true;
            }
            else if (_checkStuck)
            {
                if (StuckChecker.CheckStuck())
                {
                    Log("MoveTo", "Stuck Checker returned true!");
                    return(false);
                }
            }


            if (!CheckCanNavigate())
            {
                Log("MoveTo", "Can Navigate Return False " + location.ToString());
                return(false);
            }

            //if (StyxWoW.Me.IsMoving)
            //    return true;

            var moveresult = MoveResult.Moved;

            try
            {
                moveresult = await CommonCoroutines.MoveTo(location);
            }
            catch (Exception ex)
            {
                Navigator.Clear();
                Log("MoveTo", "Exception during movement attempt! " + location.ToString());

                try
                {
                    Navigator.MoveTo(location);
                }
                catch
                {
                    Log("MoveTo", "Double Exception during movement attempt!! " + location.ToString());
                    return(false);
                }
            }


            //Navigator.GetRunStatusFromMoveResult(moveresult);
            switch (moveresult)
            {
            case MoveResult.UnstuckAttempt:
                Log("MoveTo", "MoveResult: UnstuckAttempt " + location.ToString());
                await Buddy.Coroutines.Coroutine.Sleep(500);

                break;

            case MoveResult.Failed:
                Log("MoveTo", "MoveResult: Failed " + location.ToString());
                return(false);

            case MoveResult.ReachedDestination:
                Log("MoveTo", "MoveResult: ReachedDestination " + location.ToString());
                return(true);
            }

            if (MovementCache.ShouldRecord)
            {
                MovementCache.AddPosition(playerPos, Distance);
            }

            return(true);
        }
Пример #22
0
        public async Task <MoveResult> MoveTo_Result(bool allowDequeue = true)
        {
            if (CurrentMovementQueue.Count == 0)
            {
                return(MoveResult.ReachedDestination);
            }

            WoWPoint location        = CurrentLocation;
            WoWPoint playerPos       = Character.Player.Location;
            float    currentDistance = location.Distance(playerPos);

            if (currentDistance <= Distance)
            {
                if (allowDequeue)
                {
                    Log("MoveToResult", String.Format("has dequeued location - {0}", location.ToString()));

                    DequeuedPoints.Enqueue(CurrentMovementQueue.Dequeue());
                    DequeuedFinalPlayerPositionPoints.Add(playerPos);
                }

                if (CurrentMovementQueue.Count == 0 || CurrentMovementQueue.Count == 1 && !allowDequeue)
                {
                    Log("MoveToResult", "is finished");
                    WoWMovement.MoveStop();
                    return(MoveResult.ReachedDestination);
                }

                return(MoveResult.Moved);
            }

            if (!_didResetStuckChecker)
            {
                StuckChecker.Reset();
                _didResetStuckChecker = true;
            }
            else if (_checkStuck)
            {
                if (StuckChecker.CheckStuck())
                {
                    Log("MoveToResult", "Stuck Checker returned true!");
                    return(MoveResult.Failed);
                }
            }

            if (!CheckCanNavigate())
            {
                Log("MoveToResult", "Can Navigate Return False " + location.ToString());
                return(MoveResult.Failed);
            }


            var moveresult = MoveResult.Moved;

            try
            {
                moveresult = await CommonCoroutines.MoveTo(location);
            }
            catch (Exception ex)
            {
                Navigator.Clear();
                Log("MoveToResult", "Exception during movement attempt!! " + location.ToString());
                try
                {
                    Navigator.MoveTo(location);
                }
                catch
                {
                    Log("MoveToResult", "Double Exception during movement attempt!! " + location.ToString());
                    return(MoveResult.Failed);
                }
            }

            if (MovementCache.ShouldRecord)
            {
                MovementCache.AddPosition(playerPos, Distance);
            }

            //GarrisonBase.Log("[MoveTo] MoveResult: {0}", moveresult.ToString());
            return(moveresult);
        }