private static async Task <bool> KillArchitect(string type)
        {
            var arch = CachedIncursionData.Architects.Find(a => !a.Unwalkable && !a.Ignored && a.Type == type);

            if (arch == null)
            {
                return(false);
            }

            var pos = arch.Position;

            if (pos.IsFar)
            {
                if (!pos.TryCome())
                {
                    GlobalLog.Error($"[HandleIncursionTask] Fail to move to {pos}. Now marking it as unwalkable.");
                    arch.Unwalkable = true;
                }
                return(true);
            }
            var attempts = ++arch.InteractionAttempts;

            if (attempts > MaxArchitectAttempts)
            {
                GlobalLog.Error($"[HandleIncursionTask] {pos.Name} was not killed. Now ignoring it.");
                arch.Ignored = true;
                return(true);
            }
            await Coroutines.FinishCurrentAction();

            GlobalLog.Debug($"[HandleIncursionTask] Waiting for combat routine to kill the architect ({attempts}/{MaxArchitectAttempts})");
            await Wait.StuckDetectionSleep(200);

            return(true);
        }
        public async Task <bool> Run()
        {
            if (_transition == null)
            {
                return(false);
            }

            var pos = _transition.Position;

            if (pos.IsFar)
            {
                if (!pos.TryCome())
                {
                    GlobalLog.Debug("[ReturnAfterDeathTask] Transition is unwalkable. Skipping this task.");
                    _transition = null;
                }
                return(true);
            }
            var transitionObj = (AreaTransition)_transition.Object;

            if (!await PlayerAction.TakeTransition(transitionObj))
            {
                ErrorManager.ReportError();
                return(true);
            }
            _transition = null;
            return(true);
        }
        private static async Task <bool> FastMoveFromDevice(Vector2i itemPos)
        {
            var item = MapDevice.InventoryControl.Inventory.FindItemByPos(itemPos);

            if (item == null)
            {
                GlobalLog.Error($"[FastMoveFromDevice] Fail to find item at {itemPos} in Map Device.");
                return(false);
            }

            var itemName = item.FullName;

            GlobalLog.Debug($"[FastMoveFromDevice] Fast moving \"{itemName}\" at {itemPos} from Map Device.");

            var moved = MapDevice.InventoryControl.FastMove(item.LocalId);

            if (moved != FastMoveResult.None)
            {
                GlobalLog.Error($"[FastMoveFromDevice] Fast move error: \"{moved}\".");
                return(false);
            }
            if (await Wait.For(() => MapDevice.InventoryControl.Inventory.FindItemByPos(itemPos) == null, "fast move"))
            {
                GlobalLog.Debug($"[FastMoveFromDevice] \"{itemName}\" at {itemPos} has been successfully fast moved from Map Device.");
                return(true);
            }
            GlobalLog.Error($"[FastMoveFromDevice] Fast move timeout for \"{itemName}\" at {itemPos} in Map Device.");
            return(false);
        }
 private void InitNewLevel()
 {
     _levelAnchor = new WorldPosition(LokiPoe.MyPosition);
     _myLastPos   = _levelAnchor;
     _explorers.Add(_levelAnchor, CreateExplorer());
     GlobalLog.Debug($"[ComplexExplorer] Creating new level anchor {_levelAnchor}");
 }
        //items tend to stuck inside opened strongbox, this problem usually fixes itself upon area change
        private static void UnignoreStrongboxItems()
        {
            if (!World.CurrentArea.IsCombatArea)
            {
                return;
            }

            var strBox = LokiPoe.ObjectManager.Objects.FirstOrDefault <Chest>(c => c.IsStrongBox && c.IsOpened && !c.IsLocked);

            if (strBox == null)
            {
                return;
            }

            var boxPos = strBox.Position;

            foreach (var ignoredItem in CombatAreaCache.Current.Items.Where(i => i.Ignored))
            {
                var itemPos = ignoredItem.Position;
                if (itemPos.AsVector.Distance(boxPos) < 30)
                {
                    GlobalLog.Debug($"[LootItemTask] Removing ignored flag from {itemPos} because it is near opened strongbox.");
                    ignoredItem.Ignored = false;
                }
            }
        }
Exemple #6
0
        public static async Task <bool> HandleQuestObject(CachedObject cachedObj)
        {
            if (cachedObj == null)
            {
                return(false);
            }

            var objPos = cachedObj.Position;

            if (objPos.IsFar || objPos.IsFarByPath)
            {
                objPos.Come();
                return(true);
            }

            var obj  = cachedObj.Object;
            var name = obj.Name;

            if (obj.IsTargetable)
            {
                if (!await PlayerAction.Interact(obj, () => !obj.Fresh().IsTargetable, $"{name} interaction"))
                {
                    ErrorManager.ReportError();
                }
            }
            else
            {
                GlobalLog.Debug($"{name} is not targetable. Waiting for quest progress.");
                await Wait.StuckDetectionSleep(500);
            }
            return(true);
        }
Exemple #7
0
        private static async Task <bool> OpenExchangeUi()
        {
            var npc = GetCardExchangeNpc();

            if (npc == null)
            {
                return(false);
            }

            if (!await npc.OpenDialogPanel())
            {
                return(false);
            }

            var conversed = LokiPoe.InGameState.NpcDialogUi.Converse("Trade Divination Cards");

            if (conversed != LokiPoe.InGameState.ConverseResult.None)
            {
                GlobalLog.Error($"[OpenExchangeUi] Fail to converse \"Trade Divination Cards\". Error: \"{conversed}\".");
                return(false);
            }
            if (await Wait.For(() => ExchangeUi.IsOpened, "ExchangeUi opening"))
            {
                GlobalLog.Debug("[OpenExchangeUi] ExchangeUi has been successfully opened.");
                return(true);
            }
            return(false);
        }
Exemple #8
0
        public void ExeUpdateSQL(ICollection <String> sqls)
        {
            string lastSql = null;

            try
            {
                conn.Open();
                DbTransaction trans = conn.BeginTransaction();
                foreach (String sql in sqls)
                {
                    lastSql = sql;
                    DbCommand command = conn.CreateCommand();
                    command.CommandText = sql;
                    command.Transaction = trans;
                    LogSQL(sql);
                    command.ExecuteNonQuery();
                }
                trans.Commit();
            }
            catch (Exception e)
            {
                GlobalLog.Debug(string.Format("{0} \r\n{1}", lastSql, e.Message));
                throw e;
            }
            finally
            {
                close();
            }
        }
        private bool SkipThisTransition(AreaTransition t)
        {
            var name = t.Name;

            if (name == "Area Transition" && t.Destination == null)
            {
                GlobalLog.Debug($"[CombatAreaCache] Skipping dummy area transition (id: {t.Id})");
                return(true);
            }

            if (t.TransitionType == TransitionTypes.Local && !t.Metadata.Contains("IncursionPortal"))
            {
                if (WorldArea.Name == MapNames.Caldera && name != "Caldera of The King")
                {
                    GlobalLog.Debug($"[CombatAreaCache] Skipping \"{name}\" area transition because it leads to the same level.");
                    return(true);
                }
                if (WorldArea.Id == World.Act9.RottingCore.Id)
                {
                    var metadata = t.Metadata;
                    if (metadata == "Metadata/QuestObjects/Act9/HarvestFinalBossTransition")
                    {
                        GlobalLog.Debug($"[CombatAreaCache] Skipping \"{name}\" area transition because it is unlocked by a quest.");
                        return(true);
                    }
                    if (metadata.Contains("BellyArenaTransition"))
                    {
                        GlobalLog.Debug($"[CombatAreaCache] Skipping \"{name}\" area transition because it is not a pathfinding obstacle.");
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemple #10
0
        public static void Tick()
        {
            foreach (var obj in LokiPoe.ObjectManager.Objects)
            {
                if (!(obj is Npc npc) || npc.Name == "Navali")
                {
                    continue;
                }

                var id     = npc.Id;
                var cached = Npcs.Find(n => n.Id == id);

                if (npc.HasNpcFloatingIcon)
                {
                    if (cached == null)
                    {
                        var pos = npc.WalkablePosition(5, 20);
                        Npcs.Add(new CachedObject(id, pos));
                        GlobalLog.Debug($"[TalkToQuestgivers] Adding \"{npc.Name}\" to the talk list.");
                    }
                }
                else
                {
                    if (cached != null)
                    {
                        GlobalLog.Debug($"[TalkToQuestgivers] Removing \"{npc.Name}\" from the talk list.");
                        if (cached == _current)
                        {
                            _current = null;
                        }
                        Npcs.Remove(cached);
                    }
                }
            }
        }
        private static async Task <bool> Logout(int attempts = 5)
        {
            for (int i = 1; i <= attempts; ++i)
            {
                GlobalLog.Debug($"[Logout] Attempt: {i}/{attempts}");

                if (!LokiPoe.IsInGame)
                {
                    GlobalLog.Debug("[Logout] Now exiting this logic because we are no longer in game.");
                    return(true);
                }
                if (!LokiPoe.Me.IsDead)
                {
                    GlobalLog.Debug("[Logout] Now exiting this logic because we are no longer dead.");
                    return(true);
                }

                var err = LokiPoe.EscapeState.LogoutToTitleScreen();
                if (err == LokiPoe.EscapeState.LogoutError.None)
                {
                    if (!await Wait.For(() => LokiPoe.IsInLoginScreen, "log out", 200, 5000))
                    {
                        continue;
                    }

                    GlobalLog.Debug("[Logout] Player has been successfully logged out.");
                    return(true);
                }
                GlobalLog.Error($"[Logout] Fail to log out. Error: \"{err}\".");
                await Wait.SleepSafe(2000, 3000);
            }
            GlobalLog.Error("[Logout] All logout attempts have been spent.");
            return(false);
        }
Exemple #12
0
        private static async Task <bool> OpenBanditPanel(NetworkObject bandit)
        {
            if (LokiPoe.InGameState.BanditPanel.IsOpened)
            {
                return(true);
            }

            if (!await PlayerAction.Interact(bandit))
            {
                return(false);
            }

            const int maxAttempts = 10;

            for (int i = 1; i <= maxAttempts; ++i)
            {
                if (LokiPoe.InGameState.BanditPanel.IsOpened)
                {
                    return(true);
                }

                GlobalLog.Debug($"[OpenBanditPanel] Pressing ESC to close the topmost NPC dialog ({i}/{maxAttempts}).");
                LokiPoe.Input.SimulateKeyEvent(Keys.Escape, true, false, false);
                await Wait.SleepSafe(500);
            }
            GlobalLog.Error("[OpenBanditPanel] All attempts have been spent.");
            return(false);
        }
Exemple #13
0
        public static async Task <bool> EnterPrison()
        {
            if (World.Act1.Climb.IsCurrentArea)
            {
                var navali = Navali;
                if (navali != null)
                {
                    if (!navali.IsTargetable)
                    {
                        var navaliPos = navali.WalkablePosition();
                        if (navaliPos.IsFar)
                        {
                            navaliPos.Come();
                            return(true);
                        }
                        var cage = NavaliCage;
                        if (cage == null)
                        {
                            GlobalLog.Debug("We are near Navali but Cage object is null.");
                            await Wait.StuckDetectionSleep(500);

                            return(true);
                        }
                        if (cage.IsTargetable)
                        {
                            if (!await PlayerAction.Interact(cage, () => !cage.Fresh().IsTargetable, "Navali Cage opening", 5000))
                            {
                                ErrorManager.ReportError();
                            }
                        }
                        GlobalLog.Debug("Waiting for Navali");
                        await Wait.StuckDetectionSleep(200);

                        return(true);
                    }
                    if (navali.HasNpcFloatingIcon)
                    {
                        var navaliPos = navali.WalkablePosition();
                        if (navaliPos.IsFar)
                        {
                            navaliPos.Come();
                        }
                        else
                        {
                            await Helpers.TalkTo(navali);
                        }
                        return(true);
                    }
                }
            }

            if (World.Act1.LowerPrison.IsCurrentArea)
            {
                return(false);
            }

            await Travel.To(World.Act1.LowerPrison);

            return(true);
        }
Exemple #14
0
        private static void FinishGridning()
        {
            var bot = BotManager.Current;

            if (!bot.Name.Contains("QuestBot"))
            {
                return;
            }

            var msg = new Message("QB_get_current_quest");

            if (bot.Message(msg) != MessageResult.Processed)
            {
                GlobalLog.Debug("[EnterIncursionTask] \"QB_get_current_quest\" message was not processed.");
                return;
            }

            var questName = msg.GetOutput <string>();

            if (questName != "Grinding")
            {
                return;
            }

            msg = new Message("QB_finish_grinding");
            if (bot.Message(msg) != MessageResult.Processed)
            {
                GlobalLog.Debug("[EnterIncursionTask] \"QB_finish_grinding\" message was not processed.");
            }
        }
Exemple #15
0
        private static async Task ProcessChest()
        {
            var pos = _chest.Position;

            if (Settings.ChestOpenRange != -1)
            {
                //stop processing if other logic (combat/looting) moved us too far away from current chest
                //checking path distance is not an option because chest's position could be unwalkable
                if (pos.Distance > Settings.ChestOpenRange * AbandonDistanceMult)
                {
                    GlobalLog.Debug("[OpenChestTask] Abandoning current chest because its too far away.");

                    //we should ignore it for some time to prevent back and forth loop
                    TemporaryIgnore(_chest.Id);
                    _chest = null;
                    return;
                }
            }

            if (pos.IsFar)
            {
                if (!pos.TryCome())
                {
                    GlobalLog.Error($"[OpenChestTask] Fail to move to {pos}. Marking this chest as unwalkable.");
                    _chest.Unwalkable = true;
                    _chest            = null;
                }
                return;
            }
            var chestObj = _chest.Object as Chest;

            if (chestObj == null || chestObj.IsOpened)
            {
                CombatAreaCache.Current.Chests.Remove(_chest);
                _chest = null;
                return;
            }
            var attempts = ++_chest.InteractionAttempts;

            if (attempts > MaxChestAttempts)
            {
                GlobalLog.Error("[OpenChestTask] All attempts to open a chest have been spent. Now ignoring it.");
                _chest.Ignored = true;
                _chest         = null;
                return;
            }
            if (await PlayerAction.Interact(chestObj))
            {
                await Wait.LatencySleep();

                if (await Wait.For(() => chestObj.IsOpened, "chest opening", 50, 300))
                {
                    CombatAreaCache.Current.Chests.Remove(_chest);
                    _chest = null;
                }
                return;
            }
            await Wait.SleepSafe(300);
        }
Exemple #16
0
 public virtual bool Initialize()
 {
     if (!FindWalkable())
     {
         GlobalLog.Debug($"[WalkablePosition] Fail to find any walkable position for {this}");
         return(false);
     }
     Initialized = true;
     return(true);
 }
Exemple #17
0
        private static bool HasCurrency(string name)
        {
            if (AvailableCurrency[name])
            {
                return(true);
            }

            GlobalLog.Debug($"[TakeMapTask] HasCurrency is false for {name}.");
            return(false);
        }
Exemple #18
0
        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);
        }
        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);
        }
Exemple #20
0
 public static async Task MoveAndWait(WalkablePosition pos, string log = null, int distance = 20)
 {
     if (pos.Distance > distance)
     {
         pos.Come();
     }
     else
     {
         GlobalLog.Debug(log ?? $"Waiting for {pos.Name}");
         await Wait.StuckDetectionSleep(200);
     }
 }
        private static async Task <bool> MoveAway(int min, int max)
        {
            var pos = WorldPosition.FindPathablePositionAtDistance(min, max, 5);

            if (pos == null)
            {
                GlobalLog.Debug("[LootItemTask] Fail to find any pathable position at distance.");
                return(false);
            }
            await Move.AtOnce(pos, "distant position", 10);

            return(true);
        }
        private static async Task EnterCorruptedArea(CachedTransition transition)
        {
            var pos = transition.Position;

            if (pos.IsFar)
            {
                if (!pos.TryCome())
                {
                    GlobalLog.Debug($"[CorruptedAreaTask] Fail to move to {pos}. Marking this transition as unwalkable.");
                    transition.Unwalkable = true;
                }
                return;
            }
            var transitionObj = transition.Object;

            if (transitionObj == null)
            {
                GlobalLog.Error("[CorruptedAreaTask] Unexpected error. Transition object is null.");
                transition.Ignored = true;
                return;
            }
            var attempts = ++transition.InteractionAttempts;

            if (attempts > 5)
            {
                GlobalLog.Error("[CorruptedAreaTask] All attempts to enter corrupted area transition have been spent. Now ignoring it.");
                transition.Ignored = true;
                return;
            }
            if (!transitionObj.IsTargetable)
            {
                var blockage = TransitionBlockage;
                if (blockage != null)
                {
                    await PlayerAction.Interact(blockage, () => transitionObj.Fresh().IsTargetable, "transition become targetable");
                }
                else
                {
                    GlobalLog.Error("[CorruptedAreaTask] Unexpected error. Transition object is untargetable.");
                    transition.Ignored = true;
                }
                return;
            }

            _lastEnteredTransition = transition;

            if (!await PlayerAction.TakeTransition(transitionObj))
            {
                await Wait.SleepSafe(500);
            }
        }
        private void ProcessTransition(AreaTransition t)
        {
            var id = t.Id;

            if (_processedObjects.Contains(id))
            {
                return;
            }

            if (SkipThisTransition(t))
            {
                _processedObjects.Add(id);
                return;
            }

            TransitionType type;

            if (t.Metadata.Contains("LabyrinthTrial"))
            {
                type = TransitionType.Trial;
            }
            else if (t.Metadata.Contains("IncursionPortal"))
            {
                type = TransitionType.Incursion;
            }
            else if (t.ExplicitAffixes.Any(a => a.Category == "MapMissionMods"))
            {
                type = TransitionType.Master;
            }
            else if (t.ExplicitAffixes.Any(a => a.InternalName.Contains("CorruptedSideArea")))
            {
                type = TransitionType.Vaal;
            }
            else if (t.TransitionType == TransitionTypes.Local)
            {
                type = TransitionType.Local;
            }
            else
            {
                type = TransitionType.Regular;
            }

            var pos         = t.WalkablePosition(10, 20);
            var dest        = t.Destination ?? Dat.LookupWorldArea(1);
            var cachedTrans = new CachedTransition(id, pos, type, dest);

            AreaTransitions.Add(cachedTrans);
            _processedObjects.Add(id);
            GlobalLog.Debug($"[CombatAreaCache] Registering {pos} (Type: {type})");
            TweakTransition(cachedTrans);
        }
Exemple #24
0
        public static async Task <bool> KillSolarisLunaris()
        {
            if (_finished)
            {
                return(false);
            }

            if (World.Act8.HarbourBridge.IsCurrentArea)
            {
                UpdateSolarisLunarisFightObjects();

                if (_statue != null)
                {
                    if (await Helpers.StopBeforeBoss(Settings.BossNames.SolarisLunaris))
                    {
                        return(true);
                    }

                    if (_solaris != null && _solaris.IsActive)
                    {
                        await Helpers.MoveAndWait(_solaris.WalkablePosition());

                        return(true);
                    }
                    if (_lunaris != null && _lunaris.IsActive)
                    {
                        await Helpers.MoveAndWait(_lunaris.WalkablePosition());

                        return(true);
                    }
                    if (_statue.IsTargetable)
                    {
                        await _statue.WalkablePosition().ComeAtOnce();

                        if (!await PlayerAction.Interact(_statue, () => !_statue.Fresh().IsTargetable, "Statue interaction"))
                        {
                            ErrorManager.ReportError();
                        }

                        return(true);
                    }
                    GlobalLog.Debug("Waiting for any Solaris and Lunaris fight object");
                    await Wait.StuckDetectionSleep(500);

                    return(true);
                }
            }
            await Travel.To(World.Act9.BloodAqueduct);

            return(true);
        }
Exemple #25
0
        public static async Task MoveAndWait(NetworkObject obj, string log = null, int distance = 20)
        {
            var pos = obj.Position;

            if (LokiPoe.MyPosition.Distance(pos) > distance)
            {
                PlayerMoverManager.MoveTowards(pos);
            }
            else
            {
                GlobalLog.Debug(log ?? $"Waiting for {obj.Name}");
                await Wait.StuckDetectionSleep(200);
            }
        }
Exemple #26
0
        public static async Task <bool> KillShavronne()
        {
            if (_shavronneKilled)
            {
                return(false);
            }

            if (World.Act6.ShavronneTower.IsCurrentArea)
            {
                UpdateShavronneFightObjects();

                if (_shavronneRoomObj != null)
                {
                    if (await Helpers.StopBeforeBoss(Settings.BossNames.Shavronne))
                    {
                        return(true);
                    }

                    if (_brutus != null && _brutus.IsActive)
                    {
                        await Helpers.MoveAndWait(_brutus.WalkablePosition());

                        return(true);
                    }
                    if (_shavronne != null)
                    {
                        int distance = _shavronne.IsActive ? 20 : 35;
                        var pos      = _shavronne.WalkablePosition();
                        if (pos.Distance > distance)
                        {
                            pos.Come();
                            return(true);
                        }
                        GlobalLog.Debug($"Waiting for {pos.Name}");
                        await Coroutines.FinishCurrentAction();

                        await Wait.StuckDetectionSleep(200);

                        return(true);
                    }
                    await Helpers.MoveAndWait(_shavronneRoomObj.WalkablePosition(), "Waiting for any Shavronne fight object");

                    return(true);
                }
            }
            await Travel.To(World.Act6.PrisonerGate);

            return(true);
        }
Exemple #27
0
        public void Tick()
        {
            if (!_enabled || MapExplorationTask.MapCompleted)
            {
                return;
            }

            if (!TickInterval.Elapsed)
            {
                return;
            }

            if (!LokiPoe.IsInGame || !World.CurrentArea.IsMap)
            {
                return;
            }

            foreach (var obj in LokiPoe.ObjectManager.Objects)
            {
                if (!SpecialObjectMetadata.Contains(obj.Metadata))
                {
                    continue;
                }

                var id     = obj.Id;
                var cached = Objects.Find(s => s.Id == id);

                if (obj.IsTargetable)
                {
                    if (cached == null)
                    {
                        var pos = obj.WalkablePosition(5, 20);
                        Objects.Add(new CachedObject(obj.Id, pos));
                        GlobalLog.Debug($"[SpecialObjectTask] Registering {pos}");
                    }
                }
                else
                {
                    if (cached != null)
                    {
                        if (cached == _current)
                        {
                            _current = null;
                        }
                        Objects.Remove(cached);
                    }
                }
            }
        }
        private static async Task <bool> ApplySextant(string sextantName, string mapId)
        {
            GlobalLog.Debug($"[ApplySextant] Now going to apply \"{sextantName}\" to \"{mapId}\".");

            if (StashUi.StashTabInfo.IsPremiumCurrency)
            {
                var control = Inventories.GetControlWithCurrency(sextantName);
                if (!await control.PickItemToCursor(true))
                {
                    return(false);
                }
            }
            else
            {
                var sextant = Inventories.StashTabItems.Find(i => i.Name == sextantName);
                if (!await StashUi.InventoryControl.PickItemToCursor(sextant.LocationTopLeft, true))
                {
                    return(false);
                }
            }

            if (!await OpenAtlasUi())
            {
                return(false);
            }

            _maxSextants = LokiPoe.InGameState.AtlasUi.MaxSextants;

            var err = LokiPoe.InGameState.AtlasUi.ApplyCursorTo(mapId);

            if (err != LokiPoe.InGameState.ApplyCursorToAtlasResult.None)
            {
                GlobalLog.Error($"[ApplySextant] Fail to apply \"{sextantName}\" to \"{mapId}\". Error: \"{err}\".");
                return(false);
            }

            if (!await Wait.For(() => LokiPoe.InstanceInfo.Sextants.Exists(s => s.WorldArea.Id == mapId), "sextant applying"))
            {
                return(false);
            }

            if (!await CloseAtlasUi())
            {
                return(false);
            }

            GlobalLog.Debug($"[ApplySextant] \"{sextantName}\" has been successfully applied to \"{mapId}\".");
            return(true);
        }
 public override bool Initialize()
 {
     if (!FindTgtPositions())
     {
         GlobalLog.Debug($"[TgtPosition] Fail to find any \"{_tgtName}\" tgt.");
         return false;
     }
     if (!SetCurrentPosition())
     {
         GlobalLog.Debug("[TgtPosition] No walkable position can be found.");
         return false;
     }
     _areaHash = LokiPoe.LocalData.AreaHash;
     return true;
 }
Exemple #30
0
        public async Task <bool> Run()
        {
            if (!_shouldAssign)
            {
                return(false);
            }

            GlobalLog.Debug("[AssignMoveSkillTask] Now going to assign the Move skill to the skillbar. It must be bound to anything except left mouse button.");

            var emptySlot = FirstEmptySkillSlot;

            if (emptySlot == -1)
            {
                GlobalLog.Error("[AssignMoveSkillTask] Cannot assign the Move skill. There are no free slots on the skillbar.");
                BotManager.Stop();
                return(true);
            }

            var moveSkill = Skillbar.Skills.FirstOrDefault(s => s != null && s.InternalName == "Move");

            if (moveSkill == null)
            {
                GlobalLog.Error("[AssignMoveSkillTask] Unknown error. Cannot find the Move skill on the skillbar.");
                BotManager.Stop();
                return(true);
            }

            var err = Skillbar.SetSlot(emptySlot, moveSkill);

            if (err != LokiPoe.InGameState.SetSlotResult.None)
            {
                GlobalLog.Error($"[AssignMoveSkillTask] Fail to assign the Move skill to slot {emptySlot}. Error: \"{err}\".");
                ErrorManager.ReportError();
                await Wait.SleepSafe(500);

                return(true);
            }

            if (!await Wait.For(() => Skillbar.Slot(emptySlot)?.InternalName == "Move", "skill slot changing"))
            {
                ErrorManager.ReportError();
                return(true);
            }

            GlobalLog.Debug($"[AssignMoveSkillTask] Move skill has been successfully assigned to slot {emptySlot}.");
            _shouldAssign = false;
            return(false);
        }