Example #1
0
        public async Task <bool> GetToNpc()
        {
            if (WorldManager.ZoneId != ZoneId && WorldManager.ZoneId != 886)
            {
                while (Core.Me.IsCasting)
                {
                    await Coroutine.Sleep(1000);
                }

                if (!ConditionParser.HasAetheryte(AetheryteId))
                {
                    //Logger.Error($"We can't get to {Constants.EntranceZone.CurrentLocaleAethernetName}. You don't have that Aetheryte so do something about it...");
                    //TreeRoot.Stop();
                    return(false);
                }

                if (!WorldManager.TeleportById(AetheryteId))
                {
                    //Logger.Error($"We can't get to {Constants.EntranceZone.CurrentLocaleAethernetName}. something is very wrong...");
                    //TreeRoot.Stop();
                    return(false);
                }

                while (Core.Me.IsCasting)
                {
                    await Coroutine.Sleep(1000);
                }

                if (CommonBehaviors.IsLoading)
                {
                    await Coroutine.Wait(-1, () => !CommonBehaviors.IsLoading);
                }

                await Coroutine.Wait(10000, () => WorldManager.ZoneId == FoundationZoneId);

                await Coroutine.Sleep(3000);

                await Coroutine.Wait(10000, () => GameObjectManager.GetObjectByNPCId(70) != null);

                await Coroutine.Sleep(3000);

                var unit = GameObjectManager.GetObjectByNPCId(70);

                if (!unit.IsWithinInteractRange)
                {
                    var _target = unit.Location;
                    Navigator.PlayerMover.MoveTowards(_target);
                    while (!unit.IsWithinInteractRange)
                    {
                        Navigator.PlayerMover.MoveTowards(_target);
                        await Coroutine.Sleep(100);
                    }

                    Navigator.PlayerMover.MoveStop();
                }

                unit.Target();
                unit.Interact();
                await Coroutine.Sleep(1000);

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

                await Coroutine.Sleep(500);

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

                await Coroutine.Sleep(5000);

                if (CommonBehaviors.IsLoading)
                {
                    await Coroutine.Wait(-1, () => !CommonBehaviors.IsLoading);
                }

                await Coroutine.Sleep(3000);
            }

            //await CommonTasks.MoveTo(Npc.Location, "Moving To HandinVendor");


            if (Npc.Location.Distance(Core.Me.Location) > 5f)
            {
                var _target = new Vector3(10.58188f, -15.96282f, 163.8702f);
                Navigator.PlayerMover.MoveTowards(_target);
                while (_target.Distance2D(Core.Me.Location) >= 4)
                {
                    Navigator.PlayerMover.MoveTowards(_target);
                    await Coroutine.Sleep(100);
                }

                Navigator.PlayerMover.MoveStop();

                _target = Npc.Location;
                Navigator.PlayerMover.MoveTowards(_target);
                while (_target.Distance2D(Core.Me.Location) >= 4)
                {
                    Navigator.PlayerMover.MoveTowards(_target);
                    await Coroutine.Sleep(100);
                }

                Navigator.PlayerMover.MoveStop();
            }

            return(Npc.Location.Distance(Core.Me.Location) <= 5f);
        }
Example #2
0
        private static async Task <bool> HelpersMethod()
        {
            if (QuestLogManager.InCutscene)
            {
                if (AgentCutScene.Instance.CanSkip && !SelectString.IsOpen)
                {
                    AgentCutScene.Instance.PromptSkip();
                    if (await Coroutine.Wait(600, () => SelectString.IsOpen))
                    {
                        SelectString.ClickSlot(0);
                        await Coroutine.Sleep(1000);
                    }
                }
            }

            //if (MainSettingsModel.Instance.UseAutoTalk)
            //{
            //    if (Talk.DialogOpen)
            //        Talk.Next();

            //    if (Request.IsOpen)
            //    {
            //        Logger.SyntgohtLog("Handing over any item(s) in your Key Items.");
            //        foreach (var s in InventoryManager.GetBagByInventoryBagId(InventoryBagId.KeyItems))
            //        {
            //            s.Handover();
            //            Logger.SyntgohtLog(s.EnglishName);
            //            await Coroutine.Wait(250, () => Request.HandOverButtonClickable);
            //            if (Request.HandOverButtonClickable) { break; }
            //        }

            //        Logger.SyntgohtLog("Handing over any item(s) in your Inventory.");
            //        foreach (var s in InventoryManager.FilledSlots)
            //        {
            //            s.Handover();
            //            Logger.SyntgohtLog(s.EnglishName);
            //            await Coroutine.Wait(250, () => Request.HandOverButtonClickable);
            //            if (Request.HandOverButtonClickable) { break; }
            //        }

            //        if (Request.HandOverButtonClickable) { Request.HandOver(); }

            //        Logger.SyntgohtLog("Handing over any item(s) in your Armory.");
            //        foreach (var s in InventoryManager.FilledArmorySlots)
            //        {
            //            s.Handover();
            //            Logger.SyntgohtLog(s.EnglishName);
            //            await Coroutine.Wait(250, () => Request.HandOverButtonClickable);
            //            if (Request.HandOverButtonClickable) { break; }
            //        }

            //        if (Request.HandOverButtonClickable) { Request.HandOver(); }
            //        else { await Coroutine.Wait(3000, () => !Request.IsOpen); }
            //    }
            //}

            //if (MainSettingsModel.Instance.UseAutoQuest)
            //{
            //    if (JournalAccept.IsOpen)
            //        JournalAccept.Accept();

            //    if (JournalResult.IsOpen)
            //        JournalResult.Complete();
            //}

            return(false);
        }
Example #3
0
        protected async Task <bool> Retaining()
        {
            foreach (var unit in GameObjectManager.GameObjects.OrderBy(r => r.Distance()))
            {
                if (unit.NpcId == 2000401 || unit.NpcId == 2000441)
                {
                    unit.Interact();
                    break;
                }
            }
            if (await Coroutine.Wait(5000, () => SelectString.IsOpen))
            {
                uint count     = 0;
                int  lineC     = SelectString.LineCount;
                uint countLine = (uint)lineC;
                foreach (var retainer in SelectString.Lines())
                {
                    if (retainer.EndsWith("]") || retainer.EndsWith(")"))
                    {
                        Log("Checking Retainer n° " + (count + 1));
                        // If Venture Completed
                        if (retainer.EndsWith("[Tâche terminée]") || retainer.EndsWith("(Venture complete)"))
                        {
                            Log("Venture Completed !");
                            // Select the retainer
                            SelectString.ClickSlot(count);
                            if (await Coroutine.Wait(5000, () => Talk.DialogOpen))
                            {
                                // Skip Dialog
                                Talk.Next();
                                if (await Coroutine.Wait(5000, () => SelectString.IsOpen))
                                {
                                    // Click on the completed venture
                                    SelectString.ClickSlot(5);
                                    if (await Coroutine.Wait(5000, () => RetainerTaskResult.IsOpen))
                                    {
                                        // Assign a new venture
                                        RetainerTaskResult.Reassign();
                                        if (await Coroutine.Wait(5000, () => RetainerTaskAsk.IsOpen))
                                        {
                                            // Confirm new venture
                                            RetainerTaskAsk.Confirm();
                                            if (await Coroutine.Wait(5000, () => Talk.DialogOpen))
                                            {
                                                // Skip Dialog
                                                Talk.Next();
                                                if (await Coroutine.Wait(5000, () => SelectString.IsOpen))
                                                {
                                                    SelectString.ClickSlot((uint)SelectString.LineCount - 1);
                                                    if (await Coroutine.Wait(5000, () => Talk.DialogOpen))
                                                    {
                                                        // Skip Dialog
                                                        Talk.Next();
                                                        await Coroutine.Sleep(3000);

                                                        foreach (var unit in GameObjectManager.GameObjects.OrderBy(r => r.Distance()))
                                                        {
                                                            if (unit.NpcId == 2000401 || unit.NpcId == 2000441)
                                                            {
                                                                unit.Interact();
                                                                break;
                                                            }
                                                        }

                                                        if (await Coroutine.Wait(5000, () => SelectString.IsOpen))
                                                        {
                                                            count++;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            Log("Venture not Completed !");
                            count++;
                        }
                    }
                    else
                    {
                        Log("No more Retainer to check");
                        SelectString.ClickSlot(countLine - 1);
                    }
                }
                return(_done = true);
            }
            return(_done = true);
        }
Example #4
0
        protected override async Task <bool> Main()
        {
            var watering = GardenManager.Plants.Where(r => !Blacklist.Contains(r) && r.Distance2D(Core.Player) < 5).ToArray();

            foreach (var plant in watering)
            {
                //Water it if it needs it or if we have fertilized it 5 or more times.
                if (AlwaysWater || GardenManager.NeedsWatering(plant))
                {
                    var result = GardenManager.GetCrop(plant);
                    if (result != null)
                    {
                        Log("Watering {0} {1:X}", result, plant.ObjectId);
                        plant.Interact();
                        if (!await Coroutine.Wait(5000, () => Talk.DialogOpen))
                        {
                            continue;
                        }
                        Talk.Next();
                        if (!await Coroutine.Wait(5000, () => SelectString.IsOpen))
                        {
                            continue;
                        }
                        if (!await Coroutine.Wait(5000, () => SelectString.LineCount > 0))
                        {
                            continue;
                        }
                        if (SelectString.LineCount == 4)
                        {
                            SelectString.ClickSlot(1);
                            await Coroutine.Sleep(PostInteractDelay);
                        }
                        else
                        {
                            Log("Plant is ready to be harvested");
                            SelectString.ClickSlot(1);
                        }
                    }
                    else
                    {
                        Log("GardenManager.GetCrop returned null {0:X}", plant.ObjectId);
                    }
                }
            }
            var plants = GardenManager.Plants.Where(r => r.Distance2D(Core.Player) < 5).ToArray();

            foreach (var plant in plants)
            {
                var result = GardenManager.GetCrop(plant);
                if (result == null)
                {
                    continue;
                }
                Log("Fertilizing {0} {1:X}", GardenManager.GetCrop(plant), plant.ObjectId);
                plant.Interact();
                if (!await Coroutine.Wait(5000, () => Talk.DialogOpen))
                {
                    continue;
                }
                Talk.Next();
                if (!await Coroutine.Wait(5000, () => SelectString.IsOpen))
                {
                    continue;
                }
                if (!await Coroutine.Wait(5000, () => SelectString.LineCount > 0))
                {
                    continue;
                }
                if (SelectString.LineCount == 4)
                {
                    SelectString.ClickSlot(0);
                    if (await Coroutine.Wait(2000, () => GardenManager.ReadyToFertilize))
                    {
                        if (GardenManager.Fertilize() != FertilizeResult.Success)
                        {
                            continue;
                        }
                        Log("Plant with objectId {0:X} was fertilized", plant.ObjectId);
                        await Coroutine.Sleep(PostInteractDelay);
                    }
                    else
                    {
                        Log("Plant with objectId {0:X} not able to be fertilized, trying again later", plant.ObjectId);
                    }
                }
                else
                {
                    Log("Plant is ready to be harvested");
                    SelectString.ClickSlot(1);
                }
            }
            return(isDone = true);
        }
Example #5
0
        public async static Task DoGCDailyTurnins()
        {
            Navigator.PlayerMover        = new SlideMover();
            Navigator.NavigationProvider = new ServiceNavigationProvider();

            var items = Core.Memory.ReadArray <GCTurninItem>(Offsets.GCTurnin, Offsets.GCTurninCount);

            /*
             * foreach (var item in items)
             * {
             *  Logging.Write(item.ItemID);
             * }*/

            if (!items.Any(i => i.CanHandin))
            {
                Log("All done.");
                return;
            }

            string lisbethOrder = await GetGCSupplyList();

            if (lisbethOrder == "")
            {
                Log("Not Calling lisbeth.");
            }
            else
            {
                //Log(lisbethOrder);
                Log("Calling lisbeth");
                if (!await Lisbeth.ExecuteOrders(lisbethOrder))
                {
                    Log("Lisbeth order failed, Dumping order to GCSupply.json");
                    using (StreamWriter outputFile = new StreamWriter("GCSupply.json", false))
                    {
                        await outputFile.WriteAsync(lisbethOrder);
                    }
                }
                else
                {
                    Log("Lisbeth order should be done");
                }
            }

            items = Core.Memory.ReadArray <GCTurninItem>(Offsets.GCTurnin, Offsets.GCTurninCount);

            if (!items.Any(i => i.CanHandin && InventoryManager.FilledSlots.Any(j => j.RawItemId == i.ItemID && !j.HasMateria() && j.Count >= i.ReqCount)))
            {
                Log("No items available to hand in");
                return;
            }

            if (!GrandCompanySupplyList.Instance.IsOpen)
            {
                await GrandCompanyHelper.InteractWithNpc(GCNpc.Personnel_Officer);

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

                if (!SelectString.IsOpen)
                {
                    Log("Window is not open...maybe it didn't get to npc?");
                    return;
                }

                SelectString.ClickSlot(0);
                await Coroutine.Wait(5000, () => GrandCompanySupplyList.Instance.IsOpen);

                if (!GrandCompanySupplyList.Instance.IsOpen)
                {
                    Log("Window is not open...maybe it didn't get to npc?");
                    return;
                }
            }

            if (GrandCompanySupplyList.Instance.IsOpen)
            {
                await GrandCompanySupplyList.Instance.SwitchToSupply();

                await HandleCurrentGCWindow();

                await GrandCompanySupplyList.Instance.SwitchToProvisioning();

                await HandleCurrentGCWindow();

                GrandCompanySupplyList.Instance.Close();
                await Coroutine.Wait(5000, () => SelectString.IsOpen);

                if (SelectString.IsOpen)
                {
                    SelectString.ClickSlot((uint)(SelectString.LineCount - 1));
                }
            }
        }
Example #6
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);
        }
Example #7
0
        private async Task MainMenu()
        {
            TreeRoot.StatusText = "Running Main Menu";
            if (PartyManager.IsInParty)
            {
                Logger.Warn("I am in a party. I am waiting for everyone to join the zone.");
                await Coroutine.Wait(TimeSpan.FromMinutes(30), PartyLeaderWaitConditions);

                if (DeepDungeon.StopPlz)
                {
                    return;
                }
                if (PartyManager.IsPartyLeader)
                {
                    Logger.Warn("Everyone is now in the zone");
                    for (var i = 0; i < 6; i++)
                    {
                        Logger.Warn("Giving them {0} seconds to do what they need to at the NPC", 60 - i * 10);
                        await Coroutine.Sleep(TimeSpan.FromSeconds(10));

                        if (DeepDungeon.StopPlz)
                        {
                            return;
                        }
                    }
                }
            }
            //read the current level state
            await ReadStartingLevel();

            // have save data and our max level is
            if (GetFloorStatus(_aetherialLevels, _saveStates))
            {
                Logger.Verbose("Resetting the floor");
                await DeepDungeonSaveData.ClickReset(UseSaveSlot);

                _saveStates = Sd.SaveStates;
            }
            if (_error)
            {
                lock (_errorLock)
                    _error = false;
            }


            if (!PartyManager.IsInParty || PartyManager.IsPartyLeader)
            {
                await DeepDungeonSaveData.ClickSaveSlot(UseSaveSlot);

                // if we are using an "empty" save slot
                if (!_saveStates[UseSaveSlot].Saved)
                {
                    Logger.Verbose("Using Empty Save Slot");
                    Logger.Verbose("Going through the Talk dialogs...");
                    // -- Fixed Party --
                    await Coroutine.Sleep(1000);

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

                    SelectString.ClickSlot(0);

                    await Coroutine.Sleep(500);

                    //                    Logger.Verbose("Are you sure Fixed Party");
                    await Coroutine.Wait(1000, () => SelectYesno.IsOpen);

                    if (SelectYesno.IsOpen)
                    {
                        SelectYesno.ClickYes();
                    }

                    await Coroutine.Sleep(500);

                    //-- Are you sure you want to enter alone?
                    if (!PartyManager.IsInParty)
                    {
                        //                        Logger.Verbose("Enter Alone Talk");
                        //talk stuff
                        await Coroutine.Wait(1000, () => Talk.DialogOpen);

                        Talk.Next();

                        await Coroutine.Sleep(500);

                        //                        Logger.Verbose("Enter Alone?");
                        await Coroutine.Wait(1000, () => SelectYesno.IsOpen);

                        SelectYesno.ClickYes();
                        await Coroutine.Sleep(500);
                    }

                    //                    Logger.Verbose("Floor 51 wait");
                    //--floor 51 logic
                    await Coroutine.Wait(1000, () => SelectString.IsOpen || ContentsFinderConfirm.IsOpen);

                    if (SelectString.IsOpen)
                    {
                        await Coroutine.Sleep(500);

                        if (Settings.Instance.StartAt51)
                        {
                            Logger.Verbose("Start at 51: {0}", _targetFloor.LevelMax > 50);
                        }

                        if (Settings.Instance.StartAt51 && _targetFloor.LevelMax > 50)
                        {
                            SelectString.ClickSlot(1);
                        }
                        else
                        {
                            SelectString.ClickSlot(0);
                        }
                    }
                    Logger.Verbose("Done with window interaction.");
                }
                _targetFloor = null;
            }
            Logger.Info("Waiting on the queue, Or for an error.");
            DungeonQueue.Reset();
        }
        protected override async Task <bool> Main()
        {
            if (interactTimeout.Elapsed.TotalSeconds > Timeout)
            {
                Logger.Error(Localization.Localization.ExTurnInGuildLeve_TurninTimeout);
                isDone = true;
                return(true);
            }

            if (!checkedTransport)
            {
                checkedTransport = true;

                StatusText = Localization.Localization.ExTurnInGuildLeve_CheckTransport;

                var selectYesnoCountWindow = new SelectYesnoCount();
                if (await selectYesnoCountWindow.Refresh(2000))
                {
                    StatusText = Localization.Localization.ExTurnInGuildLeve_SelectTransport;

                    if (AcceptTransport)
                    {
                        selectYesnoCountWindow.Yes();
                        await Coroutine.Wait(5000, () => CommonBehaviors.IsLoading);

                        await Coroutine.Wait(System.Threading.Timeout.Infinite, () => !CommonBehaviors.IsLoading);
                    }
                    else
                    {
                        await selectYesnoCountWindow.CloseInstance();
                    }

                    return(true);
                }
            }

            // Movement
            if (ExProfileBehavior.Me.Distance(Location) > 3.5)
            {
                StatusText = Localization.Localization.ExTurnInGuildLeve_Move + NpcId;

                await Location.MoveTo(radius : 3.4f, name : " NpcId: " + NpcId);

                return(true);
            }

            if (!interactTimeout.IsRunning)
            {
                interactTimeout.Restart();
            }

            // Interact
            if (Core.Target == null && ExProfileBehavior.Me.Distance(Location) <= 3.5)
            {
                return(await InteractWithNpc());
            }

            if (Talk.DialogOpen)
            {
                await HandleTalk();
            }

            if (SelectIconString.IsOpen)
            {
                if (iconStringIndex == 9001)
                {
                    iconStringIndex = (uint)SelectIconString.Lines().Count - 1;
                }

                // We will just click the last quest and decrement until we have either no quests left or none to turn in.
                SelectIconString.ClickSlot(--iconStringIndex);
                await Coroutine.Sleep(500);

                if (iconStringIndex == uint.MaxValue)
                {
                    Logger.Warn(Localization.Localization.ExTurnInGuildLeve_NothingToTurnin);

                    isDone = true;
                    return(true);
                }

                return(true);
            }

            if (SelectString.IsOpen)
            {
                var lines = SelectString.Lines();

                // If Collect Reward exists, we click that; otherwise we will click Close. (-1 as uint = uint.MaxValue)
                var index = (uint)lines.IndexOf(CollectRewardText, StringComparer.InvariantCultureIgnoreCase);

                if (index != uint.MaxValue)
                {
                    Logger.Info(Localization.Localization.ExTurnInGuildLeve_CollectReward, WorldManager.EorzaTime);
                    SelectString.ClickSlot(index);
                    await Coroutine.Yield();

                    return(true);
                }

                // If yes is an option, click it to turn in more items.(crafting)
                index = (uint)lines.IndexOf(YesText, StringComparer.InvariantCultureIgnoreCase);

                if (index != uint.MaxValue)
                {
                    Logger.Info(Localization.Localization.ExTurnInGuildLeve_TurninMore, WorldManager.EorzaTime);
                    SelectString.ClickSlot(index);
                    await Coroutine.Yield();

                    return(true);
                }

                Logger.Warn(Localization.Localization.ExTurnInGuildLeve_NoRewardsLeft);
                isDone = true;
                SelectString.ClickSlot(index);
                await Coroutine.Yield();

                return(true);
            }

            if (Request.IsOpen)
            {
                var itemCount = Memory.Request.ItemsToTurnIn.Length;

                var itemId = Memory.Request.ItemId1;

                IEnumerable <BagSlot> itemSlots =
                    InventoryManager.FilledInventoryAndArmory.Where(
                        bs => bs.RawItemId == itemId && !Blacklist.Contains((uint)bs.Pointer.ToInt64(), BlacklistFlags.Loot)).ToArray();

                if (HqOnly)
                {
                    itemSlots = itemSlots.Where(bs => bs.IsHighQuality);
                }

                if (NqOnly)
                {
                    itemSlots = itemSlots.Where(bs => !bs.IsHighQuality);
                }

                var items = itemSlots.Take(itemCount).ToArray();

                if (items.Length == 0)
                {
                    Logger.Warn(Localization.Localization.ExTurnInGuildLeve_NoItemToTurnin, HqOnly, NqOnly, itemId);
                    isDone = true;
                    return(true);
                }

                StatusText = Localization.Localization.ExTurnInGuildLeve_TurnIn;

                var isHq            = items.Any(i => i.IsHighQuality);
                var itemName        = items[0].EnglishName;
                var requestAttempts = 0;
                while (Request.IsOpen && requestAttempts++ < 5 && Behaviors.ShouldContinue)
                {
                    foreach (var item in items)
                    {
                        item.Handover();
                        await Coroutine.Yield();
                    }

                    await Coroutine.Wait(1000, () => Request.HandOverButtonClickable);

                    if (Request.HandOverButtonClickable)
                    {
                        Request.HandOver();

                        if (isHq)
                        {
                            await Coroutine.Wait(2000, () => !Request.IsOpen && SelectYesno.IsOpen);
                        }
                        else
                        {
                            await Coroutine.Wait(2000, () => !Request.IsOpen);
                        }
                    }
                }

                turnedItemsIn = true;

                if (SelectYesno.IsOpen)
                {
                    SelectYesno.ClickYes();
                    await Coroutine.Yield();

                    Logger.Info(Localization.Localization.ExTurnInGuildLeve_TurnInHq, itemName, WorldManager.EorzaTime);
                }
                else
                {
                    Logger.Info(Localization.Localization.ExTurnInGuildLeve_TurnInNq, itemName, WorldManager.EorzaTime);
                }

                await HandleTalk();

                await Coroutine.Wait(2000, () => JournalResult.IsOpen);

                return(true);
            }

            if (JournalResult.IsOpen)
            {
                await Coroutine.Wait(2000, () => JournalResult.ButtonClickable);

                JournalResult.Complete();
                Logger.Info(Localization.Localization.ExTurnInGuildLeve_Complete, WorldManager.EorzaTime);

                await Coroutine.Wait(2000, () => !JournalResult.IsOpen);
                await HandleTalk();

                return(true);
            }

            if (!await WaitForOpenWindow())
            {
                if (MultipleQuests)
                {
                    Logger.Info(Localization.Localization.ExTurnInGuildLeve_OpenWindow);
                    CloseWindows();
                    ExProfileBehavior.Me.ClearTarget();
                }
                else
                {
                    isDone = true;
                }
            }

            return(true);
        }
Example #9
0
        private async Task <bool> Main()
        {
            if (!checkStopwatch.IsRunning)
            {
                checkStopwatch.Restart();
            }

            if (checkStopwatch.Elapsed < Condition.OneDay)
            {
                //return false;
            }

            checkStopwatch.Restart();

            var settings = RetainerMaidSettings.Instance;
            var mybags   =
                InventoryManager.GetBagsByInventoryBagId(
                    InventoryBagId.Bag1,
                    InventoryBagId.Bag2,
                    InventoryBagId.Bag3,
                    InventoryBagId.Bag4).SelectMany(bag => bag.Select(bagSlot => bagSlot)).ToArray();

            var myFullStacks = new Stack <BagSlot>(mybags.Where(b => b.IsFullStack()));

            if (myFullStacks.Count < 1 /* settings.MinStacksForDeposit */)
            {
                return(false);
            }

            var pLocation = Core.Player.Location;
            //HousingEventObjects don't have npcids and as such would be unuseable
            //var bell = GameObjectManager.GetObjectsByNPCId<EventObject>(2000401).OrderBy(r=>r.Distance2D(pLocation)).FirstOrDefault();
            var bell =
                GameObjectManager.GameObjects.Where(r => r.IsVisible && r.EnglishName == "Summoning Bell")
                .OrderBy(r => r.Distance2D(pLocation))
                .FirstOrDefault();

            if (bell == null)
            {
                Logger.Error(Localization.Localization.RetainerMaid_NoNearestSummoningBell);
                return(false);
            }

            bell.Interact();

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

            var retainerCount = SelectString.LineCount - 1;

            while (retainerCount-- > 0)
            {
                SelectString.ClickSlot((uint)retainerCount);

                await Coroutine.Wait(3000, () => Talk.DialogOpen);

                await Coroutine.Sleep(500);

                while (Talk.DialogOpen)
                {
                    Talk.Next();
                }

                await Coroutine.Wait(3000, () => Talk.DialogOpen);

                await Coroutine.Sleep(500);

                while (Talk.DialogOpen)
                {
                    Talk.Next();
                }

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

                retainers.Add(new Retainer(retainerCount));

                SelectString.ClickSlot(uint.MaxValue);

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

                await Coroutine.Wait(3000, () => Talk.DialogOpen);

                await Coroutine.Sleep(500);

                while (Talk.DialogOpen)
                {
                    Talk.Next();
                }

                await Coroutine.Sleep(2000);

                bell.Interact();

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

            var retainer = retainers.FirstOrDefault(r => r.BagSlots.Any(bs => !bs.IsFilled));

            if (retainer == null)
            {
                return(false);
            }

            var openSlots = new Stack <BagSlot>(retainer.BagSlots.Where(bs => !bs.IsFilled));

            SelectString.ClickSlot((uint)retainer.Index);
            await Coroutine.Wait(2000, () => !SelectString.IsOpen);

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

            BagSlot slot;

            while ((slot = myFullStacks.Pop()) != null)
            {
                var openSlot = openSlots.Pop();
                if (openSlot == null)
                {
                    return(false);
                }

                slot.Move(openSlot);

                await Coroutine.Yield();
            }

            return(false);
        }
Example #10
0
        public async Task <uint> Purchase(uint itemId, uint itemCount = 1)
        {
            if (!IsOpen)
            {
                return(0u);
            }

            var items = SpecialShopManager.Items;

            var specialShopItem = items?.Cast <SpecialShopItem?>().FirstOrDefault(i => i.HasValue && i.Value.ItemIds.Contains(itemId));

            //Logging.Write(Colors.Fuchsia, $"[ShopExchangeItem] Buying {specialShopItem}");
            if (!specialShopItem.HasValue)
            {
                return(0u);
            }

            if (itemCount > specialShopItem.Value.Item0.StackSize)
            {
                itemCount = specialShopItem.Value.Item0.StackSize;
            }

            if (!CanAfford(specialShopItem.Value))
            {
                return(0);
            }
            // Logging.Write(Colors.Fuchsia, $"[Purchase] Can afford {CanAfford(specialShopItem.Value)}");
            var index = items.IndexOf(specialShopItem.Value);
            var obj   = new ulong[8]
            {
                3uL,
                0uL,
                3uL,
                0uL,
                3uL,
                0uL,
                0uL,
                0uL
            };

            obj[3] = (uint)index;
            obj[5] = itemCount;
            SendAction(4, obj);
            // Logging.Write(Colors.Fuchsia, $"[Purchase] Sent Action");
            await Coroutine.Wait(5000, () => RaptureAtkUnitManager.GetWindowByName("ShopExchangeItemDialog") != null);

            if (RaptureAtkUnitManager.GetWindowByName("ShopExchangeItemDialog") != null)
            {
                //Logging.Write(Colors.Fuchsia, $"[Purchase] ShopExchangeItemDialog Open");
                RaptureAtkUnitManager.GetWindowByName("ShopExchangeItemDialog").SendAction(1, 3, 0);
                await Coroutine.Wait(5000, () => RaptureAtkUnitManager.GetWindowByName("ShopExchangeItemDialog") == null);

                await Coroutine.Wait(2000, () => SelectYesno.IsOpen || Request.IsOpen);

                if (SelectYesno.IsOpen)
                {
                    //Logging.Write(Colors.Fuchsia, $"[Purchase] Yes/no");
                    SelectYesno.Yes();
                    await Coroutine.Wait(2000, () => !SelectYesno.IsOpen);

                    await Coroutine.Wait(3000, () => Request.IsOpen);
                }

                if (Request.IsOpen)
                {
                    // Logging.Write(Colors.Fuchsia, $"[Purchase] Request");
                    for (int i = 0; i < 3; i++)
                    {
                        BagSlot item;
                        if (specialShopItem.Value.HqCurrencies[i])
                        {
                            item = InventoryManager.FilledInventoryAndArmory.FirstOrDefault(j => j.RawItemId == specialShopItem.Value.CurrencyTypes[i] && j.Count >= specialShopItem.Value.CurrencyCosts[i] && j.IsHighQuality == specialShopItem.Value.HqCurrencies[i]);
                        }
                        else
                        {
                            item = InventoryManager.FilledInventoryAndArmory.FirstOrDefault(j => j.RawItemId == specialShopItem.Value.CurrencyTypes[i] && j.Count >= specialShopItem.Value.CurrencyCosts[i]);
                        }
                        // Logging.Write(Colors.Fuchsia, $"[Purchase] Request item {item}");
                        if (item != null)
                        {
                            item.Handover();
                            await Coroutine.Sleep(500);
                        }
                    }

                    if (Request.HandOverButtonClickable)
                    {
                        Request.HandOver();
                    }

                    await Coroutine.Sleep(1000);
                }
                else
                {
                    //Logging.Write(Colors.Fuchsia, $"[Purchase] Request Not open");
                }

                if (QuestLogManager.InCutscene && AgentInterface <AgentCutScene> .Instance.CanSkip && !SelectString.IsOpen)
                {
                    AgentInterface <AgentCutScene> .Instance.PromptSkip();

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

                    SelectString.ClickSlot(0);
                    await CommonTasks.HandleLoading();

                    await Coroutine.Wait(6000, () => !QuestLogManager.InCutscene);

                    await CommonTasks.HandleLoading();

                    await Coroutine.Sleep(500);
                }
            }


            return(itemCount);
        }
Example #11
0
        public async Task <bool> GetToNpc()
        {
            if (WorldManager.ZoneId != ZoneId && WorldManager.ZoneId != 886)
            {
                while (Core.Me.IsCasting)
                {
                    await Coroutine.Sleep(1000);
                }

                if (!ConditionParser.HasAetheryte(AetheryteId))
                {
                    //Logger.Error($"We can't get to {Constants.EntranceZone.CurrentLocaleAethernetName}. You don't have that Aetheryte so do something about it...");
                    //TreeRoot.Stop();
                    return(false);
                }

                if (!WorldManager.TeleportById(AetheryteId))
                {
                    //Logger.Error($"We can't get to {Constants.EntranceZone.CurrentLocaleAethernetName}. something is very wrong...");
                    //TreeRoot.Stop();
                    return(false);
                }

                while (Core.Me.IsCasting)
                {
                    await Coroutine.Sleep(1000);
                }

                if (CommonBehaviors.IsLoading)
                {
                    await Coroutine.Wait(-1, () => !CommonBehaviors.IsLoading);
                }

                await Coroutine.Wait(10000, () => WorldManager.ZoneId == FoundationZoneId);

                await Coroutine.Sleep(3000);

                await Coroutine.Wait(10000, () => GameObjectManager.GetObjectByNPCId(70) != null);

                await Coroutine.Sleep(3000);

                var unit = GameObjectManager.GetObjectByNPCId(70);

                if (!unit.IsWithinInteractRange)
                {
                    var _target = unit.Location;
                    Navigator.PlayerMover.MoveTowards(_target);
                    while (!unit.IsWithinInteractRange)
                    {
                        Navigator.PlayerMover.MoveTowards(_target);
                        await Coroutine.Sleep(100);
                    }

                    Navigator.PlayerMover.MoveStop();
                }

                unit.Target();
                unit.Interact();
                await Coroutine.Sleep(1000);

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

                await Coroutine.Sleep(500);

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

                await Coroutine.Sleep(5000);

                if (CommonBehaviors.IsLoading)
                {
                    await Coroutine.Wait(-1, () => !CommonBehaviors.IsLoading);
                }

                await Coroutine.Sleep(3000);
            }

            /*            if (GameObjectManager.GetObjectByNPCId(NpcId) != null)
             *              await CommonTasks.MoveAndStop(
             *                  new MoveToParameters(GameObjectManager.GetObjectByNPCId(NpcId).Location,
             *                      "Moving toward NPC"), 5f, true);*/
            //NpcId = GameObjectManager.GameObjects.First(i => i.EnglishName == EnglishName).NpcId;
            if (Npc.Location.Distance(Core.Me.Location) > 5f)
            {
                var _target = new Vector3(10.58188f, -15.96282f, 163.8702f);
                Navigator.PlayerMover.MoveTowards(_target);
                while (_target.Distance2D(Core.Me.Location) >= 4)
                {
                    Navigator.PlayerMover.MoveTowards(_target);
                    await Coroutine.Sleep(100);
                }

                //await Buddy.Coroutines.Coroutine.Sleep(1500); // (again, probably better to just wait until distance to destination is < 2.0f or something)
                Navigator.PlayerMover.MoveStop();

                _target = Npc.Location;
                Navigator.PlayerMover.MoveTowards(_target);
                while (_target.Distance2D(Core.Me.Location) >= 4)
                {
                    Navigator.PlayerMover.MoveTowards(_target);
                    await Coroutine.Sleep(100);
                }

                //await Buddy.Coroutines.Coroutine.Sleep(1500); // (again, probably better to just wait until distance to destination is < 2.0f or something)
                Navigator.PlayerMover.MoveStop();
            }

            return(Npc.Location.Distance(Core.Me.Location) <= 5f);
        }
Example #12
0
        protected override async Task <bool> Main()
        {
            var retainerList = new RetainerList();

            foreach (var unit in GameObjectManager.GameObjects.OrderBy(r => r.Distance()))
            {
                if (unit.NpcId == 2000401 || unit.NpcId == 2000441 || unit.Name == "Summoning Bell" || unit.Name == "Sonnette" || unit.Name == "Krämerklingel" ||
                    unit.Name == "リテイナーベル" || unit.Name == "传唤铃")
                {
                    unit.Interact();
                    break;
                }
            }

            if (!await Coroutine.Wait(5000, () => RetainerList.IsOpen))
            {
                return(isDone = true);
            }
            {
                int  retainerCount = GetRetainerNum.GetNumberOfRetainers();
                uint index         = 0;
                while (index < retainerCount)
                {
                    Log("Checking Retainer n° " + (index + 1));
                    await Coroutine.Sleep(200);

                    // Select retainer
                    await retainerList.SelectRetainerAndSkipDialog(index);

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

                    if (!SelectString.IsOpen)
                    {
                        Log("Something went wrong when checking Retainer n° " + (index + 1) + ", its contract might be suspended !");
                        break;
                    }
                    string ventureLine = SelectString.Lines()[5];
                    Log("Venture Status : " + ventureLine);
                    if (ventureLine.EndsWith("(Complete)") || ventureLine.EndsWith("Unternehmung einsehen") || ventureLine.EndsWith("tâche terminée") || ventureLine.EndsWith("[完了]") || ventureLine.EndsWith("[探险归来]") || ventureLine.EndsWith("[结束]"))
                    {
                        Log("Venture Completed !");
                        // Click on the completed venture
                        SelectString.ClickSlot(5);
                        await Coroutine.Wait(5000, () => RetainerTaskResult.IsOpen);

                        // Assign a new venture
                        RetainerTaskResult.Reassign();
                        await Coroutine.Wait(5000, () => RetainerTaskAsk.IsOpen);

                        // Confirm new venture
                        RetainerTaskAsk.Confirm();
                        await Coroutine.Wait(5000, () => Talk.DialogOpen);

                        // Skip Dialog
                        Talk.Next();
                        await Coroutine.Wait(5000, () => SelectString.IsOpen);
                    }
                    SelectString.ClickSlot((uint)SelectString.LineCount - 1);
                    await Coroutine.Wait(5000, () => Talk.DialogOpen);

                    // Skip Dialog
                    Talk.Next();
                    await Coroutine.Wait(5000, () => RetainerList.IsOpen);

                    index++;
                }
                Log("No more Retainer to check");
                await retainerList.Refresh(200);

                await retainerList.CloseInstanceGently();

                return(isDone = true);
            }
        }
Example #13
0
        private async Task <bool> HandleWindows()
        {
            while (WindowsOpen())
            {
                if (SelectString.IsOpen)
                {
                    if (DialogOption > -1)
                    {
                        SelectString.ClickSlot((uint)DialogOption);
                    }

                    SelectString.ClickLineEquals(QuestName);
                    await Coroutine.Sleep(100);
                }

                if (SelectIconString.IsOpen)
                {
                    if (DialogOption > -1)
                    {
                        SelectIconString.ClickSlot((uint)DialogOption);
                    }

                    SelectIconString.ClickLineEquals(QuestName);
                    await Coroutine.Sleep(100);
                }

                if (SelectYesno.IsOpen)
                {
                    SelectYesno.ClickYes();
                    await Coroutine.Sleep(100);
                }

                if (Request.IsOpen)
                {
                    var items = InventoryManager.FilledInventoryAndArmory.ToArray();
                    for (int i = 0; i < ItemIds.Length; i++)
                    {
                        BagSlot item;
                        if (RequiresHq[i])
                        {
                            item = items.FirstOrDefault(z => z.RawItemId == ItemIds[i] && z.IsHighQuality && !usedSlots.Contains(z));
                        }
                        else
                        {
                            item = items.FirstOrDefault(z => z.RawItemId == ItemIds[i] && !usedSlots.Contains(z));
                        }

                        item.Handover();
                        usedSlots.Add(item);
                    }
                    usedSlots.Clear();
                    Request.HandOver();
                    await Coroutine.Sleep(100);
                }

                if (JournalResult.IsOpen)
                {
                    if (JournalResult.ButtonClickable)
                    {
                        JournalResult.Complete();
                    }

                    if (hasRewards)
                    {
                        JournalResult.SelectSlot(RewardSlot);
                    }

                    await Coroutine.Sleep(100);
                }

                if (JournalAccept.IsOpen)
                {
                    JournalAccept.Accept();
                    await Coroutine.Sleep(100);
                }

                if (Talk.DialogOpen)
                {
                    Talk.Next();
                    await Coroutine.Sleep(100);
                }

                if (QuestLogManager.InCutscene)
                {
                    if (AgentCutScene.Instance.CanSkip && !SelectString.IsOpen)
                    {
                        AgentCutScene.Instance.PromptSkip();
                        if (await Coroutine.Wait(600, () => SelectString.IsOpen))
                        {
                            SelectString.ClickSlot(0);
                            await Coroutine.Sleep(1000);
                        }
                    }
                }

                await Coroutine.Yield();
            }

            return(QuestLogManager.InCutscene || Core.Player.HasTarget);
        }
Example #14
0
        private async Task JoinDutyTask(int DutyId, bool Undersized, bool Trial, bool Raid)
        {
            if (Undersized)
            {
                Logging.WriteDiagnostic("Joining Duty as Undersized party.");
                GameSettingsManager.JoinWithUndersizedParty = true;
            }
            else
            {
                Logging.WriteDiagnostic("Joining Duty as normal group.");
                GameSettingsManager.JoinWithUndersizedParty = false;
            }

            Logging.WriteDiagnostic("Queuing for " + DataManager.InstanceContentResults[(uint)DutyId].CurrentLocaleName);
            DutyManager.Queue(DataManager.InstanceContentResults[(uint)DutyId]);

            await Coroutine.Wait(5000, () => (DutyManager.QueueState == QueueState.CommenceAvailable || DutyManager.QueueState == QueueState.JoiningInstance));

            Logging.WriteDiagnostic("Queued for Dungeon");

            while (DutyManager.QueueState != QueueState.None || DutyManager.QueueState != QueueState.InDungeon || CommonBehaviors.IsLoading)
            {
                if (DutyManager.QueueState == QueueState.CommenceAvailable)
                {
                    Logging.WriteDiagnostic("Waiting for queue pop.");
                    await Coroutine.Wait(-1,
                                         () => (DutyManager.QueueState == QueueState.JoiningInstance ||
                                                DutyManager.QueueState == QueueState.None));
                }

                if (DutyManager.QueueState == QueueState.JoiningInstance)
                {
                    Logging.WriteDiagnostic("Dungeon popped, commencing in 3.");
                    await Coroutine.Sleep(3000);

                    DutyManager.Commence();
                    await Coroutine.Wait(-1,
                                         () => (DutyManager.QueueState == QueueState.LoadingContent ||
                                                DutyManager.QueueState == QueueState.CommenceAvailable));
                }

                if (DutyManager.QueueState == QueueState.LoadingContent)
                {
                    Logging.WriteDiagnostic("Waiting for everyone to accept");
                    await Coroutine.Wait(-1, () => (CommonBehaviors.IsLoading || DutyManager.QueueState == QueueState.CommenceAvailable));

                    await Coroutine.Sleep(1000);
                }

                if (CommonBehaviors.IsLoading)
                {
                    break;
                }
                await Coroutine.Sleep(500);
            }

            if (DutyManager.QueueState == QueueState.None)
            {
                return;
            }

            await Coroutine.Sleep(500);

            if (CommonBehaviors.IsLoading)
            {
                await Coroutine.Wait(-1, () => !CommonBehaviors.IsLoading);
            }

            if (QuestLogManager.InCutscene)
            {
                TreeRoot.StatusText = "InCutscene";
                if (ff14bot.RemoteAgents.AgentCutScene.Instance != null)
                {
                    ff14bot.RemoteAgents.AgentCutScene.Instance.PromptSkip();
                    await Coroutine.Wait(250, () => SelectString.IsOpen);

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

            Logging.WriteDiagnostic("Should be in duty");

            var director = ((ff14bot.Directors.InstanceContentDirector)DirectorManager.ActiveDirector);

            if (director != null)
            {
                if (Trial)
                {
                    if (director.TimeLeftInDungeon >= new TimeSpan(0, 60, 0))
                    {
                        Logging.WriteDiagnostic("Barrier up");
                        await Coroutine.Wait(-1, () => director.TimeLeftInDungeon < new TimeSpan(0, 59, 58));
                    }
                }
                if (Raid)
                {
                    if (director.TimeLeftInDungeon >= new TimeSpan(2, 0, 0))
                    {
                        Logging.WriteDiagnostic("Barrier up");
                        await Coroutine.Wait(-1, () => director.TimeLeftInDungeon < new TimeSpan(1, 59, 58));
                    }
                }
                else
                {
                    if (director.TimeLeftInDungeon >= new TimeSpan(1, 30, 0))
                    {
                        Logging.WriteDiagnostic("Barrier up");
                        await Coroutine.Wait(-1, () => director.TimeLeftInDungeon < new TimeSpan(1, 29, 58));
                    }
                }
            }
            else
            {
                Logging.WriteDiagnostic("Director is null");
            }

            Logging.WriteDiagnostic("Should be ready");

            _isDone = true;
        }
Example #15
0
 protected override Composite CreateBehavior()
 {
     return(new PrioritySelector(
                new Decorator(ret => QuestId == 65713 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65714 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65715 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65716 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65717 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65718 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65719 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65752 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(0);
     })
                              ),
                new Decorator(ret => QuestId == 65789 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65987 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 66046 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(0);
     })
                              ),
                new Decorator(ret => QuestId == 67023 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(0);
     })
                              ),
                new Decorator(ret => QuestId == 67201 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(0);
     })
                              ),
                new Decorator(ret => QuestId == 67254 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(0);
     })
                              ),
                new Decorator(ret => QuestId == 67591 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(0);
     })
                              ),
                new Decorator(ret => QuestId == 67670 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(0);
     })
                              ),
                new Decorator(ret => QuestId == 67935 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(0);
     })
                              ),
                new Decorator(ret => QuestId == 67937 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(0);
     })
                              ),
                new Decorator(ret => QuestId == 67942 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(0);
     })
                              ),
                new Decorator(ret => QuestId == 67943 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(0);
     })
                              ),
                new Decorator(ret => QuestId == 68024 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(0);
     })
                              ),
                new Decorator(ret => QuestId == 68168 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(0);
     })
                              ),
                base.CreateBehavior()
                ));
 }
Example #16
0
        public async Task <bool> Shop()
        {
            var npcId = GameObjectManager.GetObjectByNPCId(1012301);

            if (!npcId.IsWithinInteractRange)
            {
                var _target = npcId.Location;
                Navigator.PlayerMover.MoveTowards(_target);
                while (_target.Distance2D(Core.Me.Location) >= 4)
                {
                    Navigator.PlayerMover.MoveTowards(_target);
                    await Coroutine.Sleep(100);
                }

                Navigator.PlayerMover.MoveStop();
            }

            npcId.Interact();

            await Coroutine.Wait(5000, () => SelectIconString.IsOpen);

            SelectIconString.ClickSlot(0);

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

            SelectString.ClickSlot(5);

            await Coroutine.Sleep(700);

            var windowName = "ShopExchangeCurrency";
            await Coroutine.Wait(5000, () => RaptureAtkUnitManager.GetWindowByName(windowName) != null);

            var windowByName = RaptureAtkUnitManager.GetWindowByName(windowName);

            if (windowByName == null)
            {
                return(false);
            }

            while (SpecialCurrencyManager.GetCurrencyCount(SpecialCurrency.YellowCraftersScrips) > 50 && InventoryManager.FreeSlots > 1)
            {
                if (windowByName != null)
                {
                    windowByName.SendAction(4, 3, 0, 3, 0x19, 3, 1, 0, 0);
                }

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

                if (SelectYesno.IsOpen)
                {
                    SelectYesno.Yes();
                }

                await Coroutine.Sleep(700);
            }

            windowByName.SendAction(1, 3uL, 4294967295uL);

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

            SelectString.ClickSlot((uint)(SelectString.LineCount - 1));

            await Coroutine.Sleep(700);

            return(true);
        }
Example #17
0
        private async Task MainMenu()
        {
            TreeRoot.StatusText = "Running Main Menu";
            if (PartyManager.IsInParty && PartyManager.IsPartyLeader)
            {
                if (!IsCrossRealm)
                {
                    Logger.Warn("I am a Party Leader, waiting for everyone to join the zone.");
                    await Coroutine.Wait(TimeSpan.FromMinutes(30), PartyLeaderWaitConditions);
                }
                else
                {
                    Logger.Warn("I am a Party Leader in a XRealm Party. I assume everyone is in the zone.");
                }

                if (DeepDungeonCombined.StopPlz)
                {
                    return;
                }

                Logger.Warn("Everyone is now in the zone");
                for (var i = 0; i < 3; i++)
                {
                    Logger.Warn("Giving them {0} seconds to do what they need to at the NPC", 30 - i * 10);
                    await Coroutine.Sleep(TimeSpan.FromSeconds(10));

                    if (DeepDungeonCombined.StopPlz)
                    {
                        return;
                    }
                }
            }

            //read the current level state
            await ReadStartingLevel();

            // have save data and our max level is
            if (GetFloorStatus(_saveStates))
            {
                Logger.Verbose("Resetting the floor");
                await DeepDungeonSaveData.ClickReset(UseSaveSlot);

                // todo: wait for server response in a better way.
                await Coroutine.Sleep(1000);
            }

            if (_error)
            {
                lock (_errorLock)
                {
                    _error = false;
                }
            }


            if (!PartyManager.IsInParty || PartyManager.IsPartyLeader)
            {
                Logger.Verbose("Starting Save Slot Selection process");

                await DeepDungeonSaveData.ClickSaveSlot(UseSaveSlot);

                await Coroutine.Wait(2000, () => SelectString.IsOpen || ContentsFinderConfirm.IsOpen || SelectYesno.IsOpen);

                // if select yesno is open (new as of 4.36 hotfixes)
                if (SelectYesno.IsOpen)
                {
                    SelectYesno.ClickYes();
                    await Coroutine.Sleep(1000);
                }

                // if we are using an "empty" save slot
                if (SelectString.IsOpen)
                {
                    Logger.Verbose("Using Empty Save Slot");
                    Logger.Verbose("Going through the Talk dialogs...");

                    await Coroutine.Sleep(1000);

                    SelectString.ClickSlot(0);

                    await Coroutine.Sleep(1000);

                    //                    Logger.Verbose("Are you sure Fixed Party");
                    await Coroutine.Wait(1000, () => SelectYesno.IsOpen);

                    await Coroutine.Sleep(150);

                    if (SelectYesno.IsOpen)
                    {
                        SelectYesno.ClickYes();
                        await Coroutine.Sleep(150);
                    }

                    await Coroutine.Sleep(1000);

                    //-- Are you sure you want to enter alone?
                    if (!PartyManager.IsInParty)
                    {
                        //                        Logger.Verbose("Enter Alone Talk");
                        //talk stuff
                        await Coroutine.Wait(1000, () => Talk.DialogOpen);

                        await Coroutine.Sleep(150);

                        Talk.Next();

                        await Coroutine.Sleep(500);

                        //                        Logger.Verbose("Enter Alone?");
                        await Coroutine.Wait(1000, () => SelectYesno.IsOpen);

                        SelectYesno.ClickYes();
                        await Coroutine.Sleep(1000);
                    }

                    //                    Logger.Verbose("Floor 51 wait");
                    //--floor 51 logic
                    await Coroutine.Wait(1000, () => SelectString.IsOpen || ContentsFinderConfirm.IsOpen);

                    if (SelectString.IsOpen)
                    {
                        await Coroutine.Sleep(1000);

                        if (Settings.Instance.StartAt51)
                        {
                            Logger.Verbose("Start at {1}: {0}", _bettertargetFloor.End > Constants.SelectedDungeon.CheckPointLevel - 1, Constants.SelectedDungeon.CheckPointLevel);
                        }

                        if (Settings.Instance.StartAt51 && _bettertargetFloor.End > Constants.SelectedDungeon.CheckPointLevel - 1)
                        {
                            SelectString.ClickSlot(1);
                        }
                        else
                        {
                            SelectString.ClickSlot(0);
                        }
                        await Coroutine.Sleep(1000);
                    }

                    Logger.Verbose("Done with window interaction.");
                }
                else
                {
                    Logger.Verbose($"ContentsFinderConfirm is open: {ContentsFinderConfirm.IsOpen} so we aren't going through the main menu.");
                }

                _bettertargetFloor = null;
            }

            Logger.Info("Waiting on the queue, Or for an error.");
            DungeonQueue.Reset();
        }
Example #18
0
        protected override async Task <bool> Main()
        {
            InitializeFoodName();
            if (CleanBefore)
            {
                for (var i = 1; i <= 3; i++)
                {
                    if (ConditionParser.HasAtLeast(8168, 1))
                    {
                        foreach (var unit in GameObjectManager.GameObjects.OrderBy(r => r.Distance()))
                        {
                            if (unit.EnglishName == "Chocobo Stable")
                            {
                                unit.Interact();
                                break;
                            }
                        }
                        await Coroutine.Wait(5000, () => SelectString.IsOpen);

                        if (!SelectString.IsOpen)
                        {
                            continue;
                        }
                        SelectString.ClickSlot((uint)SelectString.LineCount - 3);
                        await Coroutine.Wait(5000, () => SelectYesno.IsOpen);

                        Log("Cleaning Stable n°{0}", i);
                        SelectYesno.ClickYes();
                        await Coroutine.Sleep(2000);
                    }
                    else
                    {
                        Log("No Magicked Stable Broom left");
                        break;
                    }
                }
            }
            if (!ChocoboManager.IsStabled)
            {
                foreach (var unit in GameObjectManager.GameObjects.OrderBy(r => r.Distance()))
                {
                    if (unit.EnglishName == "Chocobo Stable")
                    {
                        unit.Interact();
                        break;
                    }
                }
                await Coroutine.Wait(5000, () => SelectString.IsOpen);

                if (SelectString.IsOpen)
                {
                    SelectString.ClickSlot(1);
                    await Coroutine.Wait(5000, () => SelectYesno.IsOpen);

                    Log("Chocobo Stabled");
                    SelectYesno.ClickYes();
                }
                else
                {
                    Log("Failed to open menu");
                }
            }
            await Coroutine.Sleep(3000);

            foreach (var unit in GameObjectManager.GameObjects.OrderBy(r => r.Distance()))
            {
                if (unit.EnglishName == "Chocobo Stable")
                {
                    unit.Interact();
                    break;
                }
            }
            await Coroutine.Wait(5000, () => SelectString.IsOpen);

            if (SelectString.IsOpen)
            {
                SelectString.ClickSlot(0);
                await Coroutine.Wait(5000, () => HousingChocoboList.IsOpen);

                await Coroutine.Sleep(1500);

                if (HousingChocoboList.IsOpen)
                {
                    //Look for our chocobo
                    var items = HousingChocoboList.Items;
                    //512 possible chocobos, 14 items per page...
                    for (uint stableSection = 0; stableSection < AgentHousingBuddyList.Instance.TotalPages; stableSection++)
                    {
                        if (stableSection != AgentHousingBuddyList.Instance.CurrentPage)
                        {
                            Log("Switching to page {0}", stableSection);
                            HousingChocoboList.SelectSection(stableSection);
                            await Coroutine.Sleep(5000);

                            items = HousingChocoboList.Items;
                        }
                        for (uint i = 0; i < items.Length; i++)
                        {
                            if (string.IsNullOrEmpty(items[i].PlayerName))
                            {
                                continue;
                            }
                            if (i == 0)
                            {
                                if (items[i].ReadyAt < DateTime.Now)
                                {
                                    Log("Selecting my Chocobo");
                                    HousingChocoboList.SelectMyChocobo();
                                    if (await Coroutine.Wait(5000, () => SelectYesno.IsOpen) && string.Equals("None", ThavnairianOnion, StringComparison.OrdinalIgnoreCase))
                                    {
                                        Log("{0}, {1}'s chocobo is maxed out", items[i].ChocoboName, items[i].PlayerName);
                                        SelectYesno.ClickNo();
                                        await Coroutine.Sleep(1000);

                                        continue;
                                    }
                                    if (await Coroutine.Wait(5000, () => SelectYesno.IsOpen) && !string.Equals("None", ThavnairianOnion, StringComparison.OrdinalIgnoreCase))
                                    {
                                        if (ConditionParser.HasAtLeast(8166, 1))
                                        {
                                            Log("{0}, {1}'s chocobo is maxed out, changing food to Thavnairian Onion", items[i].ChocoboName, items[i].PlayerName);
                                            SelectYesno.ClickNo();
                                            await Coroutine.Wait(1000, () => !SelectYesno.IsOpen);

                                            await Coroutine.Sleep(500);

                                            Log("Selecting {0}, {1}'s chocobo on page {2}", items[i].ChocoboName, items[i].PlayerName, stableSection);
                                            HousingChocoboList.SelectMyChocobo();
                                            await Coroutine.Wait(5000, () => SelectYesno.IsOpen);

                                            SelectYesno.ClickYes();
                                            ChocoboFoodId = 8166;
                                        }
                                        else
                                        {
                                            Log("{0}, {1}'s chocobo is maxed out but you don't have any Thavnairian Onion", items[i].ChocoboName, items[i].PlayerName);
                                            SelectYesno.ClickNo();
                                            await Coroutine.Sleep(1000);

                                            continue;
                                        }
                                    }
                                    Log("Waiting for inventory menu to appear....");
                                    //Wait for the inventory window to open and be ready
                                    //Technically the inventory windows are always 'open' so we check if their callbackhandler has been set
                                    if (!await Coroutine.Wait(5000, () => AgentInventoryContext.Instance.CallbackHandlerSet))
                                    {
                                        Log("Inventory menu failed to appear, aborting current iteration.");
                                        continue;
                                    }
                                    Log("Feeding Chocobo : Food Name : {0}, Food ID : {1}", _chocoboFood[ChocoboFoodId], ChocoboFoodId);
                                    AgentHousingBuddyList.Instance.Feed(ChocoboFoodId);
                                    if (await Coroutine.Wait(5000, () => SelectYesno.IsOpen))
                                    {
                                        SelectYesno.ClickYes();
                                        await Coroutine.Sleep(1000);
                                    }
                                    Log("Waiting for cutscene to start....");
                                    if (await Coroutine.Wait(5000, () => QuestLogManager.InCutscene))
                                    {
                                        Log("Waiting for cutscene to end....");
                                        await Coroutine.Wait(Timeout.Infinite, () => !QuestLogManager.InCutscene);
                                    }
                                    Log("Waiting for menu to reappear....");
                                    await Coroutine.Wait(Timeout.Infinite, () => HousingChocoboList.IsOpen);

                                    await Coroutine.Sleep(1000);
                                }
                                else
                                {
                                    Log("{0}, {1}'s chocobo can't be fed yet ...", items[i].ChocoboName, items[i].PlayerName);
                                }
                            }
                            else if (string.Equals(items[i].PlayerName, PlayerName, StringComparison.OrdinalIgnoreCase) || string.Equals("All", PlayerName, StringComparison.OrdinalIgnoreCase))
                            {
                                if (items[i].ReadyAt < DateTime.Now)
                                {
                                    Log("Selecting {0}, {1}'s chocobo on page {2}", items[i].ChocoboName, items[i].PlayerName, stableSection);
                                    HousingChocoboList.SelectChocobo(i);
                                    //Chocobo is maxed out, don't interact with it again
                                    if (await Coroutine.Wait(5000, () => SelectYesno.IsOpen) && string.Equals("None", ThavnairianOnion, StringComparison.OrdinalIgnoreCase))
                                    {
                                        Log("{0}, {1}'s chocobo is maxed out", items[i].ChocoboName, items[i].PlayerName);
                                        SelectYesno.ClickNo();
                                        await Coroutine.Sleep(1000);

                                        continue;
                                    }
                                    //Chocobo is maxed out, don't interact with it again
                                    if (await Coroutine.Wait(5000, () => SelectYesno.IsOpen) && string.Equals("All", ThavnairianOnion, StringComparison.OrdinalIgnoreCase))
                                    {
                                        if (ConditionParser.HasAtLeast(8166, 1))
                                        {
                                            Log("{0}, {1}'s chocobo is maxed out, changing food to Thavnairian Onion", items[i].ChocoboName, items[i].PlayerName);
                                            SelectYesno.ClickNo();
                                            await Coroutine.Wait(1000, () => !SelectYesno.IsOpen);

                                            await Coroutine.Sleep(500);

                                            Log("Selecting {0}, {1}'s chocobo on page {2}", items[i].ChocoboName, items[i].PlayerName, stableSection);
                                            HousingChocoboList.SelectChocobo(i);
                                            await Coroutine.Wait(5000, () => SelectYesno.IsOpen);

                                            SelectYesno.ClickYes();
                                            ChocoboFoodId = 8166;
                                        }
                                        else
                                        {
                                            Log("{0}, {1}'s chocobo is maxed out but you don't have any Thavnairian Onion", items[i].ChocoboName, items[i].PlayerName);
                                            SelectYesno.ClickNo();
                                            await Coroutine.Sleep(1000);

                                            continue;
                                        }
                                    }
                                    Log("Waiting for inventory menu to appear....");
                                    //Wait for the inventory window to open and be ready
                                    //Technically the inventory windows are always 'open' so we check if their callbackhandler has been set
                                    if (!await Coroutine.Wait(5000, () => AgentInventoryContext.Instance.CallbackHandlerSet))
                                    {
                                        Log("Inventory menu failed to appear, aborting current iteration.");
                                        continue;
                                    }
                                    Log("Feeding Chocobo : Food Name : {0}, Food ID : {1}", _chocoboFood[ChocoboFoodId], ChocoboFoodId);
                                    AgentHousingBuddyList.Instance.Feed(ChocoboFoodId);
                                    if (await Coroutine.Wait(5000, () => SelectYesno.IsOpen))
                                    {
                                        SelectYesno.ClickYes();
                                        await Coroutine.Sleep(1000);
                                    }
                                    Log("Waiting for cutscene to start....");
                                    if (await Coroutine.Wait(5000, () => QuestLogManager.InCutscene))
                                    {
                                        Log("Waiting for cutscene to end....");
                                        await Coroutine.Wait(Timeout.Infinite, () => !QuestLogManager.InCutscene);
                                    }
                                    Log("Waiting for menu to reappear....");
                                    await Coroutine.Wait(Timeout.Infinite, () => HousingChocoboList.IsOpen);

                                    await Coroutine.Sleep(1000);
                                }
                                else
                                {
                                    Log("{0}, {1}'s chocobo can't be fed yet ...", items[i].ChocoboName, items[i].PlayerName);
                                }
                            }
                        }
                    }
                    await Coroutine.Sleep(500);

                    HousingChocoboList.Close();
                    await Coroutine.Wait(5000, () => !HousingChocoboList.IsOpen);
                }
                else if (HousingMyChocobo.IsOpen)
                {
                    var matches = TimeRegex.Match(HousingMyChocobo.Lines[0]);
                    if (!matches.Success)
                    {
                        //We are ready to train now
                        HousingMyChocobo.SelectLine(0);
                        //Chocobo is maxed out, don't interact with it again
                        if (await Coroutine.Wait(5000, () => SelectYesno.IsOpen) && string.Equals("None", ThavnairianOnion, StringComparison.OrdinalIgnoreCase))
                        {
                            Log("Your chocobo is maxed out");
                            SelectYesno.ClickNo();
                            await Coroutine.Sleep(1000);
                        }
                        //Chocobo is maxed out, don't interact with it again
                        if (await Coroutine.Wait(5000, () => SelectYesno.IsOpen) && (string.Equals("Me", ThavnairianOnion, StringComparison.OrdinalIgnoreCase) ||
                                                                                     string.Equals("All", ThavnairianOnion, StringComparison.OrdinalIgnoreCase)))
                        {
                            if (ConditionParser.HasAtLeast(8166, 1))
                            {
                                Log("Your chocobo is maxed out, changing food to Thavnairian Onion");
                                SelectYesno.ClickNo();
                                await Coroutine.Wait(1000, () => !SelectYesno.IsOpen);

                                await Coroutine.Sleep(500);

                                HousingMyChocobo.SelectLine(0);
                                await Coroutine.Wait(5000, () => SelectYesno.IsOpen);

                                SelectYesno.ClickYes();
                                ChocoboFoodId = 8166;
                            }
                            else
                            {
                                Log("Your chocobo is maxed out but you don't have any Thavnairian Onion");
                                SelectYesno.ClickNo();
                                await Coroutine.Sleep(1000);
                            }
                        }
                        Log("Waiting for inventory menu to appear....");
                        //Wait for the inventory window to open and be ready
                        //Technically the inventory windows are always 'open' so we check if their callbackhandler has been set
                        if (!await Coroutine.Wait(5000, () => AgentInventoryContext.Instance.CallbackHandlerSet))
                        {
                            Log("Inventory menu failed to appear, aborting current iteration.");
                            return(isDone = true);
                        }
                        Log("Feeding Chocobo : Food Name : {0}, Food ID : {1}", _chocoboFood[ChocoboFoodId], ChocoboFoodId);
                        AgentHousingBuddyList.Instance.Feed(ChocoboFoodId);
                        if (await Coroutine.Wait(5000, () => SelectYesno.IsOpen))
                        {
                            SelectYesno.ClickYes();
                            await Coroutine.Sleep(1000);
                        }
                        Log("Waiting for cutscene to start....");
                        if (await Coroutine.Wait(5000, () => QuestLogManager.InCutscene))
                        {
                            Log("Waiting for cutscene to end....");
                            await Coroutine.Wait(Timeout.Infinite, () => !QuestLogManager.InCutscene);
                        }
                        Log("Waiting for menu to reappear....");
                        await Coroutine.Wait(Timeout.Infinite, () => HousingMyChocobo.IsOpen);

                        await Coroutine.Sleep(1000);
                    }
                    else
                    {
                        Log("Your chocobo can't be fed yet ...");
                    }
                    await Coroutine.Sleep(500);

                    HousingMyChocobo.Close();
                    await Coroutine.Wait(5000, () => !HousingMyChocobo.IsOpen);
                }
                else
                {
                    Log("Failed to open Chocobo list");
                }
                SelectString.ClickSlot((uint)SelectString.LineCount - 1);
                await Coroutine.Wait(5000, () => !SelectString.IsOpen);
            }
            else
            {
                Log("Failed to open menu");
            }
            await Coroutine.Sleep(3000);

            if (!FetchAfter)
            {
                return(isDone = true);
            }
            {
                foreach (var unit in GameObjectManager.GameObjects.OrderBy(r => r.Distance()))
                {
                    if (unit.EnglishName == "Chocobo Stable")
                    {
                        unit.Interact();
                        break;
                    }
                }
                await Coroutine.Wait(5000, () => SelectString.IsOpen);

                if (SelectString.IsOpen)
                {
                    SelectString.ClickSlot(1);
                    await Coroutine.Wait(5000, () => HousingMyChocobo.IsOpen);

                    if (HousingMyChocobo.IsOpen)
                    {
                        HousingMyChocobo.SelectLine(3);
                        await Coroutine.Wait(5000, () => SelectYesno.IsOpen);

                        SelectYesno.ClickYes();
                        Log("Chocobo Fetch");
                    }
                    else
                    {
                        Log("Failed to acces to my chocobo");
                        SelectString.ClickSlot((uint)SelectString.LineCount - 1);
                        await Coroutine.Wait(5000, () => !SelectString.IsOpen);
                    }
                }
                else
                {
                    Log("Failed to open menu");
                }
            }
            return(isDone = true);
        }
Example #19
0
 protected override Composite CreateBehavior()
 {
     return(new PrioritySelector(
                new Decorator(ret => Talk.DialogOpen,
                              new Action(r =>
     {
         Talk.Next();
     })
                              ),
                new Decorator(ret => IsOpen,
                              new Sequence(
                                  new Sleep(1, 2),
                                  new Action(r =>
     {
         //Logging.Write("Accepting leve...");
         AcceptLeve((uint)LeveId);
     }),
                                  new Sleep(1, 2),
                                  new Action(r =>
     {
         leveopened = true;
         //Logging.Write("Closing GuildLeve window...");
         Close();
     }),
                                  new Sleep(1, 2)
                                  )
                              ),
                new Decorator(ret => SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => SelectString.IsOpen,
                              new Action(r =>
     {
         if (!leveopened)
         {
             SelectString.ClickLineContains(LeveType);
         }
         else
         {
             SelectString.ClickSlot(5);
         }
     })
                              ),
                new Decorator(ret => JournalResult.IsOpen,
                              new Action(r =>
     {
         JournalResult.Complete();
     })
                              ),
                new Decorator(ret => interacted && !Core.Player.HasTarget,
                              new Action(r =>
     {
         _done = true;
     })
                              ),
                new Decorator(ret => Vector3.Distance(Core.Player.Location, XYZ) > 3,
                              CommonBehaviors.MoveTo(r => XYZ, "Moving to PickupLeve location")
                              ),
                new Decorator(ret => Vector3.Distance(Core.Player.Location, XYZ) <= 3 && MovementManager.IsMoving,
                              ff14bot.Behavior.CommonBehaviors.MoveStop()
                              ),
                new Decorator(ret => Vector3.Distance(Core.Player.Location, XYZ) <= 3 && !MovementManager.IsMoving && !interacted,
                              new Action(r =>
     {
         GameObjectManager.GetObjectByNPCId((uint)NpcId).Interact();
         interacted = true;
     })
                              ),
                new ActionAlwaysSucceed()
                ));
 }
Example #20
0
        public static async Task SmallTalk(int waitTime = 500)
        {
            await Coroutine.Wait(waitTime, () => InSmallTalk);

            while (InSmallTalk)
            {
                await Coroutine.Yield();

                if (CommonBehaviors.IsLoading)
                {
                    await Coroutine.Wait(-1, () => !CommonBehaviors.IsLoading);
                }

                if (SelectYesno.IsOpen)
                {
                    SelectYesno.ClickNo();
                }

                if (SelectString.IsOpen)
                {
                    if (!await WindowEscapeSpam("SelectString"))
                    {
                        if (SelectString.Lines().Contains("Cancel"))
                        {
                            SelectString.ClickLineContains("Cancel");
                        }
                        else if (SelectString.Lines().Contains("Quit"))
                        {
                            SelectString.ClickLineContains("Quit");
                        }
                        else if (SelectString.Lines().Contains("Exit"))
                        {
                            SelectString.ClickLineContains("Exit");
                        }
                        else if (SelectString.Lines().Contains("Nothing"))
                        {
                            SelectString.ClickLineContains("Nothing");
                        }
                        else
                        {
                            SelectString.ClickSlot((uint)(SelectString.LineCount - 1));
                        }
                    }
                }

                if (SelectIconString.IsOpen)
                {
                    if (!await WindowEscapeSpam("SelectIconString"))
                    {
                        if (SelectIconString.Lines().Contains("Cancel"))
                        {
                            SelectString.ClickLineContains("Cancel");
                        }
                        else if (SelectIconString.Lines().Contains("Quit"))
                        {
                            SelectString.ClickLineContains("Quit");
                        }
                        else if (SelectIconString.Lines().Contains("Exit"))
                        {
                            SelectString.ClickLineContains("Exit");
                        }
                        else if (SelectIconString.Lines().Contains("Nothing"))
                        {
                            SelectString.ClickLineContains("Nothing");
                        }
                        else
                        {
                            SelectIconString.ClickSlot((uint)(SelectIconString.LineCount - 1));
                        }
                    }
                }

                while (QuestLogManager.InCutscene)
                {
                    AgentCutScene.Instance.PromptSkip();
                    if (AgentCutScene.Instance.CanSkip && SelectString.IsOpen)
                    {
                        SelectString.ClickSlot(0);
                    }
                    await Coroutine.Yield();
                }

                while (Talk.DialogOpen)
                {
                    Talk.Next();
                    await Coroutine.Wait(100, () => !Talk.DialogOpen);

                    await Coroutine.Wait(100, () => Talk.DialogOpen);

                    await Coroutine.Yield();
                }

                if (JournalAccept.IsOpen)
                {
                    JournalAccept.Decline();
                }

                await Coroutine.Wait(500, () => InSmallTalk);
            }
        }
 protected override Composite CreateBehavior()
 {
     return(new PrioritySelector(
                new Decorator(ret => QuestId == 65539 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65590 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65622 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65667 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65668 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65669 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65821 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65846 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65880 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65964 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65988 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 66053 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(2);
     })
                              ),
                new Decorator(ret => QuestId == 66068 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 66133 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 66287 && Vector3.Distance(Core.Player.Location, XYZ) < InteractDistance && !actiontaken,
                              new Sequence(
                                  new Action(r =>
     {
         var targetnpc = GameObjectManager.GetObjectByNPCId((uint)NpcId);
         targetnpc.Target();
         foreach (ff14bot.Managers.BagSlot slot in ff14bot.Managers.InventoryManager.FilledSlots)
         {
             if (slot.RawItemId == 2000975)
             {
                 slot.UseItem(targetnpc);
                 break;
             }
         }
         actiontaken = true;
     }),
                                  new Sleep(3, 5),
                                  new Decorator(ret => !Talk.DialogOpen,
                                                new Action(r =>
     {
         actiontaken = false;
     })
                                                )
                                  )
                              ),
                new Decorator(ret => QuestId == 66426 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(2);
     })
                              ),
                new Decorator(ret => QuestId == 66493 && Vector3.Distance(Core.Player.Location, XYZ) < InteractDistance && !actiontaken,
                              new Sequence(
                                  new Action(r =>
     {
         var targetnpc = ff14bot.Managers.GameObjectManager.GetObjectByNPCId((uint)NpcId);
         targetnpc.Target();
         foreach (ff14bot.Managers.BagSlot slot in ff14bot.Managers.InventoryManager.FilledSlots)
         {
             if (slot.RawItemId == 2000976)
             {
                 slot.UseItem(targetnpc);
                 actiontaken = true;
             }
         }
     }),
                                  new Sleep(3, 5),
                                  new Decorator(ret => !Talk.DialogOpen,
                                                new Action(r =>
     {
         actiontaken = false;
     })
                                                )
                                  )
                              ),
                new Decorator(ret => QuestId == 66579 && Vector3.Distance(Core.Player.Location, XYZ) < InteractDistance && !actiontaken,
                              new Sequence(
                                  new Action(r =>
     {
         var targetnpc = ff14bot.Managers.GameObjectManager.GetObjectByNPCId((uint)NpcId);
         targetnpc.Target();
         ChatManager.SendChat("/psych");
         actiontaken = true;
     }),
                                  new Sleep(3, 5),
                                  new Decorator(ret => !Talk.DialogOpen,
                                                new Action(r =>
     {
         actiontaken = false;
     })
                                                )
                                  )
                              ),
                new Decorator(ret => QuestId == 66584 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 66642 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 66693 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 66694 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 66724 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 66740 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(1);
     })
                              ),
                new Decorator(ret => QuestId == 66979 && Vector3.Distance(Core.Player.Location, XYZ) < InteractDistance && !actiontaken,
                              new Sequence(
                                  new Action(r =>
     {
         var targetnpc = ff14bot.Managers.GameObjectManager.GetObjectByNPCId((uint)NpcId);
         targetnpc.Target();
         ChatManager.SendChat("/soothe");
         actiontaken = true;
     }),
                                  new Sleep(3, 5),
                                  new Decorator(ret => !Talk.DialogOpen,
                                                new Action(r =>
     {
         actiontaken = false;
     })
                                                )
                                  )
                              ),
                new Decorator(ret => QuestId == 67138 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(0);
     })
                              ),
                new Decorator(ret => QuestId == 67405 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(4);
     })
                              ),
                new Decorator(ret => QuestId == 67670 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 68291 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                base.CreateBehavior()
                ));
 }
Example #22
0
        protected override async Task <bool> Main()
        {
            foreach (var unit in GameObjectManager.GameObjects.OrderBy(r => r.Distance()))
            {
                if (unit.Name == "传唤铃" || unit.NpcId == 2000401 || unit.NpcId == 2000441)
                {
                    unit.Interact();
                    break;
                }
            }
            if (!await Coroutine.Wait(3000, () => SelectString.IsOpen))
            {
                if (RaptureAtkUnitManager.GetWindowByName("RetainerList") == null)
                {
                    return(isDone = true);
                }

                const int Offset0           = 0x1CA;
                const int Offset2           = 0x160;
                var       elementCount      = Core.Memory.Read <ushort>(RaptureAtkUnitManager.GetWindowByName("RetainerList").Pointer + Offset0);
                var       addr              = Core.Memory.Read <IntPtr>(RaptureAtkUnitManager.GetWindowByName("RetainerList").Pointer + Offset2);
                TwoInt[]  elements          = Core.Memory.ReadArray <TwoInt>(addr, elementCount);
                int       NumberOfRetainers = elements[2].TrimmedData;
                for (var i = 0; i < NumberOfRetainers; i++)
                {
                    RaptureAtkUnitManager.GetWindowByName("RetainerList").SendAction(2, 3UL, 2UL, 3UL, (ulong)i);
                    await Coroutine.Sleep(300);

                    await Coroutine.Wait(9000, () => Talk.DialogOpen);

                    Talk.Next();

                    if (!await Coroutine.Wait(5000, () => SelectString.IsOpen))
                    {
                        return(isDone = true);
                    }
                    foreach (var retainer in SelectString.Lines())
                    {
                        if (retainer.EndsWith("[结束]") || retainer.EndsWith("[Tâche terminée]") || retainer.EndsWith("(Venture complete)"))
                        {
                            Log("探险结束!");
                            SelectString.ClickSlot(5);
                            if (!await Coroutine.Wait(5000, () => RetainerTaskResult.IsOpen))
                            {
                                continue;
                            }
                            RetainerTaskResult.Reassign();
                            if (!await Coroutine.Wait(5000, () => RetainerTaskAsk.IsOpen))
                            {
                                continue;
                            }
                            RetainerTaskAsk.Confirm();
                            if (!await Coroutine.Wait(5000, () => Talk.DialogOpen))
                            {
                                continue;
                            }
                            Talk.Next();
                            if (!await Coroutine.Wait(5000, () => SelectString.IsOpen))
                            {
                                continue;
                            }
                        }
                    }

                    SelectString.ClickSlot((uint)SelectString.LineCount - 1);
                    if (!await Coroutine.Wait(5000, () => Talk.DialogOpen))
                    {
                        continue;
                    }
                    Talk.Next();
                    await Coroutine.Sleep(3000);
                }
                RaptureAtkUnitManager.GetWindowByName("RetainerList").SendAction(1, 3uL, 4294967295uL);
            }
            return(isDone = true);
        }
Example #23
0
        private async Task JoinDutyTask(int DutyId, bool Trial)
        {
            Logging.WriteDiagnostic("Queuing for Dungeon");
            GameSettingsManager.JoinWithUndersizedParty = true;
            DutyManager.Queue(DataManager.InstanceContentResults[(uint)DutyId]);
            await Coroutine.Wait(5000, () => (DutyManager.QueueState == QueueState.InQueue || DutyManager.QueueState == QueueState.JoiningInstance));

            Logging.WriteDiagnostic("Queued for Dungeon");

            await Coroutine.Wait(10000, () => (DutyManager.QueueState == QueueState.JoiningInstance));

            await Coroutine.Wait(10000, () => (RaptureAtkUnitManager.GetWindowByName("ContentsFinderConfirm") != null));

            Logging.WriteDiagnostic("Commencing");
            DutyManager.Commence();
            Logging.WriteDiagnostic("Waiting for Loading");
            await Coroutine.Wait(10000, () => CommonBehaviors.IsLoading || QuestLogManager.InCutscene);

            if (CommonBehaviors.IsLoading)
            {
                await Coroutine.Wait(-1, () => !CommonBehaviors.IsLoading);
            }

            if (QuestLogManager.InCutscene)
            {
                TreeRoot.StatusText = "InCutscene";
                if (ff14bot.RemoteAgents.AgentCutScene.Instance != null)
                {
                    ff14bot.RemoteAgents.AgentCutScene.Instance.PromptSkip();
                    await Coroutine.Wait(250, () => SelectString.IsOpen);

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

            Logging.WriteDiagnostic("Should be in duty");

            var director = ((ff14bot.Directors.InstanceContentDirector)DirectorManager.ActiveDirector);

            if (director != null)
            {
                if (Trial)
                {
                    if (director.TimeLeftInDungeon >= new TimeSpan(0, 60, 0))
                    {
                        Logging.WriteDiagnostic("Barrier up");
                        await Coroutine.Wait(30000, () => director.TimeLeftInDungeon < new TimeSpan(0, 59, 58));
                    }
                }
                else
                {
                    if (director.TimeLeftInDungeon >= new TimeSpan(1, 30, 0))
                    {
                        Logging.WriteDiagnostic("Barrier up");
                        await Coroutine.Wait(30000, () => director.TimeLeftInDungeon < new TimeSpan(1, 29, 58));
                    }
                }
            }
            else
            {
                Logging.WriteDiagnostic("Director is null");
            }

            Logging.WriteDiagnostic("Should be ready");

            _isDone = true;
        }
Example #24
0
        protected override async Task <bool> Main()
        {
            if (Talk.DialogOpen)
            {
                await HandleTalk();

                return(true);
            }

            if (SelectYesno.IsOpen)
            {
                SelectYesno.ClickYes();
                await Coroutine.Yield();

                return(true);
            }

            if (JournalResult.IsOpen)
            {
                await Coroutine.Wait(1000, () => JournalResult.ButtonClickable);

                JournalResult.Complete();
                await Coroutine.Yield();

                return(true);
            }

            // Movement
            if (ExProfileBehavior.Me.Distance(Location) > 3.5)
            {
                StatusText = Localization.Localization.ExPickupGuildLeve_Move + NpcId;

                await Location.MoveTo(radius : 3.4f, name : " NpcId: " + NpcId);

                return(true);
            }

            if (!interactTimeout.IsRunning)
            {
                interactTimeout.Restart();
            }

            // Interact
            if (Core.Target == null && ExProfileBehavior.Me.Distance(Location) <= 3.5)
            {
                await this.Interact();

                await Coroutine.Yield();

                return(true);
            }

            if (SelectString.IsOpen)
            {
                if (interactTimeout.Elapsed.TotalSeconds > Timeout || GuildLeve.HasLeves(Ids) || GuildLeve.Allowances == 0)
                {
                    SelectString.ClickSlot(uint.MaxValue);
                    isDone = true;
                    return(true);
                }

                SelectString.ClickLineContains(LeveType);
                return(true);
            }

            var guildLeveWindow = new GuildLeve();

            if (guildLeveWindow.IsValid)
            {
                if (interactTimeout.Elapsed.TotalSeconds > Timeout || GuildLeve.HasLeves(Ids) || GuildLeve.Allowances == 0)
                {
                    await guildLeveWindow.CloseInstance();

                    return(true);
                }

                foreach (var leveId in Ids.Where(id => !GuildLeve.HasLeve(id)))
                {
                    if (GuildLeve.Allowances > 0)
                    {
                        StatusText = Localization.Localization.ExPickupGuildLeve_Pickup + leveId;
                        Logger.Info(Localization.Localization.ExPickupGuildLeve_Pickup2 + leveId);

                        await Coroutine.Sleep(1000);

                        guildLeveWindow.AcceptLeve(leveId);
                        await Coroutine.Yield(); // so our memory lock updates and level allowances change
                    }
                }

                await Coroutine.Sleep(1000);

                return(true);
            }

            // Interact if targetting but not null (if combat behaviors prevented the first one)
            if (ExProfileBehavior.Me.Distance(Location) <= 3.5)
            {
                await this.Interact();

                return(true);
            }

            return(true);
        }
Example #25
0
        //public static void Log(string text, params object[] args) { Logger.Info(text, args); }

        public static async Task <bool> Main(Vector3 gardenLoc)
        {
            var watering = GardenManager.Plants.Where(r => !Blacklist.Contains(r) && r.Distance2D(gardenLoc) < 10).ToArray();

            foreach (var plant in watering)
            {
                //Water it if it needs it or if we have fertilized it 5 or more times.
                if (AlwaysWater || GardenManager.NeedsWatering(plant))
                {
                    var result = GardenManager.GetCrop(plant);
                    if (result != null)
                    {
                        Log($"Watering {result} {plant.ObjectId:X}");
                        await Navigation.FlightorMove(plant.Location);

                        plant.Interact();
                        if (!await Coroutine.Wait(5000, () => Talk.DialogOpen))
                        {
                            continue;
                        }
                        Talk.Next();
                        if (!await Coroutine.Wait(5000, () => SelectString.IsOpen))
                        {
                            continue;
                        }
                        if (!await Coroutine.Wait(5000, () => SelectString.LineCount > 0))
                        {
                            continue;
                        }
                        if (SelectString.LineCount == 4)
                        {
                            SelectString.ClickSlot(1);
                            await Coroutine.Sleep(2300);
                        }
                        else
                        {
                            Log("Plant is ready to be harvested");
                            SelectString.ClickSlot(1);
                            await Coroutine.Sleep(1000);
                        }
                    }
                    else
                    {
                        Log($"GardenManager.GetCrop returned null {plant.ObjectId:X}");
                    }
                }
            }
            var plants = GardenManager.Plants.Where(r => r.Distance2D(gardenLoc) < 10).ToArray();

            foreach (var plant in plants)
            {
                var result = GardenManager.GetCrop(plant);
                if (result == null)
                {
                    continue;
                }
                Log($"Fertilizing {GardenManager.GetCrop(plant)} {plant.ObjectId:X}");
                await Navigation.FlightorMove(plant.Location);

                plant.Interact();
                if (!await Coroutine.Wait(5000, () => Talk.DialogOpen))
                {
                    continue;
                }
                Talk.Next();
                if (!await Coroutine.Wait(5000, () => SelectString.IsOpen))
                {
                    continue;
                }
                if (!await Coroutine.Wait(5000, () => SelectString.LineCount > 0))
                {
                    continue;
                }
                if (SelectString.LineCount == 4)
                {
                    SelectString.ClickSlot(0);
                    if (await Coroutine.Wait(2000, () => GardenManager.ReadyToFertilize))
                    {
                        if (GardenManager.Fertilize() != FertilizeResult.Success)
                        {
                            continue;
                        }
                        Log($"Plant with objectId {plant.ObjectId:X} was fertilized");
                        await Coroutine.Sleep(2300);
                    }
                    else
                    {
                        Log($"Plant with objectId {plant.ObjectId:X} not able to be fertilized, trying again later");
                    }
                }
                else
                {
                    Log("Plant is ready to be harvested");
                    SelectString.ClickSlot(1);
                    await Coroutine.Sleep(1000);
                }
            }
            return(true);
        }
        private async Task <bool> PurchaseItems()
        {
            if (ExProfileBehavior.Me.Location.Distance(shopExchangeCurrencyNpc.Location) > 4)
            {
                // too far away, should go back to MoveToNpc
                return(true);
            }

            StatusText = Localization.Localization.ExTurnInCollectable_Purchase;

            var itemsToPurchase      = ShopPurchases.Where(ShouldPurchaseItem).ToArray();
            var npc                  = GameObjectManager.GetObjectByNPCId(shopExchangeCurrencyNpc.NpcId);
            var shopType             = ShopType.Yellow50;
            var shopExchangeCurrency = new ShopExchangeCurrency();

            foreach (var purchaseItem in itemsToPurchase)
            {
                var purchaseItemInfo = Data.ShopItemMap[purchaseItem.ShopItem];
                var purchaseItemData = purchaseItemInfo.ItemData;

                if (shopType != purchaseItemInfo.ShopType && shopExchangeCurrency.IsValid)
                {
                    await shopExchangeCurrency.CloseInstanceGently();
                }

                shopType = purchaseItemInfo.ShopType;

                // target
                var ticks = 0;
                while (Core.Target == null && !shopExchangeCurrency.IsValid && ticks++ < 10 && Behaviors.ShouldContinue)
                {
                    npc.Target();
                    await Coroutine.Wait(1000, () => Core.Target != null);
                }

                // check for timeout
                if (ticks > 10)
                {
                    Logger.Error(Localization.Localization.ExTurnInCollectable_TargetingTimeout);
                    isDone = true;
                    return(true);
                }

                // interact
                ticks = 0;
                while (!SelectIconString.IsOpen && !shopExchangeCurrency.IsValid && ticks++ < 10 && Behaviors.ShouldContinue)
                {
                    npc.Interact();
                    await Coroutine.Wait(1000, () => SelectIconString.IsOpen);
                }

                // check for timeout
                if (ticks > 10)
                {
                    Logger.Error(Localization.Localization.ExTurnInCollectable_InteractingTimeout);
                    isDone = true;
                    return(true);
                }

                if (purchaseItemInfo.Index == (int)ShopItem.OnHighOrchestrionRoll && Location != Locations.RhalgrsReach ||
                    purchaseItemInfo.Index >= (int)ShopItem.MoonbeamSilk && purchaseItemInfo.Index <= (int)ShopItem.RaziqcoatHq && Location != Locations.RhalgrsReach ||
                    purchaseItemInfo.Index == (int)ShopItem.GardenGravel && Location != Locations.RhalgrsReach ||
                    purchaseItemInfo.Index == (int)ShopItem.SongsofSaltandSufferingOrchestrionRoll && Location != Locations.RhalgrsReach)
                {
                    Logger.Warn(Localization.Localization.ExTurnInCollectable_FailedPurchaseGorRhalgrsReach, purchaseItemData.EnglishName);
                    continue;
                }

                ticks = 0;
                while (SelectIconString.IsOpen && ticks++ < 5 && Behaviors.ShouldContinue)
                {
                    SelectIconString.ClickSlot((uint)purchaseItemInfo.ShopJob);
                    await Coroutine.Wait(1000, () => SelectString.IsOpen);

                    SelectString.ClickSlot((purchaseItemInfo.ShopJob == ShopJob.Gatherer && purchaseItemInfo.ShopType > ShopType.Yellow61) ? (uint)purchaseItemInfo.ShopType - 1 : (uint)purchaseItemInfo.ShopType);

                    await shopExchangeCurrency.Refresh(5000);
                }

                if (ticks > 5 || !shopExchangeCurrency.IsValid)
                {
                    Logger.Error(Localization.Localization.ExTurnInCollectable_InteractingTimeout);
                    if (SelectIconString.IsOpen)
                    {
                        SelectIconString.ClickSlot(uint.MaxValue);
                    }

                    isDone = true;
                    return(true);
                }

                await Coroutine.Sleep(600);

                int scripsLeft;
                while (purchaseItemData.ItemCount() < purchaseItem.MaxCount && (scripsLeft = Memory.Scrips.GetRemainingScripsByShopType(purchaseItemInfo.ShopJob, purchaseItemInfo.ShopType)
                                                                                ) >= purchaseItemInfo.Cost &&
                       Behaviors.ShouldContinue)
                {
                    var qtyLeftToBuy = purchaseItem.MaxCount - (int)purchaseItemData.ItemCount();
                    var qtyBuyable   = scripsLeft / purchaseItemInfo.Cost;
                    var qtyToBuy     = Math.Min(99, Math.Min(qtyLeftToBuy, qtyBuyable));

                    var indexPurchaseItem = (Location != Locations.Idyllshire && Location != Locations.RhalgrsReach && purchaseItemInfo.ShopJob == ShopJob.Crafter && purchaseItemInfo.ShopType == ShopType.Yellow58 &&
                                             purchaseItemInfo.Index >= (int)ShopItem.MoonbeamSilk - 200)
                            ? purchaseItemInfo.Index - 12
                            : purchaseItemInfo.Index;

                    if (!await shopExchangeCurrency.PurchaseItem(indexPurchaseItem, (uint)qtyToBuy, 20))
                    {
                        Logger.Error(Localization.Localization.ExTurnInCollectable_PurchaseTimeout, purchaseItemData.EnglishName);
                        await shopExchangeCurrency.CloseInstance();

                        isDone = true;
                        return(true);
                    }

                    var left = scripsLeft;
                    await
                    Coroutine.Wait(
                        5000,
                        () => (scripsLeft = Memory.Scrips.GetRemainingScripsByShopType(purchaseItemInfo.ShopJob, purchaseItemInfo.ShopType)) != left);

                    Logger.Info(
                        Localization.Localization.ExTurnInCollectable_Purchased,
                        purchaseItemData.EnglishName,
                        purchaseItemInfo.Cost * qtyToBuy,
                        purchaseItemInfo.ShopType,
                        WorldManager.EorzaTime,
                        scripsLeft,
                        qtyToBuy);

                    await Coroutine.Yield();
                }

                await Coroutine.Sleep(1000);
            }

            Logger.Info(Localization.Localization.ExTurnInCollectable_PurchaseComplete);
            SelectYesno.ClickNo();
            if (SelectIconString.IsOpen)
            {
                SelectIconString.ClickSlot(uint.MaxValue);
            }

            await shopExchangeCurrency.CloseInstance();

            isDone = true;
            return(true);
        }
 protected override Composite CreateBehavior()
 {
     return(new PrioritySelector(
                new Decorator(ret => QuestId == 65643 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65646 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(2);
     })
                              ),
                new Decorator(ret => QuestId == 65647 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65728 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65729 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65740 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65748 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 65770 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(1);
     })
                              ),
                new Decorator(ret => QuestId == 65963 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 66426 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(2);
     })
                              ),
                new Decorator(ret => QuestId == 66601 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 66976 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 67130 && SelectIconString.IsOpen,
                              new Action(r =>
     {
         SelectIconString.ClickSlot(0);
     })
                              ),
                new Decorator(ret => QuestId == 67179 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 67183 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 67254 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 67596 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(3);
     })
                              ),
                new Decorator(ret => QuestId == 67677 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 67692 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 67769 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 67774 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 67783 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 67948 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 67982 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 68005 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 68029 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(1);
     })
                              ),
                new Decorator(ret => QuestId == 68045 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 68051 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(1);
     })
                              ),
                new Decorator(ret => QuestId == 68066 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 68079 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(1);
     })
                              ),
                new Decorator(ret => QuestId == 68096 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 68105 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 68109 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 68484 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(2);
     })
                              ),
                new Decorator(ret => QuestId == 68487 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 68502 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                new Decorator(ret => QuestId == 68506 && SelectString.IsOpen,
                              new Action(r =>
     {
         SelectString.ClickSlot(0);
     })
                              ),
                new Decorator(ret => QuestId == 68508 && SelectYesno.IsOpen,
                              new Action(r =>
     {
         SelectYesno.ClickYes();
     })
                              ),
                base.CreateBehavior()
                ));
 }
Example #28
0
        public static async Task <bool> UseItem(uint itemId, GameObject obj, int waitTime = 0, bool blacklistAfter = false, int blacklistDuration = 30)
        {
            var bagSlot = InventoryManager.FilledSlots.FirstOrDefault(s => s.RawItemId == itemId);

            if (bagSlot == null)
            {
                return(false);
            }

            if (obj == null)
            {
                return(false);
            }

            while (true)
            {
                if (Core.Me.IsDead)
                {
                    return(false);
                }

                if (SelectString.IsOpen)
                {
                    if (selectStringIndex.Count > 0)
                    {
                        SelectString.ClickSlot((uint)selectStringIndex.Dequeue());
                    }
                    else
                    {
                        SelectString.ClickSlot(0);
                    }
                }

                if (Talk.DialogOpen)
                {
                    Talk.Next();
                    await Coroutine.Sleep(300);

                    continue;
                }

                if (MovementManager.IsMoving)
                {
                    await CommonTasks.StopMoving();

                    await Coroutine.Sleep(300);

                    continue;
                }

                if (Core.Me.IsMounted)
                {
                    await CommonTasks.StopAndDismount();

                    await Coroutine.Sleep(300);

                    continue;
                }

                if (Core.Me.CurrentTarget != obj)
                {
                    obj.Target();
                    await Coroutine.Sleep(300);

                    continue;
                }

                if (bagSlot.Item.IsGroundTargeting)
                {
                    bagSlot.UseItem(obj.Location);
                }
                else
                {
                    bagSlot.UseItem(obj);
                }

                if (await Coroutine.Wait(1000, () => Core.Me.IsCasting))
                {
                    if (await Coroutine.Wait(15000, () => !Core.Me.IsCasting))
                    {
                        if (await Coroutine.Wait(5000, () => !obj.IsValid || !obj.IsTargetable || !obj.IsVisible || !bagSlot.CanUse(obj)))
                        {
                            break;
                        }
                    }
                }
                else
                {
                    return(false);
                }
            }

            if (waitTime > 0)
            {
                await Coroutine.Sleep(waitTime);
            }

            if (blacklistAfter)
            {
                Blacklist.Add(obj, BlacklistFlags.SpecialHunt, TimeSpan.FromSeconds(blacklistDuration), "BlacklistAfter");
            }

            return(true);
        }
Example #29
0
        public async Task <bool> StartOutOnLimb()
        {
            Navigator.NavigationProvider = new ServiceNavigationProvider();
            Navigator.PlayerMover        = new SlideMover();


            uint npcid = 2005423;

            if (GameObjectManager.GetObjectByNPCId(npcid) == null)
            {
                Logger.LogCritical("Not Near Machine");
                if (WorldManager.ZoneId != 388)
                {
                    await GetToMinionSquare();

                    var _target = new Vector3(32.61445f, 0.0005990267f, 18.66965f);
                    Navigator.PlayerMover.MoveTowards(_target);
                    while (_target.Distance2D(Core.Me.Location) >= _random.Next(1, 6))
                    {
                        Navigator.PlayerMover.MoveTowards(_target);
                        await Coroutine.Sleep(100);
                    }

                    Navigator.PlayerMover.MoveStop();

                    _target = PlayLocations[_random.Next(0, PlayLocations.Count - 1)];
                    Navigator.PlayerMover.MoveTowards(_target);
                    while (_target.Distance2D(Core.Me.Location) >= 4)
                    {
                        Navigator.PlayerMover.MoveTowards(_target);
                        await Coroutine.Sleep(100);
                    }

                    Navigator.PlayerMover.MoveStop();
                }
            }

            var station = GameObjectManager.GameObjects.Where(i => i.NpcId == 2005423).OrderBy(r => r.Distance()).First();

            if (!station.IsWithinInteractRange)
            {
                var _target = station.Location;
                Navigator.PlayerMover.MoveTowards(_target);
                while (_target.Distance2D(Core.Me.Location) >= 4)
                {
                    Navigator.PlayerMover.MoveTowards(_target);
                    await Coroutine.Sleep(100);
                }

                Navigator.PlayerMover.MoveStop();
            }

            station.Interact();

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

            SelectString.ClickSlot(0);

            await Coroutine.Wait(5000, () => MiniGameAimg.Instance.IsOpen);

            await Coroutine.Sleep(1000);

            AgentOutOnLimb.Instance.Refresh();

            await Coroutine.Wait(5000, () => AgentOutOnLimb.Instance.IsReadyAimg);

            await Coroutine.Sleep(_random.Next(400, 800));

            MiniGameAimg.Instance.PressButton();

            await Coroutine.Wait(5000, () => MiniGameBotanist.Instance.IsOpen);

            return(MiniGameBotanist.Instance.IsOpen);
        }