private async Task <bool> HandleCollectable() { uint required = CollectabilityValue; string itemName = string.Empty; if (!string.IsNullOrWhiteSpace(Collectables.First().Name)) { Item item = SelectYesno.Item; if (item == null || !Collectables.Any(c => string.Equals(c.Name, item.EnglishName, StringComparison.InvariantCultureIgnoreCase))) { int ticks = 0; while ((item == null || !Collectables.Any(c => string.Equals(c.Name, item.EnglishName, StringComparison.InvariantCultureIgnoreCase))) && ticks++ < 60 && Behaviors.ShouldContinue) { item = SelectYesno.Item; await Coroutine.Yield(); } if (ticks > 60) { required = (uint)Collectables.Select(c => c.Value).Max(); } } if (item != null) { itemName = item.EnglishName; Collectable collectable = Collectables.FirstOrDefault(c => string.Equals(c.Name, item.EnglishName)); if (collectable != null) { required = (uint)collectable.Value; } } } uint value = SelectYesno.CollectabilityValue; if (value >= required) { Logger.Info(Localization.ExFish_Collecting, itemName, value, required); SelectYesno.Yes(); } else { Logger.Info(Localization.ExFish_Declining, itemName, value, required); SelectYesno.No(); } await Coroutine.Wait(3000, () => !SelectYesno.IsOpen); return(true); }
private async Task <bool> Run() { var lang = (Language)typeof(DataManager).GetFields(BindingFlags.Static | BindingFlags.NonPublic) .First(i => i.FieldType == typeof(Language)).GetValue(null); if (lang != Language.Eng && lang != Language.Chn) { TreeRoot.Stop("Only works on English and Chinese Clients for now"); } await StartOutOnLimb(); //Logger.LogCritical("Start Done"); await Coroutine.Wait(5000, () => AgentOutOnLimb.Instance.IsReadyBotanist); //Logger.LogCritical("Ready"); if (await PlayBotanist()) { Logger.LogCritical("First win"); do { Logger.LogCritical("Loop"); if (!SelectYesno.IsOpen) { Logger.LogCritical("Waiting on window"); await Coroutine.Wait(5000, () => SelectYesno.IsOpen); await Coroutine.Sleep(_random.Next(300, 500)); } if (SelectYesno.IsOpen && GetDoubleDownReward() == 0) { SelectYesno.No(); Logger.LogCritical($"Won Nothing Reward: {GetDoubleDownReward()} total so far {totalMGP}"); await Coroutine.Sleep(_random.Next(300, 500)); //await Coroutine.Sleep(_random.Next(4000,5000)); break; } if (SelectYesno.IsOpen && (GetDoubleDownInfo().Key <= 2 || GetDoubleDownInfo().Value < 15)) { SelectYesno.No(); Logger.LogCritical($"Click No Reward: {GetDoubleDownReward()}"); await Coroutine.Sleep(_random.Next(300, 500)); break; } if (SelectYesno.IsOpen && GetDoubleDownInfo().Key > 1 && GetDoubleDownInfo().Value > 15) { Logger.LogCritical($"Click Yes Reward: {GetDoubleDownReward()}"); await Coroutine.Sleep(_random.Next(500, 1000)); SelectYesno.ClickYes(); await Coroutine.Wait(5000, () => AgentOutOnLimb.Instance.IsReadyBotanist); //await PlayBotanist(); } else if (SelectYesno.IsOpen) { Logger.LogCritical($"Click No Reward: {GetDoubleDownReward()}"); SelectYesno.No(); await Coroutine.Sleep(_random.Next(300, 500)); break; } } while (await PlayBotanist()); await Coroutine.Wait(5000, () => GoldSaucerReward.Instance.IsOpen); if (GoldSaucerReward.Instance.IsOpen) { var gained = GoldSaucerReward.Instance.MGPReward; totalMGP += gained; Logger.LogCritical($"Won {gained} - Total {totalMGP}"); if (gained == 0) { Logger.LogCritical($"Won {gained}"); TreeRoot.Stop("Won zero...issue"); } } Logger.LogCritical("Starting over"); } if (GoldSaucerReward.Instance.IsOpen) { GoldSaucerReward.Instance.Close(); } await Coroutine.Wait(5000, () => !GoldSaucerReward.Instance.IsOpen); Logger.LogCritical("Done"); await Coroutine.Sleep(_random.Next(1500, 3000)); if (totalMGP > threashold) { var _target = PlayLocations[_random.Next(0, PlayLocations.Count - 1)]; Logger.LogCritical($"Moving to {_target}"); Navigator.PlayerMover.MoveTowards(_target); while (_target.Distance2D(Core.Me.Location) >= 4) { Navigator.PlayerMover.MoveTowards(_target); await Coroutine.Sleep(100); } Navigator.PlayerMover.MoveStop(); threashold = _random.Next(totalMGP + 3000, totalMGP + 6000); Logger.LogCritical($"At to {Core.Me.Location} new Threshold set to {threashold}"); } //TreeRoot.Stop("Stop Requested"); return(true); }
public static async Task <bool> RunHomeMGP() { var lang = (Language)typeof(DataManager).GetFields(BindingFlags.Static | BindingFlags.NonPublic) .First(i => i.FieldType == typeof(Language)).GetValue(null); if (lang != Language.Eng && lang != Language.Chn) { TreeRoot.Stop("Only works on English and Chinese Clients for now"); } while (true) { await StartOutOnLimbHome(); //Logger.LogCritical("Start Done"); await Coroutine.Wait(5000, () => AgentOutOnLimb.Instance.IsReadyBotanist); //Logger.LogCritical("Ready"); if (await PlayBotanist()) { Logger.LogCritical("First win"); do { Logger.LogCritical("Loop"); if (!SelectYesno.IsOpen) { Logger.LogCritical("Waiting on window"); await Coroutine.Wait(5000, () => SelectYesno.IsOpen); await Coroutine.Sleep(_random.Next(300, 500)); } if (SelectYesno.IsOpen && GetDoubleDownReward() == 0) { SelectYesno.No(); Logger.LogCritical($"Won Nothing Reward: {GetDoubleDownReward()} total so far {totalMGP}"); await Coroutine.Sleep(_random.Next(300, 500)); //await Coroutine.Sleep(_random.Next(4000,5000)); break; } if (SelectYesno.IsOpen && (GetDoubleDownInfo().Key <= 2 || GetDoubleDownInfo().Value < 15)) { SelectYesno.No(); Logger.LogCritical($"Click No Reward: {GetDoubleDownReward()}"); await Coroutine.Sleep(_random.Next(300, 500)); break; } if (SelectYesno.IsOpen && GetDoubleDownInfo().Key > 1 && GetDoubleDownInfo().Value > 15) { Logger.LogCritical($"Click Yes Reward: {GetDoubleDownReward()}"); await Coroutine.Sleep(_random.Next(1000, 1500)); SelectYesno.ClickYes(); await Coroutine.Wait(5000, () => AgentOutOnLimb.Instance.IsReadyBotanist); //await PlayBotanist(); } else if (SelectYesno.IsOpen) { Logger.LogCritical($"Click No Reward: {GetDoubleDownReward()}"); SelectYesno.No(); await Coroutine.Sleep(_random.Next(300, 500)); break; } }while (await PlayBotanist()); await Coroutine.Wait(5000, () => GoldSaucerReward.Instance.IsOpen); if (GoldSaucerReward.Instance.IsOpen) { var gained = GoldSaucerReward.Instance.MGPReward; totalMGP += gained; Logger.LogCritical($"Won {gained} - Total {totalMGP}"); if (gained == 0) { Logger.LogCritical($"Won {gained}"); //TreeRoot.Stop("Won zero...issue"); break; } } Logger.LogCritical("Starting over"); } if (GoldSaucerReward.Instance.IsOpen) { GoldSaucerReward.Instance.Close(); } await Coroutine.Wait(5000, () => !GoldSaucerReward.Instance.IsOpen); Logger.LogCritical("Done"); await Coroutine.Sleep(_random.Next(3000, 4500)); } GamelogManager.MessageRecevied -= GamelogManagerOnMessageRecevied; //TreeRoot.Stop("Stop Requested"); return(true); }
public async Task <bool> HandInItem(uint itemId, int index, int job, bool stopScripMax = false) { if ((!HWDSupply.Instance.IsOpen && Npc == null) || Npc.Location.Distance(Core.Me.Location) > 5f) { await Navigation.GetTo(886, new Vector3(43.59162f, -16f, 170.3864f)); } if (!HWDSupply.Instance.IsOpen && Npc.Location.Distance(Core.Me.Location) > 4f) { await Navigation.OffMeshMove(Npc.Location); await Coroutine.Sleep(500); } if (!HWDSupply.Instance.IsOpen) { //NpcId = GameObjectManager.GameObjects.First(i => i.EnglishName == EnglishName).NpcId; Npc.Interact(); await Coroutine.Wait(5000, () => HWDSupply.Instance.IsOpen || Talk.DialogOpen); await Coroutine.Sleep(1000); while (Talk.DialogOpen) { Talk.Next(); await Coroutine.Wait(5000, () => !Talk.DialogOpen); } await Coroutine.Sleep(1000); } if (HWDSupply.Instance.IsOpen) { if (HWDSupply.Instance.ClassSelected != job) { HWDSupply.Instance.ClassSelected = job; await Coroutine.Sleep(1000); } //var item = InventoryManager.FilledSlots.FirstOrDefault(i => i.RawItemId == itemId); var items = InventoryManager.FilledSlots.Where(i => i.RawItemId == itemId); foreach (var item in items) { HWDSupply.Instance.ClickItem(index); await Coroutine.Wait(5000, () => Request.IsOpen); await Coroutine.Sleep(700); item.Handover(); await Coroutine.Sleep(100); await Coroutine.Wait(5000, () => Request.HandOverButtonClickable); Request.HandOver(); if (ScriptConditions.Helpers.GetSkybuilderScrips() > 9000) { await Coroutine.Wait(2000, () => SelectYesno.IsOpen); } else { await Coroutine.Wait(5000, () => !Request.IsOpen); await Coroutine.Sleep(100); } if (Translator.Language != Language.Chn) { Log($"Kupo Tickets: {HWDSupply.Instance.NumberOfKupoTickets()}"); if (HWDSupply.Instance.NumberOfKupoTickets() >= 9) { Log($"Going to turn in Kupo Tickets: {HWDSupply.Instance.NumberOfKupoTickets()}"); if (SelectYesno.IsOpen) { SelectYesno.Yes(); await Coroutine.Sleep(1000); } HWDSupply.Instance.Close(); await Coroutine.Sleep(2000); await HandInKupoTicket(1); break; } } if (!SelectYesno.IsOpen) { continue; } if (stopScripMax) { if (SelectYesno.IsOpen) { SelectYesno.No(); } await Coroutine.Sleep(500); if (Request.IsOpen) { Request.Cancel(); await Coroutine.Sleep(500); } if (HWDSupply.Instance.IsOpen) { HWDSupply.Instance.Close(); await Coroutine.Wait(2000, () => !HWDSupply.Instance.IsOpen); } } else { SelectYesno.Yes(); } await Coroutine.Sleep(1000); } } if (Request.IsOpen) { Request.Cancel(); await Coroutine.Sleep(2000); if (HWDSupply.Instance.IsOpen) { HWDSupply.Instance.Close(); await Coroutine.Wait(2000, () => !HWDSupply.Instance.IsOpen); } } if (InventoryManager.FilledSlots.Any(i => i.RawItemId == itemId)) { await HandInItem(itemId, index, job, stopScripMax); } return(false); }
private async Task <bool> HandleCollectable() { if (Collectables == null) { //we are not collecting return(false); } if (FishingManager.State != FishingState.Waitin) { // we are not waitin yet! return(false); } if (!SelectYesno.IsOpen) { //Wait a few seconds var opened = await Coroutine.Wait(5000, () => SelectYesno.IsOpen); if (!opened) { Logger.Info("SelectYesNo never appeared"); return(false); } } var required = CollectabilityValue; var itemName = string.Empty; if (!string.IsNullOrWhiteSpace(Collectables.First().Name)) { var item = SelectYesno.Item; if (item == null || !Collectables.Any(c => string.Equals(c.Name, item.EnglishName, StringComparison.InvariantCultureIgnoreCase))) { var ticks = 0; while ((item == null || !Collectables.Any(c => string.Equals(c.Name, item.EnglishName, StringComparison.InvariantCultureIgnoreCase))) && ticks++ < 60 && Behaviors.ShouldContinue) { item = SelectYesno.Item; await Coroutine.Yield(); } // handle timeout if (ticks > 60) { required = (uint)Collectables.Select(c => c.Value).Max(); } } if (item != null) { // handle normal itemName = item.EnglishName; var collectable = Collectables.FirstOrDefault(c => string.Equals(c.Name, item.EnglishName)); if (collectable != null) { required = (uint)collectable.Value; } } } // handle var value = SelectYesno.CollectabilityValue; if (value >= required) { Logger.Info(Localization.Localization.ExFish_Collecting, itemName, value, required); SelectYesno.Yes(); } else { Logger.Info(Localization.Localization.ExFish_Declining, itemName, value, required); SelectYesno.No(); } await Coroutine.Wait(3000, () => !SelectYesno.IsOpen && FishingManager.State != FishingState.Waitin); return(true); }