/* * LootItAll by Kamilche
*
* This is an add-on that will
*
* 1. Loot all mobs
* 2. Skin all mobs
*
* 2012/09/14 v1.0.0.0 - First version.
*
*/
using Styx;
using Styx.Common;
using Styx.CommonBot;
using Styx.CommonBot.POI;
using Styx.Helpers;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using Styx.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading;
using System.Windows.Forms;
namespace LootItAll
{
public class LootItAll : HBPlugin
{
public override string Name { get { return "LootItAll"; } }
public override string Author { get { return "Kamilche"; } }
public override Version Version { get { return _version; } }
private readonly Version _version = new Version(1, 0, 0, 0);
private static DateTime NextTime = DateTime.Now;
private int CheckFrequency = 2;
public override void Pulse()
{
NextTime = DateTime.Now.AddSeconds(CheckFrequency);
CheckForLoot();
CheckForSkin();
}
public void CheckForLoot()
{
WoWUnit target = null;
if (CharacterSettings.Instance.LootMobs == true && BotPoi.Current.Type == PoiType.None)
{
target = (from u in ObjectManager.GetObjectsOfType<WoWUnit>(false, false)
where u.Distance < 20 && u.IsDead && u.CanLoot && !Blacklist.Contains(u)
orderby u.Distance ascending
select u).ToList().FirstOrDefault();
if (target != null)
{
log("[LootItAll] Setting {0} as lootable", target.Name);
BotPoi.Current = new BotPoi(target, PoiType.Loot);
}
}
}
public void CheckForSkin()
{
WoWUnit target = null;
if (CharacterSettings.Instance.SkinMobs == true && BotPoi.Current.Type == PoiType.None)
{
target = (from u in ObjectManager.GetObjectsOfType<WoWUnit>(false, false)
where u.Distance < 20 && u.IsDead && !u.CanLoot && u.CanSkin && !Blacklist.Contains(u)
orderby u.Distance ascending
select u).ToList().FirstOrDefault();
if (target != null)
{
log("[LootItAll] Setting {0} as skinnable", target.Name);
BotPoi.Current = new BotPoi(target, PoiType.Skin);
}
}
}
private void log(String fmt, params object[] args)
{
String s = String.Format(fmt, args);
log(Color.CornflowerBlue, fmt, args);
}
private void log(Color color, String fmt, params object[] args)
{
String s = String.Format(fmt, args);
Logging.Write(System.Windows.Media.Color.FromRgb(color.R, color.G, color.B), String.Format("[{0}]: {1}", Name, s));
fmt = @"getglobal(""ChatFrame1""):AddMessage(""{0}"", {1}, {2}, {3}, 0);";
Lua.DoString(string.Format(fmt, s, color.R / 255.0, color.G / 255.0, color.B / 255.0));
}
}
}