public static async Task <bool> TpToTown(bool forceNewPortal = false, bool repeatUntilInTown = true) { if (ErrorManager.GetErrorCount("TpToTown") > 5) { GlobalLog.Debug("[TpToTown] We failed to take a portal to town more than 5 times. Now going to log out."); return(await Logout()); } GlobalLog.Debug("[TpToTown] Now going to open and take a portal to town."); var area = World.CurrentArea; if (area.IsTown || area.IsHideoutArea) { GlobalLog.Error("[TpToTown] We are already in town/hideout."); return(false); } if (!area.IsOverworldArea && !area.IsMap && !area.IsCorruptedArea && !area.IsMapRoom && !area.IsTempleOfAtzoatl) { GlobalLog.Warn($"[TpToTown] Cannot create portals in this area ({area.Name}). Now going to log out."); return(await Logout()); } Portal portal; if (forceNewPortal || (portal = PortalInRangeOf(70)) == null) { portal = await CreateTownPortal(); if (portal == null) { GlobalLog.Error("[TpToTown] Fail to create a new town portal. Now going to log out."); return(await Logout()); } } else { GlobalLog.Debug($"[TpToTown] There is a ready-to-use portal at a distance of {portal.Distance}. Now going to take it."); } if (!await TakePortal(portal)) { ErrorManager.ReportError("TpToTown"); return(false); } var newArea = World.CurrentArea; if (repeatUntilInTown && newArea.IsCombatArea) { GlobalLog.Debug($"[TpToTown] After taking a portal we appeared in another combat area ({newArea.Name}). Now calling TpToTown again."); return(await TpToTown(forceNewPortal)); } GlobalLog.Debug($"[TpToTown] We have been successfully teleported from \"{area.Name}\" to \"{newArea.Name}\"."); return(true); }
public static async Task <bool> GoToHideout() { if (Settings.Instance.UseChatForHideout && World.CurrentArea.IsTown) { if (_goToHideoutViaCommandFailSafe) { GlobalLog.Warn("[GoToHideoutViaCommand] Fail-safe enabled. Please restart the bot to use this functionality again."); return(await GoToHideoutViaWaypoint()); } return(await GoToHideoutViaCommand()); } return(await GoToHideoutViaWaypoint()); }