Exemple #1
0
        internal static void Pulse()
        {
            try
            {
                if (!Player.IsValid)
                {
                    return;
                }

                ChangeMonitor.CheckForChanges();
                ActorHistory.UpdateActors();
                PositionCache.RecordPosition();

                // Mark Dungeon Explorer nodes as Visited if combat pulls us into it
                if (ProfileManager.CurrentProfileBehavior != null)
                {
                    Type profileBehaviorType = ProfileManager.CurrentProfileBehavior.GetType();
                    if (profileBehaviorType == typeof(ExploreDungeonTag))
                    {
                        ExploreDungeonTag exploreDungeonTag = (ExploreDungeonTag)ProfileManager.CurrentProfileBehavior;
                        exploreDungeonTag.MarkNearbyNodesVisited();
                    }
                }
                LoadOnceTag.RecordLoadOnceProfile();

                RiftTrial.PulseRiftTrial();
                CheckGamesPerHourStop();
                SkipCutScene();
                AdvanceConversation();
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
            }
        }
        public static bool ActorIsAlive(int actorId)
        {
            var actor = ZetaDia.Actors.GetActorsOfType <DiaUnit>().FirstOrDefault(a => a.IsValid && a.ActorSNO == actorId && a.IsAlive);

            // Its possible that by the time other tags run this actor will have disappeared from actors collection
            // to make sure we dont lose track of it, it needs to be recorded in the history.
            ActorHistory.UpdateActor(actor);

            return(actor != null);
        }
 public static bool ActorFound(int actorId)
 {
     return(ActorHistory.HasBeenSeen(actorId) || ActorIsAlive(actorId));
 }
Exemple #4
0
        private async Task <bool> MainCoroutine()
        {
            if (ZetaDia.Me == null)
            {
                return(false);
            }

            if (!ZetaDia.IsInGame)
            {
                return(false);
            }

            if (ZetaDia.IsLoadingWorld)
            {
                await Coroutine.Sleep(50);

                return(false);
            }
            if (!ZetaDia.Me.IsValid)
            {
                return(false);
            }

            if (ZetaDia.Me.IsDead)
            {
                return(false);
            }

            if (DateTime.UtcNow.Subtract(_lastInteract).TotalMilliseconds < 500 && WorldHasChanged())
            {
                return(true);
            }

            if (Timeout > 0 && DateTime.UtcNow.Subtract(_tagStartTime).TotalSeconds > Timeout)
            {
                End("Timeout of {0} seconds exceeded for Profile Behavior {1}", Timeout, Status());
                return(true);
            }

            if (TargetIsDungeonStone && GameUI.IsElementVisible(GameUI.GenericOK))
            {
                GameUI.SafeClickElement(GameUI.GenericOK, "Generic OK");
                await Coroutine.Yield();

                await Coroutine.Sleep(3000);
            }

            GameUI.SafeClickUIButtons();

            if (Vector3.Distance(_lastPosition, ZetaDia.Me.Position) > 5f)
            {
                _lastPositionUpdate = DateTime.UtcNow;
                _lastPosition       = ZetaDia.Me.Position;
            }

            if (ExitWithVendorWindow && GameUI.IsElementVisible(UIElements.VendorWindow))
            {
                EndDebug("Vendor window is visible " + Status());
            }

            if (Actor == null && Position == Vector3.Zero && !WorldHasChanged())
            {
                var lastSeenPosition = ActorHistory.GetActorPosition(ActorId);
                if (lastSeenPosition != Vector3.Zero)
                {
                    Warn("Can't find actor! using last known position {0} Distance={1}",
                         lastSeenPosition.ToString(),
                         lastSeenPosition.Distance(ZetaDia.Me.Position));

                    Position = lastSeenPosition;
                    return(true);
                }

                EndDebug("ERROR: Could not find an actor or position to move to, finished! {0}", Status());
                return(true);
            }
            if (IsPortal && WorldHasChanged())
            {
                if (DestinationWorldId > 0 && ZetaDia.CurrentWorldId != DestinationWorldId && ZetaDia.CurrentWorldId != _startingWorldId)
                {
                    EndDebug("Error! We used a portal intending to go from WorldId={0} to WorldId={1} but ended up in WorldId={2} {3}",
                             _startingWorldId, DestinationWorldId, ZetaDia.CurrentWorldId, Status());
                    return(true);
                }
                await Coroutine.Sleep(100);

                EndDebug("Successfully used portal {0} to WorldId {1} {2}", ActorId, ZetaDia.CurrentWorldId, Status());
                return(true);
            }
            if (Actor == null && ((MaxSearchDistance > 0 && WithinMaxSearchDistance()) || WithinInteractRange()))
            {
                EndDebug("Finished: Actor {0} not found, within InteractRange {1} and  MaxSearchDistance {2} of Position {3} {4}",
                         ActorId, InteractRange, MaxSearchDistance, Position, Status());

                return(true);
            }
            if (Position.Distance(ZetaDia.Me.Position) > 1500)
            {
                EndDebug("ERROR: Position distance is {0} - this is too far! {1}", Position.Distance(ZetaDia.Me.Position), Status());
                return(true);
            }

            if (_moveResult == MoveResult.ReachedDestination && Actor == null)
            {
                EndDebug("Reached Destination, no actor found! " + Status());
                return(true);
            }

            if (Actor == null)
            {
                if (MaxSearchDistance > 0 && !WithinMaxSearchDistance())
                {
                    Move(Position);
                    return(true);
                }
                if (InteractRange > 0 && !WithinInteractRange())
                {
                    Move(Position);
                    return(true);
                }
            }

            if (Actor == null || !Actor.IsValid)
            {
                return(true);
            }

            if (((!IsPortal && _completedInteractions >= InteractAttempts && InteractAttempts > 0) || (IsPortal && WorldHasChanged()) || AnimationMatch()))
            {
                EndDebug("Successfully interacted with Actor {0} at Position {1} " + Status(), Actor.ActorSNO, Actor.Position);
                return(true);
            }
            if (InteractAttempts <= 0 && WithinInteractRange())
            {
                EndDebug("Actor is within interact range {0:0} - no interact attempts " + Status(), Actor.Distance);
                return(true);
            }
            if (_completedInteractions >= InteractAttempts)
            {
                EndDebug("Interaction failed after {0} interact attempts " + Status(), _completedInteractions);
                return(true);
            }
            if (ExitWithConversation && GameUI.IsElementVisible(GameUI.TalktoInteractButton1))
            {
                GameUI.SafeClickElement(GameUI.TalktoInteractButton1, "Conversation Interaction Button 1");
                EndDebug("Clicked Conversation Interaction Button 1 " + Status());
                return(true);
            }
            if (!WithinInteractRange())
            {
                Move(Actor.Position);
                return(true);
            }

            await Coroutine.Wait(_interactWaitMilliSeconds, ShouldWaitForInteraction);

            if ((WithinInteractRange() || DateTime.UtcNow.Subtract(_lastPositionUpdate).TotalMilliseconds > 750) && _completedInteractions < InteractAttempts)
            {
                return(await InteractRoutine());
            }

            Logger.Debug("No action taken");
            return(true);
        }