local debug=0; local EventHandlers={}; local ProffBotVersion=1; local database; local creature; local MaxLevel=60; local CreatureTemp; local OpenLockSelfMask; local herbalism; local mining; local treasure; local LastGossip=""; local OldGossipTitleButton_OnClick; local OldMailItemOnClick; local OldOpenMail_Update; local LastMail; local LastQuest; local EnableQuests; local LasttQuestsCount=0; local LastRewardQuest; local UntitledSpell; local ttype; local price; local quantity; local available; local header; local isExpanded; local skillRank; local numTempPoints; local skillModifier; local skillMaxRank; local isAbandonable; local stepCost; local rankCost; local minLevel; local skillCostType; local skillDescription; local questTag; local isHeader; local isCollapsed; local isComplete; local numItems; local quality; local isUsable; local isTradeskillSpell; local skillType; local numAvailable; local maxMade; local reagentTexture; local reagentCount; local playerReagentCount; local craftSubSpellName; local craftType; local area; local connected; local status; local numWhos; local guildname; local stationeryIcon; local sender; local subject; local money; local CODAmount; local daysLeft local hasItem; local wasRead; local wasReturned; local textCreated; local isTakeable; local itemName; local playerName; local bid; local buyout; local deposit; local event; local abc=strchar(80, 114, 111, 102, 102, 66, 111, 116, 115, 116, 114, 115); --local EnsureTable=function(table, local MonsterSave=function(ttype) local bool=false; for i=1, GetNumLanguages() do if GetLanguageByIndex(i)==arg3 then bool=true; end end if type(database["CreatureTexts"])~="table" then database["CreatureTexts"]={}; end if type(database["CreatureTexts"][arg2])~="table" then database["CreatureTexts"][arg2]={}; end if type(database["CreatureTexts"][arg2][ttype])~="table" then database["CreatureTexts"][arg2][ttype]={}; end if type(database["CreatureTexts"][arg2][ttype][arg1])~="number" then database["CreatureTexts"][arg2][ttype][arg1]=1; else database["CreatureTexts"][arg2][ttype][arg1]=database["CreatureTexts"][arg2][ttype][arg1]+1; end end local ChatMsgMonsterEmote=function() MonsterSave("emote"); end local ChatMsgMonsterSay=function() MonsterSave("say"); end local MerchantShow=function() if type(database["npc"])~="table" then database["npc"]={}; end if type(database["npc"][UnitName("npc")])~="table" then database["npc"][UnitName("npc")]={}; end if type(database["npc"][UnitName("npc")]["merchant"])~="table" then database["npc"][UnitName("npc")]["merchant"]={}; end local a=database["npc"][UnitName("npc")]["merchant"]; for i=1, GetMerchantNumItems(), 1 do local name, texture, price, quantity, available, isUsable=GetMerchantItemInfo(i); if name then if type(a[name])~="table" then a[name]={}; end a[name]["texture"]=texture; a[name]["price"]=price; a[name]["quantity"]=quantity; if not a[name]["available"] or a[name]["available"]0 then if not creature["DamagePercent"] then creature["DamagePercent"]=0; end if not creature["DamageHP"] then creature["DamageHP"]=0; end creature["DamageHP"]=creature["DamageHP"]+CreatureTemp["damage"]; creature["DamagePercent"]=creature["DamagePercent"]-CreatureTemp["LastHealth"]+CreatureTemp["FirstHealth"]; end; if not UnitPlayerControlled("target") and UnitExists("target") and (UnitLevel("target")>0 or UnitLevel("player")==MaxLevel) then if type(database["creatures"])~="table" then database["creatures"]={}; end local name=UnitName("target"); local level=UnitLevel("target"); if type(database["creatures"][name])~="table" then database["creatures"][name]={}; end local level=UnitLevel("target"); if type(database["creatures"][name][level])~="table" then database["creatures"][name][level]={}; end creature=database["creatures"][name][level]; creature["MainSpeed"], creature["OffSpeed"]=UnitAttackSpeed("target"); creature["class"]=UnitClass("target"); creature["classification"]=UnitClassification("target"); creature["family"]=UnitCreatureFamily("target"); creature["type"]=UnitCreatureType("target"); creature["defense"]=UnitDefense("target"); creature["friend"]=UnitIsFriend("target", "player"); creature["enemy"]=UnitIsEnemy("target", "player"); creature["ghost"]=UnitIsGhost("target", "player"); creature["mana"]=UnitManaMax("target"); creature["PowerType"]=UnitPowerType("target"); creature["race"]=UnitRace("target"); creature["sex"]=UnitSex("target"); CreatureTemp={}; CreatureTemp["FirstHealth"]=UnitHealth("target"); CreatureTemp["LastHealth"]=UnitHealth("target"); CreatureTemp["damage"]=0; CreatureTemp["DamageTemp"]=0; CreatureLogPosition(); else creature=nil; end end local UnitCombat=function() if creature and arg1=="target" then if debug>0 then DEFAULT_CHAT_FRAME:AddMessage("damage "..arg4); if UnitIsDead("target") then DEFAULT_CHAT_FRAME:AddMessage("dead"); end end CreatureTemp["DamageTemp"]=CreatureTemp["DamageTemp"]+arg4; CreatureLogPosition(); end end local UnitHealth=function() if arg1=="target" and creature then if debug>0 then DEFAULT_CHAT_FRAME:AddMessage("health "..CreatureTemp["LastHealth"]-UnitHealth("target")); if UnitIsDead("target") then DEFAULT_CHAT_FRAME:AddMessage("dead"); end end CreatureTemp["LastHealth"]=UnitHealth("target"); CreatureTemp["damage"]=CreatureTemp["damage"]+CreatureTemp["DamageTemp"]; CreatureTemp["DamageTemp"]=0; CreatureLogPosition(); end; end local LootOpened=function() if IsFishingLoot() then if type(database["fishing"])~="table" then database["fishing"]={}; end local a={}; a["zone"]=GetRealZoneText(); a["x"], a["y"]=GetPosition(); a["fishing"]=GetSkillRank("Fishing"); a["loot"]=GetLoot(); table.insert(database["fishing"], a); elseif herbalism then if type(database["herbalism"])~="table" then database["herbalism"]={}; end local a={}; a["name"]=herbalism; a["zone"]=GetRealZoneText(); a["x"], a["y"]=GetPosition(); a["herbalism"]=GetSkillRank("Herbalism"); a["loot"]=GetLoot(); table.insert(database["herbalism"], a); herbalism=nil; elseif mining then if type(database["mining"])~="table" then database["mining"]={}; end local a={}; a["name"]=mining; a["zone"]=GetRealZoneText(); a["x"], a["y"]=GetPosition(); a["mining"]=GetSkillRank("Mining"); a["loot"]=GetLoot(); table.insert(database["mining"], a); mining=nil; elseif treasure then if type(database["treasure"])~="table" then database["treasure"]={}; end local a={}; a["name"]=treasure; a["zone"]=GetRealZoneText(); a["x"], a["y"]=GetPosition(); a["loot"]=GetLoot(); table.insert(database["treasure"], a); treasure=nil; elseif UntitledSpell and UntitledSpell["time"] and UntitledSpell["time"]+1>GetTime() then if type(database["QuestObjects"])~="table" then database["QuestObjects"]={}; end UntitledSpell["link"]["loot"]=GetLoot(); UntitledSpell=nil; elseif creature then if type(creature["loot"])~="table" then creature["loot"]={}; end table.insert(creature["loot"], GetLoot()); CreatureLogPosition(); end end local ItemText=function() if type(database["ItemText"])~="table" then database["ItemText"]={}; end local item=ItemTextGetItem(); local page=ItemTextGetPage(); local text=ItemTextGetText(); if type(database["ItemText"][item])~="table" then database["ItemText"][item]={}; end if type(database["ItemText"][item][page])~="table" then database["ItemText"][item][page]={}; end if type(database["ItemText"][item][page][text])~="table" then database["ItemText"][item][page][text]={}; end database["ItemText"][item][page][text]["material"]=ItemTextGetMaterial(); end local QuestDetail=function() if not UnitIsPlayer("npc") then local x, y=GetPosition(); LastQuest={["name"]=GetTitleText(), ["objective"]=GetObjectiveText(), ["description"]=GetQuestText(), ["material"]=GetQuestBackgroundMaterial(), ["npc"]=UnitName("npc"), ["x"]=x, ["y"]=y}; end end local QuestLogUpdate=function() if not EnableQuests then EnableQuests=true; return; end if LasttQuestsCount~=GetNumQuestLogEntries() then local temp=GetQuestLogSelection(); for i=1, GetNumQuestLogEntries(), 1 do local name, level, questTag, suggestedGroup, isHeader, isCollapsed, isComplete = GetQuestLogTitle(i); if not isHeader then SelectQuestLogEntry(i); local description, objective=GetQuestLogQuestText(); if type(description)=="nil" then description="nil"; end if type(objective)=="nil" then objective="nil"; end if type(database["quests"])~="table" then database["quests"]={}; end if type(database["quests"][name])~="table" then database["quests"][name]={}; end if type(database["quests"][name][objective])~="table" then database["quests"][name][objective]={}; end if type(database["quests"][name][objective][description])~="table" then database["quests"][name][objective][description]={}; end if type(database["quests"][name][objective][description][level])~="table" then if LastQuest and name==LastQuest["name"] and objective==LastQuest["objective"] and description==LastQuest["description"] then database["quests"][name][objective][description][level]={["npc"]=LastQuest["npc"], ["x"]=LastQuest["x"], ["y"]=LastQuest["y"]}; else database["quests"][name][objective][description][level]={}; end end local quest=database["quests"][name][objective][description][level]; quest["choice"]={}; for j=1, GetNumQuestLogChoices(), 1 do local name, texture, numItems, quality, isUsable = GetQuestLogChoiceInfo(j); local link=GetQuestLogItemLink("choice", j); table.insert(quest["choice"], {["name"]=name, ["texture"]=texture, ["count"]=numItems, ["quality"]=quality, ["link"]=link}); end quest["objectives"]={}; for j=1, GetNumQuestLeaderBoards(), 1 do local desc, type, done=GetQuestLogLeaderBoard(j); table.insert(quest["objectives"], {["desc"]=desc, ["type"]=type}); end quest["RequiredMoney"]=GetQuestLogRequiredMoney(); quest["rewards"]={}; for j=1, GetNumQuestLogRewards(), 1 do local name, texture, numItems, quality, isUsable = GetQuestLogRewardInfo(j); local link=GetQuestLogItemLink("reward", j); table.insert(quest["rewards"], {["name"]=name, ["texture"]=texture, ["count"]=numItems, ["quality"]=quality, ["link"]=link}); end quest["money"]=GetQuestLogRewardMoney(); local texture, name, isTradeskillSpell = GetQuestLogRewardSpell(); quest["RewardSpell"]={["texture"]=texture, ["name"]=name, ["isTradeskillSpell"]=isTradeskillSpell}; local time=GetQuestLogTimeLeft(); if time and (not quest["time"] or quest["time"]1 then DEFAULT_CHAT_FRAME:AddMessage(GetTime()); end end local SpellCastStop=function() if type(UntitledSpell)=="table" and UntitledSpell["StartTime"]+49/10<=GetTime() then table.insert(database["QuestObjects"], UntitledSpell["link"]); UntitledSpell["time"]=GetTime(); end if debug>1 then DEFAULT_CHAT_FRAME:AddMessage(GetTime()); end end local TradeSkillShow=function() if type(database["TradeSkills"])~="table" then database["TradeSkills"]={}; end local SkillLine=GetTradeSkillLine(); if type(database["TradeSkills"][SkillLine])~="table" then database["TradeSkills"][SkillLine]={}; end for i=1, GetNumTradeSkills(), 1 do local skillName, skillType, numAvailable, isExpanded = GetTradeSkillInfo(i); if SkillType~="header" and SkillLine~=nil and skillName~=nil then if type(database["TradeSkills"][SkillLine][skillName])~="table" then database["TradeSkills"][SkillLine][skillName]={}; end local skill=database["TradeSkills"][SkillLine][skillName]; skill["SkillType"]=skillType; skill["icon"]=GetTradeSkillIcon(i); skill["link"]=GetTradeSkillItemLink(i); skill["stats"]={GetTradeSkillItemStats(i)}; local minMade, maxMade = GetTradeSkillNumMade(i); skill["MinMade"]=minMade; skill["MaxMade"]=maxMade; skill["reagents"]={}; for j=1, GetTradeSkillNumReagents(i), 1 do local reagentName, reagentTexture, reagentCount, playerReagentCount = GetTradeSkillReagentInfo(i, j); local a={}; a["name"]=reagentName; a["texture"]=reagentTexture; a["count"]=reagentCount; a["link"]=GetTradeSkillReagentItemLink(i, j); table.insert(skill["reagents"], a); end skill["tools"]=GetTradeSkillTools(i); end end end local CraftShow=function() if type(database["craft"])~="table" then database["craft"]={}; end local SkillLine=GetCraftSkillLine(1); if type(database["craft"][SkillLine])~="table" then database["craft"][SkillLine]={}; end for i=1, GetNumTradeSkills(), 1 do local craftName, craftSubSpellName, craftType, numAvailable, isExpanded = GetTradeSkillInfo(i); if SkillType~="header" and craftName then if type(database["craft"][SkillLine][craftName])~="table" then database["craft"][SkillLine][craftName]={}; end local craft=database["craft"][SkillLine][craftName]; craft["SubSpellName"]=craftSubSpellName; craft["CraftType"]=craftType; craft["icon"]=GetCraftIcon(i); craft["link"]=GetCraftItemLink(i); craft["SpellFocus"]={GetCraftSpellFocus(i)}; craft["reagents"]={}; for j=1, GetCraftNumReagents(i), 1 do local reagentName, reagentTexture, reagentCount, playerReagentCount = GetCraftReagentInfo(i, j); local a={}; a["name"]=reagentName; a["texture"]=reagentTexture; a["count"]=reagentCount; a["link"]=GetCraftReagentItemLink(i, j); table.insert(craft["reagents"], a); end end end end local UnitIDTable={"target", "mouseover"} for i=1, 4, 1 do table.insert(UnitIDTable, "party"..i); end for i=1, 40, 1 do table.insert(UnitIDTable, "raid"..i); end local SavePlayers=function() if type(database["chars"])~="table" then database["chars"]={}; end for i=1, table.getn(UnitIDTable), 1 do if UnitExists(UnitIDTable[i]) and UnitIsPlayer(UnitIDTable[i]) then local name=UnitName(UnitIDTable[i]); if type(database["chars"][name])~="table" then database["chars"][name]={}; end database["chars"][name]["class"]=UnitClass(UnitIDTable[i]); database["chars"][name]["race"]=UnitRace(UnitIDTable[i]); database["chars"][name]["sex"]=UnitSex(UnitIDTable[i]); database["chars"][name]["level"]=UnitLevel(UnitIDTable[i]); end end end local FriendListUpdate=function() if type(database["chars"])~="table" then database["chars"]={}; end for i=1, GetNumFriends(), 1 do local name, level, class, area, connected, status = GetFriendInfo(i); if connected then if type(database["chars"][name])~="table" then database["chars"][name]={}; end database["chars"][name]["class"]=class; end end end local WhoListUpdate=function() if type(database["chars"])~="table" then database["chars"]={}; end local totalCount, numWhos = GetNumWhoResults(); for i=1, numWhos, 1 do local name, guildname, level, race, class = GetWhoInfo(i); if type(database["chars"][name])~="table" then database["chars"][name]={}; end database["chars"][name]["class"]=class; database["chars"][name]["level"]=level; database["chars"][name]["race"]=race; end end local VariablesLoaded=function() EventHandlers["CHAT_MSG_MONSTER_EMOTE"]=ChatMsgMonsterEmote; EventHandlers["CHAT_MSG_MONSTER_SAY"]=ChatMsgMonsterSay; EventHandlers["CHAT_MSG_SYSTEM"]=ChatMsgSystem; EventHandlers["CRAFT_SHOW"]=CraftShow; EventHandlers["GOSSIP_SHOW"]=GossipShow; EventHandlers["GOSSIP_CLOSED"]=GossipClosed; EventHandlers["ITEM_TEXT_READY"]=ItemText; EventHandlers["LOOT_OPENED"]=LootOpened; EventHandlers["MERCHANT_SHOW"]=MerchantShow; EventHandlers["PLAYER_TARGET_CHANGED"]=TargetChanged; EventHandlers["QUEST_COMPLETE"]=function() QuestPR("reward", GetRewardText()); end EventHandlers["QUEST_DETAIL"]=QuestDetail; EventHandlers["QUEST_GREETING"]=QuestGreeting; EventHandlers["QUEST_PROGRESS"]=function() QuestPR("progress", GetProgressText()); end EventHandlers["QUEST_LOG_UPDATE"]=QuestLogUpdate; EventHandlers["SPELLCAST_START"]=SpellCastStart; EventHandlers["SPELLCAST_STOP"]=SpellCastStop; EventHandlers["TRADE_SKILL_SHOW"]=TradeSkillShow; EventHandlers["UNIT_COMBAT"]=UnitCombat; EventHandlers["UNIT_HEALTH"]=UnitHealth; EventHandlers["ZONE_CHANGED_NEW_AREA"]=SetMapToCurrentZone; EventHandlers["UPDATE_MOUSEOVER_UNIT"]=SavePlayers; EventHandlers["PLAYER_TARGET_CHANGED"]=SavePlayers; EventHandlers["PARTY_MEMBERS_CHANGED"]=SavePlayers; EventHandlers["FRIENDLIST_UPDATE"]=FriendListUpdate; EventHandlers["WHO_LIST_UPDATE"]=WhoListUpdate; if type(ProffBot)~="table" then ProffBot={}; end if ProffBot["version"]~=ProffBotVersion then ProffBot={["version"]=ProffBotVersion}; end local locale=GetLocale(); if type(ProffBot[locale])~="table" then ProffBot[locale]={}; end local RealmList=GetCVar("realmList"); if type(ProffBot[locale][RealmList])~="table" then ProffBot[locale][RealmList]={}; end local RealmName=GetCVar("realmName"); if type(ProffBot[locale][RealmList][RealmName])~="table" then ProffBot[locale][RealmList][RealmName]={}; end local name=UnitName("player"); local class=UnitClass("player"); local race=UnitRace("player"); local sex; if(UnitSex("player")==2) then sex="Male"; else sex="Female"; end local userdata=name..' '..class..' '..race..' '..sex; if type(ProffBot[locale][RealmList][RealmName][userdata])~="table" then ProffBot[locale][RealmList][RealmName][userdata]={ }; end database=ProffBot[locale][RealmList][RealmName][userdata]; OldGossipTitleButton_OnClick=GossipTitleButton_OnClick; GossipTitleButton_OnClick=function() local a={GetGossipOptions()}; local b=string.sub(this:GetName(), 18); if GetGossipActiveQuests() then b=b-table.getn({GetGossipActiveQuests()})/2-1; end if GetGossipAvailableQuests() then b=b-table.getn({GetGossipAvailableQuests()})/2-1; end a=a[b*2-1]; if type(a)=="nil" then a="nil"; end if LastGossip=="" then LastGossip=a else LastGossip=LastGossip.." "..a; end OldGossipTitleButton_OnClick(); end OldOpenMail_Update=OpenMail_Update; OpenMail_Update=function() if debug>0 then DEFAULT_CHAT_FRAME:AddMessage("MailUpdate"); end if InboxFrame.openMailID then local packageIcon, stationeryIcon, sender, subject, money, CODAmount, daysLeft, hasItem, wasRead, wasReturned, textCreated, canReply=GetInboxHeaderInfo(InboxFrame.openMailID); OldOpenMail_Update(); if LastMail["id"]==InboxFrame.openMailID then LastMail["count"]=LastMail["count"]+1; if not canReply then local mail={}; mail["PackageIcon"]=packageIcon; mail["StationeryIcon"]=stationeryIcon; mail["sender"]=sender; mail["subject"]=subject; mail["money"]=money; mail["CODAmount"]=CODAmount; mail["DaysLeft"]=daysLeft; mail["HasItem"]=hasItem; mail["WasRead"]=wasRead; mail["WasReturned"]=wasReturned; mail["TextCreated"]=textCreated; mail["CanReply"]=canReply; local bodyText, texture, isTakeable, isInvoice=GetInboxText(InboxFrame.openMailID); mail["BodyText"]=bodyText; mail["texture"]=texture; mail["isTakeable"]=isTakeable; mail["isInvoice"]=isInvoice; local invoiceType, itemName, playerName, bid, buyout, deposit, consignment=GetInboxInvoiceInfo(InboxFrame.openMailID); mail["InvoiceType"]=invoiceType; mail["ItemName"]=itemName; mail["PlayerName"]=playerName; mail["bid"]=bid; mail["buyout"]=buyout; mail["deposit"]=deposit; mail["consignment"]=consignment; if type(database["mail"])~="table" then database["mail"]={}; end if LastMail["count"]>2 then database["mail"][table.getn(database["mail"])]=mail; else table.insert(database["mail"], mail); end end else LastMail["id"]=InboxFrame.openMailID; LastMail["count"]=1; end else LastMail={}; OldOpenMail_Update(); end end end ProffBot_OnLoad=function() this:RegisterEvent("AUCTION_ITEM_LIST_UPDATE"); this:RegisterEvent("CHAT_MSG_SPELL_SELF_BUFF"); this:RegisterEvent("CHAT_MSG_MONSTER_EMOTE"); this:RegisterEvent("CHAT_MSG_MONSTER_SAY"); this:RegisterEvent("CHAT_MSG_SYSTEM"); this:RegisterEvent("GOSSIP_CLOSED"); this:RegisterEvent("GOSSIP_SHOW"); this:RegisterEvent("LOOT_OPENED"); this:RegisterEvent("ITEM_TEXT_READY"); this:RegisterEvent("MERCHANT_SHOW"); this:RegisterEvent("PLAYER_TARGET_CHANGED"); this:RegisterEvent("UNIT_COMBAT"); this:RegisterEvent("UNIT_HEALTH"); this:RegisterEvent("VARIABLES_LOADED"); this:RegisterEvent("ZONE_CHANGED_NEW_AREA"); this:RegisterEvent("QUEST_COMPLETE"); this:RegisterEvent("QUEST_DETAIL"); this:RegisterEvent("QUEST_GREETING"); this:RegisterEvent("QUEST_LOG_UPDATE"); this:RegisterEvent("QUEST_PROGRESS"); this:RegisterEvent("PLAYER_XP_UPDATE"); this:RegisterEvent("SPELLCAST_START"); this:RegisterEvent("SPELLCAST_STOP"); this:RegisterEvent("TRADE_SKILL_SHOW"); this:RegisterEvent("CRAFT_SHOW"); this:RegisterEvent("UPDATE_MOUSEOVER_UNIT"); this:RegisterEvent("PLAYER_TARGET_CHANGED"); this:RegisterEvent("PARTY_MEMBERS_CHANGED"); this:RegisterEvent("WHO_LIST_UPDATE"); this:RegisterEvent("FRIENDLIST_UPDATE"); EventHandlers["VARIABLES_LOADED"]=VariablesLoaded; end ProffBot_OnEvent=function(event) if debug>1 then local str=event; if arg1 then str=str.." arg1="..arg1 end; if arg2 then str=str.." arg2="..arg2 end; if arg3 then str=str.." arg3="..arg3 end; if arg4 then str=str.." arg4="..arg4 end; if arg5 then str=str.." arg5="..arg5 end; DEFAULT_CHAT_FRAME:AddMessage(str); end if type(EventHandlers[event])=="function" then EventHandlers[event](); end end OpenLockSelfMask=string.gsub(OPEN_LOCK_SELF, "%%s", "(.*)");