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); }
private static bool IsInSlot(int slot, string name) { var skill = SkillBar.Slot(slot); return(skill != null && skill.Name == name); }