private static async Task <bool> Resurrect(bool toCheckpoint, int attempts = 3) { GlobalLog.Debug($"[Resurrect] Now going to resurrect to {(toCheckpoint ? "checkpoint" : "town")}."); if (!await Wait.For(() => LokiPoe.InGameState.ResurrectPanel.IsOpened, "ResurrectPanel opening")) { return(false); } await Wait.SleepSafe(100); if (Settings.Instance.ArtificialDelays) { await Wait.ArtificialDelay(); } for (int i = 1; i <= attempts; ++i) { GlobalLog.Debug($"[Resurrect] Attempt: {i}/{attempts}"); if (!LokiPoe.IsInGame) { GlobalLog.Debug("[Resurrect] Now exiting this logic because we are no longer in game."); return(true); } if (!LokiPoe.Me.IsDead) { GlobalLog.Debug("[Resurrect] Now exiting this logic because we are no longer dead."); return(true); } var err = toCheckpoint ? LokiPoe.InGameState.ResurrectPanel.ResurrectToCheckPoint() : LokiPoe.InGameState.ResurrectPanel.ResurrectToTown(); if (err == LokiPoe.InGameState.ResurrectResult.None) { if (!await Wait.For(AliveInGame, "resurrection", 200, 5000)) { continue; } GlobalLog.Debug("[Resurrect] Player has been successfully resurrected."); await Wait.SleepSafe(250); return(true); } GlobalLog.Error($"[Resurrect] Fail to resurrect. Error: \"{err}\"."); await Wait.SleepSafe(1000, 1500); } GlobalLog.Error("[Resurrect] All resurrection attempts have been spent."); return(false); }
public async Task <bool> Run() { var mode = LokiPoe.InGameState.CursorItemOverlay.Mode; if (mode == LokiPoe.InGameState.CursorItemModes.VirtualMove || mode == LokiPoe.InGameState.CursorItemModes.VirtualUse) { GlobalLog.Error("[ClearCursorTask] A virtual item is on the cursor. Now pressing Escape to clear it."); LokiPoe.Input.SimulateKeyEvent(Keys.Escape, true, false, false); await Wait.LatencySleep(); await Wait.ArtificialDelay(); return(true); } if (mode == LokiPoe.InGameState.CursorItemModes.None) { return(false); } var cursorItem = LokiPoe.InGameState.CursorItemOverlay.Item; if (cursorItem == null) { GlobalLog.Error($"[ClearCursorTask] Unexpected error. Cursor mode = \"{mode}\", but there is no item under cursor."); ErrorManager.ReportError(); return(true); } GlobalLog.Error($"[ClearCursorTask] \"{cursorItem.Name}\" is under cursor. Now going to place it into inventory."); if (!await Inventories.OpenInventory()) { ErrorManager.ReportError(); return(true); } if (!LokiPoe.InGameState.InventoryUi.InventoryControl_Main.Inventory.CanFitItem(cursorItem.Size, out int col, out int row)) { GlobalLog.Error("[ClearCursorTask] There is no space in main inventory. Now stopping the bot because it cannot continue."); BotManager.Stop(); return(true); } if (!await LokiPoe.InGameState.InventoryUi.InventoryControl_Main.PlaceItemFromCursor(new Vector2i(col, row))) { ErrorManager.ReportError(); } return(true); }
private static async Task <bool> TakeCards() { if (!await Inventories.OpenStashTab(_tabWithCardSet)) { return(false); } if (StashUi.StashTabInfo.IsPremiumDivination) { using (new InputDelayOverride(10)) { while (true) { var cardCount = CardCountInInventory; if (cardCount >= Settings.MaxCardSets) { GlobalLog.Warn("[TakeCards] Max card sets per run has been reached."); return(true); } var control = StashUi.DivinationTab.Ordered.FirstOrDefault(c => CardSetsInControl(c) > 0); if (control == null) { _tabWithCardSet = null; return(true); } var cardName = control.CustomTabItem.Name; GlobalLog.Info($"[TakeCards] Now taking \"{cardName}\"."); var moved = StashUi.DivinationTab.Withdraw((i, u) => i.Name == cardName); if (moved != FastMoveResult.None) { GlobalLog.Error($"[TakeCards] Fail to withdraw a card set from Divination Stash Tab. Error: \"{moved}\"."); return(false); } if (!await Wait.For(() => CardCountInInventory > cardCount, "cards appear in inventory")) { return(false); } if (Settings.ArtificialDelays) { await Wait.ArtificialDelay(); } } } } while (true) { var cardCount = CardCountInInventory; if (cardCount >= Settings.MaxCardSets) { GlobalLog.Warn($"[TakeCards] Max card sets for exchange has been reached ({Settings.MaxCardSets})"); return(true); } var card = Inventories.StashTabItems .Where(ItemIsCardSet) .OrderBy(i => i.LocationTopLeft, Position.Comparer.Instance) .FirstOrDefault(); if (card == null) { _tabWithCardSet = null; return(true); } GlobalLog.Info($"[TakeCards] Now taking \"{card.Name}\"."); if (!await Inventories.FastMoveFromStashTab(card.LocationTopLeft)) { return(false); } if (!await Wait.For(() => CardCountInInventory > cardCount, "cards appear in inventory")) { return(false); } } }