Example #1
0
        private static void ClearBlacklists()
        {
            // Clear the temporary blacklist every 90 seconds (default was 90)
            if (DateTime.UtcNow.Subtract(Blacklist90LastClear).TotalSeconds > 90)
            {
                Blacklist90LastClear = DateTime.UtcNow;
                Blacklist90Seconds   = new HashSet <int>();

                // Refresh profile blacklists now, just in case
                UsedProfileManager.RefreshProfileBlacklists();
            }
            // Clear the full blacklist every 60 seconds (default was 60)
            if (DateTime.UtcNow.Subtract(Blacklist60LastClear).TotalSeconds > 60)
            {
                Blacklist60LastClear = DateTime.UtcNow;
                Blacklist60Seconds   = new HashSet <int>();
            }
            // Clear the temporary blacklist every 15 seconds (default was 15)
            if (DateTime.UtcNow.Subtract(Blacklist15LastClear).TotalSeconds > 15)
            {
                Blacklist15LastClear = DateTime.UtcNow;
                Blacklist15Seconds   = new HashSet <int>();
            }
            // Clear our very short-term ignore-monster blacklist (from not being able to raycast on them or already dead units)
            if (DateTime.UtcNow.Subtract(Blacklist3LastClear).TotalMilliseconds > 3000)
            {
                Blacklist3LastClear   = DateTime.UtcNow;
                NeedToClearBlacklist3 = false;
                Blacklist3Seconds     = new HashSet <int>();
            }
        }
Example #2
0
        private static void GameEvents_OnGameChanged(object sender, EventArgs e)
        {
            ClearCachesOnGameChange(sender, e);

            // reload the profile juuuuuuuuuuuust in case Demonbuddy missed it... which it is known to do on disconnects
            //string currentProfilePath = ProfileManager.CurrentProfile.Path;
            //ProfileManager.Load(currentProfilePath);
            //Navigator.SearchGridProvider.Update();
            ResetEverythingNewGame();
            UsedProfileManager.SetProfileInWindowTitle();
        }
Example #3
0
        /// <summary>
        /// Receive Pulse event from DemonBuddy.
        /// </summary>
        public void OnPulse()
        {
            using (new PerformanceLogger("OnPulse"))
            {
                try
                {
                    // At Login screen, derp!
                    var loginSubmitButton = Zeta.Game.Internals.UIElement.FromName("Root.NormalLayer.BattleNetLogin_main.LayoutRoot.LoginContainer.SubmitButton");
                    if (loginSubmitButton != null && loginSubmitButton.IsValid && loginSubmitButton.IsVisible && BotMain.IsRunning)
                    {
                        new Thread(() => {
                            BotMain.Stop();
                            Thread.Sleep(1000);
                            BotMain.Start();
                        })
                        {
                            IsBackground = true,
                            Name         = "LoginScreenBouncer",
                        }.Start();

                        return;
                    }

                    if (ZetaDia.Me == null)
                    {
                        return;
                    }

                    if (!ZetaDia.IsInGame || !ZetaDia.Me.IsValid || ZetaDia.IsLoadingWorld)
                    {
                        return;
                    }

                    GameUI.SafeClickUIButtons();

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

                    using (new PerformanceLogger("LazyRaiderClickToPause"))
                    {
                        if (Settings.Advanced.LazyRaiderClickToPause && !BotMain.IsPaused)
                        {
                            BotMain.PauseWhile(MouseLeft);
                        }
                    }

                    // See if we should update the stats file
                    if (DateTime.UtcNow.Subtract(ItemStatsLastPostedReport).TotalSeconds > 10)
                    {
                        ItemStatsLastPostedReport = DateTime.UtcNow;
                        OutputReport();
                    }

                    // Recording of all the XML's in use this run
                    UsedProfileManager.RecordProfile();

                    Monk_MaintainTempestRush();
                }
                catch (AccessViolationException)
                {
                    // woof!
                }
                catch (Exception ex)
                {
                    Logger.Log(LogCategory.UserInformation, "Exception in Pulse: {0}", ex.ToString());
                }
            }
        }
Example #4
0
        /// <summary>
        /// This is wired up by Plugin.OnEnabled, and called when the bot is started
        /// </summary>
        /// <param name="bot"></param>
        private static void TrinityBotStart(IBot bot)
        {
            Logger.Log("Bot Starting");
            DateTime timeBotStart = DateTime.UtcNow;

            V.ValidateLoad();

            // Recording of all the XML's in use this run
            try
            {
                string sThisProfile = GlobalSettings.Instance.LastProfile;
                if (sThisProfile != CurrentProfile)
                {
                    ProfileHistory.Add(sThisProfile);
                    CurrentProfile = sThisProfile;
                    if (FirstProfile == "")
                    {
                        FirstProfile = sThisProfile;
                    }
                }

                DebugUtil.LogSystemInformation();
            }
            catch
            {
            }

            if (!ItemDropStats.MaintainStatTracking)
            {
                ItemDropStats.ItemStatsWhenStartedBot   = DateTime.UtcNow;
                ItemDropStats.ItemStatsLastPostedReport = DateTime.UtcNow;
                ItemDropStats.MaintainStatTracking      = true;
            }
            else
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation,
                           "Note: Maintaining item stats from previous run. To reset stats fully, please restart DB.");
            }

            TrinityItemManager.ResetBackPackCheck();

            BeginInvoke(UsedProfileManager.RefreshProfileBlacklists);
            UsedProfileManager.SetProfileInWindowTitle();

            BotManager.ReplaceTreeHooks();
            TreeHooks.Instance.OnHooksCleared += BotManager.InstanceOnOnHooksCleared;


            PlayerMover.TimeLastRecordedPosition = DateTime.UtcNow;
            PlayerMover.LastRestartedGame        = DateTime.UtcNow;
            Logger.Log("Bot Starting, Resetting Gold Inactivity Timer");
            GoldInactivity.Instance.ResetCheckGold();
            XpInactivity.Instance.ResetCheckXp();

            if (CharacterSettings.Instance.KillRadius < 20)
            {
                Logger.Log("WARNING: Low Kill Radius detected, currently set to: {0} (you can change this through Demonbuddy bot settings)",
                           CharacterSettings.Instance.KillRadius);
            }

            if (CharacterSettings.Instance.LootRadius < 50)
            {
                Logger.Log("WARNING: Low Gold Loot Radius detected, currently set to: {0} (you can change this through Demonbuddy bot settings)",
                           CharacterSettings.Instance.LootRadius);
            }

            if (Settings.Loot.ItemFilterMode == ItemFilterMode.TrinityWithItemRules)
            {
                try
                {
                    if (StashRule == null)
                    {
                        StashRule = new Interpreter();
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogError("Error configuring ItemRules Interpreter: " + ex);
                }
            }

            Logger.LogDebug("Trinity BotStart took {0:0}ms", DateTime.UtcNow.Subtract(timeBotStart).TotalMilliseconds);
        }
Example #5
0
        /// <summary>
        /// Receive Pulse event from DemonBuddy.
        /// </summary>
        public void OnPulse()
        {
            try
            {
                if (ZetaDia.Me == null)
                {
                    return;
                }

                if (!ZetaDia.IsInGame || !ZetaDia.Me.IsValid || ZetaDia.IsLoadingWorld)
                {
                    return;
                }

                //ScenesStorage.Update();

                using (new PerformanceLogger("OnPulse"))
                {
                    //if (IsMoveRequested)
                    //    NavServerReport();

                    GameUI.SafeClickUIButtons();

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

                    using (new PerformanceLogger("LazyRaiderClickToPause"))
                    {
                        if (Settings.Advanced.LazyRaiderClickToPause && !BotMain.IsPaused)
                        {
                            BotMain.PauseWhile(MouseLeft);
                        }
                    }

                    // See if we should update the stats file
                    if (DateTime.UtcNow.Subtract(ItemDropStats.ItemStatsLastPostedReport).TotalSeconds > 10)
                    {
                        ItemDropStats.ItemStatsLastPostedReport = DateTime.UtcNow;
                        ItemDropStats.OutputReport();
                    }

                    // Recording of all the XML's in use this run
                    UsedProfileManager.RecordProfile();

                    DebugUtil.LogOnPulse();

                    Gamble.CheckShouldTownRunForGambling();

                    MonkCombat.RunOngoingPowers();
                }
            }
            catch (AccessViolationException)
            {
                // woof!
            }
            catch (Exception ex)
            {
                Logger.Log(LogCategory.UserInformation, "Exception in Pulse: {0}", ex.ToString());
            }
        }