Example #1
0
        public static async Task <List <Point> > ToTownWayPoint(this IPathingService pathingService, Game game, MovementMode movementMode)
        {
            switch (game.Act)
            {
            case Act.Act1:
                return(await pathingService.GetPathToObject(game.MapId, Difficulty.Normal, game.Area, game.Me.Location, EntityCode.WaypointAct1, movementMode));

            case Act.Act2:
                return(await pathingService.GetPathToObject(game.MapId, Difficulty.Normal, game.Area, game.Me.Location, EntityCode.WaypointAct2, movementMode));

            case Act.Act3:
                return(await pathingService.GetPathToObject(game.MapId, Difficulty.Normal, game.Area, game.Me.Location, EntityCode.WaypointAct3, movementMode));

            case Act.Act4:
                return(await pathingService.GetPathToObject(game.MapId, Difficulty.Normal, game.Area, game.Me.Location, EntityCode.WaypointAct4, movementMode));

            case Act.Act5:
                return(await pathingService.GetPathToObject(game.MapId, Difficulty.Normal, game.Area, game.Me.Location, EntityCode.WaypointAct5, movementMode));
            }

            throw new InvalidOperationException("WalkToTownWayPoint executed an invalid operation");
        }
Example #2
0
        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));
        }
Example #3
0
 public static async Task <List <Point> > GetPathToObject(this IPathingService pathingService, Game game, EntityCode entityCode, MovementMode movementMode)
 {
     return(await pathingService.GetPathToObject(game.MapId, Difficulty.Normal, game.Area, game.Me.Location, entityCode, movementMode));
 }
        public async Task <bool> PerformTownTasks(Client client, TownManagementOptions options)
        {
            var game         = client.Game;
            var movementMode = GetMovementMode(game);

            game.CleanupCursorItem();
            InventoryHelpers.CleanupPotionsInBelt(game);

            if (client.Game.Me.Class == CharacterClass.Paladin && client.Game.Me.HasSkill(Skill.Vigor))
            {
                client.Game.ChangeSkill(Skill.Vigor, Hand.Right);
            }

            if (!await GeneralHelpers.PickupCorpseIfExists(client, _pathingService))
            {
                Log.Error($"{client.Game.Me.Name} failed to pickup corpse");
                return(false);
            }

            if (client.Game.Act != options.Act)
            {
                var targetTownArea     = WayPointHelpers.MapTownArea(options.Act);
                var pathToTownWayPoint = await _pathingService.ToTownWayPoint(client.Game, movementMode);

                if (!await MovementHelpers.TakePathOfLocations(client.Game, pathToTownWayPoint, movementMode))
                {
                    Log.Warning($"Teleporting to {client.Game.Act} waypoint failed");
                    return(false);
                }

                var townWaypoint = client.Game.GetEntityByCode(client.Game.Act.MapTownWayPointCode()).Single();
                Log.Information($"Taking waypoint to {targetTownArea}");
                if (!GeneralHelpers.TryWithTimeout((_) =>
                {
                    client.Game.TakeWaypoint(townWaypoint, options.Act.MapTownWayPoint());
                    return(GeneralHelpers.TryWithTimeout((_) => client.Game.Area == targetTownArea, TimeSpan.FromSeconds(2)));
                }, TimeSpan.FromSeconds(5)))
                {
                    Log.Information($"Moving to {options.Act} failed");
                    return(false);
                }
            }

            var townArea = WayPointHelpers.MapTownArea(game.Act);

            if (!await IdentifyItems(game, movementMode))
            {
                return(false);
            }

            if (!await RefreshAndSellItems(game, movementMode, options))
            {
                return(false);
            }

            if (!await RepairItems(game, movementMode))
            {
                return(false);
            }

            if (InventoryHelpers.HasAnyItemsToStash(client.Game))
            {
                var pathStash = await _pathingService.GetPathToObject(game.MapId, Difficulty.Normal, townArea, game.Me.Location, EntityCode.Stash, movementMode);

                if (!await MovementHelpers.TakePathOfLocations(game, pathStash, movementMode))
                {
                    Log.Warning($"{movementMode} failed at location {game.Me.Location}");
                }

                var stashItemsResult = InventoryHelpers.StashItemsToKeep(game, _externalMessagingClient);
                if (stashItemsResult != Enums.MoveItemResult.Succes)
                {
                    Log.Warning($"Stashing items failed with result {stashItemsResult}");
                }
            }

            if (CubeHelpers.AnyGemsToTransmuteInStash(client.Game))
            {
                var pathStash = await _pathingService.GetPathToObject(game.MapId, Difficulty.Normal, townArea, game.Me.Location, EntityCode.Stash, movementMode);

                if (!await MovementHelpers.TakePathOfLocations(game, pathStash, movementMode))
                {
                    Log.Warning($"{movementMode} failed at location {game.Me.Location}");
                }
                CubeHelpers.TransmuteGems(client.Game);
            }

            if (!await GambleItems(client, movementMode))
            {
                return(false);
            }

            return(true);
        }