コード例 #1
0
 public static async Task <List <Point> > GetPathToObjectWithOffset(this IPathingService pathingService, Game game, EntityCode entityCode, short xOffset, short yOffset, MovementMode movementMode)
 {
     return(await pathingService.GetPathToObjectWithOffset(game.MapId, Difficulty.Normal, game.Area, game.Me.Location, entityCode, xOffset, yOffset, movementMode));
 }
コード例 #2
0
ファイル: CSBot.cs プロジェクト: perryh/Diablo2Clientless1.09
        private async Task <bool> TaxiCs(Client client, CSManager csManager, Action <uint> setTeleportId)
        {
            Log.Information($"Client {client.Game.Me.Name} Taking waypoint to {Waypoint.RiverOfFlame}");
            if (!await _townManagementService.TakeWaypoint(client, Waypoint.RiverOfFlame))
            {
                Log.Warning($"Client {client.Game.Me.Name} Teleporting failed at location {client.Game.Me.Location}");
                return(false);
            }

            Log.Information($"Client {client.Game.Me.Name} Teleporting to {Area.ChaosSanctuary}");
            var pathToChaos = await _pathingService.GetPathToObjectWithOffset(client.Game.MapId, Difficulty.Normal, Area.RiverOfFlame, client.Game.Me.Location, EntityCode.WaypointAct4Levels, -6, -319, MovementMode.Teleport);

            if (!await MovementHelpers.TakePathOfLocations(client.Game, pathToChaos, MovementMode.Teleport))
            {
                Log.Warning($"Client {client.Game.Me.Name} Teleporting to {Area.ChaosSanctuary} warp failed at location {client.Game.Me.Location}");
                return(false);
            }

            var goalLocation = client.Game.Me.Location.Add(0, -30);

            if (!await GeneralHelpers.TryWithTimeout(async(_) =>
            {
                return(await client.Game.TeleportToLocationAsync(goalLocation));
            }, TimeSpan.FromSeconds(5)))
            {
                return(false);
            }

            var pathToDiabloStar = await _pathingService.GetPathToObject(client.Game.MapId, Difficulty.Normal, Area.ChaosSanctuary, client.Game.Me.Location, EntityCode.DiabloStar, MovementMode.Teleport);

            if (!await MovementHelpers.TakePathOfLocations(client.Game, pathToDiabloStar, MovementMode.Teleport))
            {
                Log.Warning($"Client {client.Game.Me.Name} Teleporting to {EntityCode.DiabloStar} failed at location {client.Game.Me.Location}");
                return(false);
            }

            if (!_townManagementService.CreateTownPortal(client))
            {
                return(false);
            }

            var myPortal = client.Game.GetEntityByCode(EntityCode.TownPortal).First(t => t.TownPortalOwnerId == client.Game.Me.Id);

            setTeleportId.Invoke(myPortal.Id);
            csManager.ResetAliveMonsters();
            if (!await WaitForBo(client))
            {
                return(false);
            }

            csManager.ResetAliveMonsters();

            setTeleportId.Invoke(0);

            if (!await KillLeftSeal(client, csManager, setTeleportId))
            {
                return(false);
            }

            csManager.ResetAliveMonsters();
            setTeleportId.Invoke(0);

            if (!await KillTopSeal(client, csManager, setTeleportId))
            {
                return(false);
            }

            csManager.ResetAliveMonsters();
            setTeleportId.Invoke(0);

            if (!await KillRightSeal(client, csManager, setTeleportId))
            {
                return(false);
            }

            csManager.ResetAliveMonsters();
            setTeleportId.Invoke(0);

            return(await KillDiablo(client, csManager, setTeleportId));
        }
コード例 #3
0
        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);
        }