Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Decompiled with JetBrains decompiler
- // Type: Bags
- // Assembly: HumanMasterPlugin, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null
- // MVID: 26BB80D3-825F-40BA-9658-12D2F352D027
- // Assembly location: C:\Users\ludde\Desktop\Everything\WRobot\Plugins\HumanMasterPlugin.dll
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using wManager;
- using wManager.Wow.Helpers;
- using wManager.Wow.ObjectManager;
- public class Bags
- {
- private static Dictionary<uint, uint> _bagDictionary = new Dictionary<uint, uint>()
- {
- {
- 22976U,
- 4U
- },
- {
- 1537U,
- 4U
- },
- {
- 11845U,
- 4U
- },
- {
- 20474U,
- 4U
- },
- {
- 2082U,
- 6U
- },
- {
- 4496U,
- 6U
- },
- {
- 828U,
- 6U
- },
- {
- 5571U,
- 6U
- },
- {
- 4238U,
- 6U
- },
- {
- 805U,
- 6U
- },
- {
- 5572U,
- 6U
- },
- {
- 6756U,
- 6U
- },
- {
- 5081U,
- 6U
- },
- {
- 4957U,
- 6U
- },
- {
- 3343U,
- 8U
- },
- {
- 5574U,
- 8U
- },
- {
- 856U,
- 8U
- },
- {
- 4240U,
- 8U
- },
- {
- 3233U,
- 8U
- },
- {
- 5763U,
- 8U
- },
- {
- 2657U,
- 8U
- },
- {
- 4241U,
- 8U
- },
- {
- 4498U,
- 8U
- },
- {
- 5573U,
- 8U
- },
- {
- 804U,
- 10U
- },
- {
- 4245U,
- 10U
- },
- {
- 6446U,
- 10U
- },
- {
- 3352U,
- 10U
- },
- {
- 1470U,
- 10U
- },
- {
- 933U,
- 10U
- },
- {
- 1729U,
- 10U
- },
- {
- 857U,
- 10U
- },
- {
- 5575U,
- 10U
- },
- {
- 5576U,
- 10U
- },
- {
- 4497U,
- 10U
- },
- {
- 5764U,
- 10U
- },
- {
- 5765U,
- 10U
- },
- {
- 918U,
- 10U
- },
- {
- 1725U,
- 12U
- },
- {
- 16057U,
- 12U
- },
- {
- 4499U,
- 12U
- },
- {
- 10051U,
- 12U
- },
- {
- 1652U,
- 12U
- },
- {
- 10050U,
- 12U
- },
- {
- 14046U,
- 14U
- },
- {
- 1685U,
- 14U
- },
- {
- 3914U,
- 14U
- },
- {
- 4500U,
- 16U
- },
- {
- 14155U,
- 16U
- },
- {
- 41599U,
- 20U
- }
- };
- private static Dictionary<string, uint> _bagNameDictionary = new Dictionary<string, uint>();
- private static Dictionary<uint, uint> _slotToBag = new Dictionary<uint, uint>()
- {
- {
- 20U,
- 1U
- },
- {
- 21U,
- 2U
- },
- {
- 22U,
- 3U
- },
- {
- 23U,
- 4U
- }
- };
- private static HashSet<string> _bagBlacklist = new HashSet<string>();
- public static void EquipBetterBags()
- {
- if (((WoWUnit) wManager.Wow.ObjectManager.ObjectManager.get_Me()).get_InCombatFlagOnly())
- return;
- foreach (KeyValuePair<uint, uint> bag in Bags._bagDictionary)
- {
- string str = ItemsManager.GetNameById(bag.Key).Trim();
- if (!str.IsNullOrEmpty<char>() && !Bags._bagNameDictionary.ContainsKey(str))
- {
- Bags._bagNameDictionary.Add(str, bag.Value);
- Bags._bagBlacklist.Remove(str);
- }
- }
- string str1 = ((string) Lua.LuaDoString<string>(string.Format("\r\n for bag = 0,4 do\r\n for slot = 1,GetContainerNumSlots(bag) do\r\n local link = GetContainerItemLink(bag,slot);\r\n if link then\r\n local itemName, itemLink, itemQuality, itemLevel, itemType, itemSubType, itemCount, itemTexture = GetItemInfoFromItemLink(link);\r\n if ((itemSubType == 'Bag') and {0}) then\r\n return itemName;\r\n end\r\n end\r\n end;\r\n end", (object) Bags.LuaAndNotCondition((IEnumerable<string>) Bags._bagBlacklist, "itemName")), "")).Trim();
- if (str1.IsNullOrEmpty<char>())
- return;
- uint num = (uint) Lua.LuaDoString<uint>("\r\n for slot = 20,23,1 do\r\n if (not GetInventoryItemLink('player', slot)) then\r\n return slot;\r\n end\r\n end \r\n ", "");
- if (num > 0U)
- {
- PluginLog.Log(string.Format("Equipping bag: {0} to empty slot", (object) str1));
- Lua.LuaDoString<string>(string.Format("\r\n for bag = 0,4 do\r\n for slot = 1,GetContainerNumSlots(bag) do\r\n local link = GetContainerItemLink(bag,slot);\r\n if link then\r\n local itemName, itemLink, itemQuality, itemLevel, itemType, itemSubType, itemCount, itemTexture = GetItemInfoFromItemLink(link);\r\n if (itemName == \"{0}\") then\r\n ClearCursor();\r\n PickupContainerItem(bag, slot);\r\n PickupInventoryItem({1});\r\n end\r\n end\r\n end;\r\n end", (object) str1, (object) num), "");
- }
- else
- {
- uint newSlotCount = 0;
- bool flag = Bags._bagNameDictionary.TryGetValue(str1, out newSlotCount);
- if (newSlotCount == 0U || !flag)
- {
- PluginLog.Log(string.Format("Couldn't find bag slot count for {0}, please report this", (object) str1));
- }
- else
- {
- uint index = Bags._slotToBag.Keys.FirstOrDefault<uint>((Func<uint, bool>) (b => Bags.HasLessSlots(b, newSlotCount)));
- if (index > 0U)
- {
- PluginLog.Log(string.Format("Moving all items out of bag slot {0} and equipping {1}", (object) index, (object) str1));
- Bags.MoveAllItemsOutOfContainer(Bags._slotToBag[index]);
- Lua.LuaDoString<string>(string.Format("\r\n for bag = 0,4 do\r\n for slot = 1,GetContainerNumSlots(bag) do\r\n local link = GetContainerItemLink(bag,slot);\r\n if link then\r\n local itemName, itemLink, itemQuality, itemLevel, itemType, itemSubType, itemCount, itemTexture = GetItemInfoFromItemLink(link);\r\n if (itemName == \"{0}\") then\r\n ClearCursor();\r\n PickupContainerItem(bag, slot);\r\n PickupInventoryItem({1});\r\n end\r\n end\r\n end;\r\n end", (object) str1, (object) index), "");
- }
- else
- {
- Bags._bagBlacklist.Add(str1);
- wManagerSetting.get_CurrentSetting().get_DoNotSellList().Remove(str1);
- }
- }
- }
- }
- private static void MoveAllItemsOutOfContainer(uint container)
- {
- Lua.LuaDoString(string.Format("\r\n for slot = 1,GetContainerNumSlots({0}) do\r\n local itemExists = GetContainerItemLink({1}, slot);\r\n -- item exists in this slot, needs to be MOVED\r\n if itemExists then\r\n for bag = 0,4 do\r\n if bag ~= {2} then\r\n for slotInBag = 1,GetContainerNumSlots(bag) do\r\n local link = GetContainerItemLink(bag, slotInBag);\r\n if not link then\r\n ClearCursor();\r\n PickupContainerItem({3}, slot);\r\n PickupContainerItem(bag, slotInBag);\r\n end\r\n end\r\n end\r\n end\r\n end\r\n end", (object) container, (object) container, (object) container, (object) container), false);
- }
- private static bool HasLessSlots(uint slotId, uint slotCount)
- {
- try
- {
- string index = ((string) Lua.LuaDoString<string>(string.Format("\r\n local itemName, itemLink, itemQuality, itemLevel, itemType, itemSubType, itemCount, itemTexture = GetItemInfoFromItemLink(GetInventoryItemLink('player', {0}));\r\n return itemName;\r\n ", (object) slotId), "")).Trim();
- return Bags._bagNameDictionary[index] < slotCount;
- }
- catch (Exception ex)
- {
- }
- return false;
- }
- private static string LuaAndNotCondition(IEnumerable<string> names, string varname)
- {
- if (names.IsNullOrEmpty<string>())
- return "true";
- StringBuilder stringBuilder = new StringBuilder();
- foreach (string name in names)
- stringBuilder.Append(string.Format(" and {0} ~= \"{1}\"", (object) varname, (object) name));
- return stringBuilder.ToString().Substring(5);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement