private void CloseWindows() { if (SelectYesno.IsOpen) { SelectYesno.ClickNo(); } if (Request.IsOpen) { Request.Cancel(); } if (JournalResult.IsOpen) { JournalResult.Decline(); } if (SelectString.IsOpen) { SelectString.ClickSlot(uint.MaxValue); } if (SelectIconString.IsOpen) { SelectIconString.ClickSlot(uint.MaxValue); } if (Shop.Open) { Shop.Close(); } }
protected override void OnDone() { if (SelectYesno.IsOpen) { SelectYesno.ClickNo(); } if (Request.IsOpen) { Request.Cancel(); } if (Window <MasterPieceSupply> .IsOpen) { MasterPieceSupply.Close(); } if (Window <ShopExchangeCurrency> .IsOpen) { ShopExchangeCurrency.Close(); } if (SelectIconString.IsOpen) { SelectIconString.ClickSlot(uint.MaxValue); } }
public static async Task <bool> SelectYesNo(bool choice = true) { int ticks = 0; while (SelectYesno.IsOpen && ticks < 20) { if (choice) { SelectYesno.ClickYes(); } else { SelectYesno.ClickNo(); } await Coroutine.Sleep(500); ticks++; } if (ticks < 20) { return(true); } return(false); }
private async Task <bool> HandOver() { var masterpieceSupply = new MasterPieceSupply(); if (!masterpieceSupply.IsValid && !await masterpieceSupply.Refresh(5000)) { return(false); } if (item == null || item.Item == null) { SelectYesno.ClickNo(); await masterpieceSupply.CloseInstanceGently(15); return(false); } StatusText = Localization.Localization.ExTurnInCollectable_TurnIn; var itemName = item.Item.CurrentLocaleName; if (!await masterpieceSupply.TurnInAndHandOver(index, item)) { Logger.Error(Localization.Localization.ExTurnInCollectable_TurnInError); Blacklist.Add( (uint)item.Pointer.ToInt64(), BlacklistFlags.Loot, TimeSpan.FromMinutes(3), Localization.Localization.ExTurnInCollectable_TurnInBlackList); item = null; index = 0; if (SelectYesno.IsOpen) { SelectYesno.ClickNo(); await Coroutine.Sleep(200); } if (Request.IsOpen) { Request.Cancel(); await Coroutine.Sleep(200); } return(true); } Logger.Info(Localization.Localization.ExTurnInCollectable_TurnInSuccessful, itemName, WorldManager.EorzaTime); turnedItemsIn = true; index = 0; if (!await Coroutine.Wait(1000, () => item == null)) { item = null; } return(true); }
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 { 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 { 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 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); }
private async Task <bool> ResolveItem() { if (item != null) { return(false); } var slots = InventoryManager.FilledInventoryAndArmory.Where( i => !Blacklist.Contains((uint)i.Pointer.ToInt64(), BlacklistFlags.Loot)).ToArray(); var blackListDictionnary = new Dictionary <string, uint> { { "Fire Moraine", 5214 }, { "Lightning Moraine", 5218 }, { "Radiant Fire Moraine", 5220 }, { "Radiant Lightning Moraine", 5224 }, { "Bright Fire Rock", 12966 }, { "Bright Lightning Rock", 12967 }, { "Granular Clay", 12968 }, { "Peat Moss", 12969 }, { "Black Soil", 12970 }, { "Highland Oregano", 12971 }, { "Furymint", 12972 }, { "Clary Sage", 12973 }, { "Lover's Laurel", 15948 }, { "Radiant Astral Moraine", 15949 }, { "Near Eastern Antique", 17549 }, { "Coerthan Souvenir", 17550 }, { "Maelstrom Materiel ", 17551 }, { "Heartfelt Gift", 17552 }, { "Orphanage Donation", 17553 }, { "Dated Radz-at-Han Coin", 17557 }, { "Ice Stalagmite", 17558 }, { "Duskfall Moss", 17559 }, { "Glass Eye", 17560 }, { "Rainbow Pigment", 17561 }, { "Thavnairian Leaf", 17562 }, { "Ghost Faerie", 17563 }, { "Red Sky Coral", 17564 }, { "Lovers' Clam", 17565 }, { "River Shrimp", 17566 }, { "Windtea Leaves", 19916 }, { "Torreya Branch", 19937 }, { "Schorl", 20009 }, { "Perlite", 20010 }, { "Almandine", 20011 }, { "Doman Yellow", 20012 }, { "Gyr Abanian Souvenir", 20775 }, { "Far Eastern Antique", 20776 }, { "Gold Saucer Consolation Prize", 20777 }, { "M Tribe Sundries", 20778 }, { "Resistance Materiel", 20779 }, { "Starcrack", 20780 }, { "Shishu Koban", 20781 }, { "Cotter Dynasty Relic", 20782 }, { "Peaks Pigment", 20783 }, { "Yellow Kudzu Root", 20784 }, { "Gyr Abanian Chub", 20785 }, { "Coral Horse", 20786 }, { "Maiden's Heart", 20787 }, { "Velodyna Salmon", 20788 }, { "Purple Buckler", 20789 }, { "Gyr Abanian Remedies", 23143 }, { "Anti-shark Harpoon", 23144 }, { "Coerthan Cold-weather Gear", 23145 }, { "Sui-no-Sato Special", 23146 }, { "Cloud Pearl", 23147 }, { "Yanxian Soil", 23220 }, { "Yanxian Verbena", 23221 } }; if (Collectables == null) { item = slots.FirstOrDefault(i => i.Collectability > 0 && !blackListDictionnary.ContainsValue(i.RawItemId)); } else { foreach (var collectable in Collectables) { var bagslots = slots.Where(i => i.Collectability >= collectable.Value && i.Collectability <= collectable.MaxValueForTurnIn).ToArray(); if (collectable.Id > 0) { item = bagslots.FirstOrDefault(i => i.RawItemId == collectable.Id); } item = item ?? bagslots.FirstOrDefault( i => string.Equals(collectable.LocalName, i.Name, StringComparison.InvariantCultureIgnoreCase)) ?? bagslots.FirstOrDefault( i => string.Equals(collectable.Name, i.EnglishName, StringComparison.InvariantCultureIgnoreCase)); if (item != null) { break; } } } if (item != null && item.Item != null) { Logger.Verbose(Localization.Localization.ExTurnInCollectable_AttemptingTurnin, item.EnglishName, item.Pointer.ToString("X8")); return(false); } if ((turnedItemsIn || ForcePurchase) && !await HandleSkipPurchase()) { return(false); } if (SelectYesno.IsOpen) { SelectYesno.ClickNo(); } if (Request.IsOpen) { Request.Cancel(); } var masterpieceSupply = new MasterPieceSupply(); if (masterpieceSupply.IsValid) { await masterpieceSupply.CloseInstanceGently(); } var shopExchangeCurrency = new ShopExchangeCurrency(); if (shopExchangeCurrency.IsValid) { await shopExchangeCurrency.CloseInstanceGently(); } if (SelectIconString.IsOpen) { SelectIconString.ClickSlot(uint.MaxValue); } return(isDone = 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.RedGatherer50; 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 RB_CN if ((Location == Locations.MorDhona) && (purchaseItemInfo.ShopType == ShopType.YellowCrafterItems || purchaseItemInfo.ShopType == ShopType.YellowGathererItems)) { Logger.Warn(Localization.Localization.ExTurnInCollectable_FailedPurchaseMorDhona, purchaseItemData.EnglishName); continue; } ticks = 0; while (SelectIconString.IsOpen && ticks++ < 5 && Behaviors.ShouldContinue) { if ((Location == Locations.MorDhona) && (purchaseItemInfo.ShopType == ShopType.RedGatherer50 || purchaseItemInfo.ShopType == ShopType.RedGatherer58)) { SelectIconString.ClickSlot((uint)purchaseItemInfo.ShopType - 5); } else { SelectIconString.ClickSlot((uint)purchaseItemInfo.ShopType); } await shopExchangeCurrency.Refresh(5000); } #else if ((Location == Locations.MorDhona) && (purchaseItemInfo.ShopType == ShopType.YellowCrafterItems || purchaseItemInfo.ShopType == ShopType.YellowGathererItems)) { Logger.Warn(Localization.Localization.ExTurnInCollectable_FailedPurchaseMorDhona, purchaseItemData.EnglishName); continue; } ticks = 0; while (SelectIconString.IsOpen && ticks++ < 5 && Behaviors.ShouldContinue) { if ((Location == Locations.MorDhona) && (purchaseItemInfo.ShopType == ShopType.RedGatherer50 || purchaseItemInfo.ShopType == ShopType.RedGatherer58)) { SelectIconString.ClickSlot((uint)purchaseItemInfo.ShopType - 5); } else { SelectIconString.ClickSlot((uint)purchaseItemInfo.ShopType); } await shopExchangeCurrency.Refresh(5000); } #endif 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.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)); if (!await shopExchangeCurrency.PurchaseItem(purchaseItemInfo.Index, (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.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); }
private async Task <bool> ResolveItem() { if (item != null) { return(false); } var slots = InventoryManager.FilledInventoryAndArmory.Where( i => !Blacklist.Contains((uint)i.Pointer.ToInt64(), BlacklistFlags.Loot)).ToArray(); Dictionary <string, uint> BlackListDictionnary = new Dictionary <string, uint> { { "Fire Moraine", 5214 }, { "Lightning Moraine", 5218 }, { "Radiant Fire Moraine", 5220 }, { "Radiant Lightning Moraine", 5224 }, { "Bright Fire Rock", 12966 }, { "Bright Lightning Rock", 12967 }, { "Granular Clay", 12968 }, { "Peat Moss", 12969 }, { "Black Soil", 12970 }, { "Highland Oregano", 12971 }, { "Furymint", 12972 }, { "Clary Sage", 12973 }, { "Lover's Laurel", 15948 }, { "Radiant Astral Moraine", 15949 }, { "Dated Radz-at-Han Coin", 17557 }, { "Ice Stalagmite", 17558 }, { "Duskfall Moss", 17559 }, { "Glass Eye", 17560 }, { "Rainbow Pigment", 17561 }, { "Thavnairian Leaf", 17562 }, { "Ghost Faerie", 17563 }, { "Red Sky Coral", 17564 }, { "Lovers' Clam", 17565 }, { "River Shrimp", 17566 }, { "Windtea Leaves", 19916 }, { "Torreya Branch", 19937 }, { "Schorl", 20009 }, { "Perlite", 20010 }, { "Almandine", 20011 }, { "Doman Yellow", 20012 } }; if (Collectables == null) { item = slots.FirstOrDefault(i => i.Collectability > 0 && !BlackListDictionnary.ContainsValue(i.RawItemId)); } else { foreach (var collectable in Collectables) { var bagslots = slots.Where(i => i.Collectability >= collectable.Value && i.Collectability <= collectable.MaxValueForTurnIn).ToArray(); if (collectable.Id > 0) { item = bagslots.FirstOrDefault(i => i.RawItemId == collectable.Id); } item = item ?? bagslots.FirstOrDefault( i => string.Equals(collectable.LocalName, i.Name, StringComparison.InvariantCultureIgnoreCase)) ?? bagslots.FirstOrDefault( i => string.Equals(collectable.Name, i.EnglishName, StringComparison.InvariantCultureIgnoreCase)); if (item != null) { break; } } } if (item != null && item.Item != null) { Logger.Verbose(Localization.Localization.ExTurnInCollectable_AttemptingTurnin, item.EnglishName, item.Pointer.ToString("X8")); return(false); } if ((turnedItemsIn || ForcePurchase) && !await HandleSkipPurchase()) { return(false); } if (SelectYesno.IsOpen) { SelectYesno.ClickNo(); } if (Request.IsOpen) { Request.Cancel(); } var masterpieceSupply = new MasterPieceSupply(); if (masterpieceSupply.IsValid) { await masterpieceSupply.CloseInstanceGently(); } var shopExchangeCurrency = new ShopExchangeCurrency(); if (shopExchangeCurrency.IsValid) { await shopExchangeCurrency.CloseInstanceGently(); } if (SelectIconString.IsOpen) { SelectIconString.ClickSlot(uint.MaxValue); } return(isDone = 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); }
private async Task <bool> ResolveItem() { if (item != null) { return(false); } var slots = InventoryManager.FilledInventoryAndArmory.Where( i => !Blacklist.Contains((uint)i.Pointer.ToInt32(), BlacklistFlags.Loot)).ToArray(); if (Collectables == null) { item = slots.FirstOrDefault(i => i.Collectability > 0); } else { foreach (var collectable in Collectables) { var bagslots = slots.Where(i => i.Collectability >= collectable.Value && i.Collectability <= collectable.MaxValueForTurnIn).ToArray(); if (collectable.Id > 0) { item = bagslots.FirstOrDefault(i => i.RawItemId == collectable.Id); } item = item ?? bagslots.FirstOrDefault( i => string.Equals(collectable.LocalName, i.Name, StringComparison.InvariantCultureIgnoreCase)) ?? bagslots.FirstOrDefault( i => string.Equals(collectable.Name, i.EnglishName, StringComparison.InvariantCultureIgnoreCase)); if (item != null) { break; } } } if (item != null && item.Item != null) { Logger.Verbose(Localization.Localization.ExTurnInCollectable_AttemptingTurnin, item.EnglishName, item.Pointer.ToString("X8")); return(false); } if ((turnedItemsIn || ForcePurchase) && !await HandleSkipPurchase()) { return(false); } if (SelectYesno.IsOpen) { SelectYesno.ClickNo(); } if (Request.IsOpen) { Request.Cancel(); } var masterpieceSupply = new MasterPieceSupply(); if (masterpieceSupply.IsValid) { await masterpieceSupply.CloseInstanceGently(); } var shopExchangeCurrency = new ShopExchangeCurrency(); if (shopExchangeCurrency.IsValid) { await shopExchangeCurrency.CloseInstanceGently(); } if (SelectIconString.IsOpen) { SelectIconString.ClickSlot(uint.MaxValue); } return(isDone = true); }