Exemplo n.º 1
0
        public static bool ShouldDrop(TrinityItem i)
        {
            if (Cache.ContainsKey(i.AnnId))
            {
                return(Cache[i.AnnId]);
            }

            if (i.IsProtected())
            {
                return(false);
            }

            var action = ItemEvaluationType.Keep;

            if (StashItems.ShouldStash(i))
            {
                action = ItemEvaluationType.Keep;
            }
            else if (SellItems.ShouldSell(i))
            {
                action = ItemEvaluationType.Sell;
            }
            else if (SalvageItems.ShouldSalvage(i))
            {
                action = ItemEvaluationType.Salvage;
            }

            var decision = Combat.TrinityCombat.Loot.ShouldDrop(i, action) && !i.IsAccountBound;

            Cache.Add(i.AnnId, decision);
            return(decision);
        }
Exemplo n.º 2
0
        public static bool ShouldSalvage(TrinityItem i)
        {
            if (!i.IsValid)
            {
                return(false);
            }

            if (Core.Player.IsInventoryLockedForGreaterRift)
            {
                return(false);
            }

            if (Cache.ContainsKey(i.AnnId))
            {
                return(Cache[i.AnnId]);
            }

            if (i.IsProtected())
            {
                return(false);
            }

            if (i.IsUnidentified)
            {
                return(false);
            }

            if (!i.IsSalvageable)
            {
                return(false);
            }

            var decision = Combat.TrinityCombat.Loot.ShouldSalvage(i) && !StashItems.ShouldStash(i);

            Cache.Add(i.AnnId, decision);
            return(decision);
        }
Exemplo n.º 3
0
        public static async Task <bool> Execute()
        {
            try
            {
                if (!ZetaDia.IsInGame)
                {
                    return(false);
                }

                if (await ClearArea.Execute())
                {
                    Core.Logger.Debug("Clearing");
                    return(false);
                }

                CheckForDBVendoringBug();

                if (DateTime.UtcNow < DontAttemptTownRunUntil)
                {
                    IsVendoring = false;
                    return(false);
                }

                // Fix for Campaign quest start of ACT1
                if (ZetaDia.CurrentQuest.QuestSnoId == 87700)
                {
                    return(false);
                }

                if (Core.CastStatus.StoneOfRecall.LastResult == CastResult.Casting)
                {
                    Core.Logger.Verbose(LogCategory.GlobalHandler, "Casting");
                    return(true);
                }

                if (!ShouldStartTownRun())
                {
                    IsVendoring = false;
                    return(false);
                }

                IsWantingTownRun = true;

                Core.Logger.Debug("Town run started");

                if (ZetaDia.Globals.IsLoadingWorld)
                {
                    return(true);
                }

                if (!ZetaDia.IsInTown)
                {
                    if (ZetaDia.Me.IsInCombat && !ClearArea.IsClearing && ZetaDia.Actors.GetActorsOfType <DiaUnit>().Any(u => u?.CommonData != null && u.CommonData.IsValid && u.IsAlive && u.IsHostile && u.Distance < 16f))
                    {
                        ClearArea.Start();
                    }

                    await GoToTown();

                    if (!ZetaDia.IsInTown)
                    {
                        if (Core.CastStatus.StoneOfRecall.LastResult == CastResult.Failed)
                        {
                            Core.Logger.Debug("Setting Town Run Cooldown because of cast failure");
                            DontAttemptTownRunUntil = DateTime.UtcNow.AddSeconds(5);
                        }
                        return(true);
                    }
                }

                Core.Logger.Verbose($"Starting Townrun");

                IsInTownVendoring = true;

                while (DateTime.UtcNow.Subtract(ChangeEvents.WorldId.LastChanged).TotalMilliseconds < 2000 || ZetaDia.Globals.IsLoadingWorld || ZetaDia.Globals.WorldSnoId <= 0)
                {
                    await Coroutine.Yield();
                }

                await Coroutine.Wait(8000, () => Core.Actors.Inventory.Any());

                await Coroutine.Yield();

                Core.Actors.Update();
                Core.Player.Update();
                await Coroutine.Sleep(1000);

                Core.Logger.Debug("Started Town Run Loop");

                var checkCycles = 2;

                while (!Core.Player.IsInventoryLockedForGreaterRift)
                {
                    Core.Inventory.Backpack.ForEach(i => Core.Logger.Debug($"Backpack Item: {i.Name} ({i.ActorSnoId} / {i.InternalName}) RawItemType={i.RawItemType} TrinityItemType={i.TrinityItemType}"));

                    await Coroutine.Yield();

                    GameUI.CloseVendorWindow();
                    await IdentifyItems.Execute();

                    if (!ZetaDia.IsInGame)
                    {
                        StartedOutOfTown  = false;
                        IsWantingTownRun  = false;
                        IsInTownVendoring = false;
                        IsVendoring       = false;
                        return(false);
                    }

                    if (!await ExtractLegendaryPowers.Execute())
                    {
                        continue;
                    }

                    if (!await Gamble.Execute())
                    {
                        continue;
                    }

                    if (!await CubeRaresToLegendary.Execute())
                    {
                        continue;
                    }

                    if (!await CubeItemsToMaterials.Execute())
                    {
                        continue;
                    }

                    if (await Any(
                            DropItems.Execute,
                            () => StashItems.Execute(true),
                            SellItems.Execute,
                            SalvageItems.Execute))
                    {
                        continue;
                    }

                    checkCycles--;
                    if (checkCycles == 0)
                    {
                        break;
                    }
                }

                await StashItems.Execute();

                await RepairItems.Execute();

                Core.Logger.Log("Finished Town Run woo!");
                DontAttemptTownRunUntil = DateTime.UtcNow + TimeSpan.FromSeconds(15);

                if (StartedOutOfTown)
                {
                    StartedOutOfTown = false;
                    await TakeReturnPortal();
                }
            }
            finally
            {
                IsWantingTownRun  = false;
                IsInTownVendoring = false;
                IsVendoring       = false;
            }
            return(false);
        }