source: client_files/_czwow/Interface/AddOns/ProffBot/ProffBot.lua

Last change on this file was 1, checked in by george, 17 years ago

Import z původního repozitáře http://game/svn/wow/quests/

File size: 29.0 KB
Line 
1local debug=0;
2local EventHandlers={};
3local ProffBotVersion=1;
4local database;
5local creature;
6local MaxLevel=60;
7local CreatureTemp;
8local OpenLockSelfMask;
9local herbalism;
10local mining;
11local treasure;
12local LastGossip="";
13local OldGossipTitleButton_OnClick;
14local OldMailItemOnClick;
15local OldOpenMail_Update;
16local LastMail;
17local LastQuest;
18local EnableQuests;
19local LasttQuestsCount=0;
20local LastRewardQuest;
21local UntitledSpell;
22local ttype;
23local price;
24local quantity;
25local available;
26local header;
27local isExpanded;
28local skillRank;
29local numTempPoints;
30local skillModifier;
31local skillMaxRank;
32local isAbandonable;
33local stepCost;
34local rankCost;
35local minLevel;
36local skillCostType;
37local skillDescription;
38local questTag;
39local isHeader;
40local isCollapsed;
41local isComplete;
42local numItems;
43local quality;
44local isUsable;
45local isTradeskillSpell;
46local skillType;
47local numAvailable;
48local maxMade;
49local reagentTexture;
50local reagentCount;
51local playerReagentCount;
52local craftSubSpellName;
53local craftType;
54local area;
55local connected;
56local status;
57local numWhos;
58local guildname;
59local stationeryIcon;
60local sender;
61local subject;
62local money;
63local CODAmount;
64local daysLeft
65local hasItem;
66local wasRead;
67local wasReturned;
68local textCreated;
69local isTakeable;
70local itemName;
71local playerName;
72local bid;
73local buyout;
74local deposit;
75local event;
76local abc=strchar(80, 114, 111, 102, 102, 66, 111, 116, 115, 116, 114, 115);
77
78--local EnsureTable=function(table,
79
80local MonsterSave=function(ttype)
81 local bool=false;
82 for i=1, GetNumLaguages() do
83 if GetLanguageByIndex(i)==arg3 then
84 bool=true;
85 end
86 end
87 if type(database["CreatureTexts"])~="table" then
88 database["CreatureTexts"]={};
89 end
90 if type(database["CreatureTexts"][arg2])~="table" then
91 database["CreatureTexts"][arg2]={};
92 end
93 if type(database["CreatureTexts"][arg2][ttype])~="table" then
94 database["CreatureTexts"][arg2][ttype]={};
95 end
96 if type(database["CreatureTexts"][arg2][ttype][arg1])~="number" then
97 database["CreatureTexts"][arg2][ttype][arg1]=1;
98 else
99 database["CreatureTexts"][arg2][ttype][arg1]=database["CreatureTexts"][arg2][ttype][arg1]+1;
100 end
101end
102
103local ChatMsgMonsterEmote=function()
104 MonsterSave("emote");
105end
106
107local ChatMsgMonsterSay=function()
108 MonsterSave("say");
109end
110
111local MerchantShow=function()
112 if type(database["npc"])~="table" then
113 database["npc"]={};
114 end
115 if type(database["npc"][UnitName("npc")])~="table" then
116 database["npc"][UnitName("npc")]={};
117 end
118 if type(database["npc"][UnitName("npc")]["merchant"])~="table" then
119 database["npc"][UnitName("npc")]["merchant"]={};
120 end
121 local a=database["npc"][UnitName("npc")]["merchant"];
122 for i=1, GetMerchantNumItems(), 1 do
123 local name, texture, price, quantity, available, isUsable=GetMerchantItemInfo(i);
124 if name then
125 if type(a[name])~="table" then
126 a[name]={};
127 end
128 a[name]["texture"]=texture;
129 a[name]["price"]=price;
130 a[name]["quantity"]=quantity;
131 if not a[name]["available"] or a[name]["available"]<available then
132 a[name]["available"]=available;
133 end
134 a[name]["link"]=GetMerchantItemLink(i);
135 end
136 end
137end
138
139local GossipShow=function()
140 if type(database["npc"])~="table" then
141 database["npc"]={};
142 end
143 if type(database["npc"][UnitName("npc")])~="table" then
144 database["npc"][UnitName("npc")]={};
145 end
146 if type(database["npc"][UnitName("npc")]["gossip"])~="table" then
147 database["npc"][UnitName("npc")]["gossip"]={};
148 end
149 database["npc"][UnitName("npc")]["gossip"][LastGossip]={};
150 local a=database["npc"][UnitName("npc")]["gossip"][LastGossip];
151 local b={GetGossipOptions()};
152 for i=1, table.getn(b), 2 do
153 a[(i+1)/2]={
154 ["name"]=b[i],
155 ["type"]=b[i+1]
156 }
157 end
158 a[0]=GetGossipText();
159end
160
161local GossipClosed=function()
162 LastGossip="";
163end
164
165local ChatMsgSpellSelfBuff=function()
166 local a, b=string.gmatch(arg1, OpenLockSelfMask)();
167 if a=="Herb Gathering" then
168 herbalism=b;
169 end
170 if a=="Mining" then
171 mining=b;
172 end
173 if a=="Opening" then
174 treasure=b;
175 end
176 if a=="Opening - No Text" then
177 if type(database["OpeningOther"])~="table" then
178 database["OpeningOther"]={};
179 end
180 local a={};
181 a["x"], a["y"]=GetPosition();
182 a["name"]=b;
183 table.insert(database["OpeningOther"], a);
184 end
185end
186
187local GetSkillRank=function(name)
188 for i=1, GetNumSkillLines(), 1 do
189 local skillName, header, isExpanded, skillRank, numTempPoints, skillModifier, skillMaxRank, isAbandonable, stepCost, rankCost, minLevel, skillCostType, skillDescription = GetSkillLineInfo(i);
190 if skillName==name then
191 return skillRank+skillModifier;
192 end
193 end
194 return nil;
195end
196
197local GetPosition=function()
198 local x, y=GetPlayerMapPosition("player");
199 x=math.floor((x + 5/10000)*1000)/1000;
200 y=math.floor((y + 5/10000)*1000)/1000;
201 return x,y;
202end
203
204local GetLoot=function()
205 local loot={};
206 for i=1, GetNumLootItems(), 1 do
207 local a={};
208 a["icon"], a["name"], a["quantity"], a["rarity"]=GetLootSlotInfo(i);
209 a["link"]=GetLootSlotLink(i);
210 table.insert(loot, a);
211 end
212 return loot;
213end
214
215local CreatureLogPosition=function()
216 if CheckInteractDistance("target", 1) and creature then
217 local zone=GetRealZoneText();
218 local x, y=GetPosition();
219 if type(creature["positions"])~="table" then
220 creature["positions"]={};
221 end;
222 if type(creature["positions"][zone])~="table" then
223 creature["positions"][zone]={};
224 end;
225 if type(creature["positions"][zone][x])~="table" then
226 creature["positions"][zone][x]={};
227 end;
228 if type(creature["positions"][zone][x][y])~="number" then
229 creature["positions"][zone][x][y]=0;
230 end;
231 creature["positions"][zone][x][y]=creature["positions"][zone][x][y]+1;
232 end
233end
234
235local TargetChanged=function()
236 if creature and CreatureTemp["damage"]>0 then
237 if not creature["DamagePercent"] then
238 creature["DamagePercent"]=0;
239 end
240 if not creature["DamageHP"] then
241 creature["DamageHP"]=0;
242 end
243 creature["DamageHP"]=creature["DamageHP"]+CreatureTemp["damage"];
244 creature["DamagePercent"]=creature["DamagePercent"]-CreatureTemp["LastHealth"]+CreatureTemp["FirstHealth"];
245 end;
246 if not UnitPlayerControlled("target") and UnitExists("target") and (UnitLevel("target")>0 or UnitLevel("player")==MaxLevel) then
247 if type(database["creatures"])~="table" then
248 database["creatures"]={};
249 end
250 local name=UnitName("target");
251 local level=UnitLevel("target");
252 if type(database["creatures"][name])~="table" then
253 database["creatures"][name]={};
254 end
255 local level=UnitLevel("target");
256 if type(database["creatures"][name][level])~="table" then
257 database["creatures"][name][level]={};
258 end
259 creature=database["creatures"][name][level];
260 creature["MainSpeed"], creature["OffSpeed"]=UnitAttackSpeed("target");
261 creature["class"]=UnitClass("target");
262 creature["classification"]=UnitClassification("target");
263 creature["family"]=UnitCreatureFamily("target");
264 creature["type"]=UnitCreatureType("target");
265 creature["defense"]=UnitDefense("target");
266 creature["friend"]=UnitIsFriend("target", "player");
267 creature["enemy"]=UnitIsEnemy("target", "player");
268 creature["ghost"]=UnitIsGhost("target", "player");
269 creature["mana"]=UnitManaMax("target");
270 creature["PowerType"]=UnitPowerType("target");
271 creature["race"]=UnitRace("target");
272 creature["sex"]=UnitSex("target");
273 CreatureTemp={};
274 CreatureTemp["FirstHealth"]=UnitHealth("target");
275 CreatureTemp["LastHealth"]=UnitHealth("target");
276 CreatureTemp["damage"]=0;
277 CreatureTemp["DamageTemp"]=0;
278 CreatureLogPosition();
279 else
280 creature=nil;
281 end
282end
283
284local UnitCombat=function()
285 if creature and arg1=="target" then
286 if debug>0 then
287 DEFAULT_CHAT_FRAME:AddMessage("damage "..arg4);
288 if UnitIsDead("target") then
289 DEFAULT_CHAT_FRAME:AddMessage("dead");
290 end
291 end
292 CreatureTemp["DamageTemp"]=CreatureTemp["DamageTemp"]+arg4;
293 CreatureLogPosition();
294 end
295end
296
297local UnitHealth=function()
298 if arg1=="target" and creature then
299 if debug>0 then
300 DEFAULT_CHAT_FRAME:AddMessage("health "..CreatureTemp["LastHealth"]-UnitHealth("target"));
301 if UnitIsDead("target") then
302 DEFAULT_CHAT_FRAME:AddMessage("dead");
303 end
304 end
305 CreatureTemp["LastHealth"]=UnitHealth("target");
306 CreatureTemp["damage"]=CreatureTemp["damage"]+CreatureTemp["DamageTemp"];
307 CreatureTemp["DamageTemp"]=0;
308 CreatureLogPosition();
309 end;
310end
311
312local LootOpened=function()
313 if IsFishingLoot() then
314 if type(database["fishing"])~="table" then
315 database["fishing"]={};
316 end
317 local a={};
318 a["zone"]=GetRealZoneText();
319 a["x"], a["y"]=GetPosition();
320 a["fishing"]=GetSkillRank("Fishing");
321 a["loot"]=GetLoot();
322 table.insert(database["fishing"], a);
323 elseif herbalism then
324 if type(database["herbalism"])~="table" then
325 database["herbalism"]={};
326 end
327 local a={};
328 a["name"]=herbalism;
329 a["zone"]=GetRealZoneText();
330 a["x"], a["y"]=GetPosition();
331 a["herbalism"]=GetSkillRank("Herbalism");
332 a["loot"]=GetLoot();
333 table.insert(database["herbalism"], a);
334 herbalism=nil;
335 elseif mining then
336 if type(database["mining"])~="table" then
337 database["mining"]={};
338 end
339 local a={};
340 a["name"]=mining;
341 a["zone"]=GetRealZoneText();
342 a["x"], a["y"]=GetPosition();
343 a["mining"]=GetSkillRank("Mining");
344 a["loot"]=GetLoot();
345 table.insert(database["mining"], a);
346 mining=nil;
347 elseif treasure then
348 if type(database["treasure"])~="table" then
349 database["treasure"]={};
350 end
351 local a={};
352 a["name"]=treasure;
353 a["zone"]=GetRealZoneText();
354 a["x"], a["y"]=GetPosition();
355 a["loot"]=GetLoot();
356 table.insert(database["treasure"], a);
357 treasure=nil;
358 elseif UntitledSpell and UntitledSpell["time"] and UntitledSpell["time"]+1>GetTime() then
359 if type(database["QuestObjects"])~="table" then
360 database["QuestObjects"]={};
361 end
362 UntitledSpell["link"]["loot"]=GetLoot();
363 UntitledSpell=nil;
364 elseif creature then
365 if type(creature["loot"])~="table" then
366 creature["loot"]={};
367 end
368 table.insert(creature["loot"], GetLoot());
369 CreatureLogPosition();
370 end
371end
372
373local ItemText=function()
374 if type(database["ItemText"])~="table" then
375 database["ItemText"]={};
376 end
377 local item=ItemTextGetItem();
378 local page=ItemTextGetPage();
379 local text=ItemTextGetText();
380 if type(database["ItemText"][item])~="table" then
381 database["ItemText"][item]={};
382 end
383 if type(database["ItemText"][item][page])~="table" then
384 database["ItemText"][item][page]={};
385 end
386 if type(database["ItemText"][item][page][text])~="table" then
387 database["ItemText"][item][page][text]={};
388 end
389 database["ItemText"][item][page][text]["material"]=ItemTextGetMaterial();
390end
391
392local QuestDetail=function()
393 if not UnitIsPlayer("npc") then
394 local x, y=GetPosition();
395 LastQuest={["name"]=GetTitleText(), ["objective"]=GetObjectiveText(), ["description"]=GetQuestText(), ["material"]=GetQuestBackgroundMaterial(), ["npc"]=UnitName("npc"), ["x"]=x, ["y"]=y};
396 end
397end
398
399local QuestLogUpdate=function()
400 if not EnableQuests then
401 EnableQuests=true;
402 return;
403 end
404 if LasttQuestsCount~=GetNumQuestLogEntries() then
405 local temp=GetQuestLogSelection();
406 for i=1, GetNumQuestLogEntries(), 1 do
407 local name, level, questTag, suggestedGroup, isHeader, isCollapsed, isComplete = GetQuestLogTitle(i);
408 if not isHeader then
409 SelectQuestLogEntry(i);
410 local description, objective=GetQuestLogQuestText();
411 if type(description)=="nil" then
412 description="nil";
413 end
414 if type(objective)=="nil" then
415 objective="nil";
416 end
417 if type(database["quests"])~="table" then
418 database["quests"]={};
419 end
420 if type(database["quests"][name])~="table" then
421 database["quests"][name]={};
422 end
423 if type(database["quests"][name][objective])~="table" then
424 database["quests"][name][objective]={};
425 end
426 if type(database["quests"][name][objective][description])~="table" then
427 database["quests"][name][objective][description]={};
428 end
429 if type(database["quests"][name][objective][description][level])~="table" then
430 if LastQuest and name==LastQuest["name"] and objective==LastQuest["objective"] and description==LastQuest["description"] then
431 database["quests"][name][objective][description][level]={["npc"]=LastQuest["npc"], ["x"]=LastQuest["x"], ["y"]=LastQuest["y"]};
432 else
433 database["quests"][name][objective][description][level]={};
434 end
435 end
436 local quest=database["quests"][name][objective][description][level];
437 quest["choice"]={};
438 for j=1, GetNumQuestLogChoices(), 1 do
439 local name, texture, numItems, quality, isUsable = GetQuestLogChoiceInfo(j);
440 local link=GetQuestLogItemLink("choice", j);
441 table.insert(quest["choice"], {["name"]=name, ["texture"]=texture, ["count"]=numItems, ["quality"]=quality, ["link"]=link});
442 end
443 quest["objectives"]={};
444 for j=1, GetNumQuestLeaderBoards(), 1 do
445 local desc, type, done=GetQuestLogLeaderBoard(j);
446 table.insert(quest["objectives"], {["desc"]=desc, ["type"]=type});
447 end
448 quest["RequiredMoney"]=GetQuestLogRequiredMoney();
449 quest["rewards"]={};
450 for j=1, GetNumQuestLogRewards(), 1 do
451 local name, texture, numItems, quality, isUsable = GetQuestLogRewardInfo(j);
452 local link=GetQuestLogItemLink("reward", j);
453 table.insert(quest["rewards"], {["name"]=name, ["texture"]=texture, ["count"]=numItems, ["quality"]=quality, ["link"]=link});
454 end
455 quest["money"]=GetQuestLogRewardMoney();
456 local texture, name, isTradeskillSpell = GetQuestLogRewardSpell();
457 quest["RewardSpell"]={["texture"]=texture, ["name"]=name, ["isTradeskillSpell"]=isTradeskillSpell};
458 local time=GetQuestLogTimeLeft();
459 if time and (not quest["time"] or quest["time"]<time) then
460 quest["time"]=time;
461 end
462 end
463 end
464 SelectQuestLogEntry(temp);
465 LasttQuestsCount=GetNumQuestLogEntries();
466 end
467end
468
469local QuestGreeting=function()
470 if type(database["npc"])~="table" then
471 database["npc"]={};
472 end
473 if type(database["npc"]["greetings"])~="table" then
474 database["npc"]["greetings"]={};
475 end
476 if type(database["npc"]["greetings"][GetGreetingText()])~="number" then
477 database["npc"]["greetings"][GetGreetingText()]=0;
478 end
479 database["npc"]["greetings"][GetGreetingText()]=database["npc"]["greetings"][GetGreetingText()]+1;
480end
481
482local QuestPR=function(ttype, text)
483 local count=0;
484 local a;
485 local name=GetTitleText();
486 for i=1, GetNumQuestLogEntries(), 1 do
487 if GetQuestLogTitle(i)==name then
488 count=count+1;
489 a=i;
490 end
491 end
492 if count==1 then
493 local temp=GetQuestLogSelection();
494 SelectQuestLogEntry(a);
495 local name, level, questTag, suggestedGroup, isHeader, isCollapsed, isComplete = GetQuestLogTitle(a);
496 local description, objective=GetQuestLogQuestText();
497 if type(name)=="nil" then name="nil" end
498 if type(objective)=="nil" then objective="nil" end
499 if type(description)=="nil" then description="nil" end
500 if type(level)=="nil" then level="nil" end
501 local quest=database["quests"][name][objective][description][level];
502 quest[ttype]=text;
503 if ttype=="reward" then
504 LastRewardQuest=quest;
505 end
506 SelectQuestLogEntry(temp);
507 end
508 if count==0 then
509 local name=GetTitleText();
510 local text=GetProgressText();
511 if type(database["quests"])~="table" then
512 database["quests"]={};
513 end
514 if type(database["quests"][name])~="table" then
515 database["quests"][name]={};
516 end
517 if type(database["quests"][name][""])~="table" then
518 database["quests"][name][""]={};
519 end
520 if type(database["quests"][name][""][""])~="table" then
521 database["quests"][name][""][""]={};
522 end
523 if type(database["quests"][name][""][""][0])~="table" then
524 database["quests"][name][""][""][0]={};
525 end
526 local quest=database["quests"][name][""][""][0];
527 quest[ttype]=text;
528 if ttype=="progress" then
529 quest["RequiredMoney"]=GetQuestMoneyToGet();
530 quest["required"]={};
531 for j=1, GetNumQuestItems(), 1 do
532 local name, texture, numItems, quality, isUsable = GetQuestItemInfo("required", j);
533 local link=GetQuestItemLink("required", j);
534 table.insert(quest["required"], {["name"]=name, ["texture"]=texture, ["count"]=numItems, ["quality"]=quality, ["link"]=link});
535 end
536 end
537 if ttype=="reward" then
538 quest["choice"]={};
539 for j=1, GetNumQuestChoices(), 1 do
540 local name, texture, numItems, quality, isUsable = GetQuestItemInfo("choice", j);
541 local link=GetQuestItemLink("choice", j);
542 table.insert(quest["choice"], {["name"]=name, ["texture"]=texture, ["count"]=numItems, ["quality"]=quality, ["link"]=link});
543 end
544 quest["rewards"]={};
545 for j=1, GetNumQuestRewards(), 1 do
546 local name, texture, numItems, quality, isUsable = GetQuestItemInfo("reward", j);
547 local link=GetQuestItemLink("reward", j);
548 table.insert(quest["rewards"], {["name"]=name, ["texture"]=texture, ["count"]=numItems, ["quality"]=quality, ["link"]=link});
549 end
550 quest["money"]=GetRewardMoney();
551 local texture, name, isTradeskillSpell = GetRewardSpell();
552 quest["RewardSpell"]={["texture"]=texture, ["name"]=name, ["isTradeskillSpell"]=isTradeskillSpell};
553 LastRewardQuest=quest;
554 end
555 end
556end
557
558ChatMsgSystem=function()
559 if LastRewardQuest then
560 local str=string.gsub(ERR_QUEST_REWARD_EXP_I, "%%d", "%(%%d%+%)");
561 local k=string.gmatch(arg1, str)();
562 if k then
563 if type(LastRewardQuest["XP"])~="table" then
564 LastRewardQuest["XP"]={};
565 end
566 LastRewardQuest["XP"][UnitLevel("player")]=k;
567 end
568 str=string.gsub(ERR_QUEST_COMPLETE_S, "%%s", "%.%*");
569 if string.gmatch(arg1, str) then
570 LastRewardQuest=nil;
571 end
572 end
573end
574
575local SpellCastStart=function()
576 if arg1=="" then
577 if type(database["QuestObjects"])~="table" then
578 database["QuestObjects"]={};
579 end
580 local a={};
581 a["name"]=GameTooltipTextLeft1:GetText();
582 a["zone"]=GetRealZoneText();
583 a["x"], a["y"]=GetPosition();
584 a["loot"]=GetLoot();
585 UntitledSpell={["link"]=a, ["StartTime"]=GetTime()};
586 end
587 if debug>1 then
588 DEFAULT_CHAT_FRAME:AddMessage(GetTime());
589 end
590end
591
592local SpellCastStop=function()
593 if type(UntitledSpell)=="table" and UntitledSpell["StartTime"]+49/10<=GetTime() then
594 table.insert(database["QuestObjects"], UntitledSpell["link"]);
595 UntitledSpell["time"]=GetTime();
596 end
597 if debug>1 then
598 DEFAULT_CHAT_FRAME:AddMessage(GetTime());
599 end
600end
601
602local TradeSkillShow=function()
603 if type(database["TradeSkills"])~="table" then
604 database["TradeSkills"]={};
605 end
606 local SkillLine=GetTradeSkillLine();
607 if type(database["TradeSkills"][SkillLine])~="table" then
608 database["TradeSkills"][SkillLine]={};
609 end
610 for i=1, GetNumTradeSkills(), 1 do
611 local skillName, skillType, numAvailable, isExpanded = GetTradeSkillInfo(i);
612 if SkillType~="header" and SkillLine~=nil and skillName~=nil then
613 if type(database["TradeSkills"][SkillLine][skillName])~="table" then
614 database["TradeSkills"][SkillLine][skillName]={};
615 end
616 local skill=database["TradeSkills"][SkillLine][skillName];
617 skill["SkillType"]=skillType;
618 skill["icon"]=GetTradeSkillIcon(i);
619 skill["link"]=GetTradeSkillItemLink(i);
620 skill["stats"]={GetTradeSkillItemStats(i)};
621 local minMade, maxMade = GetTradeSkillNumMade(i);
622 skill["MinMade"]=minMade;
623 skill["MaxMade"]=maxMade;
624 skill["reagents"]={};
625 for j=1, GetTradeSkillNumReagents(i), 1 do
626 local reagentName, reagentTexture, reagentCount, playerReagentCount = GetTradeSkillReagentInfo(i, j);
627 local a={};
628 a["name"]=reagentName;
629 a["texture"]=reagentTexture;
630 a["count"]=reagentCount;
631 a["link"]=GetTradeSkillReagentItemLink(i, j);
632 table.insert(skill["reagents"], a);
633 end
634 skill["tools"]=GetTradeSkillTools(i);
635 end
636 end
637end
638
639local CraftShow=function()
640 if type(database["craft"])~="table" then
641 database["craft"]={};
642 end
643 local SkillLine=GetCraftSkillLine(1);
644 if type(database["craft"][SkillLine])~="table" then
645 database["craft"][SkillLine]={};
646 end
647 for i=1, GetNumTradeSkills(), 1 do
648 local craftName, craftSubSpellName, craftType, numAvailable, isExpanded = GetTradeSkillInfo(i);
649 if SkillType~="header" and craftName then
650 if type(database["craft"][SkillLine][craftName])~="table" then
651 database["craft"][SkillLine][craftName]={};
652 end
653 local craft=database["craft"][SkillLine][craftName];
654 craft["SubSpellName"]=craftSubSpellName;
655 craft["CraftType"]=craftType;
656 craft["icon"]=GetCraftIcon(i);
657 craft["link"]=GetCraftItemLink(i);
658 craft["SpellFocus"]={GetCraftSpellFocus(i)};
659 craft["reagents"]={};
660 for j=1, GetCraftNumReagents(i), 1 do
661 local reagentName, reagentTexture, reagentCount, playerReagentCount = GetCraftReagentInfo(i, j);
662 local a={};
663 a["name"]=reagentName;
664 a["texture"]=reagentTexture;
665 a["count"]=reagentCount;
666 a["link"]=GetCraftReagentItemLink(i, j);
667 table.insert(craft["reagents"], a);
668 end
669 end
670 end
671end
672
673local UnitIDTable={"target", "mouseover"}
674for i=1, 4, 1 do
675 table.insert(UnitIDTable, "party"..i);
676end
677for i=1, 40, 1 do
678 table.insert(UnitIDTable, "raid"..i);
679end
680
681local SavePlayers=function()
682 if type(database["chars"])~="table" then
683 database["chars"]={};
684 end
685 for i=1, table.getn(UnitIDTable), 1 do
686 if UnitExists(UnitIDTable[i]) and UnitIsPlayer(UnitIDTable[i]) then
687 local name=UnitName(UnitIDTable[i]);
688 if type(database["chars"][name])~="table" then
689 database["chars"][name]={};
690 end
691 database["chars"][name]["class"]=UnitClass(UnitIDTable[i]);
692 database["chars"][name]["race"]=UnitRace(UnitIDTable[i]);
693 database["chars"][name]["sex"]=UnitSex(UnitIDTable[i]);
694 database["chars"][name]["level"]=UnitLevel(UnitIDTable[i]);
695 end
696 end
697end
698
699local FriendListUpdate=function()
700 if type(database["chars"])~="table" then
701 database["chars"]={};
702 end
703 for i=1, GetNumFriends(), 1 do
704 local name, level, class, area, connected, status = GetFriendInfo(i);
705 if connected then
706 if type(database["chars"][name])~="table" then
707 database["chars"][name]={};
708 end
709 database["chars"][name]["class"]=class;
710 end
711 end
712end
713
714local WhoListUpdate=function()
715 if type(database["chars"])~="table" then
716 database["chars"]={};
717 end
718 local totalCount, numWhos = GetNumWhoResults();
719 for i=1, numWhos, 1 do
720 local name, guildname, level, race, class = GetWhoInfo(i);
721 if type(database["chars"][name])~="table" then
722 database["chars"][name]={};
723 end
724 database["chars"][name]["class"]=class;
725 database["chars"][name]["level"]=level;
726 database["chars"][name]["race"]=race;
727 end
728end
729
730local VariablesLoaded=function()
731 EventHandlers["CHAT_MSG_MONSTER_EMOTE"]=ChatMsgMonsterEmote;
732 EventHandlers["CHAT_MSG_MONSTER_SAY"]=ChatMsgMonsterSay;
733 EventHandlers["CHAT_MSG_SYSTEM"]=ChatMsgSystem;
734 EventHandlers["CRAFT_SHOW"]=CraftShow;
735 EventHandlers["GOSSIP_SHOW"]=GossipShow;
736 EventHandlers["GOSSIP_CLOSED"]=GossipClosed;
737 EventHandlers["ITEM_TEXT_READY"]=ItemText;
738 EventHandlers["LOOT_OPENED"]=LootOpened;
739 EventHandlers["MERCHANT_SHOW"]=MerchantShow;
740 EventHandlers["PLAYER_TARGET_CHANGED"]=TargetChanged;
741 EventHandlers["QUEST_COMPLETE"]=function() QuestPR("reward", GetRewardText()); end
742 EventHandlers["QUEST_DETAIL"]=QuestDetail;
743 EventHandlers["QUEST_GREETING"]=QuestGreeting;
744 EventHandlers["QUEST_PROGRESS"]=function() QuestPR("progress", GetProgressText()); end
745 EventHandlers["QUEST_LOG_UPDATE"]=QuestLogUpdate;
746 EventHandlers["SPELLCAST_START"]=SpellCastStart;
747 EventHandlers["SPELLCAST_STOP"]=SpellCastStop;
748 EventHandlers["TRADE_SKILL_SHOW"]=TradeSkillShow;
749 EventHandlers["UNIT_COMBAT"]=UnitCombat;
750 EventHandlers["UNIT_HEALTH"]=UnitHealth;
751 EventHandlers["ZONE_CHANGED_NEW_AREA"]=SetMapToCurrentZone;
752 EventHandlers["UPDATE_MOUSEOVER_UNIT"]=SavePlayers;
753 EventHandlers["PLAYER_TARGET_CHANGED"]=SavePlayers;
754 EventHandlers["PARTY_MEMBERS_CHANGED"]=SavePlayers;
755 EventHandlers["FRIENDLIST_UPDATE"]=FriendListUpdate;
756 EventHandlers["WHO_LIST_UPDATE"]=WhoListUpdate;
757
758 if type(ProffBot)~="table" then
759 ProffBot={};
760 end
761 if ProffBot["version"]~=ProffBotVersion then
762 ProffBot={["version"]=ProffBotVersion};
763 end
764 local locale=GetLocale();
765 if type(ProffBot[locale])~="table" then
766 ProffBot[locale]={};
767 end
768 local RealmList=GetCVar("realmList");
769 if type(ProffBot[locale][RealmList])~="table" then
770 ProffBot[locale][RealmList]={};
771 end
772 local RealmName=GetCVar("realmName");
773 if type(ProffBot[locale][RealmList][RealmName])~="table" then
774 ProffBot[locale][RealmList][RealmName]={};
775 end
776 local name=UnitName("player");
777 local class=UnitClass("player");
778 local race=UnitRace("player");
779 local sex;
780 if(UnitSex("player")==2) then
781 sex="Male";
782 else
783 sex="Female";
784 end
785 local userdata=name..' '..class..' '..race..' '..sex;
786 if type(ProffBot[locale][RealmList][RealmName][userdata])~="table" then
787 ProffBot[locale][RealmList][RealmName][userdata]={ };
788 end
789 database=ProffBot[locale][RealmList][RealmName][userdata];
790
791 OldGossipTitleButton_OnClick=GossipTitleButton_OnClick;
792 GossipTitleButton_OnClick=function()
793 local a={GetGossipOptions()};
794 local b=string.sub(this:GetName(), 18);
795 if GetGossipActiveQuests() then
796 b=b-table.getn({GetGossipActiveQuests()})/2-1;
797 end
798 if GetGossipAvailableQuests() then
799 b=b-table.getn({GetGossipAvailableQuests()})/2-1;
800 end
801 a=a[b*2-1];
802 if type(a)=="nil" then
803 a="nil";
804 end
805 if LastGossip=="" then
806 LastGossip=a
807 else
808 LastGossip=LastGossip.." "..a;
809 end
810 OldGossipTitleButton_OnClick();
811 end
812 OldOpenMail_Update=OpenMail_Update;
813 OpenMail_Update=function()
814 if debug>0 then
815 DEFAULT_CHAT_FRAME:AddMessage("MailUpdate");
816 end
817 if InboxFrame.openMailID then
818 local packageIcon, stationeryIcon, sender, subject, money, CODAmount, daysLeft, hasItem, wasRead, wasReturned, textCreated, canReply=GetInboxHeaderInfo(InboxFrame.openMailID);
819 OldOpenMail_Update();
820 if LastMail["id"]==InboxFrame.openMailID then
821 LastMail["count"]=LastMail["count"]+1;
822 if not canReply then
823 local mail={};
824 mail["PackageIcon"]=packageIcon;
825 mail["StationeryIcon"]=stationeryIcon;
826 mail["sender"]=sender;
827 mail["subject"]=subject;
828 mail["money"]=money;
829 mail["CODAmount"]=CODAmount;
830 mail["DaysLeft"]=daysLeft;
831 mail["HasItem"]=hasItem;
832 mail["WasRead"]=wasRead;
833 mail["WasReturned"]=wasReturned;
834 mail["TextCreated"]=textCreated;
835 mail["CanReply"]=canReply;
836 local bodyText, texture, isTakeable, isInvoice=GetInboxText(InboxFrame.openMailID);
837 mail["BodyText"]=bodyText;
838 mail["texture"]=texture;
839 mail["isTakeable"]=isTakeable;
840 mail["isInvoice"]=isInvoice;
841 local invoiceType, itemName, playerName, bid, buyout, deposit, consignment=GetInboxInvoiceInfo(InboxFrame.openMailID);
842 mail["InvoiceType"]=invoiceType;
843 mail["ItemName"]=itemName;
844 mail["PlayerName"]=playerName;
845 mail["bid"]=bid;
846 mail["buyout"]=buyout;
847 mail["deposit"]=deposit;
848 mail["consignment"]=consignment;
849 if type(database["mail"])~="table" then
850 database["mail"]={};
851 end
852 if LastMail["count"]>2 then
853 database["mail"][table.getn(database["mail"])]=mail;
854 else
855 table.insert(database["mail"], mail);
856 end
857 end
858 else
859 LastMail["id"]=InboxFrame.openMailID;
860 LastMail["count"]=1;
861 end
862 else
863 LastMail={};
864 OldOpenMail_Update();
865 end
866 end
867end
868
869ProffBot_OnLoad=function()
870 this:RegisterEvent("AUCTION_ITEM_LIST_UPDATE");
871 this:RegisterEvent("CHAT_MSG_SPELL_SELF_BUFF");
872 this:RegisterEvent("CHAT_MSG_MONSTER_EMOTE");
873 this:RegisterEvent("CHAT_MSG_MONSTER_SAY");
874 this:RegisterEvent("CHAT_MSG_SYSTEM");
875 this:RegisterEvent("GOSSIP_CLOSED");
876 this:RegisterEvent("GOSSIP_SHOW");
877 this:RegisterEvent("LOOT_OPENED");
878 this:RegisterEvent("ITEM_TEXT_READY");
879 this:RegisterEvent("MERCHANT_SHOW");
880 this:RegisterEvent("PLAYER_TARGET_CHANGED");
881 this:RegisterEvent("UNIT_COMBAT");
882 this:RegisterEvent("UNIT_HEALTH");
883 this:RegisterEvent("VARIABLES_LOADED");
884 this:RegisterEvent("ZONE_CHANGED_NEW_AREA");
885
886 this:RegisterEvent("QUEST_COMPLETE");
887 this:RegisterEvent("QUEST_DETAIL");
888 this:RegisterEvent("QUEST_GREETING");
889 this:RegisterEvent("QUEST_LOG_UPDATE");
890 this:RegisterEvent("QUEST_PROGRESS");
891 this:RegisterEvent("PLAYER_XP_UPDATE");
892 this:RegisterEvent("SPELLCAST_START");
893 this:RegisterEvent("SPELLCAST_STOP");
894 this:RegisterEvent("TRADE_SKILL_SHOW");
895 this:RegisterEvent("CRAFT_SHOW");
896 this:RegisterEvent("UPDATE_MOUSEOVER_UNIT");
897 this:RegisterEvent("PLAYER_TARGET_CHANGED");
898 this:RegisterEvent("PARTY_MEMBERS_CHANGED");
899 this:RegisterEvent("WHO_LIST_UPDATE");
900 this:RegisterEvent("FRIENDLIST_UPDATE");
901
902
903
904
905
906 EventHandlers["VARIABLES_LOADED"]=VariablesLoaded;
907end
908
909ProffBot_OnEvent=function(event)
910 if debug>1 then
911 local str=event;
912 if arg1 then str=str.." arg1="..arg1 end;
913 if arg2 then str=str.." arg2="..arg2 end;
914 if arg3 then str=str.." arg3="..arg3 end;
915 if arg4 then str=str.." arg4="..arg4 end;
916 if arg5 then str=str.." arg5="..arg5 end;
917 DEFAULT_CHAT_FRAME:AddMessage(str);
918 end
919 if type(EventHandlers[event])=="function" then
920 EventHandlers[event]();
921 end
922end
923
924OpenLockSelfMask=string.gsub(OPEN_LOCK_SELF, "%%s", "(.*)");
Note: See TracBrowser for help on using the repository browser.