<?xml version="1.0" encoding="utf-8"?>
<Professionbuddy>
<ChangeBotAction BotName="Combat Bot" />
<CallSubRoutine SubRoutineName="CacheGBItems" />
<!-- Movement -->
<Declaration Code="WoWPoint gotoPoint;" />
<!-- Shortcut for HB's logtext colors and formating -->
<Declaration Code="private void LogText(string format, params object[] args) { Logging.Write(Colors.DarkOrange, "[CachedItem]: " + format, args); }" />
<!-- Cache GuildBank items -->
<Declaration Code="public Dictionary<uint, int> CachedGBankCount;
public int FreeGBankSlots;
public void CacheGBankCount()
{
CachedGBankCount = new Dictionary<uint, int>();
using (StyxWoW.Memory.AcquireFrame())
{
var tabCount = Lua.GetReturnVal<int>("return GetNumGuildBankTabs()", 0);
var GoldInGB = Lua.GetReturnVal<int>("return GetGuildBankMoney()", 0);
var numFreeSlots = 0;
for (int i = 1; i <= tabCount; i++)
{
numFreeSlots += FreeSlotsInTab(i);
var tabInfo = Lua.GetReturnValues(string.Format("return GetGuildBankTabInfo({0})", i));
var viewable = int.Parse(tabInfo[2]) == 1;
var withdrawsAllowed = int.Parse(tabInfo[4]);
if (viewable && withdrawsAllowed > 0)
{
for (int j = 1; j <= 98; j++)
{
var id = Lua.GetReturnVal<uint>(string.Format("id = string.match(GetGuildBankItemLink({0},{1}), \"item:[%d]+\") id=string.sub(id, 6) return id", i, j), 0);
var count = Lua.GetReturnVal<int>(string.Format("return GetGuildBankItemInfo({0},{1})", i, j), 1);
if (!CachedGBankCount.ContainsKey(id))
CachedGBankCount.Add(id, count);
else
CachedGBankCount[id] += count;
}
}
}
FreeGBankSlots = numFreeSlots;
}
}
public int GBankCount(uint id)
{
int count = 0;
CachedGBankCount.TryGetValue(id, out count);
return count;
}
private static int FreeSlotsInTab(int tabIndex)
{
const string lua = "local tab = {0} " +
"local c = 0 " +
"for i=1, MAX_GUILDBANK_SLOTS_PER_TAB do " +
" local link = GetGuildBankItemLink(tab,i)" +
" if not link then " +
" c = c+1 " +
" end " +
"end " +
"return c";
return Lua.GetReturnVal<int>(string.Format(lua, tabIndex), 0);
}" />
<!-- Output to Hbs Log-->
<CustomAction Code="LogText("Green Tea Leaf in GB {0} ",GBankCount(72234));" />
<CustomAction Code="LogText("Silkweed in GB {0} ",GBankCount(72235));" />
<CustomAction Code="LogText("Rain Poppy in GB {0} ",GBankCount(72237));" />
<CustomAction Code="LogText("Snow Lily in GB {0} ",GBankCount(79010));" />
<CustomAction Code="LogText("Fools Cap in GB {0} ",GBankCount(79011));" />
<CustomAction Code="LogText("Desecrated Herb in GB {0} ",GBankCount(89639));" />
<CustomAction Code="LogText("Crap Orange in GB {0} ",GBankCount(76130));" />
<CustomAction Code="LogText("Crap Blue in GB {0} ",GBankCount(76133));" />
<CustomAction Code="LogText("Crap Yellow in GB {0} ",GBankCount(76134));" />
<CustomAction Code="LogText("Crap Violet in GB {0} ",GBankCount(76135));" />
<CustomAction Code="LogText("Crap Red in GB {0} ",GBankCount(76136));" />
<CustomAction Code="LogText("Crap Green in GB {0} ",GBankCount(76137));" />
<CustomAction Code="LogText("Rare Orange in GB {0} ",GBankCount(76140));" />
<CustomAction Code="LogText("Rare Blue in GB {0} ",GBankCount(76138));" />
<CustomAction Code="LogText("Rare Yellow in GB {0} ",GBankCount(76142));" />
<CustomAction Code="LogText("Rare Violet in GB {0} ",GBankCount(76141));" />
<CustomAction Code="LogText("Rare Red in GB {0} ",GBankCount(76131));" />
<CustomAction Code="LogText("Rare Green in GB {0} ",GBankCount(76139));" />
<CustomAction Code="LogText("Starlight Ink in GB {0} ",GBankCount(79255));" />
<CustomAction Code="LogText("Ink of Dreams in GB {0} ",GBankCount(79254));" />
<!-- Movement -->
<SubRoutine SubRoutineName="Goto Point">
<While Condition="gotoPoint.Distance(Me.Location) > 3" IgnoreCanRun="True">
<CustomAction Code="MoveTo(gotoPoint);" />
</While>
</SubRoutine>
<!-- Go To GuildBank -->
<SubRoutine SubRoutineName="GoToGuildBank">
<If Condition="Me.ZoneId == 4395" IgnoreCanRun="True">
<CustomAction Code="gotoPoint = new WoWPoint(5973.146, 630.3968, 650.6273);" />
<CallSubRoutine SubRoutineName="Goto Point" />
</If>
</SubRoutine>
<!-- Cache GuildBank items -->
<SubRoutine SubRoutineName="CacheGBItems">
<CallSubRoutine SubRoutineName="GoToGuildBank" />
<CustomAction Code="LogText("Caching GuildBank items");" />
<InteractionAction InteractType="GameObject" Entry="0" InteractDelay="2000" GameObjectType="GuildBank" SpellFocus="Anvil" />
<CustomAction Code="CacheGBankCount();" />
<WaitAction Condition="false" Timeout="5000" />
</SubRoutine>
</Professionbuddy>