using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Styx.Plugins.PluginClass;
using Styx;
using Styx.WoWInternals.WoWObjects;
using Styx.Helpers;
using Styx.Logic.Pathing;
using System.Threading;
using Styx.Logic.Inventory.Frames.LootFrame;
using System.Drawing;
using Styx.WoWInternals;
namespace OnlyLootGold
{
class OnlyLootGold : HBPlugin
{
public OnlyLootGold()
{
BotEvents.Player.OnMobKilled += OnMobKilled;
Bots.Gatherbuddy.GatherbuddySettings.Instance.LootMobs = false;
CharacterSettings.Instance.LootMobs = false;
CharacterSettings.Instance.LootChests = false;
}
public override string Author
{
get { return "Vastico"; }
}
public override string Name
{
get { return "OnlyLootGold"; }
}
public override Version Version
{
get { return new Version(0, 0, 0, 2); }
}
private LocalPlayer Me = StyxWoW.Me;
private WaitTimer lootTimer = new WaitTimer(TimeSpan.FromSeconds(15));
private Queue<WoWUnit> KilledUnits = new Queue<WoWUnit>();
private IDictionary<ulong, WaitTimer> Blacklist = new Dictionary<ulong, WaitTimer>();
public override void Pulse()
{
if (Me.Combat || Me.Dead || Me.IsGhost)
{
return;
}
List<ulong> removals = new List<ulong>();
foreach (KeyValuePair<ulong, WaitTimer> unit in Blacklist)
{
if (unit.Value.IsFinished)
{
removals.Add(unit.Key);
}
}
foreach (ulong remove in removals)
{
Blacklist.Remove(remove);
}
while (KilledUnits.Count > 0)
{
WoWUnit target = KilledUnits.Dequeue();
if (Blacklist.ContainsKey(target.Guid) || target.Distance > Styx.Logic.LootTargeting.LootRadius)
{
continue;
}
WaitTimer lootableTimer = new WaitTimer(TimeSpan.FromMilliseconds(1500));
lootableTimer.Reset();
while (!lootableTimer.IsFinished)
{
if (target.Lootable)
{
break;
}
System.Threading.Thread.Sleep(20);
}
if (!target.Lootable)
{
Logging.Write(Color.Crimson, "Blacklisted [loot][lootable] " + target.Name + ".");
Blacklist.Add(target.Guid, new WaitTimer(TimeSpan.FromMinutes(30)));
continue;
}
WaitTimer movementTimer = new WaitTimer(TimeSpan.FromSeconds(30));
movementTimer.Reset();
Logging.Write(Color.Crimson, "Moving to loot items from " + target.Name + ".");
while (target.Distance > 4 || !target.InLineOfSpellSight && !movementTimer.IsFinished)
{
Navigator.MoveTo(target.Location);
System.Threading.Thread.Sleep(20);
}
if (target.Distance > 4)
{
Logging.Write(Color.Crimson, "Blacklisted [loot][movement] " + target.Name + ".");
Blacklist.Add(target.Guid, new WaitTimer(TimeSpan.FromMinutes(30)));
}
else
{
Navigator.PlayerMover.MoveStop();
StyxWoW.SleepForLagDuration();
target.Interact();
StyxWoW.SleepForLagDuration();
WaitTimer lootTimer = new WaitTimer(TimeSpan.FromSeconds(5));
lootTimer.Reset();
Logging.Write(Color.Crimson, "Looting items from " + target.Name + ".");
while ((LootFrame.Instance == null || !LootFrame.Instance.IsVisible) && !lootTimer.IsFinished)
{
System.Threading.Thread.Sleep(20);
}
if (LootFrame.Instance == null || !LootFrame.Instance.IsVisible)
{
Blacklist.Add(target.Guid, new WaitTimer(TimeSpan.FromMinutes(30)));
Logging.Write(Color.Crimson, "Blacklisted [loot] " + target.Name + ".");
}
else
{
StringBuilder builder = new StringBuilder();
builder.Append("for i=1,GetNumLootItems() do ");
builder.Append("if LootSlotIsCoin(i) then ");
builder.Append("LootSlot(i) ConfirmLootSlot(i) ");
builder.Append("elseif LootSlotIsItem(i) and select(4, GetLootSlotInfo(i)) > 2 then ");
builder.Append("LootSlot(i) ConfirmLootSlot(i) ");
builder.Append("end ");
builder.Append("end");
Lua.DoString(builder.ToString());
lootTimer = new WaitTimer(TimeSpan.FromMilliseconds(1500));
lootTimer.Reset();
while (!lootTimer.IsFinished)
{
System.Threading.Thread.Sleep(20);
Lua.DoString(builder.ToString());
}
Lua.DoString("CloseLoot()");
Logging.Write(Color.Crimson, "Looted items and closed loot frame.");
}
}
}
}
public void OnMobKilled(BotEvents.Player.MobKilledEventArgs args)
{
KilledUnits.Enqueue(args.KilledMob);
}
}
}
You could add option for it to loot blues/epics should it see it
Hey Vastico, could you either edit this to also include greens or post the proper code and where to place it? This is extremely helpful while I'm farming for rep and such, but I notice that I'm missing a shit ton of green items that can be DE'd or posted on the AH. I'm just trying to pull in every copper that I can get.OnlyLootGold is a plugin that only loots gold/silver/copper from killed mobs.
View attachment 27070
Instructions
Enable the plugin
Thanks
Let me know of any issues/problem you find with the plugin.
I finally got round to updating this, it's faster at looting and now loots blues and purples.
Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; using Styx.Plugins.PluginClass; using Styx; using Styx.WoWInternals.WoWObjects; using Styx.Helpers; using Styx.Logic.Pathing; using System.Threading; using Styx.Logic.Inventory.Frames.LootFrame; using System.Drawing; using Styx.WoWInternals; namespace OnlyLootGold { class OnlyLootGold : HBPlugin { public OnlyLootGold() { BotEvents.Player.OnMobKilled += OnMobKilled; Bots.Gatherbuddy.GatherbuddySettings.Instance.LootMobs = false; CharacterSettings.Instance.LootMobs = false; CharacterSettings.Instance.LootChests = false; } public override string Author { get { return "Vastico"; } } public override string Name { get { return "OnlyLootGold"; } } public override Version Version { get { return new Version(0, 0, 0, 2); } } private LocalPlayer Me = StyxWoW.Me; private WaitTimer lootTimer = new WaitTimer(TimeSpan.FromSeconds(15)); private Queue<WoWUnit> KilledUnits = new Queue<WoWUnit>(); private IDictionary<ulong, WaitTimer> Blacklist = new Dictionary<ulong, WaitTimer>(); public override void Pulse() { if (Me.Combat || Me.Dead || Me.IsGhost) { return; } List<ulong> removals = new List<ulong>(); foreach (KeyValuePair<ulong, WaitTimer> unit in Blacklist) { if (unit.Value.IsFinished) { removals.Add(unit.Key); } } foreach (ulong remove in removals) { Blacklist.Remove(remove); } while (KilledUnits.Count > 0) { WoWUnit target = KilledUnits.Dequeue(); if (Blacklist.ContainsKey(target.Guid) || target.Distance > Styx.Logic.LootTargeting.LootRadius) { continue; } WaitTimer lootableTimer = new WaitTimer(TimeSpan.FromMilliseconds(1500)); lootableTimer.Reset(); while (!lootableTimer.IsFinished) { if (target.Lootable) { break; } System.Threading.Thread.Sleep(20); } if (!target.Lootable) { Logging.Write(Color.Crimson, "Blacklisted [loot][lootable] " + target.Name + "."); Blacklist.Add(target.Guid, new WaitTimer(TimeSpan.FromMinutes(30))); continue; } WaitTimer movementTimer = new WaitTimer(TimeSpan.FromSeconds(30)); movementTimer.Reset(); Logging.Write(Color.Crimson, "Moving to loot items from " + target.Name + "."); while (target.Distance > 4 || !target.InLineOfSpellSight && !movementTimer.IsFinished) { Navigator.MoveTo(target.Location); System.Threading.Thread.Sleep(20); } if (target.Distance > 4) { Logging.Write(Color.Crimson, "Blacklisted [loot][movement] " + target.Name + "."); Blacklist.Add(target.Guid, new WaitTimer(TimeSpan.FromMinutes(30))); } else { Navigator.PlayerMover.MoveStop(); StyxWoW.SleepForLagDuration(); target.Interact(); StyxWoW.SleepForLagDuration(); WaitTimer lootTimer = new WaitTimer(TimeSpan.FromSeconds(5)); lootTimer.Reset(); Logging.Write(Color.Crimson, "Looting items from " + target.Name + "."); while ((LootFrame.Instance == null || !LootFrame.Instance.IsVisible) && !lootTimer.IsFinished) { System.Threading.Thread.Sleep(20); } if (LootFrame.Instance == null || !LootFrame.Instance.IsVisible) { Blacklist.Add(target.Guid, new WaitTimer(TimeSpan.FromMinutes(30))); Logging.Write(Color.Crimson, "Blacklisted [loot] " + target.Name + "."); } else { StringBuilder builder = new StringBuilder(); builder.Append("for i=1,GetNumLootItems() do "); builder.Append("if LootSlotIsCoin(i) then "); builder.Append("LootSlot(i) ConfirmLootSlot(i) "); builder.Append("elseif LootSlotIsItem(i) and select(4, GetLootSlotInfo(i)) > 2 then "); builder.Append("LootSlot(i) ConfirmLootSlot(i) "); builder.Append("end "); builder.Append("end"); Lua.DoString(builder.ToString()); lootTimer = new WaitTimer(TimeSpan.FromMilliseconds(1500)); lootTimer.Reset(); while (!lootTimer.IsFinished) { System.Threading.Thread.Sleep(20); Lua.DoString(builder.ToString()); } Lua.DoString("CloseLoot()"); Logging.Write(Color.Crimson, "Looted items and closed loot frame."); } } } } public void OnMobKilled(BotEvents.Player.MobKilledEventArgs args) { KilledUnits.Enqueue(args.KilledMob); } } }