public static bool CanTownRun() { if (!ZetaDia.Me.CanUseTownPortal(out var cantUseTPreason) && !ZetaDia.IsInTown) { Core.Logger.Verbose("Can't townrun because '{0}'", cantUseTPreason); DontAttemptTownRunUntil = DateTime.UtcNow + TimeSpan.FromSeconds(10); return(false); } if (Core.Player.IsDead) { return(false); } if (!RepairItems.EquipmentNeedsRepair()) { if (Core.Player.IsInventoryLockedForGreaterRift) { Core.Logger.Verbose("Can't townrun while in greater rift!"); DontAttemptTownRunUntil = DateTime.UtcNow + TimeSpan.FromSeconds(5); return(false); } // Close Greater rift before doing a town run. if (!Core.Settings.Items.KeepLegendaryUnid && Core.Player.ParticipatingInTieredLootRun) { return(false); } } if (ErrorDialog.IsVisible) { Core.Logger.Log("Can't townrun with an error dialog present!"); DontAttemptTownRunUntil = DateTime.UtcNow + TimeSpan.FromSeconds(10); return(false); } if (Core.Player.WorldSnoId == 71150 && ZetaDia.CurrentQuest.QuestSnoId == 87700 && ZetaDia.CurrentQuest.StepId == -1) { Core.Logger.Debug("Can't townrun with the current quest (A1 New Game) !"); DontAttemptTownRunUntil = DateTime.UtcNow + TimeSpan.FromSeconds(30); return(false); } if (GameData.BossLevelAreaIDs.Contains(Core.Player.LevelAreaId)) { Core.Logger.Debug("Unable to Town Portal - Boss Area!"); DontAttemptTownRunUntil = DateTime.UtcNow + TimeSpan.FromSeconds(10); return(false); } if (GameData.NeverTownPortalLevelAreaIds.Contains(Core.Player.LevelAreaId)) { Core.Logger.Log("Unable to Town Portal in this area!"); DontAttemptTownRunUntil = DateTime.UtcNow + TimeSpan.FromSeconds(10); return(false); } return(true); }
private static bool ShouldStartTownRun() { if (ZetaDia.IsInTown && BrainBehavior.IsVendoring) { return(!IsInTownVendoring); } if (!CanTownRun()) { return(false); } if (IsWantingTownRun) { Core.Logger.Debug("Is wanting to town run."); return(true); } // Close Normal rift before doing a town run. if (ZetaDia.IsInTown && !StartedOutOfTown && ZetaDia.Storage.RiftCompleted && ZetaDia.Storage.RiftStarted) { var orek = TownInfo.Orek?.GetActor() as DiaUnit; if (orek != null && orek.IsQuestGiver) { return(false); } } var validLocation = DefaultLootProvider.FindBackpackLocation(true, false); if (validLocation.X < 0 || validLocation.Y < 0) { Core.Logger.Log("No more space to pickup a 2-slot item, now running town-run routine. (TownRun)"); return(true); } var needRepair = RepairItems.EquipmentNeedsRepair(); if (needRepair) { Core.Logger.Debug("Townrun for repair."); return(true); } return(BrainBehavior.IsVendoring); }