Exemple #1
0
        internal static async Task <bool> HandleZoneChange(uint zoneId, bool bind)
        {
            const ushort dravanianHinterlands = 399;
            const uint   idyllshireAetheryte  = 75;
            uint         aetheryteId;

            // Ensure we have no FATE selected to prevent null references.
            await OracleFateManager.ClearCurrentFate("Zone change needed.", false);

            if (zoneId == dravanianHinterlands)
            {
                aetheryteId = idyllshireAetheryte;
            }
            else
            {
                var aetheryte = OracleFateManager.GetAetheryteIdsForZone(zoneId).FirstOrDefault();
                if (aetheryte == null)
                {
                    Logger.SendErrorLog("There's no aetherytes for this zone.");
                    OracleBot.StopOracle("Cannot teleport to destination.");
                    return(false);
                }

                aetheryteId = aetheryte.Item1;
            }

            if (!WorldManager.HasAetheryteId(aetheryteId))
            {
                Logger.SendErrorLog("Can't find requested teleport destination, make sure you've unlocked it.");
                OracleBot.StopOracle("Cannot teleport to destination.");
                return(false);
            }

            if (!WorldManager.CanTeleport())
            {
                return(false);
            }

            var zoneName = WorldManager.AvailableLocations.FirstOrDefault(teleport => teleport.AetheryteId == aetheryteId).Name;

            Logger.SendLog("Teleporting to " + zoneName + ".");
            await OracleTeleportManager.TeleportToAetheryte(aetheryteId);

            if (WorldManager.ZoneId != WorldManager.GetZoneForAetheryteId(aetheryteId))
            {
                return(true);
            }

            if (bind && MovementSettings.Instance.BindHomePoint)
            {
                await BindHomePoint.Main(aetheryteId);
            }

            if (aetheryteId == idyllshireAetheryte)
            {
                await OracleMovementManager.MoveOutOfIdyllshire();
            }

            return(true);
        }
Exemple #2
0
        private static async Task <bool> BlacklistUnnavigableAetherytes()
        {
            if (WorldManager.CanFly)
            {
                return(true);
            }

            var aetherytes = OracleFateManager.GetAetheryteIdsForZone(WorldManager.ZoneId);
            var navRequest = aetherytes.Select(target => new CanFullyNavigateTarget
            {
                Id       = target.Item1,
                Position = target.Item2
            }).ToList();
            var navTask    = Navigator.NavigationProvider.CanFullyNavigateTo(navRequest, Core.Player.Location, WorldManager.ZoneId);
            var navResults = await Coroutine.ExternalTask(navTask);

            foreach (var navResult in navResults.Where(result => result.CanNavigate == 0))
            {
                var aetheryte = aetherytes.FirstOrDefault(result => result.Item1 == navResult.Id);
                if (aetheryte != null)
                {
                    Blacklist.Add(aetheryte.Item1, BlacklistFlags.Node, TimeSpan.FromMinutes(10), "Cannot navigate to aetheryte crystal.");
                }
            }

            return(true);
        }
Exemple #3
0
        private static async Task <Dictionary <FateData, float> > GetFateDistances()
        {
            if (!MovementSettings.Instance.TeleportIfQuicker || !MovementSettings.Instance.ConsiderAetheryteFateDistances || WorldManager.CanFly)
            {
                return(await OracleFateManager.GetActiveFateDistances());
            }

            Logger.SendDebugLog("Taking into account the distance to a FATE if we teleport to it.");
            var fateDistances = await OracleFateManager.GetActiveFateDistances();

            var fateDistancesFromAetherytes = new List <Dictionary <FateData, float> >();

            foreach (var aetheryte in
                     OracleFateManager.GetAetheryteIdsForZone(WorldManager.ZoneId).Where(item => WorldManager.KnownAetheryteIds.Contains(item.Item1)))
            {
                fateDistancesFromAetherytes.Add(await OracleFateManager.GetActiveFateDistances(aetheryte.Item2));
            }

            foreach (var fateDistance in await OracleFateManager.GetActiveFateDistances())
            {
                if (fateDistance.Key.Progress < MovementSettings.Instance.FateProgressTeleportLimit)
                {
                    continue;
                }

                Logger.SendDebugLog("Ignoring teleport distance for " + fateDistance.Key.Name + ", its progress (" + fateDistance.Key.Progress
                                    + "%) equals or exceeds the limit (" + MovementSettings.Instance.FateProgressTeleportLimit + "%).");
            }

            foreach (var aetheryteDistanceDict in fateDistancesFromAetherytes)
            {
                foreach (var fateDistance in aetheryteDistanceDict)
                {
                    float currentDistance;
                    if (!fateDistances.TryGetValue(fateDistance.Key, out currentDistance))
                    {
                        continue;
                    }

                    if (fateDistance.Key.Progress >= MovementSettings.Instance.FateProgressTeleportLimit)
                    {
                        continue;
                    }

                    // Add the minimum distance delta to ensure we don't teleport if distance saved is under that amount.
                    if (fateDistance.Value + MovementSettings.Instance.MinDistanceToTeleport >= currentDistance)
                    {
                        continue;
                    }

                    fateDistances.Remove(fateDistance.Key);
                    fateDistances.Add(fateDistance.Key, fateDistance.Value);
                }
            }

            return(fateDistances);
        }
Exemple #4
0
        private static Vector3 GetClosestAetheryteLocation()
        {
            var aetherytes     = OracleFateManager.GetAetheryteIdsForZone(WorldManager.ZoneId);
            var playerLocation = Core.Player.Location;
            var location       = Vector3.Zero;

            // Vectors are non-nullable, so return zeroed location and handle in task.
            if (aetherytes == null || aetherytes.Length == 0)
            {
                return(location);
            }

            foreach (var aetheryte in aetherytes)
            {
                if (!Blacklist.Contains(aetheryte.Item1) &&
                    (location == Vector3.Zero || playerLocation.Distance2D(location) > playerLocation.Distance2D(aetheryte.Item2)))
                {
                    location = aetheryte.Item2;
                }
            }

            return(location);
        }