private static Dictionary<WoWSpellSchool, HashSet<ulong>> ImmunityMap = new Dictionary<WoWSpellSchool, HashSet<ulong>>();
private void HandleCombatLogEvent(object sender, LuaEventArgs args)
{
switch (args.Args[1].ToString())
{
case "SPELL_MISSED":
if (args.Args[11].ToString() == "IMMUNE")
{
try
{
var spellSchool = (WoWSpellSchool)(int)(double)args.Args[10];
ulong aguid = ulong.Parse(args.Args[2].ToString().Replace("0x", ""), NumberStyles.HexNumber);
if (Me.Guid != aguid) return;
ulong guid = ulong.Parse(args.Args[5].ToString().Replace("0x", ""), NumberStyles.HexNumber);
var obj = ObjectManager.GetObjectsOfType<WoWUnit>(true, true).FirstOrDefault(o => o.Guid == guid || o.DescriptorGuid == guid);
if (obj == null)
{
Log("Can't find the object in the object manager...");
return;
}
if (!ImmunityMap.ContainsKey(spellSchool))
ImmunityMap[spellSchool] = new HashSet<ulong>();
if (!ImmunityMap[spellSchool].Contains(obj.Guid))
{
Log("Adding " + obj.Name + " [" + obj.Guid + "] to the " + spellSchool + " immunity list.");
ImmunityMap[spellSchool].Add(obj.Guid);
}
}
catch (Exception e)
{
dLog(e.ToString());
}
}
if (args.Args[11].ToString() == "EVADE")
{
try
{
ulong guid = ulong.Parse(args.Args[5].ToString().Replace("0x", ""), NumberStyles.HexNumber);
var obj = ObjectManager.GetObjectsOfType<WoWUnit>(true, true).FirstOrDefault(o => o.Guid == guid || o.DescriptorGuid == guid);
if (obj == null)
{
Log("Can't find the object in the object manager...");
return;
}
Styx.Logic.Blacklist.Add(obj, TimeSpan.FromMinutes(10));
Log("Evading mob detected: {0} Blacklisting", obj.Name);
if (obj == Me.CurrentTarget)
Me.ClearTarget();
}
catch (Exception e)
{
Log(e.ToString());
}
}
break;
}
}