コード例 #1
0
        internal static void DumpItemSNOReference()
        {
            string[] names  = Enum.GetNames(typeof(SNOActor));
            int[]    values = (int[])Enum.GetValues(typeof(SNOActor));
            var      toLog  = new List <string>();

            for (int i = 0; i < names.Length; i++)
            {
                var sno  = values[i];
                var name = names[i];
                var type = TrinityItemManager.DetermineItemType(name, ItemType.Unknown);
                if (type != TrinityItemType.Unknown || DataDictionary.GoldSNO.Contains(sno) ||
                    DataDictionary.ForceToItemOverrideIds.Contains(sno) || DataDictionary.HealthGlobeSNO.Contains(sno) || Legendary.ItemIds.Contains(sno))
                {
                    toLog.Add(string.Format("{{ {0}, TrinityItemType.{1} }}, // {2}", sno, type, name));
                }
            }

            var path = WriteLinesToLog("ItemSNOReference.log", toLog, true);

            Logger.Log("Finished Dumping Item SNO Reference to {0}", path);
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigViewModel" /> class.
        /// </summary>
        /// <param name="model">The model.</param>
        public ConfigViewModel(TrinitySetting model)
        {
            try
            {
                _OriginalModel = model;
                _Model         = new TrinitySetting();
                _OriginalModel.CopyTo(_Model);
                InitializeResetCommand();
                SaveCommand = new RelayCommand(
                    (parameter) =>
                {
                    try
                    {
                        if (Trinity.StashRule == null && _Model.Loot.ItemFilterMode == ItemFilterMode.TrinityWithItemRules)
                        {
                            // Load interpreter for the first time if needed
                            Trinity.StashRule = new ItemRules.Interpreter();
                        }

                        _Model.CopyTo(_OriginalModel);
                        _OriginalModel.Save();

                        if (_Model.Advanced.TPSEnabled != _OriginalModel.Advanced.TPSEnabled)
                        {
                            BotManager.SetBotTicksPerSecond();
                        }

                        if (_Model.Advanced.UnstuckerEnabled != _OriginalModel.Advanced.UnstuckerEnabled)
                        {
                            BotManager.SetUnstuckProvider();
                        }

                        if (_Model.Loot.ItemFilterMode != _OriginalModel.Loot.ItemFilterMode)
                        {
                            BotManager.SetItemManagerProvider();
                        }

                        CacheData.FullClear();
                        UsedProfileManager.SetProfileInWindowTitle();

                        UILoader.CloseWindow();
                    }
                    catch (Exception ex)
                    {
                        Logger.Log("Exception in UI SaveCommand {0}", ex);
                    }
                });
                DumpBackpackCommand = new RelayCommand(
                    (parameter) =>
                {
                    try
                    {
                        Logger.Log(
                            "\n############################################\n"
                            + "\nDumping Backpack Items. This will hang your client. Please wait....\n"
                            + "##########################");
                        UILoader.CloseWindow();
                        TrinityItemManager.DumpItems(TrinityItemManager.DumpItemLocation.Backpack);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception dumping Backpack: {0}", ex);
                    }
                });
                DumpQuickItemsCommand = new RelayCommand(
                    (parameter) =>
                {
                    try
                    {
                        Logger.Log(
                            "\n############################################\n"
                            + "\nQuick Dumping Items. This will hang your client. Please wait....\n"
                            + "##########################");
                        UILoader.CloseWindow();
                        TrinityItemManager.DumpQuickItems();
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception Quick Dumping: {0}", ex);
                    }
                });
                DumpAllItemsCommand = new RelayCommand(
                    (parameter) =>
                {
                    try
                    {
                        Logger.Log(
                            "\n############################################\n"
                            + "\nDumping ALL Items. This will hang your client. Please wait....\n"
                            + "##########################");
                        UILoader.CloseWindow();
                        TrinityItemManager.DumpItems(TrinityItemManager.DumpItemLocation.All);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception Dumping ALL Items: {0}", ex);
                    }
                });
                DumpMerchantItemsCommand = new RelayCommand(
                    (parameter) =>
                {
                    try
                    {
                        Logger.Log(
                            "\n############################################\n"
                            + "\nDumping Merchant Items. This will hang your client. Please wait....\n"
                            + "##########################");
                        UILoader.CloseWindow();
                        TrinityItemManager.DumpItems(TrinityItemManager.DumpItemLocation.Merchant);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception dumping Merchant: {0}", ex);
                    }
                });
                DumpEquippedCommand = new RelayCommand(
                    (parameter) =>
                {
                    try
                    {
                        Logger.Log(
                            "\n############################################\n"
                            + "\nDumping Equipped Items. This will hang your client. Please wait....\n"
                            + "##########################");
                        UILoader.CloseWindow();
                        TrinityItemManager.DumpItems(TrinityItemManager.DumpItemLocation.Equipped);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception dumping Equipped: {0}", ex);
                    }
                });
                DumpGroundItemsCommand = new RelayCommand(
                    (parameter) =>
                {
                    try
                    {
                        Logger.Log(
                            "\n############################################\n"
                            + "\nDumping Ground Items. This will hang your client. Please wait....\n"
                            + "##########################");
                        UILoader.CloseWindow();
                        TrinityItemManager.DumpItems(TrinityItemManager.DumpItemLocation.Ground);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception dumping Ground: {0}", ex);
                    }
                });
                DumpStashCommand = new RelayCommand(
                    (parameter) =>
                {
                    try
                    {
                        Logger.Log(
                            "\n############################################\n"
                            + "\nDumping Stash Items. This will hang your client. Please wait....\n"
                            + "##########################");
                        UILoader.CloseWindow();
                        TrinityItemManager.DumpItems(TrinityItemManager.DumpItemLocation.Stash);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception dumping Stash: {0}", ex);
                    }
                });
                TestScoreCommand = new RelayCommand(
                    (parameter) =>
                {
                    try
                    {
                        Trinity.TestScoring();
                        //UILoader.CloseWindow();
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "{0}", ex);
                    }
                });
                OrderStashCommand = new RelayCommand(
                    (parameter) =>
                {
                    try
                    {
                        //TownRun.SortStash();
                        UILoader.CloseWindow();
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "{0}", ex);
                    }
                });
                HelpLinkCommand = new RelayCommand(
                    (parameter) =>
                {
                    string link = parameter as string;
                    if (!string.IsNullOrWhiteSpace(link))
                    {
                        Process.Start(link);
                    }
                });
                ConfigureLootToHunting = new RelayCommand(
                    (parameter) =>
                {
                    ConfigHuntingLoot();
                });
                ConfigureLootToQuesting = new RelayCommand(
                    (parameter) =>
                {
                    ConfigQuestingLoot();
                });
                LoadItemRuleSetCommand = new RelayCommand(
                    (parameter) =>
                {
                    try
                    {
                        LoadItemRulesPath();
                    }
                    catch (Exception ex)
                    {
                        Logger.Log("Exception in LoadItemRuleSetCommand: {0}", ex);
                    }
                });
                OpenTVarsCommand = new RelayCommand(
                    (parameter) =>
                {
                    try
                    {
                        V.ValidateLoad();
                        TVarsViewModel.CreateWindow().Show();
                    }
                    catch (Exception ex)
                    {
                        Logger.Log("Exception in OpenTVarsCommand: {0}", ex);
                    }
                });
                UseGlobalConfigFileCommand = new RelayCommand(
                    (parameter) =>
                {
                    DialogResult rusure = MessageBox.Show("This will force all bots running under this Demonbuddy directory to use a shared configuration file.\n"
                                                          + "You can undo this by removing the Trinity.xml file under your Demonbuddy settings directory. \n"
                                                          + "Are you sure?",
                                                          "Confirm global settings",
                                                          MessageBoxButtons.OKCancel);

                    if (rusure == DialogResult.OK)
                    {
                        Trinity.Settings.Save(true);
                    }
                });
                DumpSkillsCommand = new RelayCommand(
                    (parameter) =>
                {
                    PlayerInfoCache.DumpPlayerSkills();

                    UILoader.CloseWindow();
                });
            }
            catch (Exception ex)
            {
                Logger.LogError("Error creating Trinity View Model {0}", ex);
            }
        }
コード例 #3
0
ファイル: Extensions.cs プロジェクト: shmilyzxt/db-plugins
 public static TrinityItemType GetTrinityItemType(this ACDItem item)
 {
     return(TrinityItemManager.DetermineItemType(item));
 }
コード例 #4
0
        public static async Task <bool> RecipeBotRunner()
        {
            if (!ZetaDia.IsInTown)
            {
                return(false);
            }

            // For Smith plans, move to blacksmith
            // Use Item if not already known
            if (HasSmithPlans && Forge != null && UIElements.SalvageWindow.IsVisible)
            {
                ZetaDia.Me.Inventory.UseItem(BackPackSmithPlans.FirstOrDefault().DynamicId);
                return(true);
            }
            // Open Blacksmith window
            if (HasSmithPlans && Forge != null && !UIElements.SalvageWindow.IsVisible)
            {
                if (Forge.Distance > 10f)
                {
                    var moveResult = await CommonCoroutines.MoveAndStop(Forge.Position, 10f, "Forge Location");

                    if (moveResult == MoveResult.ReachedDestination)
                    {
                        return(false);
                    }
                }
                else
                {
                    Forge.Interact();
                    return(true);
                }
            }

            // Upgrade Blacksmith to max.. not sure if we can do that?
            // If already known: Move to Vendor
            // Sell Item

            // For Jeweler plans
            // Move to Jeweler
            // Open Window
            // Upgrade Jeweler to max
            // Use Item if not already known
            // If already Known: move to vendor
            // Sell Item

            if (await MoveToAndOpenStash())
            {
                return(true);
            }

            // Couldn't move to stash, something derpd?
            if (Stash == null)
            {
                return(false);
            }

            // Transfer Plans to backpack until pack full
            while (UIElements.StashWindow.IsVisible && TrinityItemManager.FindValidBackpackLocation(false) != TrinityItemManager.NoFreeSlot)
            {
                ZetaDia.Me.Inventory.QuickWithdraw(FirstStashPlan);
            }


            return(false);
        }
コード例 #5
0
ファイル: TownRun.cs プロジェクト: shmilyzxt/db-plugins
        /// <summary>
        ///     TownRunCheckOverlord - determine if we should do a town-run or not
        /// </summary>
        /// <param name="ret"></param>
        /// <returns></returns>
        internal static bool TownRunCanRun(object ret)
        {
            try
            {
                using (new PerformanceLogger("TownRunOverlord"))
                {
                    if (ZetaDia.Me == null || !ZetaDia.Me.IsValid)
                    {
                        return(false);
                    }

                    Trinity.WantToTownRun = false;

                    if (Trinity.Player.IsDead)
                    {
                        return(false);
                    }

                    // Check if we should be forcing a town-run
                    if (Trinity.ForceVendorRunASAP || BrainBehavior.IsVendoring)
                    {
                        if (!LastTownRunCheckResult)
                        {
                            if (BrainBehavior.IsVendoring)
                            {
                                Logger.Log("Looks like we are being asked to force a town-run by a profile/plugin/new DB feature, now doing so.");
                            }
                        }
                        SetPreTownRunPosition();
                        Trinity.WantToTownRun = true;
                    }

                    // Time safety switch for more advanced town-run checking to prevent CPU spam
                    if (DateTime.UtcNow.Subtract(LastCheckBackpackDurability).TotalSeconds > 6)
                    {
                        LastCheckBackpackDurability = DateTime.UtcNow;

                        // Check for no space in backpack
                        if (!Trinity.Player.ParticipatingInTieredLootRun)
                        {
                            Vector2 validLocation = TrinityItemManager.FindValidBackpackLocation(true);
                            if (validLocation.X < 0 || validLocation.Y < 0)
                            {
                                Logger.Log("No more space to pickup a 2-slot item, now running town-run routine. (TownRun)");
                                if (!LastTownRunCheckResult)
                                {
                                    LastTownRunCheckResult = true;
                                }
                                Trinity.WantToTownRun = true;

                                Trinity.ForceVendorRunASAP = true;
                                // Record the first position when we run out of bag space, so we can return later
                                SetPreTownRunPosition();
                            }
                        }
                        if (ZetaDia.Me.IsValid)
                        {
                            List <ACDItem> equippedItems = ZetaDia.Me.Inventory.Equipped.Where(i => i.DurabilityMax > 0 && i.DurabilityCurrent != i.DurabilityMax).ToList();
                            if (equippedItems.Any())
                            {
                                double min       = equippedItems.Average(i => i.DurabilityPercent);
                                var    dbsetting = CharacterSettings.Instance.RepairWhenDurabilityBelow;

                                float threshold   = Trinity.Player.IsInTown ? Math.Min(0.50f, dbsetting) : dbsetting;
                                bool  needsRepair = min <= threshold;

                                if (needsRepair)
                                {
                                    Logger.Log("Items may need repair, now running town-run routine.");

                                    Trinity.WantToTownRun      = true;
                                    Trinity.ForceVendorRunASAP = true;
                                    SetPreTownRunPosition();
                                }
                            }
                        }
                    }

                    if (ErrorDialog.IsVisible)
                    {
                        Trinity.WantToTownRun = false;
                    }

                    LastTownRunCheckResult = Trinity.WantToTownRun;

                    // Clear blacklists to triple check any potential targets
                    if (Trinity.WantToTownRun)
                    {
                        Trinity.Blacklist1Second   = new HashSet <int>();
                        Trinity.Blacklist3Seconds  = new HashSet <int>();
                        Trinity.Blacklist15Seconds = new HashSet <int>();
                        Trinity.Blacklist60Seconds = new HashSet <int>();
                        Trinity.Blacklist90Seconds = new HashSet <int>();
                    }

                    // Fix for A1 new game with bags full
                    if (Trinity.Player.LevelAreaId == 19947 && ZetaDia.CurrentQuest.QuestSNO == 87700)
                    {
                        Logger.Log(TrinityLogLevel.Verbose, LogCategory.UserInformation, "Can't townrun with the current quest!");
                        Trinity.WantToTownRun = false;
                    }

                    if (Trinity.WantToTownRun && !(BrainBehavior.IsVendoring || Trinity.Player.IsInTown))
                    {
                        string cantUseTPreason;
                        if (!ZetaDia.Me.CanUseTownPortal(out cantUseTPreason) && !ZetaDia.IsInTown)
                        {
                            Logger.Log(TrinityLogLevel.Verbose, LogCategory.UserInformation, "It appears we need to town run but can't: {0}", cantUseTPreason);
                            Trinity.WantToTownRun = false;
                        }
                    }


                    if (Trinity.WantToTownRun && DataDictionary.BossLevelAreaIDs.Contains(Trinity.Player.LevelAreaId))
                    {
                        Logger.Log(TrinityLogLevel.Debug, LogCategory.GlobalHandler, "Unable to Town Portal - Boss Area!");
                        return(false);
                    }
                    if (Trinity.WantToTownRun && ZetaDia.IsInTown && DeathHandler.EquipmentNeedsEmergencyRepair())
                    {
                        Logger.Log(TrinityLogLevel.Debug, LogCategory.GlobalHandler, "EquipmentNeedsEmergencyRepair!");
                        return(true);
                    }
                    if (Trinity.WantToTownRun && Trinity.CurrentTarget != null)
                    {
                        TownRunCheckTimer.Restart();
                        Logger.Log(TrinityLogLevel.Debug, LogCategory.GlobalHandler, "Restarting TownRunCheckTimer, we have a target!");
                        return(false);
                    }

                    if (Trinity.WantToTownRun && DataDictionary.NeverTownPortalLevelAreaIds.Contains(Trinity.Player.LevelAreaId))
                    {
                        Logger.Log(TrinityLogLevel.Debug, LogCategory.GlobalHandler, "Unable to Town Portal in this area!");
                        return(false);
                    }
                    if (Trinity.WantToTownRun && (TownRunTimerFinished() || BrainBehavior.IsVendoring))
                    {
                        //Logger.Log(TrinityLogLevel.Verbose, LogCategory.UserInformation, "Town run timer finished {0} or in town {1} or is vendoring {2} (TownRun)",
                        //    TownRunTimerFinished(), Trinity.Player.IsInTown, BrainBehavior.IsVendoring);
                        Trinity.WantToTownRun = false;
                        return(true);
                    }
                    if (Trinity.WantToTownRun && !TownRunCheckTimer.IsRunning)
                    {
                        Logger.Log(TrinityLogLevel.Verbose, LogCategory.UserInformation, "Starting town run timer");
                        TownRunCheckTimer.Start();
                        _loggedAnythingThisStash = false;
                        _loggedJunkThisStash     = false;
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError("Error Getting TownRun {0}", ex.Message);
                return(false);
            }
        }