public CompleteRetainer(RetainerInfo info, int index, List <BagSlot> itemsForSale, List <BagSlot> inventory) { Info = info; ItemsForSale = itemsForSale.Select(x => new RetainerInventoryItem(x.TrueItemId, x.RawItemId, x.Count, x.Slot)).ToList(); Inventory = inventory.Select(x => new RetainerInventoryItem(x.TrueItemId, x.RawItemId, x.Count, x.Slot)).ToList(); Index = index; }
public static async Task <CompleteRetainer> RetainerCheck(RetainerInfo retainer, int Index) { //Log($"Selected Retainer ({Index}): {retainer.Name}"); /*if (SelectString.IsOpen) * { * SelectString.ClickLineContains(Translator.SellInventory); * await Coroutine.Wait(9000, () =>RaptureAtkUnitManager.GetWindowByName("RetainerSellList") != null); * await Coroutine.Sleep(2000); * RaptureAtkUnitManager.GetWindowByName("RetainerSellList").SendAction(1, 3uL, 4294967295uL); * await Coroutine.Wait(9000, () =>SelectString.IsOpen); * * }*/ var ItemsForSale = InventoryManager.GetBagByInventoryBagId(InventoryBagId.Retainer_Market).FilledSlots.ToList(); foreach (var item in ItemsForSale) { Log($"{item}"); } var Inventory = InventoryManager.GetBagsByInventoryBagId(RetainerBagIds).Select(i => i.FilledSlots).SelectMany(x => x).ToList(); var completeRetainer = new CompleteRetainer(retainer, Index, ItemsForSale, Inventory); return(completeRetainer); }
public async Task <bool> RetainerCheck(RetainerInfo retainer) { if (RetainerSettings.Instance.ReassignVentures && retainer.Active && retainer.Job != ClassJobType.Adventurer) { if (retainer.VentureTask != 0) { var now = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; var timeLeft = retainer.VentureEndTimestamp - now; if (timeLeft <= 0 && SpecialCurrencyManager.GetCurrencyCount(SpecialCurrency.Venture) > 2) { await RetainerHandleVentures(); } else { Log($"Venture will be done at {RetainerInfo.UnixTimeStampToDateTime(retainer.VentureEndTimestamp)}"); } } } if (RetainerSettings.Instance.DepositFromPlayer) { await RetainerRoutine.DumpItems(); } if (RetainerSettings.Instance.GetGil) { GetRetainerGil(); } return(true); }
public static void UpdateFromCache(RetainerInfo[] retData) { ClearAll(); var mainBagsArray = InventoryManager.GetBagsByInventoryBagId(GeneralFunctions.MainBags).ToArray(); PlayerInventory.Update(mainBagsArray); StoredSaddleBagInventory storedSaddlebagInventory = ItemFinder.GetCachedSaddlebagInventoryComplete(); SaddlebagInventory.Update(storedSaddlebagInventory); var cachedRetInventories = ItemFinder.GetCachedRetainerInventories(); for (var i = 0; i < retData.Length; i++) { RetainerInfo retInfo = retData[i]; if (!retInfo.Active) { continue; } if (cachedRetInventories.TryGetValue(retInfo.Unique, out StoredRetainerInventory storedInventory)) { if (RetainerInventories.ContainsKey(i)) { RetainerInventories[i].Update(storedInventory); } else { RetainerInventories.Add(i, new CachedInventory(retInfo.Name, i)); RetainerInventories[i].Update(storedInventory); } } } foreach (CachedInventory cachedInventory in GetAllInventories()) { if (cachedInventory.AllBelong() && cachedInventory.FreeSlots == 0) { FilledAndSortedInventories.Add(cachedInventory.Index); } } foreach (ItemSortInfo sortInfo in PlayerInventory.ItemCounts.Select(x => GetSortInfo(x.Key))) { if (sortInfo.ItemInfo.Unique) { PlayerInventoryUniques.Add(sortInfo.TrueItemId); } } }
public static async Task <bool> RetainerCheckOnlyVenture(RetainerInfo retainer) { if (retainer.VentureTask != 0) { var now = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; var timeLeft = retainer.VentureEndTimestamp - now; if (timeLeft <= 0 && SpecialCurrencyManager.GetCurrencyCount(SpecialCurrency.Venture) > 2) { await RetainerHandleVentures(); } else { Log($"Venture will be done at {RetainerInfo.UnixTimeStampToDateTime(retainer.VentureEndTimestamp)}"); } } return(true); }
public RetainerInfo[] OrderedRetainerList(RetainerInfo[] retainers) { if (Translator.Language == Language.Chn) { return(retainers); } int count = retainers.Length; var result = new RetainerInfo[count]; //Logging.Write($"Retainer length {retainers.Length}"); int index = 0; for (int i = 0; i < count; i++) { //Logging.Write($"Retainer name:{RetainerName(i)}"); result[index] = retainers.First(j => j.Name.Trim().Contains(RetainerName(i).Trim())); Logging.Write($"{i} {result[index].Name}"); index++; } return(result); }
public RetainerInfo[] OrderedRetainerList(RetainerInfo[] retainers) { int count = RetainerList.Count(i => i != IntPtr.Zero); if (count == 0) { return(retainers); } var result = new RetainerInfo[count]; // new List<KeyValuePair<int, RetainerInfo>>(); //IntPtr[] RetainerList = Core.Memory.ReadArray<IntPtr>(new IntPtr(0x18FD0C64510) + 0x4a8, 0xA); int index = 0; foreach (var ptr in RetainerList.Where(i => i != IntPtr.Zero)) { var next = Core.Memory.Read <IntPtr>(ptr); result[index] = retainers.First(j => j.Name.Equals(Core.Memory.ReadStringUTF8(next))); index++; } return(result); }
public async Task RetainerRun() { var bell = await GoToSummoningBell(); if (bell == false) { LogCritical("No summoning bell near by"); TreeRoot.Stop("Done playing with retainers"); return; } await RetainerRoutine.ReadRetainers(RetainerCheck); await Coroutine.Sleep(1000); if (!RetainerSettings.Instance.Loop || !RetainerSettings.Instance.ReassignVentures) { LogCritical($"Loop Setting {RetainerSettings.Instance.Loop} ReassignVentures {RetainerSettings.Instance.ReassignVentures}"); TreeRoot.Stop("Done playing with retainers"); } if (RetainerSettings.Instance.Loop && InventoryManager.FreeSlots < 2) { LogCritical($"I am overburdened....free up some space you hoarder"); TreeRoot.Stop("Done playing with retainers"); } var count = await GetNumberOfRetainers(); var rets = Core.Memory.ReadArray <RetainerInfo>(Offsets.RetainerData, count); if (!rets.Any(i => i.VentureTask != 0 && i.Active)) { LogCritical($"No ventures assigned or completed"); TreeRoot.Stop("Done playing with retainers"); } var nextVenture = rets.Where(i => i.VentureTask != 0 && i.Active).OrderBy(i => i.VentureEndTimestamp).First(); if (nextVenture.VentureEndTimestamp == 0) { LogCritical($"No ventures running"); TreeRoot.Stop("Done playing with retainers"); } if (SpecialCurrencyManager.GetCurrencyCount(SpecialCurrency.Venture) <= 2) { LogCritical($"Get more venture tokens...bum"); TreeRoot.Stop("Done playing with retainers"); } var now = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; var timeLeft = nextVenture.VentureEndTimestamp - now; Log($"Waiting till {RetainerInfo.UnixTimeStampToDateTime(nextVenture.VentureEndTimestamp)}"); await Coroutine.Sleep(timeLeft * 1000); await Coroutine.Sleep(30000); Log($"{nextVenture.Name} Venture should be done"); }
private void AutoSetup_Click(object sender, EventArgs e) { if (!AutoRetainerSortSettings.Instance.InventoryOptions.ContainsKey(ItemSortStatus.PlayerInventoryIndex)) { DialogResult dr = MessageBox.Show( "It looks like you don't have the player inventory added to the indexes... somehow. Do you want me to re-add that for you?", "Um.", MessageBoxButtons.YesNo, MessageBoxIcon.Warning ); if (dr == DialogResult.Yes) { AutoRetainerSortSettings.Instance.InventoryOptions.Add(ItemSortStatus.PlayerInventoryIndex, new InventorySortInfo("Player Inventory")); } } if (!AutoRetainerSortSettings.Instance.InventoryOptions.ContainsKey(ItemSortStatus.SaddlebagInventoryIndex)) { DialogResult dr = MessageBox.Show( "It looks like you don't have the chocobo saddlebag added to the indexes. Do you want me to re-add that for you?", "Hey Listen!", MessageBoxButtons.YesNo, MessageBoxIcon.Information ); if (dr == DialogResult.Yes) { AutoRetainerSortSettings.Instance.InventoryOptions.Add(ItemSortStatus.SaddlebagInventoryIndex, new InventorySortInfo("Chocobo Saddlebag")); } } MessageBox.Show( Strings.AutoSetup_CacheAdvice, "Careful!", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult warningResult = MessageBox.Show( Strings.AutoSetup_OverwriteWarning, "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (warningResult == DialogResult.No) { return; } bool conflictUnsorted = MessageBox.Show( Strings.AutoSetup_ConflictQuestion, "Conflict?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; var newInventorySetup = AutoRetainerSortSettings.Instance.InventoryOptions; foreach (InventorySortInfo inventorySortInfo in newInventorySetup.Values) { inventorySortInfo.SortTypes.Clear(); } var orderedRetainerList = RetainerList.Instance.OrderedRetainerList; for (var i = 0; i < orderedRetainerList.Length; i++) { if (newInventorySetup.ContainsKey(i)) { continue; } RetainerInfo retInfo = orderedRetainerList[i]; if (!retInfo.Active) { continue; } newInventorySetup.Add(i, new InventorySortInfo(retInfo.Name)); } AutoRetainerSortSettings.Instance.InventoryOptions = newInventorySetup; ItemSortStatus.UpdateFromCache(orderedRetainerList); var sortTypeCounts = new Dictionary <SortType, Dictionary <int, int> >(); foreach (SortType sortType in Enum.GetValues(typeof(SortType)).Cast <SortType>()) { sortTypeCounts[sortType] = new Dictionary <int, int>(); } foreach (CachedInventory cachedInventory in ItemSortStatus.GetAllInventories()) { foreach (SortType sortType in cachedInventory.ItemCounts.Select(x => ItemSortStatus.GetSortInfo(x.Key).SortType)) { var indexCountDic = sortTypeCounts[sortType]; if (indexCountDic.ContainsKey(cachedInventory.Index)) { indexCountDic[cachedInventory.Index]++; } else { indexCountDic.Add(cachedInventory.Index, 1); } } } foreach (var typeDicPair in sortTypeCounts) { SortType sortType = typeDicPair.Key; int indexCount = typeDicPair.Value.Keys.Count; if (indexCount == 0) { continue; } if (indexCount > 1 && conflictUnsorted) { continue; } int desiredIndex = typeDicPair.Value.OrderByDescending(x => x.Value).First().Key; AutoRetainerSortSettings.Instance.InventoryOptions[desiredIndex].SortTypes.Add(new SortTypeWithCount(sortType)); } ResetBindingSource(); AutoRetainerSortSettings.Instance.Save(); AutoRetainerSort.LogSuccess("Auto-Setup done!"); }