예제 #1
0
        /// <summary>
        /// UIElement validation check
        /// </summary>
        /// <param name="hash">UIElement hash to check</param>
        /// <param name="isEnabled">should be enabled</param>
        /// <param name="isVisible">should be visible</param>
        /// <param name="bisValid">should be a valid UIElement</param>
        /// <returns>true if all requirements are valid</returns>
        public static bool isValid(ulong hash, bool isEnabled = true, bool isVisible = true, bool bisValid = true)
        {
            try
            {
                if (!UIElement.IsValidElement(hash))
                {
                    return(false);
                }
                else
                {
                    var element = UIElement.FromHash(hash);

                    if ((isEnabled && !element.IsEnabled) || (!isEnabled && element.IsEnabled))
                    {
                        return(false);
                    }
                    if ((isVisible && !element.IsVisible) || (!isVisible && element.IsVisible))
                    {
                        return(false);
                    }
                    if ((bisValid && !element.IsValid) || (!bisValid && element.IsValid))
                    {
                        return(false);
                    }
                }
            }
            catch
            {
                return(false);
            }
            return(true);
        }
예제 #2
0
 private void ErrorHandling()
 {
     if (ErrorDialog.IsVisible)
     { // Check if Demonbuddy found errordialog
         if (!handlederror)
         {
             Send("CheckConnection", pause: true);
             handlederror = true;
         }
         else
         {
             handlederror = false;
             ErrorDialog.Click();
             bootTo();
         }
     }
     else if (UIElementTester.isValid(_UIElement.errordialog_okbutton))
     { // Demonbuddy failed to find error dialog use static hash to find the OK button
         Send("CheckConnection", pause: true);
         UIElement.FromHash(_UIElement.errordialog_okbutton).Click();
         bootTo();
     }
     else
     {
         handlederror = false;
         if (UIElementTester.isValid(_UIElement.loginscreen_username))
         { // We are at loginscreen
             Send("CheckConnection", pause: true);
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Check if we are stuck or not by simply checking for position changing max once every 3 seconds
        /// </summary>
        /// <param name="vMyCurrentPosition"></param>
        /// <param name="checkDuration"></param>
        /// <returns></returns>
        public static bool UnstuckChecker(Vector3 vMyCurrentPosition, int checkDuration = 3000)
        {
            // set checkDuration to 30 sec while in town or vendoring, just to avoid annoyances
            if (ZetaDia.Me.IsInTown || GilesTrinity.ForceVendorRunASAP || Zeta.CommonBot.Logic.BrainBehavior.IsVendoring)
            {
                checkDuration = 15000;
            }

            // Keep checking distance changes every 3 seconds
            if (DateTime.Now.Subtract(TimeLastRecordedPosition).TotalMilliseconds >= checkDuration)
            {
                if (ZetaDia.Me.IsInTown && (UIElements.VendorWindow.IsVisible || UIElements.SalvageWindow.IsVisible))
                {
                    UnStuckCheckerLastResult = false;
                    return(UnStuckCheckerLastResult);
                }

                if (checkDuration >= 3000)
                {
                    TimeLastRecordedPosition = DateTime.Now;
                }

                ProfileBehavior c = null;

                try
                {
                    if (ProfileManager.CurrentProfileBehavior != null)
                    {
                        c = ProfileManager.CurrentProfileBehavior;
                    }
                }
                catch { }

                if (c != null && c.GetType() == typeof(WaitTimerTag))
                {
                    vOldPosition = Vector3.Zero;
                    GoldInactivity.ResetCheckGold();
                    UnStuckCheckerLastResult = false;
                    return(UnStuckCheckerLastResult);
                }

                Zeta.Internals.UIElement vendorWindow = Zeta.Internals.UIElements.VendorWindow;

                // We're not stuck if we're doing stuff!
                if (ZetaDia.Me.IsInConversation || ZetaDia.IsPlayingCutscene || ZetaDia.IsLoadingWorld || (vendorWindow.IsValid && vendorWindow.IsVisible))
                {
                    vOldPosition = Vector3.Zero;
                    GoldInactivity.ResetCheckGold();
                    UnStuckCheckerLastResult = false;
                    return(UnStuckCheckerLastResult);
                }

                AnimationState aState = ZetaDia.Me.CommonData.AnimationState;
                // We're not stuck if we're doing stuff!
                if (aState == AnimationState.Attacking ||
                    aState == AnimationState.Casting ||
                    aState == AnimationState.Channeling)
                {
                    vOldPosition = Vector3.Zero;
                    GoldInactivity.ResetCheckGold();
                    UnStuckCheckerLastResult = false;
                    return(UnStuckCheckerLastResult);
                }

                if (vOldPosition != Vector3.Zero && vOldPosition.Distance(vMyCurrentPosition) <= 4f)
                {
                    UnStuckCheckerLastResult = true;
                    return(UnStuckCheckerLastResult);
                }

                if (checkDuration >= 3000)
                {
                    vOldPosition = vMyCurrentPosition;
                }
            }

            // Return last result if within the specified timeframe
            return(false);
        }