#region Enchanting
private static readonly List<WoWItem> AlreadyDisenchanted = new List<WoWItem>();
/// <summary>
/// List from wowhead
/// http://www.wowhead.com/?items=7.12#0+2-1
/// </summary>
private readonly List<uint> _doNotDisenchant = new List<uint>()
{
// mats
10940, 10938, 10939, 10998, 10978, 11082, 11083, 11084, 11134, 11139, 11174, 11175,
11176, 11177, 11178, 14343, 14344, 16202, 16203, 16204, 20725, 22445, 22446, 22447,
22448, 22449, 22450, 34052, 34053, 34054, 34055, 34056, 34057, 46849, 49649,
// rods
44452,
// lockbox
43622,
// healthstones
5509, 5510, 5511, 5512, 9421, 19004, 19005, 19006,
19007, 19008, 19009, 19010, 19011, 19012, 19013,
22103, 22104, 22105, 36889, 36890, 36891, 36892,
36893, 36894,
// soulstones
// firestones
3615, 3616, 3617, 3618, 3619, 3620,
// spellstones
41191, 41192, 41193, 41194, 41195, 41196,
};
private List<WoWItem> GetItemsToDisenchant()
{
try
{
if (!DisenchantGreens || !SpellManager.KnownSpells.ContainsKey("Disenchant") || Me.ZoneId == 3277 || Me.ZoneId == 3358 || Me.ZoneId == 2597) // wsg, ab and av
return null;
List<WoWItem> targetItems = ObjectManager.GetObjectsOfType<WoWItem>(false);
for (int a = targetItems.Count - 1; a >= 0; --a)
{
if (_doNotDisenchant.Contains(targetItems[a].Entry) ||
AlreadyDisenchanted.Contains(targetItems[a]))
{
targetItems.RemoveAt(a);
}
else if (targetItems[a].IsSoulbound ||
targetItems[a].IsAccountBound ||
targetItems[a].Quality != WoWItemQuality.Uncommon)
{
AlreadyDisenchanted.Add(targetItems[a]);
targetItems.RemoveAt(a);
}
}
if (targetItems.Count > 0)
{
foreach (WoWItem deItem in targetItems)
{
Log("Disenchant: {0}.", deItem.Name);
}
return targetItems;
}
}
catch
{
Log("Getting Disenchant list failed");
}
// Log("Nothing to Disenchant.");
return null;
}
private static void DisenchantItems(IEnumerable<WoWItem> itemList)
{
try
{
if (itemList == null)
return;
foreach (WoWItem item in itemList)
{
Log("Disenchanting: {0} Entry: {1}.", item.Name, item.Entry);
SpellManager.CastSpell("Disenchant", false);
Thread.Sleep(500);
Lua.DoString("UseItemByName(\"" + item.Name + "\")");
Thread.Sleep(500);
int tickCount = Environment.TickCount;
while (Me.Casting > 0 && !Me.Combat && Environment.TickCount - tickCount <= 5000)
Thread.Sleep(250);
Thread.Sleep(2500);
// wait for lootframe to close
var timer = new Stopwatch();
timer.Start();
tickCount = Environment.TickCount;
while (ObjectManager.Wow.ReadUInt((uint)GlobalOffsets.LootFrame) != 0 && !Me.Combat && Environment.TickCount - tickCount <= 7000)
{
Thread.Sleep(1000);
if (timer.ElapsedMilliseconds >= 6000)
{
break;
}
}
if (!Me.Combat)
{
Thread.Sleep(1500);
AlreadyDisenchanted.Add(item);
}
else
{
return;
}
}
}
catch
{
Log("DE failed");
return;
}
return;
}
#endregion