comparison Main.lua @ 97:f6369b88454f

Record quest progress and reward texts.
author James D. Callahan III <jcallahan@curse.com>
date Thu, 30 Aug 2012 15:45:43 -0500
parents e378295b2d6f
children 6b118dd1baf4
comparison
equal deleted inserted replaced
96:e378295b2d6f 97:f6369b88454f
67 PET_BAR_UPDATE = true, 67 PET_BAR_UPDATE = true,
68 PLAYER_TARGET_CHANGED = true, 68 PLAYER_TARGET_CHANGED = true,
69 QUEST_COMPLETE = true, 69 QUEST_COMPLETE = true,
70 QUEST_DETAIL = true, 70 QUEST_DETAIL = true,
71 QUEST_LOG_UPDATE = true, 71 QUEST_LOG_UPDATE = true,
72 QUEST_PROGRESS = true,
72 TAXIMAP_OPENED = true, 73 TAXIMAP_OPENED = true,
73 TRADE_SKILL_SHOW = true, 74 TRADE_SKILL_SHOW = true,
74 TRAINER_SHOW = true, 75 TRAINER_SHOW = true,
75 TRANSMOGRIFY_OPEN = true, 76 TRANSMOGRIFY_OPEN = true,
76 UNIT_QUEST_LOG_CHANGED = true, 77 UNIT_QUEST_LOG_CHANGED = true,
484 table.insert(loot_table, action_data.loot_list[index]) 485 table.insert(loot_table, action_data.loot_list[index])
485 end 486 end
486 end 487 end
487 end -- do-block 488 end -- do-block
488 489
490
491 local ReplaceKeywords
492 do
493 local KEYWORD_SUBSTITUTIONS = {
494 class = PLAYER_CLASS,
495 name = PLAYER_NAME,
496 race = PLAYER_RACE,
497 }
498
499
500 function ReplaceKeywords(text)
501 if not text or text == "" then
502 return ""
503 end
504
505 for category, lookup in pairs(KEYWORD_SUBSTITUTIONS) do
506 local category_format = ("<%s>"):format(category)
507 text = text:gsub(lookup, category_format):gsub(lookup:lower(), category_format)
508 end
509 return text
510 end
511
512
513 end -- do-block
514
515
489 ----------------------------------------------------------------------- 516 -----------------------------------------------------------------------
490 -- Methods. 517 -- Methods.
491 ----------------------------------------------------------------------- 518 -----------------------------------------------------------------------
492 function WDP:OnInitialize() 519 function WDP:OnInitialize()
493 db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default").global 520 db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default").global
629 GenericLootUpdate("zones") 656 GenericLootUpdate("zones")
630 table.wipe(action_data) 657 table.wipe(action_data)
631 end 658 end
632 659
633 660
634 do 661 function WDP:RecordQuote(event_name, message, source_name, language_name)
635 local KEYWORD_SUBSTITUTIONS = { 662 if not source_name or not name_to_id_map[source_name] or (language_name ~= "" and not languages_known[language_name]) then
636 class = PLAYER_CLASS, 663 return
637 name = PLAYER_NAME, 664 end
638 race = PLAYER_RACE, 665 local npc = NPCEntry(name_to_id_map[source_name])
639 } 666 npc.quotes = npc.quotes or {}
640 667 npc.quotes[event_name] = npc.quotes[event_name] or {}
641 668 npc.quotes[event_name][ReplaceKeywords(message)] = true
642 local function ReplaceKeywords(text) 669 end
643 if not text or text == "" then
644 return ""
645 end
646
647 for category, lookup in pairs(KEYWORD_SUBSTITUTIONS) do
648 local category_format = ("<%s>"):format(category)
649 text = text:gsub(lookup, category_format):gsub(lookup:lower(), category_format)
650 end
651 return text
652 end
653
654
655 function WDP:RecordQuote(event_name, message, source_name, language_name)
656 if not source_name or not name_to_id_map[source_name] or (language_name ~= "" and not languages_known[language_name]) then
657 return
658 end
659 local npc = NPCEntry(name_to_id_map[source_name])
660 npc.quotes = npc.quotes or {}
661 npc.quotes[event_name] = npc.quotes[event_name] or {}
662 npc.quotes[event_name][ReplaceKeywords(message)] = true
663 end
664 end -- do-block
665 670
666 671
667 do 672 do
668 local SOBER_MATCH = _G.DRUNK_MESSAGE_ITEM_SELF1:gsub("%%s", ".+") 673 local SOBER_MATCH = _G.DRUNK_MESSAGE_ITEM_SELF1:gsub("%%s", ".+")
669 674
1307 return quest 1312 return quest
1308 end 1313 end
1309 1314
1310 1315
1311 function WDP:QUEST_COMPLETE(event_name) 1316 function WDP:QUEST_COMPLETE(event_name)
1317 local quest = UpdateQuestJuncture("end")
1318 quest.reward_text = ReplaceKeywords(_G.GetRewardText())
1319
1312 -- Make sure the quest NPC isn't erroneously recorded as giving reputation for quests which award it. 1320 -- Make sure the quest NPC isn't erroneously recorded as giving reputation for quests which award it.
1313 reputation_npc_id = nil 1321 reputation_npc_id = nil
1314 UpdateQuestJuncture("end")
1315 end 1322 end
1316 1323
1317 1324
1318 function WDP:QUEST_DETAIL(event_name) 1325 function WDP:QUEST_DETAIL(event_name)
1319 local quest = UpdateQuestJuncture("begin") 1326 local quest = UpdateQuestJuncture("begin")
1351 end 1358 end
1352 entry_index = entry_index + 1 1359 entry_index = entry_index + 1
1353 end 1360 end
1354 _G.SelectQuestLogEntry(selected_quest) 1361 _G.SelectQuestLogEntry(selected_quest)
1355 self:UnregisterEvent("QUEST_LOG_UPDATE") 1362 self:UnregisterEvent("QUEST_LOG_UPDATE")
1363 end
1364
1365
1366 function WDP:QUEST_PROGRESS(event_name)
1367 DBEntry("quests", _G.GetQuestID()).progress_text = ReplaceKeywords(_G.GetProgressText())
1356 end 1368 end
1357 1369
1358 1370
1359 function WDP:UNIT_QUEST_LOG_CHANGED(event_name, unit_id) 1371 function WDP:UNIT_QUEST_LOG_CHANGED(event_name, unit_id)
1360 if unit_id ~= "player" then 1372 if unit_id ~= "player" then