internal async Task <bool> ChangeZone()
        {
            // Skip if OnPulse disabled the plugin functionality
            if (_enabled == false)
            {
                return(false);
            }

            var nextAetherite = FindNextAetherite();

            if (nextAetherite == null)
            {
                Log("There is no recommended zone for your level registered.");
                DisablePluginUntilLevelChange();

                return(false);
            }

            bool playerIsOnCorrectMap = WorldManager.ZoneId == nextAetherite.ZoneId;

            if (playerIsOnCorrectMap)
            {
                return(false);
            }

            try
            {
                WorldManager.TeleportLocation aetherite = FindAetheriteInAvailableLocations(nextAetherite.Name);

                await PrepareForTeleport();

                Log("Teleporting to " + aetherite.Name);
                await CommonTasks.Teleport(aetherite.AetheryteId);
            }
            catch (Exception exception)
            {
                Logging.WriteVerbose(exception.ToString());
                LogZone();
                Log("The required aetherite is not yet known by your character. You need: " + nextAetherite.Name);
                Log("Please disable/enable the plugin once you have the aetherite acquired.");

                // TODO Manually MoveTo if aetherite is not known

                DisablePluginUntilLevelChange();

                return(false);
            }

            return(true);
        }
Exemple #2
0
        private static async Task <bool> GoToHousingBell(WorldManager.TeleportLocation house)
        {
            Log($"Teleporting to housing: (ZID: {house.ZoneId}, AID: {house.AetheryteId}) {house.Name}");
            await CommonTasks.Teleport(house.AetheryteId);

            Log("Waiting for zone to change");
            await Coroutine.Wait(20000, () => WorldManager.ZoneId == house.ZoneId);

            Log("Getting closest housing entrance");
            uint houseEntranceId = 2002737;
            uint aptEntranceId   = 2007402;

            var entranceIds = new uint[] { houseEntranceId, aptEntranceId };

            var entrance = GameObjectManager.GetObjectsByNPCIds <GameObject>(entranceIds).OrderBy(x => x.Distance2D()).FirstOrDefault();

            if (entrance != null)
            {
                Log("Found housing entrance, approaching");
                await Navigation.FlightorMove(entrance.Location);

                if (entrance.IsWithinInteractRange)
                {
                    Navigator.NavigationProvider.ClearStuckInfo();
                    Navigator.Stop();
                    await Coroutine.Wait(5000, () => !IsJumping);

                    entrance.Interact();

                    // Handle different housing entrance menus
                    if (entrance.NpcId == houseEntranceId)
                    {
                        Log("Entering house");

                        await Coroutine.Wait(10000, () => SelectYesno.IsOpen);

                        if (SelectYesno.IsOpen)
                        {
                            SelectYesno.Yes();
                        }
                    }
                    else if (entrance.NpcId == aptEntranceId)
                    {
                        Log("Entering apartment");

                        await Coroutine.Wait(10000, () => SelectString.IsOpen);

                        if (SelectString.IsOpen)
                        {
                            SelectString.ClickSlot(0);
                        }
                    }

                    await CommonTasks.HandleLoading();

                    Log("Getting best summoning bell");
                    var bell = HelperFunctions.FindSummoningBell();
                    if (bell != null)
                    {
                        Log("Found summoning bell, approaching");
                        await HelperFunctions.GoToSummoningBell();

                        return(true);
                    }
                    else
                    {
                        Log("Couldn't find any summoning bells");
                    }
                }
            }
            else
            {
                Log($"Couldn't find any housing entrances.  Are we in the right zone?  Current: ({WorldManager.ZoneId}) {WorldManager.CurrentZoneName}");
            }

            return(false);
        }