コード例 #1
0
        /*The await sleeps shouldn't be necessary but if they aren't there the game crashes some times since
         * it tries to send commands to a window that isn't open even though it reports it as open (guess it didn't load yet)*/

        private async Task <bool> RetainerTest()
        {
            if (done)
            {
                return(true);
            }

            Log(" ");
            Log("==================================================");
            Log("====================Retainers=====================");
            Log("==================================================");
            Log(" ");

            //var retainerIndex = 0;

            //Settings variables
            debug = RetainerSettings.Instance.DebugLogging;

            await UseSummoningBell();

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

/*            while (RetainerList.Instance.IsOpen)
 *          {
 *              Log($"{Core.Memory.Read<uint>(RetainerList.Instance.WindowByName.Pointer + 0x180) & 0xF00000u}");
 *              await Coroutine.Sleep(50);
 *          }*/
            await Coroutine.Wait(5000, () => RetainerList.Instance.IsOpen);

            //Log("Visible:" + RetainerList.Instance.IsOpen);
            //await Coroutine.Sleep(1000);

            var numRetainers = RetainerList.Instance.NumberOfRetainers; //GetNumberOfRetainers();

            var retList         = new List <RetainerInventory>();
            var moveToOrder     = new List <KeyValuePair <uint, int> >();
            var masterInventory = new Dictionary <uint, List <KeyValuePair <int, uint> > >();

            var retainerNames = new Dictionary <int, string>();

            if (numRetainers <= 0)
            {
                LogCritical("Can't find number of retainers either you have none or not near a bell");
                RetainerList.Instance.Close();

                TreeRoot.Stop("Failed: Find a bell or some retainers");
                return(true);
            }

            //Moves
            var moveFrom = new List <uint> [numRetainers];

            for (var retainerIndex = 0; retainerIndex < numRetainers; retainerIndex++)
            {
                moveFrom[retainerIndex] = new List <uint>();
            }

            for (var retainerIndex = 0; retainerIndex < numRetainers; retainerIndex++)
            {
                if (!retainerNames.ContainsKey(retainerIndex))
                {
                    retainerNames.Add(retainerIndex, RetainerList.Instance.RetainerName(retainerIndex));
                }
                Log($"Selecting {RetainerList.Instance.RetainerName(retainerIndex)}");
                await RetainerRoutine.SelectRetainer(retainerIndex);

                var inventory = new RetainerInventory();

                if (RetainerSettings.Instance.GetGil)
                {
                    GetRetainerGil();
                }

                LogVerbose("Inventory open");
                foreach (var item in InventoryManager.GetBagsByInventoryBagId(RetainerBagIds).Select(i => i.FilledSlots).SelectMany(x => x).Where(FilterStackable))
                {
                    try
                    {
                        inventory.AddItem(item);
                        if (masterInventory.ContainsKey(item.TrueItemId))
                        {
                            masterInventory[item.TrueItemId]
                            .Add(new KeyValuePair <int, uint>(retainerIndex, item.Count));
                        }
                        else
                        {
                            masterInventory.Add(item.TrueItemId, new List <KeyValuePair <int, uint> >());
                            masterInventory[item.TrueItemId]
                            .Add(new KeyValuePair <int, uint>(retainerIndex, item.Count));
                        }
                    }
                    catch (Exception e)
                    {
                        LogCritical("SHIT:" + e);
                        throw;
                    }
                }

                LogVerbose("Inventory done");

                Log("Checking retainer[{0}] against player inventory", retainerNames[retainerIndex]);

                if (RetainerSettings.Instance.DepositFromPlayer)
                {
                    await RetainerRoutine.DumpItems();
                }


                Log("Done checking against player inventory");

/*                   AgentModule.ToggleAgentInterfaceById(274);
 *                  await Coroutine.Sleep(200);
 *                  var cho1 = InventoryManager.GetBagByInventoryBagId((InventoryBagId)4000);
 *                  var cho2 = InventoryManager.GetBagByInventoryBagId((InventoryBagId)4001);
 *                  if (cho1 != null && cho2 != null)
 *                  {
 *                      var chocobags = (cho1.FilledSlots).Concat(cho2.FilledSlots);
 *                      foreach (var item in chocobags.Where(FilterStackable).Where(item => inventory.HasItem(item.TrueItemId)))
 *                      {
 *                          Log($"Chocobo AND RETAINER both have Name: {item.Item.CurrentLocaleName}\tId: {item.Item.Id}");
 *                          Log("Moved: " + MoveItem(item, inventory.GetItem(item.TrueItemId)));
 *                          await Coroutine.Sleep(100);
 *                      }
 *                  }*/

                //RetainerTasks.CloseInventory();

                //await Coroutine.Sleep(200);

                await RetainerRoutine.DeSelectRetainer();

                LogVerbose("Should be back at retainer list by now");

                // await Coroutine.Sleep(200);
                // }

                retList.Add(inventory);
            }

            //await Coroutine.Sleep(1000);

            if (RetainerSettings.Instance.DontOrganizeRetainers || !RetainerSettings.Instance.DepositFromPlayer)
            {
                RetainerList.Instance.Close();

                TreeRoot.Stop("Done playing with retainers (Don't organize or don't deposit items.)");
                return(true);
            }

            if (debug)
            {
                foreach (var itemId in masterInventory)
                {
                    var retainers = "";

                    foreach (var retainerId in itemId.Value)
                    {
                        retainers += $"Retainer[{retainerNames[retainerId.Key]}] has {retainerId.Value} ";
                    }

                    Log("Item {0}: {1}", itemId.Key, retainers);
                }
            }

            LogCritical("Duplicate items Found:");

            if (debug)
            {
                foreach (var itemId in masterInventory.Where(r => r.Value.Count > 1))
                {
                    var retainers  = "";
                    var retListInv = new List <KeyValuePair <int, uint> >(itemId.Value.OrderByDescending(r => r.Value));

                    foreach (var retainerId in retListInv)
                    {
                        retainers += $"Retainer[{retainerNames[retainerId.Key]}] has {retainerId.Value} ";
                    }

                    Log("Item {0}: {1}", itemId.Key, retainers);
                }
            }

            /*
             * Same as above but before the second foreach save retainer/count
             * remove that one since it's where we're going to move stuff to
             */
            var numOfMoves = 0;

            foreach (var itemId in masterInventory.Where(r => r.Value.Count > 1))
            {
                var retListInv = new List <KeyValuePair <int, uint> >(itemId.Value.OrderByDescending(r => r.Value));

                var retainerTemp = retListInv[0].Key;
                var countTemp    = retListInv[0].Value;

                var retainers = "";

                retListInv.RemoveAt(0);

                foreach (var retainerId in retListInv)
                {
                    retainers += $"Retainer[{retainerNames[retainerId.Key]}] has {retainerId.Value} ";
                    countTemp += retainerId.Value;
                }

                Log($"Item: {DataManager.GetItem(NormalRawId(itemId.Key))} ({itemId.Key}) Total:{countTemp} should be in {retainerNames[retainerTemp]} and {retainers}");

                if (countTemp > 999)
                {
                    LogCritical("This item will have a stack size over 999: {0}", itemId.Key);
                }
                else
                {
                    numOfMoves++;
                    foreach (var retainerIdTemp in retListInv)
                    {
                        moveFrom[retainerIdTemp.Key].Add(itemId.Key);
                    }
                }
            }

            LogCritical("Looks like we need to do {0} moves", numOfMoves);

            if (numOfMoves < InventoryManager.FreeSlots && numOfMoves > 0)
            {
                LogCritical($"Looks like we have {InventoryManager.FreeSlots} free spaces in inventory so we can just dump into player inventory");

                //First loop
                for (var retainerIndex = 0; retainerIndex < numRetainers; retainerIndex++)
                {
                    var inventory = new RetainerInventory();

                    if (!RetainerList.Instance.IsOpen)
                    {
                        await UseSummoningBell();

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

                        //await Coroutine.Sleep(1000);
                    }

                    if (!RetainerList.Instance.IsOpen)
                    {
                        Log("Failed opening retainer list");
                    }

                    LogVerbose("Open:" + RetainerList.Instance.IsOpen);

                    await RetainerList.Instance.SelectRetainer(retainerIndex);

                    Log($"Selected Retainer: {retainerNames[retainerIndex]}");

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

                    //    RetainerTasks.OpenInventory();
//
                    //    await Coroutine.Wait(5000, RetainerTasks.IsInventoryOpen);

                    //   if (!RetainerTasks.IsInventoryOpen()) continue;
                    //await Coroutine.Sleep(500);

                    Log("Checking retainer[{0}] against move list", retainerNames[retainerIndex]);

                    foreach (var item in moveFrom[retainerIndex])
                    {
                        if (!InventoryManager.GetBagsByInventoryBagId(RetainerBagIds).Select(i => i.FilledSlots).SelectMany(x => x).Any(i => i.TrueItemId == item))
                        {
                            continue;
                        }

                        Log("Moved: " + InventoryManager.GetBagsByInventoryBagId(RetainerBagIds).Select(i => i.FilledSlots).SelectMany(x => x).First(i => i.TrueItemId == item)
                            .Move(InventoryManager.GetBagsByInventoryBagId(inventoryBagId_0).First(bag => bag.FreeSlots > 0).GetFirstFreeSlot()));
                        await Coroutine.Sleep(200);
                    }

                    Log("Done checking against player inventory");

                    //        RetainerTasks.CloseInventory();

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

                    RetainerTasks.CloseTasks();

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

                    if (DialogOpen)
                    {
                        Next();
                    }

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

                    LogVerbose("Should be back at retainer list by now");
                }
            }
            else
            {
                if (numOfMoves <= 0)
                {
                    LogCritical("No duplicate stacks found so no moved needed.");
                    RetainerList.Instance.Close();

                    TreeRoot.Stop("Done playing with retainers");
                    return(true);
                }

                LogCritical("Crap, we don't have enough player inventory to dump it all here");
                RetainerList.Instance.Close();

                TreeRoot.Stop("Done playing with retainers");
                return(false);
            }


            for (var retainerIndex = 0; retainerIndex < numRetainers; retainerIndex++)
            {
                Log($"Selecting {RetainerList.Instance.RetainerName(retainerIndex)}");
                await RetainerRoutine.SelectRetainer(retainerIndex);

                await RetainerRoutine.DumpItems();

                await RetainerRoutine.DeSelectRetainer();

                Log($"Done with {RetainerList.Instance.RetainerName(retainerIndex)}");
            }
            //   await RetainerRoutine.ReadRetainers(RetainerRoutine.DumpItems());

            LogVerbose("Closing Retainer List");

            RetainerList.Instance.Close();

            TreeRoot.Stop("Done playing with retainers");

            done = true;

            return(true);
        }
コード例 #2
0
ファイル: Retainers.cs プロジェクト: siune-one/LlamaLibrary
        /*The await sleeps shouldn't be necessary but if they aren't there the game crashes some times since
         * it tries to send commands to a window that isn't open even though it reports it as open (guess it didn't load yet)*/

        private async Task <bool> RetainerTest()
        {
            if (done)
            {
                return(true);
            }

            Log(" ");
            Log("==================================================");
            Log("====================Retainers=====================");
            Log("==================================================");
            Log(" ");

            var count = await HelperFunctions.GetNumberOfRetainers();

            var rets = Core.Memory.ReadArray <RetainerInfo>(Offsets.RetainerData, count);


            //var retainerIndex = 0;

            //Settings variables
            debug = RetainerSettings.Instance.DebugLogging;
            var bell = await GoToSummoningBell();

            if (bell == false)
            {
                LogCritical("No summoning bell near by");
                TreeRoot.Stop("Done playing with retainers");
                return(false);
            }
            await UseSummoningBell();

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

            if (!RetainerList.Instance.IsOpen)
            {
                LogCritical("Can't Open Bell");
                TreeRoot.Stop("Done playing with retainers");
                return(false);
            }

            if (SelectString.IsOpen)
            {
                await RetainerRoutine.DeSelectRetainer();
            }
            var ordered      = RetainerList.Instance.OrderedRetainerList(rets).Where(i => i.Active).ToArray();
            var numRetainers = ordered.Count(); //GetNumberOfRetainers();

            var retList         = new List <RetainerInventory>();
            var moveToOrder     = new List <KeyValuePair <uint, int> >();
            var masterInventory = new Dictionary <uint, List <KeyValuePair <int, uint> > >();

            var retainerNames = new Dictionary <int, string>();

            if (numRetainers <= 0)
            {
                LogCritical("Can't find number of retainers either you have none or not near a bell");
                RetainerList.Instance.Close();

                TreeRoot.Stop("Failed: Find a bell or some retainers");
                return(true);
            }

            //Moves
            var moveFrom = new List <uint> [numRetainers];

            for (var retainerIndex = 0; retainerIndex < numRetainers; retainerIndex++)
            {
                moveFrom[retainerIndex] = new List <uint>();
            }

            ventures = RetainerList.Instance.NumberOfVentures;

            for (var retainerIndex = 0; retainerIndex < numRetainers; retainerIndex++)
            {
                if (!retainerNames.ContainsKey(retainerIndex))
                {
                    retainerNames.Add(retainerIndex, RetainerList.Instance.RetainerName(retainerIndex));
                }
                bool hasJob = RetainerList.Instance.RetainerHasJob(retainerIndex);
                Log($"Selecting {RetainerList.Instance.RetainerName(retainerIndex)}");
                await RetainerRoutine.SelectRetainer(retainerIndex);

                var inventory = new RetainerInventory();

                if (RetainerSettings.Instance.GetGil)
                {
                    GetRetainerGil();
                }

                LogVerbose("Inventory open");
                foreach (var item in InventoryManager.GetBagsByInventoryBagId(RetainerBagIds).Select(i => i.FilledSlots).SelectMany(x => x).Where(FilterStackable))
                {
                    try
                    {
                        inventory.AddItem(item);
                        if (masterInventory.ContainsKey(item.TrueItemId))
                        {
                            masterInventory[item.TrueItemId]
                            .Add(new KeyValuePair <int, uint>(retainerIndex, item.Count));
                        }
                        else
                        {
                            masterInventory.Add(item.TrueItemId, new List <KeyValuePair <int, uint> >());
                            masterInventory[item.TrueItemId]
                            .Add(new KeyValuePair <int, uint>(retainerIndex, item.Count));
                        }
                    }
                    catch (Exception e)
                    {
                        LogCritical("SHIT:" + e);
                        throw;
                    }
                }

                LogVerbose("Inventory done");

                Log("Checking retainer[{0}] against player inventory", retainerNames[retainerIndex]);

                if (RetainerSettings.Instance.DepositFromPlayer)
                {
                    await RetainerRoutine.DumpItems();
                }

                Log("Done checking against player inventory");

                if (RetainerSettings.Instance.ReassignVentures && (ordered[retainerIndex].Job != ClassJobType.Adventurer) && ventures > 2 && (ordered[retainerIndex].VentureEndTimestamp - UnixTimestamp) <= 0)
                {
                    Log("Checking Ventures");
                    await RetainerHandleVentures(); //CheckVentures();
                }
                else if ((ordered[retainerIndex].VentureEndTimestamp - UnixTimestamp) > 0)
                {
                    Log($"Venture will be done in {(ordered[retainerIndex].VentureEndTimestamp - UnixTimestamp)/60} minutes");
                }
                else
                {
                    Log("Retainer has no job");
                }

                await RetainerRoutine.DeSelectRetainer();

                LogVerbose("Should be back at retainer list by now");

                // await Coroutine.Sleep(200);
                // }

                retList.Add(inventory);
            }

            //await Coroutine.Sleep(1000);

            if (RetainerSettings.Instance.DontOrganizeRetainers || !RetainerSettings.Instance.DepositFromPlayer)
            {
                RetainerList.Instance.Close();

                TreeRoot.Stop("Done playing with retainers (Don't organize or don't deposit items.)");
                return(true);
            }

            if (debug)
            {
                foreach (var itemId in masterInventory)
                {
                    var retainers = "";

                    foreach (var retainerId in itemId.Value)
                    {
                        retainers += $"Retainer[{retainerNames[retainerId.Key]}] has {retainerId.Value} ";
                    }

                    Log("Item {0}: {1}", itemId.Key, retainers);
                }
            }

            LogCritical("Duplicate items Found:");

            if (debug)
            {
                foreach (var itemId in masterInventory.Where(r => r.Value.Count > 1))
                {
                    var retainers  = "";
                    var retListInv = new List <KeyValuePair <int, uint> >(itemId.Value.OrderByDescending(r => r.Value));

                    foreach (var retainerId in retListInv)
                    {
                        retainers += $"Retainer[{retainerNames[retainerId.Key]}] has {retainerId.Value} ";
                    }

                    Log("Item {0}: {1}", itemId.Key, retainers);
                }
            }

            /*
             * Same as above but before the second foreach save retainer/count
             * remove that one since it's where we're going to move stuff to
             */
            var numOfMoves = 0;

            foreach (var itemId in masterInventory.Where(r => r.Value.Count > 1))
            {
                var retListInv = new List <KeyValuePair <int, uint> >(itemId.Value.OrderByDescending(r => r.Value));

                var retainerTemp = retListInv[0].Key;
                var countTemp    = retListInv[0].Value;

                var retainers = "";

                retListInv.RemoveAt(0);

                foreach (var retainerId in retListInv)
                {
                    retainers += $"Retainer[{retainerNames[retainerId.Key]}] has {retainerId.Value} ";
                    countTemp += retainerId.Value;
                }

                Log($"Item: {DataManager.GetItem(NormalRawId(itemId.Key))} ({itemId.Key}) Total:{countTemp} should be in {retainerNames[retainerTemp]} and {retainers}");

                if (countTemp > 999)
                {
                    LogCritical("This item will have a stack size over 999: {0}", itemId.Key);
                }
                else if (numOfMoves < InventoryManager.FreeSlots - 1)
                {
                    numOfMoves++;
                    foreach (var retainerIdTemp in retListInv)
                    {
                        moveFrom[retainerIdTemp.Key].Add(itemId.Key);
                    }
                }
            }

            LogCritical("Looks like we need to do {0} moves", numOfMoves);

            if (numOfMoves < InventoryManager.FreeSlots && numOfMoves > 0)
            {
                LogCritical($"Looks like we have {InventoryManager.FreeSlots} free spaces in inventory so we can just dump into player inventory");

                //First loop
                for (var retainerIndex = 0; retainerIndex < numRetainers; retainerIndex++)
                {
                    var inventory = new RetainerInventory();

                    if (!RetainerList.Instance.IsOpen)
                    {
                        await UseSummoningBell();

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

                        //await Coroutine.Sleep(1000);
                    }

                    if (!RetainerList.Instance.IsOpen)
                    {
                        Log("Failed opening retainer list");
                    }

                    LogVerbose("Open:" + RetainerList.Instance.IsOpen);

                    await RetainerList.Instance.SelectRetainer(retainerIndex);

                    Log($"Selected Retainer: {retainerNames[retainerIndex]}");

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

                    RetainerTasks.OpenInventory();
                    //
                    await Coroutine.Wait(5000, RetainerTasks.IsInventoryOpen);

                    if (!RetainerTasks.IsInventoryOpen())
                    {
                        continue;
                    }
                    await Coroutine.Sleep(500);

                    Log("Checking retainer[{0}] against move list", retainerNames[retainerIndex]);

                    foreach (var item in moveFrom[retainerIndex])
                    {
                        if (!InventoryManager.GetBagsByInventoryBagId(RetainerBagIds).Select(i => i.FilledSlots).SelectMany(x => x).Any(i => i.TrueItemId == item))
                        {
                            continue;
                        }

                        Log("Moved: " + InventoryManager.GetBagsByInventoryBagId(RetainerBagIds).Select(i => i.FilledSlots).SelectMany(x => x).First(i => i.TrueItemId == item)
                            .Move(InventoryManager.GetBagsByInventoryBagId(inventoryBagId_0).First(bag => bag.FreeSlots > 0).GetFirstFreeSlot()));
                        await Coroutine.Sleep(200);
                    }

                    Log("Done checking against player inventory");

                    RetainerTasks.CloseInventory();

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

                    RetainerTasks.CloseTasks();

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

                    if (DialogOpen)
                    {
                        Next();
                    }

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

                    LogVerbose("Should be back at retainer list by now");
                }
            }
            else
            {
                if (numOfMoves <= 0)
                {
                    LogCritical("No duplicate stacks found so no moved needed.");
                    RetainerList.Instance.Close();

                    TreeRoot.Stop("Done playing with retainers");
                    return(true);
                }

                LogCritical("Crap, we don't have enough player inventory to dump it all here");
                RetainerList.Instance.Close();

                TreeRoot.Stop("Done playing with retainers");
                return(false);
            }


            for (var retainerIndex = 0; retainerIndex < numRetainers; retainerIndex++)
            {
                Log($"Selecting {RetainerList.Instance.RetainerName(retainerIndex)}");
                await RetainerRoutine.SelectRetainer(retainerIndex);

                await RetainerRoutine.DumpItems();

                await RetainerRoutine.DeSelectRetainer();

                Log($"Done with {RetainerList.Instance.RetainerName(retainerIndex)}");
            }
            //   await RetainerRoutine.ReadRetainers(RetainerRoutine.DumpItems());

            LogVerbose("Closing Retainer List");

            RetainerList.Instance.Close();

            TreeRoot.Stop("Done playing with retainers");

            done = true;

            return(true);
        }
コード例 #3
0
        /*The await sleeps shouldn't be necessary but if they aren't there the game crashes some times since
         * it tries to send commands to a window that isn't open even though it reports it as open (guess it didn't load yet)*/

        private async Task <bool> RetainerTest()
        {
            if (done)
            {
                return(true);
            }

            Log(" ");
            Log("==================================================");
            Log("====================Retainers=====================");
            Log("==================================================");
            Log(" ");

            //var retainerIndex = 0;
            Dictionary <MyItemRole, int> itemRoleCount = Enum.GetValues(typeof(MyItemRole)).Cast <MyItemRole>().ToDictionary(eItemUiCRole => eItemUiCRole, eItemUiCategory => 0);

            Dictionary <ItemUiCategory, int> itemUiCount = Enum.GetValues(typeof(ItemUiCategory)).Cast <ItemUiCategory>().ToDictionary(eItemUiCategory => eItemUiCategory, eItemUiCategory => 0);
            int count = 0;

            //Settings variables
            debug = RetainerSettings.Instance.DebugLogging;

            await UseSummoningBell();

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

            await Coroutine.Sleep(1000);

            var numRetainers = RetainerList.Instance.NumberOfRetainers; //GetNumberOfRetainers();

            var retList         = new List <RetainerInventory>();
            var moveToOrder     = new List <KeyValuePair <uint, int> >();
            var masterInventory = new Dictionary <uint, List <KeyValuePair <int, uint> > >();

            var retainerNames = new Dictionary <int, string>();

            if (numRetainers <= 0)
            {
                LogCritical("Can't find number of retainers either you have none or not near a bell");
                RetainerList.Instance.Close();

                TreeRoot.Stop("Failed: Find a bell or some retainers");
                return(true);
            }

            //Moves
            var moveFrom = new List <uint> [numRetainers];

            for (var retainerIndex = 0; retainerIndex < numRetainers; retainerIndex++)
            {
                moveFrom[retainerIndex] = new List <uint>();
            }

            for (var retainerIndex = 0; retainerIndex < numRetainers; retainerIndex++)
            {
                var inventory = new RetainerInventory();

                if (!RetainerList.Instance.IsOpen)
                {
                    await UseSummoningBell();

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

                    await Coroutine.Sleep(500);
                }

                if (!RetainerList.Instance.IsOpen)
                {
                    Log("Failed opening retainer list");
                }

                LogVerbose("Open:" + RetainerList.Instance.IsOpen);

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

                await Coroutine.Sleep(500);

                if (!retainerNames.ContainsKey(retainerIndex))
                {
                    retainerNames.Add(retainerIndex, RetainerList.Instance.RetainerName(retainerIndex));
                }
                await RetainerList.Instance.SelectRetainer(retainerIndex);

                await Coroutine.Sleep(200);

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

                Log("Selected Retainer: " + retainerNames[retainerIndex]);

                if (RetainerSettings.Instance.GetGil)
                {
                    GetRetainerGil();
                }

                RetainerTasks.OpenInventory();
                await Coroutine.Wait(5000, RetainerTasks.IsInventoryOpen);


/*                ItemUiCategory[] HousingItems = new[]
 *              {
 *                  ItemUiCategory.Roof, ItemUiCategory.Exterior_Wall, ItemUiCategory.Exterior_Wall, ItemUiCategory.Window, ItemUiCategory.Door, ItemUiCategory.Roof_Decoration, ItemUiCategory.Exterior_Wall_Decoration,
 *                  ItemUiCategory.Placard, ItemUiCategory.Fence, ItemUiCategory.Interior_Wall, ItemUiCategory.Flooring, ItemUiCategory.Ceiling_Light, ItemUiCategory.Outdoor_Furnishing, ItemUiCategory.Tabletop, ItemUiCategory.Wall_mounted,
 *                  ItemUiCategory.Rug, (ItemUiCategory) 95
 *              };
 *              ItemUiCategory[] categories = new[] {ItemUiCategory.Roof};*/


                if (RetainerTasks.IsInventoryOpen())
                {
                    LogVerbose("Inventory open");
                    foreach (var retbag in InventoryManager.GetBagsByInventoryBagId(RetainerBagIds))
                    {
                        foreach (var item in retbag.FilledSlots)
                        {
                            if (itemRoleCount.ContainsKey(item.Item.MyItemRole()))
                            {
                                itemRoleCount[item.Item.MyItemRole()]++;
                            }
                            else
                            {
                                itemRoleCount.Add(item.Item.MyItemRole(), 1);
                            }

                            if (itemUiCount.ContainsKey(item.Item.EquipmentCatagory))
                            {
                                itemUiCount[item.Item.EquipmentCatagory]++;
                            }
                            else
                            {
                                itemUiCount.Add(item.Item.EquipmentCatagory, 1);
                            }

                            if (item.Item.MyItemRole() == MyItemRole.CraftingMaterial && item.Item.EquipmentCatagory == ItemUiCategory.Stone && item.Item.EnglishName.Contains("Ore"))
                            {
                                count++;
                                Log($"Match {item.Item.CurrentLocaleName}");
                            }
                        }

/*
 *                      foreach (var bagSlot in InventoryManager.FilledSlots.Where(i => i.EnglishName.Contains("Koppranickel Ore")))
 *                      {
 *                          Log(string.Format("Match {0} {2} {1:X}", bagSlot.Count, bagSlot.Pointer.ToInt64(), bagSlot.Slot));
 *                      }
 *
 *                      foreach (var ptr in AgentModule.AgentPointers)
 *                      {
 *                          Log(string.Format("Agent {0:X}",  ptr.ToInt64()));
 *                      }
 */
                        //foreach (var item in retbag.FilledSlots.Where(i => HousingItems.Contains(i.Item.EquipmentCatagory)))
                        if (RetainerSettings.Instance.RoleCheck)
                        {
                            foreach (var item in retbag.FilledSlots.Where(i => i.Item.MyItemRole() == RetainerSettings.Instance.ItemRoleToPull))
                            {
                                if (InventoryManager.FreeSlots <= 1)
                                {
                                    break;
                                }
                                Log($"Moving {item.Item.CurrentLocaleName}\t To Player");
                                item.Move(PlayerInventory.First(bag => bag.FreeSlots > 0).GetFirstFreeSlot());
                            }
                        }

                        if (RetainerSettings.Instance.CategoryCheck)
                        {
                            foreach (var item in retbag.FilledSlots.Where(i => i.Item.EquipmentCatagory == RetainerSettings.Instance.ItemCategoryToPull))
                            {
                                if (InventoryManager.FreeSlots <= 1)
                                {
                                    break;
                                }
                                Log($"Moving {item.Item.CurrentLocaleName}\t To Player");
                                item.Move(PlayerInventory.First(bag => bag.FreeSlots > 0).GetFirstFreeSlot());
                            }
                        }
                    }

/*
 *                  LogVerbose("Inventory done");
 *
 *                  Log("Checking retainer[{0}] against player inventory", retainerNames[retainerIndex]);
 *
 *                  foreach (var item in InventoryManager.FilledSlots.Where(x => x.BagId == InventoryBagId.Bag1 || x.BagId == InventoryBagId.Bag2 || x.BagId == InventoryBagId.Bag3 || x.BagId == InventoryBagId.Bag4)
 *                      .Where(FilterStackable).Where(item => inventory.HasItem(item.TrueItemId)))
 *                  {
 *                      Log($"PLAYER AND RETAINER both have Name: {item.Item.CurrentLocaleName}\tId: {item.Item.Id}");
 *
 *                      if (RetainerSettings.Instance.DepositFromPlayer)
 *                      {
 *                          Log("Moved: " + MoveItem(item, inventory.GetItem(item.TrueItemId)));
 *                          await Coroutine.Sleep(100);
 *                      }
 *                  }
 */

                    Log("Done checking against player inventory");

                    /*
                     * AgentModule.ToggleAgentInterfaceById(274);
                     * await Coroutine.Sleep(200);
                     * var cho1 = InventoryManager.GetBagByInventoryBagId((InventoryBagId)4000);
                     * var cho2 = InventoryManager.GetBagByInventoryBagId((InventoryBagId)4001);
                     * if (cho1 != null && cho2 != null)
                     * {
                     *  var chocobags = (cho1.FilledSlots).Concat(cho2.FilledSlots);
                     *  foreach (var item in chocobags.Where(FilterStackable).Where(item => inventory.HasItem(item.TrueItemId)))
                     *  {
                     *      Log($"Chocobo AND RETAINER both have Name: {item.Item.CurrentLocaleName}\tId: {item.Item.Id}");
                     *      Log("Moved: " + MoveItem(item, inventory.GetItem(item.TrueItemId)));
                     *      await Coroutine.Sleep(100);
                     *  }
                     * }
                     */

                    RetainerTasks.CloseInventory();

                    await Coroutine.Sleep(200);

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

                    await Coroutine.Sleep(200);

                    RetainerTasks.CloseTasks();

                    await Coroutine.Wait(1500, () => DialogOpen);

                    await Coroutine.Sleep(200);

                    if (DialogOpen)
                    {
                        Next();
                    }

                    await Coroutine.Sleep(200);

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

                    LogVerbose("Should be back at retainer list by now");

                    await Coroutine.Sleep(200);
                }

                retList.Add(inventory);
            }

            //await Coroutine.Sleep(1000);


            LogVerbose("Closing Retainer List");

            RetainerList.Instance.Close();

            Log("\nItem Roles");

            foreach (var role in itemRoleCount)
            {
                Log($"{role.Key.ToString()} - {role.Value}");
            }

            Log("\nItem UiCategory");

            foreach (var role in itemUiCount)
            {
                Log($"{role.Key.ToString()} - {role.Value}");
            }

            Log($"Ore Count: \t{count}");

            TreeRoot.Stop("Done playing with retainers");

            done = true;

            return(true);
        }