private async Task <bool> BaseCsBot(CSManager csManager, Func <uint> getTeleportId, CancellationTokenSource nextGameCancellation, Client client, Func <CSManager, List <AliveMonster>, List <AliveMonster>, Task> action) { var localTeleportId = 0U; while (!nextGameCancellation.IsCancellationRequested && client.Game.IsInGame()) { await Task.Delay(100); if (localTeleportId != getTeleportId() && !client.Game.IsInTown()) { Log.Information($"Client {client.Game.Me.Name} Taking town portal to town"); if (!await _townManagementService.TakeTownPortalToTown(client)) { continue; } } if (client.Game.IsInTown() && getTeleportId() != 0 && getTeleportId() != localTeleportId) { Log.Information($"Client {client.Game.Me.Name} taking town portal to chaos"); var teleportPlayer = client.Game.Players.First(p => p.Name.Equals(_csconfig.TeleportCharacterName, StringComparison.CurrentCultureIgnoreCase)); if (!await _townManagementService.TakeTownPortalToArea(client, teleportPlayer, Area.ChaosSanctuary)) { continue; } localTeleportId = getTeleportId(); } if (!client.Game.IsInTown()) { var anyPlayersWithoutShouts = ClassHelpers.AnyPlayerIsMissingShouts(client); if (anyPlayersWithoutShouts && client.Game.Me.Class == CharacterClass.Barbarian) { await ClassHelpers.CastAllShouts(client); } else if (ClassHelpers.IsMissingShouts(client.Game.Me)) { Log.Information($"Client {client.Game.Me.Name} waiting for bo"); await WaitForBo(client); } else { await Task.Delay(100); if (!await KillBosses(client, csManager, nextGameCancellation, client.Game.Me.Location, action, localTeleportId, getTeleportId)) { return(false); } } } } if (!nextGameCancellation.IsCancellationRequested && !client.Game.IsInGame()) { return(false); } return(true); }
protected override async Task <bool> RunSingleGame(Client client) { Log.Information("In game"); client.Game.RequestUpdate(client.Game.Me.Id); while (client.Game.Me.Location.X == 0 && client.Game.Me.Location.Y == 0) { Thread.Sleep(10); } if (client.Game.Me.Class != CharacterClass.Barbarian) { throw new NotSupportedException("Only barbarian is supported on travincal"); } /* * * while (client.Game.Players.Count < 2) * { * Thread.Sleep(TimeSpan.FromMilliseconds(100)); * } */ var townManagementOptions = new TownManagementOptions() { Act = Act.Act4 }; await _townManagementService.PerformTownTasks(client, townManagementOptions); NeedsMule = client.Game.Inventory.Items.Any(i => i.IsIdentified && Pickit.Pickit.ShouldKeepItem(client.Game, i) && Pickit.Pickit.CanTouchInventoryItem(client.Game, i)) || client.Game.Cube.Items.Any(i => i.IsIdentified && Pickit.Pickit.ShouldKeepItem(client.Game, i)); if (NeedsMule) { return(true); } Log.Information("Taking travincal wp"); if (!await _townManagementService.TakeWaypoint(client, Waypoint.Travincal)) { Log.Information("Taking trav waypoint failed"); return(false); } Log.Information("Doing bo"); if (!BarbBo(client.Game)) { return(false); } Log.Information("Walking to council members"); var pathToCouncil = await _pathingService.GetPathToObjectWithOffset(client.Game, EntityCode.CompellingOrb, 23, 25, MovementMode.Walking); if (!await MovementHelpers.TakePathOfLocations(client.Game, pathToCouncil, MovementMode.Walking)) { Log.Information($"Walking to councile members failed"); return(false); } Log.Information("Kill council members"); if (!await KillCouncilMembers(client.Game)) { Log.Information("Kill council members failed"); return(false); } Log.Information("Using find item"); if (!await UseFindItemOnCouncilMembers(client.Game)) { Log.Information("Finditem failed"); return(false); } Log.Information("Picking up left over items"); if (!await PickupNearbyItems(client.Game, 300)) { Log.Information("Pickup nearby items 1 failed"); } if (!await PickupNearbyItems(client.Game, 300)) { Log.Information("Pickup nearby items 2 failed"); } Log.Information("Moving to town"); if (!await _townManagementService.TakeTownPortalToTown(client)) { Log.Information("Move to town failed"); return(false); } await _townManagementService.PerformTownTasks(client, townManagementOptions); Log.Information("Successfully finished game"); return(true); }