public async Task <bool> TakeWaypoint(Client client, Waypoint waypoint) { var movementMode = GetMovementMode(client.Game); var pathToTownWayPoint = await _pathingService.ToTownWayPoint(client.Game, movementMode); if (!await MovementHelpers.TakePathOfLocations(client.Game, pathToTownWayPoint, movementMode)) { Log.Information($"Walking to {client.Game.Act} waypoint failed"); return(false); } WorldObject townWaypoint = null; GeneralHelpers.TryWithTimeout((retryCount) => { townWaypoint = client.Game.GetEntityByCode(client.Game.Act.MapTownWayPointCode()).Single(); return(townWaypoint != null); }, TimeSpan.FromSeconds(2)); if (townWaypoint == null) { Log.Error("No waypoint found"); return(false); } if (!await GeneralHelpers.TryWithTimeout(async(retryCount) => { while (client.Game.Me.Location.Distance(townWaypoint.Location) > 5) { if (client.Game.Me.HasSkill(Skill.Teleport)) { await client.Game.TeleportToLocationAsync(townWaypoint.Location); } else { await client.Game.MoveToAsync(townWaypoint); } } client.Game.TakeWaypoint(townWaypoint, waypoint); return(GeneralHelpers.TryWithTimeout((retryCount) => client.Game.Area == waypoint.ToArea(), TimeSpan.FromSeconds(2))); }, TimeSpan.FromSeconds(5))) { return(false); } if (!await GeneralHelpers.TryWithTimeout(async(retryCount) => { client.Game.RequestUpdate(client.Game.Me.Id); var isValidPoint = await _pathingService.IsNavigatablePointInArea(client.Game.MapId, Difficulty.Normal, waypoint.ToArea(), client.Game.Me.Location); return(isValidPoint); }, TimeSpan.FromSeconds(3.5))) { Log.Error("Checking whether moved to area failed"); return(false); } return(true); }