private static async Task ProcessStrongbox() { var pos = _strongbox.Position; if (Settings.StrongboxOpenRange != -1) { if (pos.Distance > Settings.StrongboxOpenRange * AbandonDistanceMult) { GlobalLog.Debug("[OpenChestTask] Abandoning current strongbox because its too far away."); TemporaryIgnore(_strongbox.Id); _strongbox = null; return; } } if (pos.IsFar) { if (!pos.TryCome()) { GlobalLog.Error($"[OpenChestTask] Fail to move to {pos}. Marking this strongbox as unwalkable."); _strongbox.Unwalkable = true; _strongbox = null; } return; } var boxObj = _strongbox.Object; if (boxObj == null || boxObj.IsOpened || boxObj.IsLocked) { CombatAreaCache.Current.Strongboxes.Remove(_strongbox); _strongbox = null; return; } var attempts = ++_strongbox.InteractionAttempts; if (attempts > MaxStrongboxAttempts) { GlobalLog.Error("[OpenChestTask] All attempts to open a strongbox have been spent. Now ignoring it."); _strongbox.Ignored = true; _strongbox = null; return; } if (await PlayerAction.Interact(boxObj)) { await Wait.LatencySleep(); if (await Wait.For(() => boxObj.IsLocked, "strongbox opening", 100, 400)) { CombatAreaCache.Current.Strongboxes.Remove(_strongbox); _strongbox = null; } return; } await Wait.SleepSafe(400); }
public MessageResult Message(Message message) { if (message.Id == Events.Messages.AreaChanged) { _chest = null; _specialChest = null; _strongbox = null; _shrine = null; TemporaryIgnoredObjects.Clear(); return(MessageResult.Processed); } return(MessageResult.Unprocessed); }
public void Tick() { if (!LokiPoe.IsInGame || !TickInterval.Elapsed) { return; } if (_chest != null) { var chestObj = _chest.Object as Chest; if (chestObj != null && chestObj.IsOpened) { CombatAreaCache.Current.Chests.Remove(_chest); _chest = null; } } if (_strongbox != null) { var boxObj = _strongbox.Object; if (boxObj != null && (boxObj.IsOpened || boxObj.IsLocked)) { CombatAreaCache.Current.Strongboxes.Remove(_strongbox); _strongbox = null; } } if (_shrine != null) { var shrineObj = _shrine.Object as Shrine; if (shrineObj != null && shrineObj.IsDeactivated) { CombatAreaCache.Current.Shrines.Remove(_shrine); _shrine = null; } } if (_specialChest != null) { var chestObj = _specialChest.Object as Chest; if (chestObj != null && chestObj.IsOpened) { CombatAreaCache.Current.SpecialChests.Remove(_specialChest); _specialChest = null; } } }
public async Task <bool> Run() { if (!World.CurrentArea.IsCombatArea) { return(false); } var cache = CombatAreaCache.Current; if (Settings.ChestOpenRange != 0) { if (_chest != null) { await ProcessChest(); return(true); } var closestChest = cache.Chests.ClosestValid(); if (closestChest != null && ShouldOpen(closestChest, Settings.ChestOpenRange, Settings.Chests)) { _chest = closestChest; return(true); } } if (Settings.ShrineOpenRange != 0) { if (_shrine != null) { await ProcessShrine(); return(true); } var closestShrine = cache.Shrines.ClosestValid(); if (closestShrine != null && ShouldOpen(closestShrine, Settings.ShrineOpenRange, Settings.Shrines)) { _shrine = closestShrine; return(true); } } if (Settings.StrongboxOpenRange != 0) { if (_strongbox != null) { await ProcessStrongbox(); return(true); } var closestStrongbox = cache.Strongboxes.ClosestValid(); if (closestStrongbox != null && closestStrongbox.Rarity <= Settings.MaxStrongboxRarity && ShouldOpen(closestStrongbox, Settings.StrongboxOpenRange, Settings.Strongboxes)) { _strongbox = closestStrongbox; return(true); } } if (_specialChest != null) { await ProcessSpecialChest(); return(true); } var closestSpecialChest = cache.SpecialChests.ClosestValid(); if (closestSpecialChest != null) { _specialChest = closestSpecialChest; return(true); } return(false); }